Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: third_party/grpc/test/cpp/end2end/client_crash_test_server.cc

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 *
3 * Copyright 2015-2016, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 #include <gflags/gflags.h>
35 #include <iostream>
36 #include <memory>
37 #include <string>
38
39 #include <grpc++/server.h>
40 #include <grpc++/server_builder.h>
41 #include <grpc++/server_context.h>
42 #include "src/proto/grpc/testing/echo.grpc.pb.h"
43
44 DEFINE_string(address, "", "Address to bind to");
45
46 using grpc::testing::EchoRequest;
47 using grpc::testing::EchoResponse;
48
49 // In some distros, gflags is in the namespace google, and in some others,
50 // in gflags. This hack is enabling us to find both.
51 namespace google {}
52 namespace gflags {}
53 using namespace google;
54 using namespace gflags;
55
56 namespace grpc {
57 namespace testing {
58
59 class ServiceImpl GRPC_FINAL
60 : public ::grpc::testing::EchoTestService::Service {
61 Status BidiStream(ServerContext* context,
62 ServerReaderWriter<EchoResponse, EchoRequest>* stream)
63 GRPC_OVERRIDE {
64 EchoRequest request;
65 EchoResponse response;
66 while (stream->Read(&request)) {
67 gpr_log(GPR_INFO, "recv msg %s", request.message().c_str());
68 response.set_message(request.message());
69 stream->Write(response);
70 }
71 return Status::OK;
72 }
73 };
74
75 void RunServer() {
76 ServiceImpl service;
77
78 ServerBuilder builder;
79 builder.AddListeningPort(FLAGS_address, grpc::InsecureServerCredentials());
80 builder.RegisterService(&service);
81 std::unique_ptr<Server> server(builder.BuildAndStart());
82 std::cout << "Server listening on " << FLAGS_address << std::endl;
83 server->Wait();
84 }
85 }
86 }
87
88 int main(int argc, char** argv) {
89 ParseCommandLineFlags(&argc, &argv, true);
90 grpc::testing::RunServer();
91
92 return 0;
93 }
OLDNEW
« no previous file with comments | « third_party/grpc/test/cpp/end2end/client_crash_test.cc ('k') | third_party/grpc/test/cpp/end2end/end2end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698