From cf133f41f84c6c8d306293a5dc8f81fbd9aed1a1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 26 Feb 2015 14:05:56 -0800 Subject: Make it possible to compile with gcc4.6 --- test/build/c++11.cc | 52 ++++++++++++++++++++++++++++++++++ test/cpp/end2end/async_end2end_test.cc | 4 +-- test/cpp/end2end/end2end_test.cc | 18 ++++++------ test/cpp/interop/client.cc | 5 ++-- test/cpp/interop/server.cc | 3 +- test/cpp/qps/server.cc | 6 ++-- 6 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 test/build/c++11.cc (limited to 'test') diff --git a/test/build/c++11.cc b/test/build/c++11.cc new file mode 100644 index 0000000000..519395f20a --- /dev/null +++ b/test/build/c++11.cc @@ -0,0 +1,52 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* This is just a compilation test, to see if we have zlib installed. */ + +#include +#include + +class Base { + public: + virtual void foo() = 0; +}; + +class Foo final : public Base { + public: + void foo() override {} +}; + +int main() { + Foo().foo(); + return 0; +} diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 9e25a5308d..5a2762d049 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -81,7 +81,7 @@ class AsyncEnd2endTest : public ::testing::Test { protected: AsyncEnd2endTest() : service_(&srv_cq_) {} - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; // Setup server @@ -91,7 +91,7 @@ class AsyncEnd2endTest : public ::testing::Test { server_ = builder.BuildAndStart(); } - void TearDown() override { + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); void* ignored_tag; bool ignored_ok; diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 45f12a9e9d..1d5dfc4e34 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -83,7 +83,7 @@ void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request, class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { public: Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { response->set_message(request->message()); MaybeEchoDeadline(context, request, response); return Status::OK; @@ -93,7 +93,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { Status RequestStream(ServerContext* context, ServerReader* reader, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { EchoRequest request; response->set_message(""); while (reader->Read(&request)) { @@ -105,7 +105,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { // Return 3 messages. // TODO(yangg) make it generic by adding a parameter into EchoRequest Status ResponseStream(ServerContext* context, const EchoRequest* request, - ServerWriter* writer) override { + ServerWriter* writer) GRPC_OVERRIDE { EchoResponse response; response.set_message(request->message() + "0"); writer->Write(response); @@ -117,9 +117,9 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { return Status::OK; } - Status BidiStream( - ServerContext* context, - ServerReaderWriter* stream) override { + Status BidiStream(ServerContext* context, + ServerReaderWriter* stream) + GRPC_OVERRIDE { EchoRequest request; EchoResponse response; while (stream->Read(&request)) { @@ -135,7 +135,7 @@ class TestServiceImplDupPkg : public ::grpc::cpp::test::util::duplicate::TestService::Service { public: Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { response->set_message("no package"); return Status::OK; } @@ -145,7 +145,7 @@ class End2endTest : public ::testing::Test { protected: End2endTest() : thread_pool_(2) {} - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; // Setup server @@ -157,7 +157,7 @@ class End2endTest : public ::testing::Test { server_ = builder.BuildAndStart(); } - void TearDown() override { server_->Shutdown(); } + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { std::shared_ptr channel = diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index acfaa87ec8..f7537c2d7b 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -38,6 +38,8 @@ #include #include +#include + #include #include #include @@ -313,8 +315,7 @@ void DoResponseStreamingWithSlowConsumer() { GPR_ASSERT(response.payload().body() == grpc::string(kResponseMessageSize, '\0')); gpr_log(GPR_INFO, "received message %d", i); - std::this_thread::sleep_for( - std::chrono::milliseconds(kReceiveDelayMilliSeconds)); + usleep(kReceiveDelayMilliSeconds * 1000); ++i; } GPR_ASSERT(kNumResponseMessages == i); diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 263bd8e304..9810ff6622 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -222,7 +223,7 @@ void RunServer() { std::unique_ptr server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); while (!got_sigint) { - std::this_thread::sleep_for(std::chrono::seconds(5)); + sleep(5); } } diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc index 8e136349a1..be27c12b30 100644 --- a/test/cpp/qps/server.cc +++ b/test/cpp/qps/server.cc @@ -36,6 +36,8 @@ #include #include +#include + #include #include #include @@ -97,7 +99,7 @@ static bool SetPayload(PayloadType type, int size, Payload* payload) { namespace { -class TestServiceImpl final : public TestService::Service { +class TestServiceImpl GRPC_FINAL : public TestService::Service { public: Status CollectServerStats(ServerContext* context, const StatsRequest*, ServerStats* response) { @@ -146,7 +148,7 @@ static void RunServer() { grpc_profiler_start("qps_server.prof"); while (!got_sigint) { - std::this_thread::sleep_for(std::chrono::seconds(5)); + sleep(5); } grpc_profiler_stop(); -- cgit v1.2.3