blob: 27d630623edee91cf9b1c6cd574d6d5525cb82e9 [file] [log] [blame]
Craig Tiller5cb79622016-03-15 14:46:54 -07001/*
2 *
Craig Tiller084aa622016-04-05 08:36:49 -07003 * Copyright 2015, Google Inc.
Craig Tiller5cb79622016-03-15 14:46:54 -07004 * 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
Craig Tiller12064232016-03-29 07:40:47 -070034#include "src/core/lib/iomgr/iomgr.h"
35#include "src/core/lib/iomgr/closure.h"
36#include "src/core/lib/iomgr/endpoint.h"
37#include "src/core/lib/iomgr/exec_ctx.h"
38#include "src/core/lib/iomgr/executor.h"
Craig Tiller5cb79622016-03-15 14:46:54 -070039
40/*******************************************************************************
41 * NOTE: If this test fails to compile, then the api changes are likely to cause
42 * merge failures downstream. Please pay special attention to reviewing
43 * these changes, and solicit help as appropriate when merging downstream.
44 *
45 * This test is NOT expected to be run directly.
46 ******************************************************************************/
47
48static void test_code(void) {
49 /* iomgr.h */
50 grpc_iomgr_init();
51 grpc_iomgr_shutdown();
52
53 /* closure.h */
54 grpc_closure closure;
55 closure.cb = NULL;
56 closure.cb_arg = NULL;
Craig Tillerf707d622016-05-06 14:26:12 -070057 closure.next_data.scratch = 0;
Craig Tiller5cb79622016-03-15 14:46:54 -070058
59 grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT;
60 closure_list.head = NULL;
61 closure_list.tail = NULL;
62
63 grpc_closure_init(&closure, NULL, NULL);
64
65 grpc_closure_create(NULL, NULL);
66
67 grpc_closure_list_move(NULL, NULL);
Craig Tillerf707d622016-05-06 14:26:12 -070068 grpc_closure_list_append(NULL, NULL, GRPC_ERROR_CREATE("Foo"));
69 grpc_closure_list_empty(closure_list);
Craig Tiller5cb79622016-03-15 14:46:54 -070070
Craig Tiller5cb79622016-03-15 14:46:54 -070071 /* exec_ctx.h */
72 grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
73 grpc_exec_ctx_flush(&exec_ctx);
74 grpc_exec_ctx_finish(&exec_ctx);
Craig Tiller332f1b32016-05-24 13:21:21 -070075 grpc_exec_ctx_sched(&exec_ctx, &closure, GRPC_ERROR_CREATE("Foo"), NULL);
Craig Tiller5cb79622016-03-15 14:46:54 -070076 grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL);
77
Craig Tillerca5acf82016-03-29 07:38:27 -070078 /* endpoint.h */
79 grpc_endpoint endpoint;
Craig Tiller70bd4832016-06-30 14:20:46 -070080 grpc_endpoint_vtable vtable = {grpc_endpoint_read,
81 grpc_endpoint_write,
82 grpc_endpoint_get_workqueue,
83 grpc_endpoint_add_to_pollset,
84 grpc_endpoint_add_to_pollset_set,
85 grpc_endpoint_shutdown,
86 grpc_endpoint_destroy,
87 grpc_endpoint_get_peer};
Craig Tillerca5acf82016-03-29 07:38:27 -070088 endpoint.vtable = &vtable;
89
90 grpc_endpoint_read(&exec_ctx, &endpoint, NULL, NULL);
91 grpc_endpoint_get_peer(&endpoint);
92 grpc_endpoint_write(&exec_ctx, &endpoint, NULL, NULL);
93 grpc_endpoint_shutdown(&exec_ctx, &endpoint);
94 grpc_endpoint_destroy(&exec_ctx, &endpoint);
95 grpc_endpoint_add_to_pollset(&exec_ctx, &endpoint, NULL);
96 grpc_endpoint_add_to_pollset_set(&exec_ctx, &endpoint, NULL);
97
Craig Tiller5cb79622016-03-15 14:46:54 -070098 /* executor.h */
99 grpc_executor_init();
Craig Tillerf707d622016-05-06 14:26:12 -0700100 grpc_executor_push(&closure, GRPC_ERROR_CREATE("Phi"));
Craig Tiller5cb79622016-03-15 14:46:54 -0700101 grpc_executor_shutdown();
102
103 /* pollset.h */
104 grpc_pollset_size();
105 grpc_pollset_init(NULL, NULL);
106 grpc_pollset_shutdown(NULL, NULL, NULL);
107 grpc_pollset_reset(NULL);
108 grpc_pollset_destroy(NULL);
Craig Tiller1aee5362016-05-07 11:26:50 -0700109 GRPC_ERROR_UNREF(grpc_pollset_work(NULL, NULL, NULL,
110 gpr_now(GPR_CLOCK_REALTIME),
111 gpr_now(GPR_CLOCK_MONOTONIC)));
112 GRPC_ERROR_UNREF(grpc_pollset_kick(NULL, NULL));
Craig Tiller5cb79622016-03-15 14:46:54 -0700113}
114
115int main(void) {
116 if (false) test_code();
117 return 0;
118}