Fix C++ tests to enable running on android

pull/21095/head
Prashant Jaikumar 5 years ago
parent 838f6c9fb1
commit c9117fa198
  1. 5
      test/cpp/client/BUILD
  2. 5
      test/cpp/common/time_jump_test.cc
  3. 4
      test/cpp/end2end/BUILD
  4. 7
      test/cpp/end2end/xds_end2end_test.cc

@ -37,7 +37,10 @@ grpc_cc_test(
srcs = ["client_channel_stress_test.cc"], srcs = ["client_channel_stress_test.cc"],
# TODO(jtattermusch): test fails frequently on Win RBE, but passes locally # TODO(jtattermusch): test fails frequently on Win RBE, but passes locally
# reenable the tests once it works reliably on Win RBE. # reenable the tests once it works reliably on Win RBE.
tags = ["no_windows"], tags = [
"no_test_android", # fails on android due to "Too many open files".
"no_windows",
],
deps = [ deps = [
"//:gpr", "//:gpr",
"//:grpc", "//:grpc",

@ -36,6 +36,10 @@
extern char** environ; extern char** environ;
#ifdef GPR_ANDROID
// Android doesn't have posix_spawn. Use std::system instead
void run_cmd(const char* cmd) { std::system(cmd); }
#else
void run_cmd(const char* cmd) { void run_cmd(const char* cmd) {
pid_t pid; pid_t pid;
const char* argv[] = {const_cast<const char*>("sh"), const char* argv[] = {const_cast<const char*>("sh"),
@ -50,6 +54,7 @@ void run_cmd(const char* cmd) {
} }
} }
} }
#endif
class TimeJumpTest : public ::testing::TestWithParam<std::string> { class TimeJumpTest : public ::testing::TestWithParam<std::string> {
protected: protected:

@ -91,6 +91,7 @@ grpc_cc_test(
"gtest", "gtest",
], ],
tags = [ tags = [
"no_test_android", # android_cc_test doesn't work with data dependency.
"no_test_ios", "no_test_ios",
"no_windows", "no_windows",
], ],
@ -116,6 +117,7 @@ grpc_cc_test(
"gtest", "gtest",
], ],
tags = [ tags = [
"no_test_android", # android_cc_test doesn't work with data dependency.
"no_test_ios", "no_test_ios",
"no_windows", "no_windows",
], ],
@ -571,6 +573,7 @@ grpc_cc_test(
"gtest", "gtest",
], ],
tags = [ tags = [
"no_test_android", # android_cc_test doesn't work with data dependency.
"no_test_ios", "no_test_ios",
"no_windows", "no_windows",
], ],
@ -730,6 +733,7 @@ grpc_cc_test(
], ],
tags = [ tags = [
"manual", "manual",
"no_test_android",
"no_test_ios", "no_test_ios",
], # test requires root, won't work with bazel RBE ], # test requires root, won't work with bazel RBE
deps = [ deps = [

@ -764,13 +764,14 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> {
} }
void WaitForBackend(size_t backend_idx, bool reset_counters = true) { void WaitForBackend(size_t backend_idx, bool reset_counters = true) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO, "========= WAITING FOR BACKEND %lu ==========",
"========= WAITING FOR BACKEND %lu ==========", backend_idx); static_cast<unsigned long>(backend_idx));
do { do {
(void)SendRpc(); (void)SendRpc();
} while (backends_[backend_idx]->backend_service()->request_count() == 0); } while (backends_[backend_idx]->backend_service()->request_count() == 0);
if (reset_counters) ResetBackendCounters(); if (reset_counters) ResetBackendCounters();
gpr_log(GPR_INFO, "========= BACKEND %lu READY ==========", backend_idx); gpr_log(GPR_INFO, "========= BACKEND %lu READY ==========",
static_cast<unsigned long>(backend_idx));
} }
grpc_core::ServerAddressList CreateAddressListFromPortList( grpc_core::ServerAddressList CreateAddressListFromPortList(

Loading…
Cancel
Save