Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame^] | 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 "src/core/iomgr/iomgr.h" |
| 35 | #include "src/core/iomgr/closure.h" |
| 36 | #include "src/core/iomgr/endpoint.h" |
| 37 | #include "src/core/iomgr/exec_ctx.h" |
| 38 | #include "src/core/iomgr/executor.h" |
| 39 | |
| 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 | |
| 48 | static 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; |
| 57 | closure.final_data = 0; |
| 58 | |
| 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); |
| 68 | grpc_closure_list_add(NULL, NULL, true); |
| 69 | bool x = grpc_closure_list_empty(closure_list); |
| 70 | grpc_closure_next(&closure); |
| 71 | |
| 72 | /* endpoint.h */ |
| 73 | grpc_endpoint_read(NULL, NULL, NULL, NULL); |
| 74 | grpc_endpoint_get_peer(NULL); |
| 75 | grpc_endpoint_write(NULL, NULL, NULL, NULL); |
| 76 | grpc_endpoint_shutdown(NULL, NULL); |
| 77 | grpc_endpoint_destroy(NULL, NULL); |
| 78 | grpc_endpoint_add_to_pollset(NULL, NULL, NULL); |
| 79 | grpc_endpoint_add_to_pollset_set(NULL, NULL, NULL); |
| 80 | |
| 81 | grpc_endpoint endpoint; |
| 82 | grpc_endpoint_vtable vtable = { |
| 83 | grpc_endpoint_read, grpc_endpoint_write, |
| 84 | grpc_endpoint_add_to_pollset, grpc_endpoint_add_to_pollset_set, |
| 85 | grpc_endpoint_shutdown, grpc_endpoint_destroy, |
| 86 | grpc_endpoint_get_peer}; |
| 87 | endpoint.vtable = &vtable; |
| 88 | |
| 89 | /* exec_ctx.h */ |
| 90 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
| 91 | grpc_exec_ctx_flush(&exec_ctx); |
| 92 | grpc_exec_ctx_finish(&exec_ctx); |
| 93 | grpc_exec_ctx_enqueue(&exec_ctx, &closure, x, NULL); |
| 94 | grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL); |
| 95 | |
| 96 | /* executor.h */ |
| 97 | grpc_executor_init(); |
| 98 | grpc_executor_enqueue(&closure, x); |
| 99 | grpc_executor_shutdown(); |
| 100 | |
| 101 | /* pollset.h */ |
| 102 | grpc_pollset_size(); |
| 103 | grpc_pollset_init(NULL, NULL); |
| 104 | grpc_pollset_shutdown(NULL, NULL, NULL); |
| 105 | grpc_pollset_reset(NULL); |
| 106 | grpc_pollset_destroy(NULL); |
| 107 | grpc_pollset_work(NULL, NULL, NULL, gpr_now(GPR_CLOCK_REALTIME), |
| 108 | gpr_now(GPR_CLOCK_MONOTONIC)); |
| 109 | grpc_pollset_kick(NULL, NULL); |
| 110 | } |
| 111 | |
| 112 | int main(void) { |
| 113 | if (false) test_code(); |
| 114 | return 0; |
| 115 | } |