From e8e2426f985c09b4e81ca997c688a824000607f2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 26 Jan 2018 18:23:41 -0800 Subject: Bazel fix for httpcli_test --- test/core/http/BUILD | 14 ++++++++++++-- test/core/http/httpcli_test.cc | 17 ++++++++++++----- test/core/http/httpscli_test.cc | 17 ++++++++++++----- test/core/http/python_wrapper.sh | 1 + 4 files changed, 37 insertions(+), 12 deletions(-) create mode 120000 test/core/http/python_wrapper.sh (limited to 'test/core/http') diff --git a/test/core/http/BUILD b/test/core/http/BUILD index a5ae6272db..c2ed1cd540 100644 --- a/test/core/http/BUILD +++ b/test/core/http/BUILD @@ -66,7 +66,12 @@ grpc_cc_test( name = "httpcli_test", srcs = ["httpcli_test.cc"], language = "C++", - data = ["test_server.py"], + data = [ + "python_wrapper.sh", + "test_server.py", + "//src/core/tsi/test_creds:server1.pem", + "//src/core/tsi/test_creds:server1.key" + ], deps = [ "//:gpr", "//:grpc", @@ -80,7 +85,12 @@ grpc_cc_test( name = "httpscli_test", srcs = ["httpscli_test.cc"], language = "C++", - data = ["test_server.py"], + data = [ + "python_wrapper.sh", + "test_server.py", + "//src/core/tsi/test_creds:server1.pem", + "//src/core/tsi/test_creds:server1.key" + ], deps = [ "//:gpr", "//:grpc", diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 259e3aa463..a8853c86dc 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -154,10 +154,17 @@ int main(int argc, char** argv) { int arg_shift = 0; /* figure out where we are */ char* root; - if (lslash) { - root = static_cast(gpr_malloc((size_t)(lslash - me + 1))); + if (lslash != nullptr) { + /* Hack for bazel target */ + if (lslash - me >= (unsigned)(sizeof("http") - 1) && + strncmp(me + (lslash - me) - sizeof("http") + 1, "http", + sizeof("http") - 1) == 0) { + lslash = me + (lslash - me) - sizeof("http"); + } + root = static_cast( + gpr_malloc((size_t)(lslash - me + sizeof("/../..")))); memcpy(root, me, (size_t)(lslash - me)); - root[lslash - me] = 0; + memcpy(root + (lslash - me), "/../..", sizeof("/../..")); } else { root = gpr_strdup("."); } @@ -167,8 +174,8 @@ int main(int argc, char** argv) { args[0] = gpr_strdup(argv[1]); } else { arg_shift = 1; - gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); + gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root); + gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root); } /* start the server */ diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index adf69f1b16..5f497fc920 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -152,10 +152,17 @@ int main(int argc, char** argv) { int arg_shift = 0; /* figure out where we are */ char* root; - if (lslash) { - root = static_cast(gpr_malloc((size_t)(lslash - me + 1))); + if (lslash != nullptr) { + /* Hack for bazel target */ + if (lslash - me >= (unsigned)(sizeof("http") - 1) && + strncmp(me + (lslash - me) - sizeof("http") + 1, "http", + sizeof("http") - 1) == 0) { + lslash = me + (lslash - me) - sizeof("http"); + } + root = static_cast( + gpr_malloc((size_t)(lslash - me + sizeof("/../..")))); memcpy(root, me, (size_t)(lslash - me)); - root[lslash - me] = 0; + memcpy(root + (lslash - me), "/../..", sizeof("/../..")); } else { root = gpr_strdup("."); } @@ -165,8 +172,8 @@ int main(int argc, char** argv) { args[0] = gpr_strdup(argv[1]); } else { arg_shift = 1; - gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); + gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root); + gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root); } /* start the server */ diff --git a/test/core/http/python_wrapper.sh b/test/core/http/python_wrapper.sh new file mode 120000 index 0000000000..9ed6e3293f --- /dev/null +++ b/test/core/http/python_wrapper.sh @@ -0,0 +1 @@ +../../../tools/distrib/python_wrapper.sh \ No newline at end of file -- cgit v1.2.3