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

Side by Side Diff: third_party/grpc/test/core/surface/server_test.c

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, 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 <grpc/grpc.h>
35 #include <grpc/support/alloc.h>
36 #include <grpc/support/log.h>
37 #include <grpc/support/string_util.h>
38 #include "test/core/util/port.h"
39 #include "test/core/util/test_config.h"
40
41 void test_register_method_fail(void) {
42 grpc_server *server = grpc_server_create(NULL, NULL);
43 void *method;
44 void *method_old;
45 method = grpc_server_register_method(server, NULL, NULL);
46 GPR_ASSERT(method == NULL);
47 method_old = grpc_server_register_method(server, "m", "h");
48 GPR_ASSERT(method_old != NULL);
49 method = grpc_server_register_method(server, "m", "h");
50 GPR_ASSERT(method == NULL);
51 grpc_server_destroy(server);
52 }
53
54 void test_request_call_on_no_server_cq(void) {
55 grpc_completion_queue *cc = grpc_completion_queue_create(NULL);
56 GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
57 grpc_server_request_call(NULL, NULL, NULL, NULL, cc, cc, NULL));
58 GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
59 grpc_server_request_registered_call(NULL, NULL, NULL, NULL, NULL,
60 NULL, cc, cc, NULL));
61 grpc_completion_queue_destroy(cc);
62 }
63
64 void test_bind_server_twice(void) {
65 char *addr;
66 grpc_server *server1 = grpc_server_create(NULL, NULL);
67 grpc_server *server2 = grpc_server_create(NULL, NULL);
68 grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
69 int port = grpc_pick_unused_port_or_die();
70 gpr_asprintf(&addr, "[::]:%d", port);
71 grpc_server_register_completion_queue(server1, cq, NULL);
72 grpc_server_register_completion_queue(server2, cq, NULL);
73 GPR_ASSERT(port == grpc_server_add_insecure_http2_port(server1, addr));
74 GPR_ASSERT(0 == grpc_server_add_insecure_http2_port(server2, addr));
75 grpc_server_shutdown_and_notify(server1, cq, NULL);
76 grpc_server_shutdown_and_notify(server2, cq, NULL);
77 grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
78 grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
79 grpc_server_destroy(server1);
80 grpc_server_destroy(server2);
81 grpc_completion_queue_destroy(cq);
82 gpr_free(addr);
83 }
84
85 int main(int argc, char **argv) {
86 grpc_test_init(argc, argv);
87 grpc_init();
88 test_register_method_fail();
89 test_request_call_on_no_server_cq();
90 test_bind_server_twice();
91 grpc_shutdown();
92 return 0;
93 }
OLDNEW
« no previous file with comments | « third_party/grpc/test/core/surface/server_chttp2_test.c ('k') | third_party/grpc/test/core/transport/chttp2/alpn_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698