Merge pull request #6863 from vjpai/wheezy

Make C++ compile and run under gcc-4.4
pull/6960/head
Jan Tattermusch 9 years ago committed by GitHub
commit 56f98620bb
  1. 54
      Makefile
  2. 6
      doc/cpp-style-guide.md
  3. 2
      include/grpc++/ext/proto_server_reflection_plugin.h
  4. 2
      include/grpc++/impl/codegen/call.h
  5. 17
      include/grpc++/impl/codegen/config.h
  6. 46
      include/grpc++/impl/codegen/core_codegen.h
  7. 3
      include/grpc++/impl/server_builder_option.h
  8. 2
      include/grpc++/server_builder.h
  9. 7
      src/compiler/cpp_generator.cc
  10. 3
      src/compiler/generator_helpers.h
  11. 4
      src/core/lib/support/log.c
  12. 6
      src/cpp/codegen/codegen_init.cc
  13. 4
      src/cpp/ext/proto_server_reflection.cc
  14. 8
      src/cpp/ext/proto_server_reflection_plugin.cc
  15. 6
      src/cpp/server/server.cc
  16. 17
      src/cpp/server/server_builder.cc
  17. 24
      templates/Makefile.template
  18. 4
      templates/tools/dockerfile/test/cxx_wheezy_x64/Dockerfile.template
  19. 2
      test/core/support/log_test.c
  20. 21
      test/cpp/end2end/async_end2end_test.cc
  21. 21
      test/cpp/end2end/end2end_test.cc
  22. 171
      test/cpp/end2end/hybrid_end2end_test.cc
  23. 34
      test/cpp/end2end/server_builder_plugin_test.cc
  24. 3
      test/cpp/end2end/test_service_impl.cc
  25. 4
      test/cpp/end2end/thread_stress_test.cc
  26. 5
      test/cpp/interop/interop_client.cc
  27. 6
      test/cpp/interop/interop_client.h
  28. 9
      test/cpp/qps/client_async.cc
  29. 1
      test/cpp/qps/driver.cc
  30. 4
      test/cpp/util/metrics_server.cc
  31. 2
      test/cpp/util/proto_reflection_descriptor_database.cc
  32. 59
      test/cpp/util/test_credentials_provider.cc
  33. 4
      tools/dockerfile/test/cxx_wheezy_x64/Dockerfile
  34. 5
      tools/run_tests/run_tests.py

