Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 084aa62 | 2016-04-05 08:36:49 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 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 | |
Craig Tiller | 1206423 | 2016-03-29 07:40:47 -0700 | [diff] [blame] | 34 | #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 Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 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; |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 57 | closure.next_data.scratch = 0; |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 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); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 68 | grpc_closure_list_append(NULL, NULL, GRPC_ERROR_CREATE("Foo")); |
| 69 | grpc_closure_list_empty(closure_list); |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 70 | |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 71 | /* 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 Tiller | 332f1b3 | 2016-05-24 13:21:21 -0700 | [diff] [blame] | 75 | grpc_exec_ctx_sched(&exec_ctx, &closure, GRPC_ERROR_CREATE("Foo"), NULL); |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 76 | grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL); |
| 77 | |
Craig Tiller | ca5acf8 | 2016-03-29 07:38:27 -0700 | [diff] [blame] | 78 | /* endpoint.h */ |
| 79 | grpc_endpoint endpoint; |
Craig Tiller | 70bd483 | 2016-06-30 14:20:46 -0700 | [diff] [blame] | 80 | 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 Tiller | ca5acf8 | 2016-03-29 07:38:27 -0700 | [diff] [blame] | 88 | 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 Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 98 | /* executor.h */ |
| 99 | grpc_executor_init(); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 100 | grpc_executor_push(&closure, GRPC_ERROR_CREATE("Phi")); |
Craig Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 101 | 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 Tiller | 1aee536 | 2016-05-07 11:26:50 -0700 | [diff] [blame] | 109 | 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 Tiller | 5cb7962 | 2016-03-15 14:46:54 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | int main(void) { |
| 116 | if (false) test_code(); |
| 117 | return 0; |
| 118 | } |