Craig Tiller | ae7fe92 | 2015-02-13 23:16:32 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 0605995 | 2015-02-18 08:34:56 -0800 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Craig Tiller | ae7fe92 | 2015-02-13 23:16:32 -0800 | [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 | |
| 34 | #include "test/core/end2end/end2end_tests.h" |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | #include <string.h> |
| 38 | #include <unistd.h> |
| 39 | |
| 40 | #include "src/core/channel/client_channel.h" |
| 41 | #include "src/core/channel/connected_channel.h" |
Craig Tiller | ae7fe92 | 2015-02-13 23:16:32 -0800 | [diff] [blame] | 42 | #include "src/core/channel/http_server_filter.h" |
| 43 | #include "src/core/support/string.h" |
| 44 | #include "src/core/surface/channel.h" |
| 45 | #include "src/core/surface/client.h" |
| 46 | #include "src/core/surface/server.h" |
| 47 | #include "src/core/transport/chttp2_transport.h" |
| 48 | #include <grpc/support/alloc.h> |
| 49 | #include <grpc/support/host_port.h> |
| 50 | #include <grpc/support/log.h> |
| 51 | #include <grpc/support/sync.h> |
| 52 | #include <grpc/support/thd.h> |
| 53 | #include <grpc/support/useful.h> |
| 54 | #include "test/core/util/port.h" |
| 55 | #include "test/core/util/test_config.h" |
| 56 | |
| 57 | typedef struct fullstack_fixture_data { |
| 58 | char *localaddr; |
| 59 | } fullstack_fixture_data; |
| 60 | |
| 61 | static int unique = 1; |
| 62 | |
| 63 | static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( |
| 64 | grpc_channel_args *client_args, grpc_channel_args *server_args) { |
| 65 | grpc_end2end_test_fixture f; |
| 66 | fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); |
| 67 | memset(&f, 0, sizeof(f)); |
| 68 | |
Craig Tiller | d209ed0 | 2015-02-13 23:18:15 -0800 | [diff] [blame] | 69 | gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), |
| 70 | unique++); |
Craig Tiller | ae7fe92 | 2015-02-13 23:16:32 -0800 | [diff] [blame] | 71 | |
| 72 | f.fixture_data = ffd; |
| 73 | f.client_cq = grpc_completion_queue_create(); |
| 74 | f.server_cq = grpc_completion_queue_create(); |
| 75 | |
| 76 | return f; |
| 77 | } |
| 78 | |
| 79 | void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, |
| 80 | grpc_channel_args *client_args) { |
| 81 | fullstack_fixture_data *ffd = f->fixture_data; |
| 82 | f->client = grpc_channel_create(ffd->localaddr, client_args); |
| 83 | } |
| 84 | |
| 85 | void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, |
| 86 | grpc_channel_args *server_args) { |
| 87 | fullstack_fixture_data *ffd = f->fixture_data; |
| 88 | if (f->server) { |
| 89 | grpc_server_destroy(f->server); |
| 90 | } |
| 91 | f->server = grpc_server_create(f->server_cq, server_args); |
| 92 | GPR_ASSERT(grpc_server_add_http2_port(f->server, ffd->localaddr)); |
| 93 | grpc_server_start(f->server); |
| 94 | } |
| 95 | |
| 96 | void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { |
| 97 | fullstack_fixture_data *ffd = f->fixture_data; |
| 98 | gpr_free(ffd->localaddr); |
| 99 | gpr_free(ffd); |
| 100 | } |
| 101 | |
| 102 | /* All test configurations */ |
| 103 | static grpc_end2end_test_config configs[] = { |
| 104 | {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, |
| 105 | chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, |
Craig Tiller | d209ed0 | 2015-02-13 23:18:15 -0800 | [diff] [blame] | 106 | chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, |
| 107 | }; |
Craig Tiller | ae7fe92 | 2015-02-13 23:16:32 -0800 | [diff] [blame] | 108 | |
| 109 | int main(int argc, char **argv) { |
| 110 | size_t i; |
| 111 | |
| 112 | grpc_test_init(argc, argv); |
| 113 | grpc_init(); |
| 114 | |
| 115 | for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
| 116 | grpc_end2end_tests(configs[i]); |
| 117 | } |
| 118 | |
| 119 | grpc_shutdown(); |
| 120 | |
| 121 | return 0; |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 122 | } |