@ -1211,7 +1211,12 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
ifeq ($(EMBED_OPENSSL),true)
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a
else
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a
endif
ifeq ($(HAS_ZOOKEEPER),true)
privatelibs_zookeeper:
@ -1377,6 +1382,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/uri_fuzzer_test_one_entry \
ifeq ($(EMBED_OPENSSL),true)
buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/alarm_cpp_test \
$(BINDIR)/$(CONFIG)/async_end2end_test \
@ -1460,6 +1466,54 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/boringssl_pqueue_test \
$(BINDIR)/$(CONFIG)/boringssl_ssl_test \
else
buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/alarm_cpp_test \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/auth_property_iterator_test \
$(BINDIR)/$(CONFIG)/channel_arguments_test \
$(BINDIR)/$(CONFIG)/cli_call_test \
$(BINDIR)/$(CONFIG)/client_crash_test \
$(BINDIR)/$(CONFIG)/client_crash_test_server \
$(BINDIR)/$(CONFIG)/codegen_test_full \
$(BINDIR)/$(CONFIG)/codegen_test_minimal \
$(BINDIR)/$(CONFIG)/credentials_test \
$(BINDIR)/$(CONFIG)/cxx_byte_buffer_test \
$(BINDIR)/$(CONFIG)/cxx_slice_test \
$(BINDIR)/$(CONFIG)/cxx_string_ref_test \
$(BINDIR)/$(CONFIG)/cxx_time_test \
$(BINDIR)/$(CONFIG)/end2end_test \
$(BINDIR)/$(CONFIG)/generic_end2end_test \
$(BINDIR)/$(CONFIG)/golden_file_test \
$(BINDIR)/$(CONFIG)/grpc_cli \
$(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
$(BINDIR)/$(CONFIG)/interop_client \
$(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \
$(BINDIR)/$(CONFIG)/json_run_localhost \
$(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/proto_server_reflection_test \
$(BINDIR)/$(CONFIG)/qps_interarrival_test \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/secure_auth_context_test \
$(BINDIR)/$(CONFIG)/secure_sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/server_builder_plugin_test \
$(BINDIR)/$(CONFIG)/server_crash_test \
$(BINDIR)/$(CONFIG)/server_crash_test_client \
$(BINDIR)/$(CONFIG)/shutdown_test \
$(BINDIR)/$(CONFIG)/status_test \
$(BINDIR)/$(CONFIG)/streaming_throughput_test \
$(BINDIR)/$(CONFIG)/stress_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
endif
ifeq ($(HAS_ZOOKEEPER),true)
buildtests_zookeeper: privatelibs_zookeeper \

@ -53,6 +53,12 @@ default capture). Other C++ functional features such as
(../include/grpc++/impl/codegen/config.h). Instead, pointers should
be checked for validity using their implicit conversion to `bool`.
In other words, use `if (p)` rather than `if (p != nullptr)`
- Do not initialize global/static pointer variables to `nullptr`. Just let
the compiler implicitly initialize them to `nullptr` (which it will
definitely do). The reason is that `nullptr` is an actual object in
our implementation rather than just a constant pointer value, so
static/global constructors will be called in a potentially
undesirable sequence.
- Do not use `final` or `override` as these are not supported by some
compilers. Instead use `GRPC_FINAL` and `GRPC_OVERRIDE` . These
compile down to the traditional C++ forms for compilers that support

@ -56,7 +56,7 @@ class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin {
bool has_sync_methods() const GRPC_OVERRIDE;
private:
std::shared_ptr<::grpc::ProtoServerReflection> reflection_service_;
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
};
// Add proto reflection plugin to ServerBuilder. This function should be called

@ -337,7 +337,7 @@ class DeserializeFuncType GRPC_FINAL : public DeserializeFunc {
return SerializationTraits<R>::Deserialize(buf, message_, max_message_size);
}
~DeserializeFuncType() override {}
~DeserializeFuncType() GRPC_OVERRIDE {}
private:
R* message_; // Not a managed pointer because management is external to this

@ -54,6 +54,7 @@
// nullptr was added in gcc 4.6
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 406)
#define GRPC_CXX0X_NO_NULLPTR 1
#define GRPC_CXX0X_LIMITED_TOSTRING 1
#endif
// final and override were added in gcc 4.7
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 407)
@ -78,6 +79,7 @@
#endif
#ifdef GRPC_CXX0X_NO_NULLPTR
#include <functional>
#include <memory>
namespace grpc {
const class {
@ -95,6 +97,10 @@ const class {
return std::shared_ptr<T>(static_cast<T *>(0));
}
operator bool() const { return false; }
template <class F>
operator std::function<F>() const {
return std::function<F>();
}
private:
void operator&() const = delete;
@ -111,6 +117,17 @@ namespace grpc {
typedef GRPC_CUSTOM_STRING string;
#ifdef GRPC_CXX0X_LIMITED_TOSTRING
inline grpc::string to_string(const int x) {
return std::to_string(static_cast<const long long int>(x));
}
inline grpc::string to_string(const unsigned int x) {
return std::to_string(static_cast<const long long unsigned int>(x));
}
#else
using std::to_string;
#endif
} // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_CONFIG_H

@ -42,42 +42,44 @@ namespace grpc {
/// Implementation of the core codegen interface.
class CoreCodegen : public CoreCodegenInterface {
private:
grpc_completion_queue* grpc_completion_queue_create(void* reserved) override;
void grpc_completion_queue_destroy(grpc_completion_queue* cq) override;
grpc_completion_queue* grpc_completion_queue_create(void* reserved)
GRPC_OVERRIDE;
void grpc_completion_queue_destroy(grpc_completion_queue* cq) GRPC_OVERRIDE;
grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline,
void* reserved) override;
void* reserved) GRPC_OVERRIDE;
void* gpr_malloc(size_t size) override;
void gpr_free(void* p) override;
void* gpr_malloc(size_t size) GRPC_OVERRIDE;
void gpr_free(void* p) GRPC_OVERRIDE;
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) GRPC_OVERRIDE;
void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) override;
void grpc_byte_buffer_reader_destroy(
grpc_byte_buffer_reader* reader) override;
grpc_byte_buffer* buffer) GRPC_OVERRIDE;
void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader)
GRPC_OVERRIDE;
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
gpr_slice* slice) override;
gpr_slice* slice) GRPC_OVERRIDE;
grpc_byte_buffer* grpc_raw_byte_buffer_create(gpr_slice* slice,
size_t nslices) override;
size_t nslices) GRPC_OVERRIDE;
gpr_slice gpr_slice_malloc(size_t length) override;
void gpr_slice_unref(gpr_slice slice) override;
gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) override;
void gpr_slice_buffer_add(gpr_slice_buffer* sb, gpr_slice slice) override;
void gpr_slice_buffer_pop(gpr_slice_buffer* sb) override;
gpr_slice gpr_slice_malloc(size_t length) GRPC_OVERRIDE;
void gpr_slice_unref(gpr_slice slice) GRPC_OVERRIDE;
gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) GRPC_OVERRIDE;
void gpr_slice_buffer_add(gpr_slice_buffer* sb,
gpr_slice slice) GRPC_OVERRIDE;
void gpr_slice_buffer_pop(gpr_slice_buffer* sb) GRPC_OVERRIDE;
void grpc_metadata_array_init(grpc_metadata_array* array) override;
void grpc_metadata_array_destroy(grpc_metadata_array* array) override;
void grpc_metadata_array_init(grpc_metadata_array* array) GRPC_OVERRIDE;
void grpc_metadata_array_destroy(grpc_metadata_array* array) GRPC_OVERRIDE;
gpr_timespec gpr_inf_future(gpr_clock_type type) override;
gpr_timespec gpr_inf_future(gpr_clock_type type) GRPC_OVERRIDE;
virtual const Status& ok() override;
virtual const Status& cancelled() override;
virtual const Status& ok() GRPC_OVERRIDE;
virtual const Status& cancelled() GRPC_OVERRIDE;
void assert_fail(const char* failed_assertion) override;
void assert_fail(const char* failed_assertion) GRPC_OVERRIDE;
};
} // namespace grpc

