aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop/interop_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/interop/interop_test.cc')
-rw-r--r--test/cpp/interop/interop_test.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc
index 8e71a2bb29..d4004740a4 100644
--- a/test/cpp/interop/interop_test.cc
+++ b/test/cpp/interop/interop_test.cc
@@ -44,17 +44,21 @@
#include <sys/wait.h>
#include <unistd.h>
+#include <gflags/gflags.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "test/core/util/port.h"
+#include "test/cpp/util/test_config.h"
extern "C" {
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/support/string.h"
}
+DEFINE_string(extra_server_flags, "", "Extra flags to pass to server.");
+
int test_client(const char* root, const char* host, int port) {
int status;
pid_t cli;
@@ -80,6 +84,7 @@ int test_client(const char* root, const char* host, int port) {
}
int main(int argc, char** argv) {
+ grpc::testing::InitTest(&argc, &argv, true);
char* me = argv[0];
char* lslash = strrchr(me, '/');
char root[1024];
@@ -105,19 +110,23 @@ int main(int argc, char** argv) {
/* start the server */
svr = fork();
if (svr == 0) {
- char* binary_path;
- char* port_arg;
- gpr_asprintf(&binary_path, "%s/interop_server", root);
- gpr_asprintf(&port_arg, "--port=%d", port);
-
- execl(binary_path, binary_path, port_arg, NULL);
-
- gpr_free(binary_path);
- gpr_free(port_arg);
+ const size_t num_args = 3 + !FLAGS_extra_server_flags.empty();
+ char** args = (char**)gpr_malloc(sizeof(char*) * num_args);
+ memset(args, 0, sizeof(char*) * num_args);
+ gpr_asprintf(&args[0], "%s/interop_server", root);
+ gpr_asprintf(&args[1], "--port=%d", port);
+ if (!FLAGS_extra_server_flags.empty()) {
+ args[2] = gpr_strdup(FLAGS_extra_server_flags.c_str());
+ }
+ execv(args[0], args);
+ for (size_t i = 0; i < num_args - 1; ++i) {
+ gpr_free(args[i]);
+ }
+ gpr_free(args);
return 1;
}
/* wait a little */
- sleep(2);
+ sleep(10);
/* start the clients */
ret = test_client(root, "127.0.0.1", port);
if (ret != 0) return ret;