aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/benchmark_config.cc11
-rw-r--r--test/cpp/util/byte_buffer_test.cc20
-rw-r--r--test/cpp/util/cli_call.cc2
-rw-r--r--test/cpp/util/cli_call_test.cc6
-rw-r--r--test/cpp/util/create_test_channel.cc15
-rw-r--r--test/cpp/util/create_test_channel.h8
-rw-r--r--test/cpp/util/grpc_cli.cc2
-rw-r--r--test/cpp/util/metrics_server.cc2
-rw-r--r--test/cpp/util/subprocess.cc8
-rw-r--r--test/cpp/util/subprocess.h3
-rw-r--r--test/cpp/util/test_config.cc2
-rw-r--r--test/cpp/util/test_credentials_provider.cc2
-rw-r--r--test/cpp/util/time_test.cc4
13 files changed, 59 insertions, 26 deletions
diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc
index 3c38221b4c..6fc864069e 100644
--- a/test/cpp/util/benchmark_config.cc
+++ b/test/cpp/util/benchmark_config.cc
@@ -31,14 +31,14 @@
*
*/
-#include <gflags/gflags.h>
#include "test/cpp/util/benchmark_config.h"
+#include <gflags/gflags.h>
DEFINE_bool(enable_log_reporter, true,
"Enable reporting of benchmark results through GprLog");
-DEFINE_bool(report_metrics_db, false,
- "True if metrics to be reported to performance database");
+DEFINE_string(scenario_result_file, "",
+ "Write JSON benchmark report to the file specified.");
DEFINE_string(hashed_id, "", "Hash of the user id");
@@ -71,10 +71,9 @@ static std::shared_ptr<Reporter> InitBenchmarkReporters() {
composite_reporter->add(
std::unique_ptr<Reporter>(new GprLogReporter("LogReporter")));
}
- if (FLAGS_report_metrics_db) {
+ if (FLAGS_scenario_result_file != "") {
composite_reporter->add(std::unique_ptr<Reporter>(
- new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name,
- FLAGS_sys_info, FLAGS_server_address, FLAGS_tag)));
+ new JsonReporter("JsonReporter", FLAGS_scenario_result_file)));
}
return std::shared_ptr<Reporter>(composite_reporter);
diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc
index f36c32cac5..1167c790d4 100644
--- a/test/cpp/util/byte_buffer_test.cc
+++ b/test/cpp/util/byte_buffer_test.cc
@@ -36,8 +36,8 @@
#include <cstring>
#include <vector>
-#include <grpc/support/slice.h>
#include <grpc++/support/slice.h>
+#include <grpc/support/slice.h>
#include <gtest/gtest.h>
namespace grpc {
@@ -105,6 +105,24 @@ TEST_F(ByteBufferTest, Dump) {
EXPECT_TRUE(SliceEqual(slices[1], world));
}
+TEST_F(ByteBufferTest, SerializationMakesCopy) {
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
+ gpr_slice world = gpr_slice_from_copied_string(kContent2);
+ std::vector<Slice> slices;
+ slices.push_back(Slice(hello, Slice::STEAL_REF));
+ slices.push_back(Slice(world, Slice::STEAL_REF));
+ grpc_byte_buffer* send_buffer = nullptr;
+ bool owned = false;
+ ByteBuffer buffer(&slices[0], 2);
+ slices.clear();
+ auto status = SerializationTraits<ByteBuffer, void>::Serialize(
+ buffer, &send_buffer, &owned);
+ EXPECT_TRUE(status.ok());
+ EXPECT_TRUE(owned);
+ EXPECT_TRUE(send_buffer != nullptr);
+ grpc_byte_buffer_destroy(send_buffer);
+}
+
} // namespace
} // namespace grpc
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index d452be360d..99fad7f2fe 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc
index 5fdf519320..75e90f824f 100644
--- a/test/cpp/util/cli_call_test.cc
+++ b/test/cpp/util/cli_call_test.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,18 +33,18 @@
#include "test/cpp/util/cli_call.h"
-#include <grpc/grpc.h>
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
+#include <grpc/grpc.h>
#include <gtest/gtest.h>
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/util/string_ref_helper.h"
using grpc::testing::EchoRequest;
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index 0cd9f9e767..fe8b5d5423 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,8 +58,9 @@ namespace grpc {
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots,
- const std::shared_ptr<CallCredentials>& creds) {
- ChannelArguments channel_args;
+ const std::shared_ptr<CallCredentials>& creds,
+ const ChannelArguments& args) {
+ ChannelArguments channel_args(args);
if (enable_ssl) {
const char* roots_certs = use_prod_roots ? "" : test_root_cert;
SslCredentialsOptions ssl_opts = {roots_certs, "", ""};
@@ -83,6 +84,14 @@ std::shared_ptr<Channel> CreateTestChannel(
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
+ bool enable_ssl, bool use_prod_roots,
+ const std::shared_ptr<CallCredentials>& creds) {
+ return CreateTestChannel(server, override_hostname, enable_ssl,
+ use_prod_roots, creds, ChannelArguments());
+}
+
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots) {
return CreateTestChannel(server, override_hostname, enable_ssl,
use_prod_roots, std::shared_ptr<CallCredentials>());
diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h
index b50d653de3..4ff666dc1b 100644
--- a/test/cpp/util/create_test_channel.h
+++ b/test/cpp/util/create_test_channel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,6 +53,12 @@ std::shared_ptr<Channel> CreateTestChannel(
bool enable_ssl, bool use_prod_roots,
const std::shared_ptr<CallCredentials>& creds);
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, const grpc::string& override_hostname,
+ bool enable_ssl, bool use_prod_roots,
+ const std::shared_ptr<CallCredentials>& creds,
+ const ChannelArguments& args);
+
} // namespace grpc
#endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H
diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc
index f9b9f0c40a..68cf4114a8 100644
--- a/test/cpp/util/grpc_cli.cc
+++ b/test/cpp/util/grpc_cli.cc
@@ -65,11 +65,11 @@
#include <sstream>
#include <gflags/gflags.h>
-#include <grpc/grpc.h>
#include <grpc++/channel.h>
#include <grpc++/create_channel.h>
#include <grpc++/security/credentials.h>
#include <grpc++/support/string_ref.h>
+#include <grpc/grpc.h>
#include "test/cpp/util/cli_call.h"
#include "test/cpp/util/string_ref_helper.h"
diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc
index 34d51eb316..d9b44a6a92 100644
--- a/test/cpp/util/metrics_server.cc
+++ b/test/cpp/util/metrics_server.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/cpp/util/subprocess.cc b/test/cpp/util/subprocess.cc
index 33f3820a2b..00c6244a4f 100644
--- a/test/cpp/util/subprocess.cc
+++ b/test/cpp/util/subprocess.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,15 +39,15 @@
namespace grpc {
-static gpr_subprocess *MakeProcess(std::initializer_list<std::string> args) {
- std::vector<const char *> vargs;
+static gpr_subprocess* MakeProcess(const std::vector<std::string>& args) {
+ std::vector<const char*> vargs;
for (auto it = args.begin(); it != args.end(); ++it) {
vargs.push_back(it->c_str());
}
return gpr_subprocess_create(vargs.size(), &vargs[0]);
}
-SubProcess::SubProcess(std::initializer_list<std::string> args)
+SubProcess::SubProcess(const std::vector<std::string>& args)
: subprocess_(MakeProcess(args)) {}
SubProcess::~SubProcess() { gpr_subprocess_destroy(subprocess_); }
diff --git a/test/cpp/util/subprocess.h b/test/cpp/util/subprocess.h
index 8fafe3d177..f7b553ae03 100644
--- a/test/cpp/util/subprocess.h
+++ b/test/cpp/util/subprocess.h
@@ -36,6 +36,7 @@
#include <initializer_list>
#include <string>
+#include <vector>
struct gpr_subprocess;
@@ -43,7 +44,7 @@ namespace grpc {
class SubProcess {
public:
- SubProcess(std::initializer_list<std::string> args);
+ SubProcess(const std::vector<std::string>& args);
~SubProcess();
int Join();
diff --git a/test/cpp/util/test_config.cc b/test/cpp/util/test_config.cc
index e74f8fb14f..8711746129 100644
--- a/test/cpp/util/test_config.cc
+++ b/test/cpp/util/test_config.cc
@@ -31,8 +31,8 @@
*
*/
-#include <gflags/gflags.h>
#include "test/cpp/util/test_config.h"
+#include <gflags/gflags.h>
// In some distros, gflags is in the namespace google, and in some others,
// in gflags. This hack is enabling us to find both.
diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc
index e314fd6d75..9c09a73115 100644
--- a/test/cpp/util/test_credentials_provider.cc
+++ b/test/cpp/util/test_credentials_provider.cc
@@ -36,8 +36,8 @@
#include <unordered_map>
-#include <grpc/support/sync.h>
#include <grpc++/impl/sync.h>
+#include <grpc/support/sync.h>
#include "test/core/end2end/data/ssl_test_data.h"
diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc
index 48c6ce7697..a292c210c8 100644
--- a/test/cpp/util/time_test.cc
+++ b/test/cpp/util/time_test.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#include <grpc/support/time.h>
#include <grpc++/support/time.h>
+#include <grpc/support/time.h>
#include <gtest/gtest.h>
using std::chrono::duration_cast;