From ac35926a2f7c41313c3d2c778ffd0695863a7e7d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 29 Jan 2018 16:36:05 -0800 Subject: Manually set roots pem env variable for httpscli_test --- test/core/http/BUILD | 1 + test/core/http/httpcli_test.cc | 2 +- test/core/http/httpscli_test.cc | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'test/core/http') diff --git a/test/core/http/BUILD b/test/core/http/BUILD index c2ed1cd540..03b8f4edfe 100644 --- a/test/core/http/BUILD +++ b/test/core/http/BUILD @@ -88,6 +88,7 @@ grpc_cc_test( data = [ "python_wrapper.sh", "test_server.py", + "//src/core/tsi/test_creds:ca.pem", "//src/core/tsi/test_creds:server1.pem", "//src/core/tsi/test_creds:server1.key" ], diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index a8853c86dc..6ad0753f7e 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -156,7 +156,7 @@ int main(int argc, char** argv) { char* root; if (lslash != nullptr) { /* Hack for bazel target */ - if (lslash - me >= (unsigned)(sizeof("http") - 1) && + if ((unsigned)(lslash - me) >= (sizeof("http") - 1) && strncmp(me + (lslash - me) - sizeof("http") + 1, "http", sizeof("http") - 1) == 0) { lslash = me + (lslash - me) - sizeof("http"); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index 5f497fc920..92193bb442 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -21,11 +21,13 @@ #include #include +#include #include #include #include #include #include +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -154,7 +156,7 @@ int main(int argc, char** argv) { char* root; if (lslash != nullptr) { /* Hack for bazel target */ - if (lslash - me >= (unsigned)(sizeof("http") - 1) && + if ((unsigned)(lslash - me) >= (sizeof("http") - 1) && strncmp(me + (lslash - me) - sizeof("http") + 1, "http", sizeof("http") - 1) == 0) { lslash = me + (lslash - me) - sizeof("http"); @@ -176,6 +178,12 @@ int main(int argc, char** argv) { gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root); } + /* Set the environment variable for the SSL certificate file */ + char* pem_file; + gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file); + gpr_free(pem_file); + /* start the server */ args[1 + arg_shift] = const_cast("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); -- cgit v1.2.3