aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2017-01-19 18:09:50 +0100
committerGravatar Jan Tattermusch <jtattermusch@google.com>2017-02-02 00:01:09 +0100
commitbd0b0546a6e12dc6b9276502341446e91f0253f0 (patch)
tree5302fefb40614a19ec7ab318da90cf24cb302129 /test
parentd5a5bec6039a50737bc032092792f76c5e138f80 (diff)
windows compilation fixes
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/data/ssl_test_data.h8
-rw-r--r--test/cpp/end2end/async_end2end_test.cc1
-rw-r--r--test/cpp/grpclb/grpclb_api_test.cc2
-rw-r--r--test/cpp/interop/client.cc2
-rw-r--r--test/cpp/interop/client_helper.cc2
-rw-r--r--test/cpp/interop/interop_client.cc6
-rw-r--r--test/cpp/interop/interop_server.cc6
-rw-r--r--test/cpp/interop/interop_server_bootstrap.cc1
-rw-r--r--test/cpp/interop/reconnect_interop_server.cc1
-rw-r--r--test/cpp/qps/usage_timer.cc29
-rw-r--r--test/cpp/qps/worker.cc2
-rw-r--r--test/cpp/thread_manager/thread_manager_test.cc1
-rw-r--r--test/cpp/util/grpc_tool.cc15
13 files changed, 49 insertions, 27 deletions
diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h
index 4a64af1e27..0b274e0d95 100644
--- a/test/core/end2end/data/ssl_test_data.h
+++ b/test/core/end2end/data/ssl_test_data.h
@@ -34,6 +34,10 @@
#ifndef GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H
#define GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern const char test_root_cert[];
extern const char test_server1_cert[];
extern const char test_server1_key[];
@@ -42,4 +46,8 @@ extern const char test_self_signed_client_key[];
extern const char test_signed_client_cert[];
extern const char test_signed_client_key[];
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index f53601297c..32e8a41795 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -42,6 +42,7 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/tls.h>
diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc
index 191d729a9e..82ccf436f8 100644
--- a/test/cpp/grpclb/grpclb_api_test.cc
+++ b/test/cpp/grpclb/grpclb_api_test.cc
@@ -63,7 +63,7 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) {
} else {
abort();
}
- GPR_ASSERT(inet_ntop(af, pb_ip.bytes, ip_str, 46) != NULL);
+ GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != NULL);
return ip_str;
}
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 1df2fc8320..8a00b61cef 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -34,8 +34,6 @@
#include <memory>
#include <unordered_map>
-#include <unistd.h>
-
#include <gflags/gflags.h>
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc
index 91564e5dce..d3192ad0c9 100644
--- a/test/cpp/interop/client_helper.cc
+++ b/test/cpp/interop/client_helper.cc
@@ -33,8 +33,6 @@
#include "test/cpp/interop/client_helper.h"
-#include <unistd.h>
-
#include <fstream>
#include <memory>
#include <sstream>
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index aa34d94f61..b7f2723c39 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -31,7 +31,6 @@
*
*/
-#include <unistd.h>
#include <cinttypes>
#include <fstream>
#include <memory>
@@ -43,6 +42,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/transport/byte_stream.h"
@@ -618,7 +618,9 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() {
GPR_ASSERT(response.payload().body() ==
grpc::string(kResponseMessageSize, '\0'));
gpr_log(GPR_DEBUG, "received message %d", i);
- usleep(kReceiveDelayMilliSeconds * 1000);
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(kReceiveDelayMilliSeconds, GPR_TIMESPAN)));
++i;
}
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index 1810cd076f..77e309dde4 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -31,8 +31,6 @@
*
*/
-#include <unistd.h>
-
#include <fstream>
#include <memory>
#include <sstream>
@@ -45,6 +43,7 @@
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
+#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/support/string.h"
@@ -348,6 +347,7 @@ void grpc::testing::interop::RunServer(
std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str());
while (!gpr_atm_no_barrier_load(&g_got_sigint)) {
- sleep(5);
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(5, GPR_TIMESPAN)));
}
}
diff --git a/test/cpp/interop/interop_server_bootstrap.cc b/test/cpp/interop/interop_server_bootstrap.cc
index 99518c6943..7cbf221a03 100644
--- a/test/cpp/interop/interop_server_bootstrap.cc
+++ b/test/cpp/interop/interop_server_bootstrap.cc
@@ -32,7 +32,6 @@
*/
#include <signal.h>
-#include <unistd.h>
#include "test/cpp/interop/server_helper.h"
#include "test/cpp/util/test_config.h"
diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc
index 53d51e80e7..634d0a90fc 100644
--- a/test/cpp/interop/reconnect_interop_server.cc
+++ b/test/cpp/interop/reconnect_interop_server.cc
@@ -34,7 +34,6 @@
// Test description at doc/connection-backoff-interop-test-description.md
#include <signal.h>
-#include <unistd.h>
#include <condition_variable>
#include <memory>
diff --git a/test/cpp/qps/usage_timer.cc b/test/cpp/qps/usage_timer.cc
index c6697fbdfd..70ef26e82a 100644
--- a/test/cpp/qps/usage_timer.cc
+++ b/test/cpp/qps/usage_timer.cc
@@ -39,8 +39,15 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
+#ifdef __linux__
#include <sys/resource.h>
#include <sys/time.h>
+
+static double time_double(struct timeval* tv) {
+ return tv->tv_sec + 1e-6 * tv->tv_usec;
+}
+#endif
+
UsageTimer::UsageTimer() : start_(Sample()) {}
double UsageTimer::Now() {
@@ -48,8 +55,16 @@ double UsageTimer::Now() {
return ts.tv_sec + 1e-9 * ts.tv_nsec;
}
-static double time_double(struct timeval* tv) {
- return tv->tv_sec + 1e-6 * tv->tv_usec;
+static void get_resource_usage(double* utime, double* stime) {
+#ifdef __linux__
+ struct rusage usage;
+ getrusage(RUSAGE_SELF, &usage);
+ *utime = time_double(&usage.ru_utime);
+ *stime = time_double(&usage.ru_stime);
+#else
+ *utime = 0;
+ *stime = 0;
+#endif
}
static void get_cpu_usage(unsigned long long* total_cpu_time,
@@ -74,15 +89,9 @@ static void get_cpu_usage(unsigned long long* total_cpu_time,
}
UsageTimer::Result UsageTimer::Sample() {
- struct rusage usage;
- struct timeval tv;
- gettimeofday(&tv, NULL);
- getrusage(RUSAGE_SELF, &usage);
-
Result r;
- r.wall = time_double(&tv);
- r.user = time_double(&usage.ru_utime);
- r.system = time_double(&usage.ru_stime);
+ r.wall = Now();
+ get_resource_usage(&r.user, &r.system);
r.total_cpu_time = 0;
r.idle_cpu_time = 0;
get_cpu_usage(&r.total_cpu_time, &r.idle_cpu_time);
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index 2068b7c213..e88d0647dd 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -31,7 +31,7 @@
*
*/
-#include <sys/signal.h>
+#include <signal.h>
#include <chrono>
#include <thread>
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index 284761c53a..35c8d5d088 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -31,6 +31,7 @@
*is % allowed in string
*/
+#include <ctime>
#include <memory>
#include <string>
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index 39acd8eb4b..856cd32c3c 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -33,7 +33,7 @@
#include "test/cpp/util/grpc_tool.h"
-#include <unistd.h>
+#include <cstdio>
#include <fstream>
#include <iostream>
#include <memory>
@@ -48,12 +48,19 @@
#include <grpc++/security/credentials.h>
#include <grpc++/support/string_ref.h>
#include <grpc/grpc.h>
+#include <grpc/support/port_platform.h>
#include "test/cpp/util/cli_call.h"
#include "test/cpp/util/proto_file_parser.h"
#include "test/cpp/util/proto_reflection_descriptor_database.h"
#include "test/cpp/util/service_describer.h"
+#if GPR_WINDOWS
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
namespace grpc {
namespace testing {
@@ -484,7 +491,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
CliCall call(channel, formatted_method_name, client_metadata);
if (FLAGS_infile.empty()) {
- if (isatty(STDIN_FILENO)) {
+ if (isatty(fileno(stdin))) {
print_mode = true;
fprintf(stderr, "reading streaming request message from stdin...\n");
}
@@ -566,7 +573,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
} else {
std::stringstream input_stream;
if (FLAGS_infile.empty()) {
- if (isatty(STDIN_FILENO)) {
+ if (isatty(fileno(stdin))) {
fprintf(stderr, "reading request message from stdin...\n");
}
input_stream << std::cin.rdbuf();
@@ -668,7 +675,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
} else {
std::stringstream input_stream;
if (FLAGS_infile.empty()) {
- if (isatty(STDIN_FILENO)) {
+ if (isatty(fileno(stdin))) {
fprintf(stderr, "reading request message from stdin...\n");
}
input_stream << std::cin.rdbuf();