@ -50,8 +50,7 @@ class ServerBuilderOption {
virtual void UpdateArguments(ChannelArguments* args) = 0;
/// Alter the ServerBuilderPlugin map that will be added into ServerBuilder.
virtual void UpdatePlugins(
std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin> >*
plugins) = 0;
std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) = 0;
};
} // namespace grpc

@ -174,7 +174,7 @@ class ServerBuilder {
std::vector<Port> ports_;
std::vector<ServerCompletionQueue*> cqs_;
std::shared_ptr<ServerCredentials> creds_;
std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin>> plugins_;
std::vector<std::unique_ptr<ServerBuilderPlugin>> plugins_;
AsyncGenericService* generic_service_;
struct {
bool is_set;

@ -73,9 +73,10 @@ void PrintIncludes(Printer *printer, const std::vector<grpc::string>& headers, c
vars["l"] = params.use_system_headers ? '<' : '"';
vars["r"] = params.use_system_headers ? '>' : '"';
if (!params.grpc_search_path.empty()) {
vars["l"] += params.grpc_search_path;
if (params.grpc_search_path.back() != '/') {
auto& s = params.grpc_search_path;
if (!s.empty()) {
vars["l"] += s;
if (s[s.size()-1] != '/') {
vars["l"] += '/';
}
}

@ -253,7 +253,8 @@ inline void GetComment(const grpc::protobuf::FileDescriptor *desc,
inline grpc::string GenerateCommentsWithPrefix(
const std::vector<grpc::string> &in, const grpc::string &prefix) {
std::ostringstream oss;
for (const grpc::string &elem : in) {
for (auto it = in.begin(); it != in.end(); it++) {
const grpc::string& elem = *it;
if (elem.empty()) {
oss << prefix << "\n";
} else if (elem[0] == ' ') {

@ -96,4 +96,6 @@ void gpr_log_verbosity_init() {
}
}
void gpr_set_log_function(gpr_log_func f) { g_log_func = f; }
void gpr_set_log_function(gpr_log_func f) {
g_log_func = f ? f : gpr_default_log;
}

@ -34,12 +34,12 @@
#include <grpc++/impl/codegen/core_codegen_interface.h>
#include <grpc++/impl/codegen/grpc_library.h>
/// Initializes the global gRPC variables for the codegen library. These will
/// Null-initializes the global gRPC variables for the codegen library. These
/// stay null in the absence of of grpc++ library. In this case, no gRPC
/// features such as the ability to perform calls will be available. Trying to
/// perform them would result in a segmentation fault when trying to deference
/// the following nulled globals. These should be associated with actual
/// as part of the instantiation of a \a grpc::GrpcLibraryInitializer variable.
grpc::CoreCodegenInterface* grpc::g_core_codegen_interface = nullptr;
grpc::GrpcLibraryInterface* grpc::g_glip = nullptr;
grpc::CoreCodegenInterface* grpc::g_core_codegen_interface;
grpc::GrpcLibraryInterface* grpc::g_glip;

@ -197,8 +197,8 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
std::vector<const protobuf::FieldDescriptor*> extensions;
descriptor_pool_->FindAllExtensions(desc, &extensions);
for (auto extension : extensions) {
response->add_extension_number(extension->number());
for (auto it = extensions.begin(); it != extensions.end(); it++) {
response->add_extension_number((*it)->number());
}
response->set_base_type_name(type);
return Status::OK;

@ -60,21 +60,21 @@ void ProtoServerReflectionPlugin::ChangeArguments(const grpc::string& name,
void* value) {}
bool ProtoServerReflectionPlugin::has_sync_methods() const {
if (reflection_service_ != nullptr) {
if (reflection_service_) {
return reflection_service_->has_synchronous_methods();
}
return false;
}
bool ProtoServerReflectionPlugin::has_async_methods() const {
if (reflection_service_ != nullptr) {
if (reflection_service_) {
return reflection_service_->has_async_methods();
}
return false;
}
static std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() {
return std::unique_ptr<::grpc::ServerBuilderPlugin>(
static std::unique_ptr< ::grpc::ServerBuilderPlugin> CreateProtoReflection() {
return std::unique_ptr< ::grpc::ServerBuilderPlugin>(
new ProtoServerReflectionPlugin());
}

@ -67,7 +67,7 @@ static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr;
static gpr_once g_once_init_callbacks = GPR_ONCE_INIT;
static void InitGlobalCallbacks() {
if (g_callbacks == nullptr) {
if (!g_callbacks) {
g_callbacks.reset(new DefaultGlobalCallbacks());
}
}
@ -324,8 +324,8 @@ Server::~Server() {
}
void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
GPR_ASSERT(g_callbacks == nullptr);
GPR_ASSERT(callbacks != nullptr);
GPR_ASSERT(!g_callbacks);
GPR_ASSERT(callbacks);
g_callbacks.reset(callbacks);
}

@ -55,9 +55,10 @@ static void do_plugin_list_init(void) {
ServerBuilder::ServerBuilder()
: max_message_size_(-1), generic_service_(nullptr) {
gpr_once_init(&once_init_plugin_list, do_plugin_list_init);
for (auto factory : (*g_plugin_factory_list)) {
std::unique_ptr<ServerBuilderPlugin> plugin = factory();
plugins_[plugin->name()] = std::move(plugin);
for (auto it = g_plugin_factory_list->begin();
it != g_plugin_factory_list->end(); it++) {
auto& factory = *it;
plugins_.emplace_back(factory());
}
// all compression algorithms enabled by default.
enabled_compression_algorithms_bitset_ =
@ -141,7 +142,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
bool has_sync_methods = false;
for (auto it = services_.begin(); it != services_.end(); ++it) {
if ((*it)->service->has_synchronous_methods()) {
if (thread_pool == nullptr) {
if (!thread_pool) {
thread_pool.reset(CreateDefaultThreadPool());
has_sync_methods = true;
break;
@ -153,9 +154,9 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
(*option)->UpdateArguments(&args);
(*option)->UpdatePlugins(&plugins_);
}
if (thread_pool == nullptr) {
if (!thread_pool) {
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
if ((*plugin).second->has_sync_methods()) {
if ((*plugin)->has_sync_methods()) {
thread_pool.reset(CreateDefaultThreadPool());
has_sync_methods = true;
break;
@ -212,7 +213,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
}
}
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
(*plugin).second->InitServer(initializer);
(*plugin)->InitServer(initializer);
}
if (generic_service_) {
server->RegisterAsyncGenericService(generic_service_);
@ -238,7 +239,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
return nullptr;
}
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
(*plugin).second->Finish(initializer);
(*plugin)->Finish(initializer);
}
return server;
}

@ -923,6 +923,7 @@
pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
ifeq ($(EMBED_OPENSSL),true)
privatelibs_cxx: \
% for lib in libs:
% if 'Makefile' in lib.get('build_system', ['Makefile']):
@ -932,6 +933,18 @@
% endif
% endfor
else
privatelibs_cxx: \
% for lib in libs:
% if 'Makefile' in lib.get('build_system', ['Makefile']):
% if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None) and not lib.boringssl:
$(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
% endif
% endif
% endfor
endif
ifeq ($(HAS_ZOOKEEPER),true)
privatelibs_zookeeper: \
@ -958,6 +971,7 @@
% endfor
ifeq ($(EMBED_OPENSSL),true)
buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
@ -965,6 +979,16 @@
% endif
% endfor
else
buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
% for tgt in targets:
% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
$(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
% endif
% endfor
endif
ifeq ($(HAS_ZOOKEEPER),true)
buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>

@ -36,7 +36,9 @@
RUN apt-get update && apt-get install -y ${'\\'}
gcc-4.4 ${'\\'}
gcc-4.4-multilib
gcc-4.4-multilib ${'\\'}
g++-4.4 ${'\\'}
g++-4.4-multilib
RUN wget ${openssl_fallback.base_uri + openssl_fallback.tarball}

@ -78,11 +78,13 @@ int main(int argc, char **argv) {
gpr_set_log_function(test_callback);
gpr_log_message(GPR_INFO, "hello 1 2 3");
gpr_log(GPR_INFO, "hello %d %d %d", 1, 2, 3);
gpr_set_log_function(NULL);
/* gpr_log_verbosity_init() will be effective only once, and only before
* gpr_set_log_verbosity() is called */
gpr_setenv("GRPC_VERBOSITY", "ERROR");
gpr_log_verbosity_init();
test_log_function_reached(GPR_ERROR);
test_log_function_unreached(GPR_INFO);
test_log_function_unreached(GPR_DEBUG);

@ -31,6 +31,7 @@
*
*/
#include <cinttypes>
#include <memory>
#include <thread>
@ -207,12 +208,11 @@ class ServerBuilderSyncPluginDisabler : public ::grpc::ServerBuilderOption {
public:
void UpdateArguments(ChannelArguments* arg) GRPC_OVERRIDE {}
void UpdatePlugins(
std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin>>* plugins)
void UpdatePlugins(std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins)
GRPC_OVERRIDE {
auto plugin = plugins->begin();
while (plugin != plugins->end()) {
if ((*plugin).second->has_sync_methods()) {
if ((*plugin)->has_sync_methods()) {
plugins->erase(plugin++);
} else {
plugin++;
@ -235,8 +235,11 @@ class TestScenario {
disable_blocking, credentials_type.c_str(), message_content.size());
}
bool disable_blocking;
const grpc::string credentials_type;
const grpc::string message_content;
// Although the below grpc::string's are logically const, we can't declare
// them const because of a limitation in the way old compilers (e.g., gcc-4.4)
// manage vector insertion using a copy constructor
grpc::string credentials_type;
grpc::string message_content;
};
class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> {
@ -940,7 +943,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Client sends 3 messages (tags 3, 4 and 5)
for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
send_request.set_message("Ping " + std::to_string(tag_idx));
send_request.set_message("Ping " + grpc::to_string(tag_idx));
cli_stream->Write(send_request, tag(tag_idx));
Verifier(GetParam().disable_blocking)
.Expect(tag_idx, true)
@ -1106,7 +1109,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// Server sends three messages (tags 3, 4 and 5)
// But if want_done tag is true, we might also see tag 11
for (int tag_idx = 3; tag_idx <= 5; tag_idx++) {
send_response.set_message("Pong " + std::to_string(tag_idx));
send_response.set_message("Pong " + grpc::to_string(tag_idx));
srv_stream.Write(send_response, tag(tag_idx));
// Note that we'll add something to the verifier and verify that
// something was seen, but it might be tag 11 and not what we
@ -1397,9 +1400,9 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
for (auto cred = credentials_types.begin(); cred != credentials_types.end();
++cred) {
for (auto msg = messages.begin(); msg != messages.end(); msg++) {
scenarios.push_back(TestScenario(false, *cred, *msg));
scenarios.emplace_back(false, *cred, *msg);
if (test_disable_blocking) {
scenarios.push_back(TestScenario(true, *cred, *msg));
scenarios.emplace_back(true, *cred, *msg);
}
}
}

@ -199,7 +199,10 @@ class TestScenario {
credentials_type.c_str());
}
bool use_proxy;
const grpc::string credentials_type;
// Although the below grpc::string is logically const, we can't declare
// them const because of a limitation in the way old compilers (e.g., gcc-4.4)
// manage vector insertion using a copy constructor
grpc::string credentials_type;
};
class End2endTest : public ::testing::TestWithParam<TestScenario> {
@ -329,7 +332,7 @@ class End2endServerTryCancelTest : public End2endTest {
// Send server_try_cancel value in the client metadata
context.AddMetadata(kServerTryCancelRequest,
std::to_string(server_try_cancel));
grpc::to_string(server_try_cancel));
auto stream = stub_->RequestStream(&context, &response);
@ -402,7 +405,7 @@ class End2endServerTryCancelTest : public End2endTest {
// Send server_try_cancel in the client metadata
context.AddMetadata(kServerTryCancelRequest,
std::to_string(server_try_cancel));
grpc::to_string(server_try_cancel));
request.set_message("hello");
auto stream = stub_->ResponseStream(&context, request);
@ -413,7 +416,7 @@ class End2endServerTryCancelTest : public End2endTest {
break;
}
EXPECT_EQ(response.message(),
request.message() + std::to_string(num_msgs_read));
request.message() + grpc::to_string(num_msgs_read));
num_msgs_read++;
}
gpr_log(GPR_INFO, "Read %d messages", num_msgs_read);
@ -479,14 +482,14 @@ class End2endServerTryCancelTest : public End2endTest {
// Send server_try_cancel in the client metadata
context.AddMetadata(kServerTryCancelRequest,
std::to_string(server_try_cancel));
grpc::to_string(server_try_cancel));
auto stream = stub_->BidiStream(&context);
int num_msgs_read = 0;
int num_msgs_sent = 0;
while (num_msgs_sent < num_messages) {
request.set_message("hello " + std::to_string(num_msgs_sent));
request.set_message("hello " + grpc::to_string(num_msgs_sent));
if (!stream->Write(request)) {
break;
}
@ -548,7 +551,7 @@ TEST_P(End2endServerTryCancelTest, RequestEchoServerCancel) {
ClientContext context;
context.AddMetadata(kServerTryCancelRequest,
std::to_string(CANCEL_BEFORE_PROCESSING));
grpc::to_string(CANCEL_BEFORE_PROCESSING));
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code());
@ -1431,9 +1434,9 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
}
for (auto it = credentials_types.begin(); it != credentials_types.end();
++it) {
scenarios.push_back(TestScenario(false, *it));
scenarios.emplace_back(false, *it);
if (use_proxy) {
scenarios.push_back(TestScenario(true, *it));
scenarios.emplace_back(true, *it);
}
}
return scenarios;

@ -347,47 +347,50 @@ class HybridEnd2endTest : public ::testing::Test {
}
grpc::testing::UnimplementedService::Service unimplemented_service_;
std::vector<std::unique_ptr<ServerCompletionQueue> > cqs_;
std::vector<std::unique_ptr<ServerCompletionQueue>> cqs_;
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<Server> server_;
std::ostringstream server_address_;
};
TEST_F(HybridEnd2endTest, AsyncEcho) {
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> service;
typedef EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(),
false);
TestAllMethods();
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(),
false);
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
echo_handler_thread.join();
request_stream_handler_thread.join();
}
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
response_stream_handler_thread.join();
request_stream_handler_thread.join();
@ -395,16 +398,17 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) {
// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
SendEchoToDupService();
response_stream_handler_thread.join();
@ -413,18 +417,20 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
// Add a second service with one async method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread echo_handler_thread(
[this, &dup_service] { HandleEcho(&dup_service, cqs_[2].get(), true); });
HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service,
cqs_[2].get(), true);
TestAllMethods();
SendEchoToDupService();
response_stream_handler_thread.join();
@ -437,25 +443,24 @@ TEST_F(HybridEnd2endTest, GenericEcho) {
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
TestAllMethods();
generic_handler_thread.join();
}
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();
@ -463,18 +468,18 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) {
// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
SendEchoToDupService();
generic_handler_thread.join();
@ -483,20 +488,21 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
// Add a second service with one async method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread echo_handler_thread(
[this, &dup_service] { HandleEcho(&dup_service, cqs_[2].get(), true); });
HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service,
cqs_[2].get(), true);
TestAllMethods();
SendEchoToDupService();
generic_handler_thread.join();
@ -505,20 +511,20 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
}
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_RequestStream<
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[2].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[2].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();
@ -526,21 +532,20 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) {
}
TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) {
EchoTestService::WithGenericMethod_RequestStream<
typedef EchoTestService::WithGenericMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread generic_handler_thread2([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[1].get());
});
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[2].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread generic_handler_thread2(HandleGenericCall, &generic_service,
cqs_[1].get());
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[2].get());
TestAllMethods();
generic_handler_thread.join();
generic_handler_thread2.join();
@ -552,7 +557,7 @@ TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) {
TEST_F(HybridEnd2endTest, GenericMethodWithoutGenericService) {
EchoTestService::WithGenericMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
service;
SetUpServer(&service, nullptr, nullptr);
EXPECT_EQ(nullptr, server_.get());

@ -113,15 +113,14 @@ class InsertPluginServerBuilderOption : public ServerBuilderOption {
void UpdateArguments(ChannelArguments* arg) GRPC_OVERRIDE {}
void UpdatePlugins(
std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin>>* plugins)
void UpdatePlugins(std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins)
GRPC_OVERRIDE {
plugins->clear();
std::unique_ptr<TestServerBuilderPlugin> plugin(
new TestServerBuilderPlugin());
if (register_service_) plugin->SetRegisterService();
(*plugins)[plugin->name()] = std::move(plugin);
plugins->emplace_back(std::move(plugin));
}
void SetRegisterService() { register_service_ = true; }
@ -162,7 +161,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
void InsertPlugin() {
if (GetParam()) {
// Add ServerBuilder plugin in static initialization
EXPECT_TRUE(builder_->plugins_[PLUGIN_NAME] != nullptr);
CheckPresent();
} else {
// Add ServerBuilder plugin using ServerBuilder::SetOption()
builder_->SetOption(std::unique_ptr<ServerBuilderOption>(
@ -173,10 +172,8 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
void InsertPluginWithTestService() {
if (GetParam()) {
// Add ServerBuilder plugin in static initialization
EXPECT_TRUE(builder_->plugins_[PLUGIN_NAME] != nullptr);
auto plugin = static_cast<TestServerBuilderPlugin*>(
builder_->plugins_[PLUGIN_NAME].get());
EXPECT_TRUE(plugin != nullptr);
auto plugin = CheckPresent();
EXPECT_TRUE(plugin);
plugin->SetRegisterService();
} else {
// Add ServerBuilder plugin using ServerBuilder::SetOption()
@ -192,7 +189,7 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
builder_->AddListeningPort(server_address, InsecureServerCredentials());
cq_ = builder_->AddCompletionQueue();
server_ = builder_->BuildAndStart();
EXPECT_TRUE(builder_->plugins_[PLUGIN_NAME] != nullptr);
EXPECT_TRUE(CheckPresent());
}
void ResetStub() {
@ -202,10 +199,8 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
}
void TearDown() GRPC_OVERRIDE {
EXPECT_TRUE(builder_->plugins_[PLUGIN_NAME] != nullptr);
auto plugin = static_cast<TestServerBuilderPlugin*>(
builder_->plugins_[PLUGIN_NAME].get());
EXPECT_TRUE(plugin != nullptr);
auto plugin = CheckPresent();
EXPECT_TRUE(plugin);
EXPECT_TRUE(plugin->init_server_is_called());
EXPECT_TRUE(plugin->finish_is_called());
server_->Shutdown();
@ -230,6 +225,19 @@ class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> {
std::unique_ptr<Server> server_;
TestServiceImpl service_;
int port_;
private:
TestServerBuilderPlugin* CheckPresent() {
auto it = builder_->plugins_.begin();
for (; it != builder_->plugins_.end(); it++) {
if ((*it)->name() == PLUGIN_NAME) break;
}
if (it != builder_->plugins_.end()) {
return static_cast<TestServerBuilderPlugin*>(it->get());
} else {
return nullptr;
}
}
};
TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) {

@ -33,6 +33,7 @@
#include "test/cpp/end2end/test_service_impl.h"
#include <string>
#include <thread>
#include <grpc++/security/credentials.h>
@ -253,7 +254,7 @@ Status TestServiceImpl::ResponseStream(ServerContext* context,
}
for (int i = 0; i < kNumResponseStreamsMsgs; i++) {
response.set_message(request->message() + std::to_string(i));
response.set_message(request->message() + grpc::to_string(i));
writer->Write(response);
}

@ -230,7 +230,7 @@ class CommonStressTestSyncServer : public CommonStressTest<TestServiceImpl> {
};
class CommonStressTestAsyncServer
: public CommonStressTest<::grpc::testing::EchoTestService::AsyncService> {
: public CommonStressTest<grpc::testing::EchoTestService::AsyncService> {
public:
void SetUp() GRPC_OVERRIDE {
shutting_down_ = false;
@ -394,7 +394,7 @@ class AsyncClientEnd2endTest : public ::testing::Test {
for (int i = 0; i < num_rpcs; ++i) {
AsyncClientCall* call = new AsyncClientCall;
EchoRequest request;
request.set_message("Hello: " + std::to_string(i));
request.set_message("Hello: " + grpc::to_string(i));
call->response_reader =
common_.GetStub()->AsyncEcho(&call->context, request, &cq_);
call->response_reader->Finish(&call->response, &call->status,

@ -31,10 +31,8 @@
*
*/
#include "test/cpp/interop/interop_client.h"
#include <unistd.h>
#include <cinttypes>
#include <fstream>
#include <memory>
@ -51,6 +49,7 @@
#include "src/proto/grpc/testing/messages.grpc.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/client_helper.h"
#include "test/cpp/interop/interop_client.h"
namespace grpc {
namespace testing {

@ -45,9 +45,9 @@ namespace grpc {
namespace testing {
// Function pointer for custom checks.
using CheckerFn =
std::function<void(const InteropClientContextInspector&,
const SimpleRequest*, const SimpleResponse*)>;
typedef std::function<void(const InteropClientContextInspector&,
const SimpleRequest*, const SimpleResponse*)>
CheckerFn;
class InteropClient {
public:

@ -249,7 +249,8 @@ class AsyncUnaryClient GRPC_FINAL
: public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
public:
explicit AsyncUnaryClient(const ClientConfig& config)
: AsyncClient(config, SetupCtx, BenchmarkStubCreator) {
: AsyncClient<BenchmarkService::Stub, SimpleRequest>(
config, SetupCtx, BenchmarkStubCreator) {
StartThreads(num_async_threads_);
}
~AsyncUnaryClient() GRPC_OVERRIDE { EndThreads(); }
@ -376,7 +377,8 @@ class AsyncStreamingClient GRPC_FINAL
: public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
public:
explicit AsyncStreamingClient(const ClientConfig& config)
: AsyncClient(config, SetupCtx, BenchmarkStubCreator) {
: AsyncClient<BenchmarkService::Stub, SimpleRequest>(
config, SetupCtx, BenchmarkStubCreator) {
StartThreads(num_async_threads_);
}
@ -511,7 +513,8 @@ class GenericAsyncStreamingClient GRPC_FINAL
: public AsyncClient<grpc::GenericStub, ByteBuffer> {
public:
explicit GenericAsyncStreamingClient(const ClientConfig& config)
: AsyncClient(config, SetupCtx, GenericStubCreator) {
: AsyncClient<grpc::GenericStub, ByteBuffer>(config, SetupCtx,
GenericStubCreator) {
StartThreads(num_async_threads_);
}

@ -31,6 +31,7 @@
*
*/
#include <cinttypes>
#include <deque>
#include <list>
#include <thread>

@ -99,7 +99,7 @@ std::shared_ptr<QpsGauge> MetricsServiceImpl::CreateQpsGauge(
std::lock_guard<std::mutex> lock(mu_);
std::shared_ptr<QpsGauge> qps_gauge(new QpsGauge());
const auto p = qps_gauges_.emplace(name, qps_gauge);
const auto p = qps_gauges_.insert(std::make_pair(name, qps_gauge));
// p.first is an iterator pointing to <name, shared_ptr<QpsGauge>> pair.
// p.second is a boolean which is set to 'true' if the QpsGauge is
@ -114,7 +114,7 @@ std::shared_ptr<QpsGauge> MetricsServiceImpl::CreateQpsGauge(
std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
gpr_log(GPR_INFO, "Building metrics server..");
const grpc::string address = "0.0.0.0:" + std::to_string(port);
const grpc::string address = "0.0.0.0:" + grpc::to_string(port);
ServerBuilder builder;
builder.AddListeningPort(address, grpc::InsecureServerCredentials());

@ -298,7 +298,7 @@ void ProtoReflectionDescriptorDatabase::AddFileFromResponse(
const std::shared_ptr<ProtoReflectionDescriptorDatabase::ClientStream>
ProtoReflectionDescriptorDatabase::GetStream() {
if (stream_ == nullptr) {
if (!stream_) {
stream_ = stub_->ServerReflectionInfo(&ctx_);
}
return stream_;

@ -41,15 +41,9 @@
#include "test/core/end2end/data/ssl_test_data.h"
namespace grpc {
namespace {
using grpc::ChannelArguments;
using grpc::ChannelCredentials;
using grpc::InsecureChannelCredentials;
using grpc::InsecureServerCredentials;
using grpc::ServerCredentials;
using grpc::SslCredentialsOptions;
using grpc::SslServerCredentialsOptions;
using grpc::testing::CredentialTypeProvider;
// Provide test credentials. Thread-safe.
@ -69,19 +63,27 @@ class CredentialsProvider {
class DefaultCredentialsProvider : public CredentialsProvider {
public:
~DefaultCredentialsProvider() override {}
~DefaultCredentialsProvider() GRPC_OVERRIDE {}
void AddSecureType(
const grpc::string& type,
std::unique_ptr<CredentialTypeProvider> type_provider) override {
void AddSecureType(const grpc::string& type,
std::unique_ptr<CredentialTypeProvider> type_provider)
GRPC_OVERRIDE {
// This clobbers any existing entry for type, except the defaults, which
// can't be clobbered.
grpc::unique_lock<grpc::mutex> lock(mu_);
added_secure_types_[type] = std::move(type_provider);
auto it = std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type);
if (it == added_secure_type_names_.end()) {
added_secure_type_names_.push_back(type);
added_secure_type_providers_.push_back(std::move(type_provider));
} else {
added_secure_type_providers_[it - added_secure_type_names_.begin()] =
std::move(type_provider);
}
}
std::shared_ptr<ChannelCredentials> GetChannelCredentials(
const grpc::string& type, ChannelArguments* args) override {
const grpc::string& type, ChannelArguments* args) GRPC_OVERRIDE {
if (type == grpc::testing::kInsecureCredentialsType) {
return InsecureChannelCredentials();
} else if (type == grpc::testing::kTlsCredentialsType) {
@ -90,17 +92,19 @@ class DefaultCredentialsProvider : public CredentialsProvider {
return SslCredentials(ssl_opts);
} else {
grpc::unique_lock<grpc::mutex> lock(mu_);
auto it(added_secure_types_.find(type));
if (it == added_secure_types_.end()) {
auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str());
return nullptr;
}
return it->second->GetChannelCredentials(args);
return added_secure_type_providers_[it - added_secure_type_names_.begin()]
->GetChannelCredentials(args);
}
}
std::shared_ptr<ServerCredentials> GetServerCredentials(
const grpc::string& type) override {
const grpc::string& type) GRPC_OVERRIDE {
if (type == grpc::testing::kInsecureCredentialsType) {
return InsecureServerCredentials();
} else if (type == grpc::testing::kTlsCredentialsType) {
@ -112,28 +116,32 @@ class DefaultCredentialsProvider : public CredentialsProvider {
return SslServerCredentials(ssl_opts);
} else {
grpc::unique_lock<grpc::mutex> lock(mu_);
auto it(added_secure_types_.find(type));
if (it == added_secure_types_.end()) {
auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str());
return nullptr;
}
return it->second->GetServerCredentials();
return added_secure_type_providers_[it - added_secure_type_names_.begin()]
->GetServerCredentials();
}
}
std::vector<grpc::string> GetSecureCredentialsTypeList() override {
std::vector<grpc::string> GetSecureCredentialsTypeList() GRPC_OVERRIDE {
std::vector<grpc::string> types;
types.push_back(grpc::testing::kTlsCredentialsType);
grpc::unique_lock<grpc::mutex> lock(mu_);
for (const auto& type_pair : added_secure_types_) {
types.push_back(type_pair.first);
for (auto it = added_secure_type_names_.begin();
it != added_secure_type_names_.end(); it++) {
types.push_back(*it);
}
return types;
}
private:
grpc::mutex mu_;
std::unordered_map<grpc::string, std::unique_ptr<CredentialTypeProvider> >
added_secure_types_;
std::vector<grpc::string> added_secure_type_names_;
std::vector<std::unique_ptr<CredentialTypeProvider>>
added_secure_type_providers_;
};
gpr_once g_once_init_provider = GPR_ONCE_INIT;
@ -148,7 +156,6 @@ CredentialsProvider* GetProvider() {
} // namespace
namespace grpc {
namespace testing {
void AddSecureType(const grpc::string& type,

@ -70,7 +70,9 @@ RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev c
RUN apt-get update && apt-get install -y \
gcc-4.4 \
gcc-4.4-multilib
gcc-4.4-multilib \
g++-4.4 \
g++-4.4-multilib
RUN wget https://openssl.org/source/old/1.0.2/openssl-1.0.2f.tar.gz

@ -793,6 +793,7 @@ argp.add_argument('-n', '--runs_per_test', default=1, type=runs_per_test_type,
help='A positive integer or "inf". If "inf", all tests will run in an '
'infinite loop. Especially useful in combination with "-f"')
argp.add_argument('-r', '--regex', default='.*', type=str)
argp.add_argument('--regex_exclude', default='', type=str)
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
argp.add_argument('-s', '--slowdown', default=1.0, type=float)
argp.add_argument('-f', '--forever',
@ -1209,7 +1210,9 @@ def _build_and_run(
spec
for language in languages
for spec in language.test_specs()
if re.search(args.regex, spec.shortname))
if (re.search(args.regex, spec.shortname) and
(args.regex_exclude == '' or
not re.search(args.regex_exclude, spec.shortname))))
# When running on travis, we want out test runs to be as similar as possible
# for reproducibility purposes.
if args.travis:

Loading…
Cancel
Save