diff options
author | Craig Tiller <ctiller@google.com> | 2016-03-23 14:57:52 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-03-23 14:57:52 -0700 |
commit | 995bc78441cbd58fe026644265c204d2a2a7551b (patch) | |
tree | dfa81e4a49ab5b77c0313c9acc6b09a260aafb43 /test/core | |
parent | e5b19fe84f0c4b473872632553b3cf5b21e82e60 (diff) | |
parent | 634e67617b3b445185b5485f493b591b53b35d9d (diff) |
Merge github.com:grpc/grpc into fuzzy-bits
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/end2end/fixtures/h2_full+trace.c | 8 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_uchannel.c | 350 | ||||
-rwxr-xr-x | test/core/end2end/gen_build_yaml.py | 1 | ||||
-rw-r--r-- | test/core/http/format_request_test.c (renamed from test/core/httpcli/format_request_test.c) | 36 | ||||
-rw-r--r-- | test/core/http/httpcli_test.c (renamed from test/core/httpcli/httpcli_test.c) | 8 | ||||
-rw-r--r-- | test/core/http/httpscli_test.c (renamed from test/core/httpcli/httpscli_test.c) | 8 | ||||
-rw-r--r-- | test/core/http/parser_test.c (renamed from test/core/httpcli/parser_test.c) | 135 | ||||
-rw-r--r-- | test/core/http/request_corpus/request1.txt | 3 | ||||
-rw-r--r-- | test/core/http/request_fuzzer.c (renamed from test/core/httpcli/fuzzer.c) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427 (renamed from test/core/httpcli/corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/05e613853d64a9669ea3cf41b0de777dc24931ba (renamed from test/core/httpcli/corpus/05e613853d64a9669ea3cf41b0de777dc24931ba) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/069352518a1d1baa05f317c677d275cefda2ac97 (renamed from test/core/httpcli/corpus/069352518a1d1baa05f317c677d275cefda2ac97) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/0c5b7c2569410b526605e308309a7f36574e530d (renamed from test/core/httpcli/corpus/0c5b7c2569410b526605e308309a7f36574e530d) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf (renamed from test/core/httpcli/corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/1e1273f90187fdf5df3625764245610f86af6aa4 (renamed from test/core/httpcli/corpus/1e1273f90187fdf5df3625764245610f86af6aa4) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2 (renamed from test/core/httpcli/corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece (renamed from test/core/httpcli/corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/39b19c41ba537f37511eff7727733715db432e76 (renamed from test/core/httpcli/corpus/39b19c41ba537f37511eff7727733715db432e76) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac (renamed from test/core/httpcli/corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046 (renamed from test/core/httpcli/corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/487725eb38511c79a9340bf4560a1411061fa6fa (renamed from test/core/httpcli/corpus/487725eb38511c79a9340bf4560a1411061fa6fa) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55 (renamed from test/core/httpcli/corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/5028c56a5116a186b7343ff59567b47347a0796d (renamed from test/core/httpcli/corpus/5028c56a5116a186b7343ff59567b47347a0796d) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5 (renamed from test/core/httpcli/corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/657368df512ca6294b9df16adf935a3f374a8be2 (renamed from test/core/httpcli/corpus/657368df512ca6294b9df16adf935a3f374a8be2) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/81f59a12b458ec3604035cb962165c604d1355e6 (renamed from test/core/httpcli/corpus/81f59a12b458ec3604035cb962165c604d1355e6) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9 (renamed from test/core/httpcli/corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/97e4499d450c95660de86747f527e670f2012548 (renamed from test/core/httpcli/corpus/97e4499d450c95660de86747f527e670f2012548) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441 (renamed from test/core/httpcli/corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/b04fea5c041c707db0ad9c09a81672557b52cc47 (renamed from test/core/httpcli/corpus/b04fea5c041c707db0ad9c09a81672557b52cc47) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8 (renamed from test/core/httpcli/corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2 (renamed from test/core/httpcli/corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453 (renamed from test/core/httpcli/corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/d936dad71c129cf659097dc3db64550c4dd467f4 (renamed from test/core/httpcli/corpus/d936dad71c129cf659097dc3db64550c4dd467f4) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066 (renamed from test/core/httpcli/corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066) | 0 | ||||
-rw-r--r-- | test/core/http/response_corpus/response1.txt (renamed from test/core/httpcli/corpus/response1.txt) | 0 | ||||
-rw-r--r-- | test/core/http/response_fuzzer.c | 50 | ||||
-rwxr-xr-x | test/core/http/test_server.py (renamed from test/core/httpcli/test_server.py) | 2 | ||||
-rw-r--r-- | test/core/iomgr/udp_server_test.c | 1 | ||||
-rw-r--r-- | test/core/security/credentials_test.c | 25 | ||||
-rw-r--r-- | test/core/security/jwt_verifier_test.c | 10 | ||||
-rw-r--r-- | test/core/transport/chttp2/timeout_encoding_test.c | 11 | ||||
-rw-r--r-- | test/core/util/port_posix.c | 1 | ||||
-rw-r--r-- | test/core/util/port_server_client.c | 8 | ||||
-rw-r--r-- | test/core/util/port_windows.c | 1 | ||||
-rw-r--r-- | test/core/util/test_config.c | 2 |
46 files changed, 228 insertions, 432 deletions
diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 90b0063089..042ee212d7 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -118,14 +118,14 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(argc, argv, configs[i]); - } - GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0)); GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1)); GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1)); + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(argc, argv, configs[i]); + } + grpc_shutdown(); return 0; diff --git a/test/core/end2end/fixtures/h2_uchannel.c b/test/core/end2end/fixtures/h2_uchannel.c deleted file mode 100644 index 25a4804bea..0000000000 --- a/test/core/end2end/fixtures/h2_uchannel.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * - * Copyright 2015-2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "test/core/end2end/end2end_tests.h" - -#include <string.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/sync.h> -#include <grpc/support/thd.h> -#include <grpc/support/useful.h> -#include "src/core/channel/channel_args.h" -#include "src/core/channel/client_channel.h" -#include "src/core/channel/client_uchannel.h" -#include "src/core/channel/connected_channel.h" -#include "src/core/channel/http_client_filter.h" -#include "src/core/channel/http_server_filter.h" -#include "src/core/client_config/resolver_registry.h" -#include "src/core/iomgr/tcp_client.h" -#include "src/core/surface/channel.h" -#include "src/core/surface/server.h" -#include "src/core/transport/chttp2_transport.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -typedef struct { - grpc_connector base; - gpr_refcount refs; - - grpc_closure *notify; - grpc_connect_in_args args; - grpc_connect_out_args *result; - - grpc_endpoint *tcp; - - grpc_closure connected; -} connector; - -static void connector_ref(grpc_connector *con) { - connector *c = (connector *)con; - gpr_ref(&c->refs); -} - -static void connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *con) { - connector *c = (connector *)con; - if (gpr_unref(&c->refs)) { - gpr_free(c); - } -} - -static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) { - connector *c = arg; - grpc_closure *notify; - grpc_endpoint *tcp = c->tcp; - if (tcp != NULL) { - c->result->transport = - grpc_create_chttp2_transport(exec_ctx, c->args.channel_args, tcp, 1); - grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport, NULL, - 0); - GPR_ASSERT(c->result->transport); - } else { - memset(c->result, 0, sizeof(*c->result)); - } - notify = c->notify; - c->notify = NULL; - notify->cb(exec_ctx, notify->cb_arg, 1); -} - -static void connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *con) {} - -static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con, - const grpc_connect_in_args *args, - grpc_connect_out_args *result, - grpc_closure *notify) { - connector *c = (connector *)con; - GPR_ASSERT(c->notify == NULL); - GPR_ASSERT(notify->cb); - c->notify = notify; - c->args = *args; - c->result = result; - c->tcp = NULL; - grpc_closure_init(&c->connected, connected, c); - grpc_tcp_client_connect(exec_ctx, &c->connected, &c->tcp, - args->interested_parties, args->addr, args->addr_len, - args->deadline); -} - -static const grpc_connector_vtable connector_vtable = { - connector_ref, connector_unref, connector_shutdown, connector_connect}; - -typedef struct { - grpc_subchannel_factory base; - gpr_refcount refs; - grpc_channel_args *merge_args; - grpc_channel *master; - grpc_subchannel **sniffed_subchannel; -} subchannel_factory; - -static void subchannel_factory_ref(grpc_subchannel_factory *scf) { - subchannel_factory *f = (subchannel_factory *)scf; - gpr_ref(&f->refs); -} - -static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx, - grpc_subchannel_factory *scf) { - subchannel_factory *f = (subchannel_factory *)scf; - if (gpr_unref(&f->refs)) { - GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, f->master, "subchannel_factory"); - grpc_channel_args_destroy(f->merge_args); - gpr_free(f); - } -} - -static grpc_subchannel *subchannel_factory_create_subchannel( - grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *scf, - grpc_subchannel_args *args) { - subchannel_factory *f = (subchannel_factory *)scf; - connector *c = gpr_malloc(sizeof(*c)); - grpc_channel_args *final_args = - grpc_channel_args_merge(args->args, f->merge_args); - grpc_subchannel *s; - memset(c, 0, sizeof(*c)); - c->base.vtable = &connector_vtable; - gpr_ref_init(&c->refs, 1); - args->args = final_args; - s = grpc_subchannel_create(exec_ctx, &c->base, args); - grpc_connector_unref(exec_ctx, &c->base); - grpc_channel_args_destroy(final_args); - if (*f->sniffed_subchannel) { - GRPC_SUBCHANNEL_UNREF(exec_ctx, *f->sniffed_subchannel, "sniffed"); - } - *f->sniffed_subchannel = s; - GRPC_SUBCHANNEL_REF(s, "sniffed"); - return s; -} - -static const grpc_subchannel_factory_vtable test_subchannel_factory_vtable = { - subchannel_factory_ref, subchannel_factory_unref, - subchannel_factory_create_subchannel}; - -/* The evil twin of grpc_insecure_channel_create. It allows the test to use the - * custom-built sniffing subchannel_factory */ -grpc_channel *channel_create(const char *target, const grpc_channel_args *args, - grpc_subchannel **sniffed_subchannel) { - grpc_channel *channel = NULL; - grpc_resolver *resolver; - subchannel_factory *f; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - - channel = - grpc_channel_create(&exec_ctx, target, args, GRPC_CLIENT_CHANNEL, NULL); - - f = gpr_malloc(sizeof(*f)); - f->sniffed_subchannel = sniffed_subchannel; - f->base.vtable = &test_subchannel_factory_vtable; - gpr_ref_init(&f->refs, 1); - f->merge_args = grpc_channel_args_copy(args); - f->master = channel; - GRPC_CHANNEL_INTERNAL_REF(f->master, "test_subchannel_factory"); - resolver = grpc_resolver_create(target, &f->base); - if (!resolver) { - return NULL; - } - - grpc_client_channel_set_resolver( - &exec_ctx, grpc_channel_get_channel_stack(channel), resolver); - GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_create"); - grpc_subchannel_factory_unref(&exec_ctx, &f->base); - - grpc_exec_ctx_finish(&exec_ctx); - - return channel; -} - -typedef struct micro_fullstack_fixture_data { - char *localaddr; - grpc_channel *master_channel; - grpc_subchannel *sniffed_subchannel; -} micro_fullstack_fixture_data; - -static grpc_end2end_test_fixture chttp2_create_fixture_micro_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { - grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die(); - micro_fullstack_fixture_data *ffd = - gpr_malloc(sizeof(micro_fullstack_fixture_data)); - memset(&f, 0, sizeof(f)); - memset(ffd, 0, sizeof(*ffd)); - - gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); - - f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); - - return f; -} - -grpc_connectivity_state g_state = GRPC_CHANNEL_IDLE; -grpc_pollset_set *g_interested_parties; - -static void state_changed(grpc_exec_ctx *exec_ctx, void *arg, bool success) { - if (g_state != GRPC_CHANNEL_READY) { - grpc_subchannel_notify_on_state_change( - exec_ctx, arg, g_interested_parties, &g_state, - grpc_closure_create(state_changed, arg)); - } -} - -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *arg, bool success) { - grpc_pollset_destroy(arg); -} - -static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) { - gpr_mu *mu; - grpc_pollset *pollset = gpr_malloc(grpc_pollset_size()); - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_init(pollset, &mu); - g_interested_parties = grpc_pollset_set_create(); - grpc_pollset_set_add_pollset(&exec_ctx, g_interested_parties, pollset); - grpc_subchannel_notify_on_state_change(&exec_ctx, c, g_interested_parties, - &g_state, - grpc_closure_create(state_changed, c)); - grpc_exec_ctx_flush(&exec_ctx); - gpr_mu_lock(mu); - while (g_state != GRPC_CHANNEL_READY) { - grpc_pollset_worker *worker = NULL; - grpc_pollset_work(&exec_ctx, pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); - gpr_mu_unlock(mu); - grpc_exec_ctx_flush(&exec_ctx); - gpr_mu_lock(mu); - } - grpc_pollset_shutdown(&exec_ctx, pollset, - grpc_closure_create(destroy_pollset, pollset)); - grpc_pollset_set_destroy(g_interested_parties); - gpr_mu_unlock(mu); - grpc_exec_ctx_finish(&exec_ctx); - gpr_free(pollset); - return grpc_subchannel_get_connected_subchannel(c); -} - -static void chttp2_init_client_micro_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - micro_fullstack_fixture_data *ffd = f->fixture_data; - grpc_connectivity_state conn_state; - grpc_connected_subchannel *connected_subchannel; - char *ipv4_localaddr; - - gpr_asprintf(&ipv4_localaddr, "ipv4:%s", ffd->localaddr); - ffd->master_channel = - channel_create(ipv4_localaddr, client_args, &ffd->sniffed_subchannel); - gpr_free(ipv4_localaddr); - gpr_log(GPR_INFO, "MASTER CHANNEL %p ", ffd->master_channel); - /* the following will block. That's ok for this test */ - conn_state = grpc_channel_check_connectivity_state(ffd->master_channel, - 1 /* try to connect */); - GPR_ASSERT(conn_state == GRPC_CHANNEL_IDLE); - - /* here sniffed_subchannel should be ready to use */ - GPR_ASSERT(conn_state == GRPC_CHANNEL_IDLE); - GPR_ASSERT(ffd->sniffed_subchannel != NULL); - - connected_subchannel = connect_subchannel(ffd->sniffed_subchannel); - f->client = grpc_client_uchannel_create(ffd->sniffed_subchannel, client_args); - grpc_client_uchannel_set_connected_subchannel(f->client, - connected_subchannel); - gpr_log(GPR_INFO, "CHANNEL WRAPPING SUBCHANNEL: %p(%p)", f->client, - ffd->sniffed_subchannel); - - GPR_ASSERT(f->client); -} - -static void chttp2_init_server_micro_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - micro_fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) { - grpc_server_destroy(f->server); - } - f->server = grpc_server_create(server_args, NULL); - grpc_server_register_completion_queue(f->server, f->cq, NULL); - GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); - grpc_server_start(f->server); -} - -static void chttp2_tear_down_micro_fullstack(grpc_end2end_test_fixture *f) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - micro_fullstack_fixture_data *ffd = f->fixture_data; - grpc_channel_destroy(ffd->master_channel); - if (ffd->sniffed_subchannel) { - GRPC_SUBCHANNEL_UNREF(&exec_ctx, ffd->sniffed_subchannel, "sniffed"); - } - gpr_free(ffd->localaddr); - gpr_free(ffd); - grpc_exec_ctx_finish(&exec_ctx); -} - -/* All test configurations */ -static grpc_end2end_test_config configs[] = { - {"chttp2/micro_fullstack", 0, chttp2_create_fixture_micro_fullstack, - chttp2_init_client_micro_fullstack, chttp2_init_server_micro_fullstack, - chttp2_tear_down_micro_fullstack}, -}; - -int main(int argc, char **argv) { - size_t i; - - grpc_test_init(argc, argv); - grpc_init(); - - for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(argc, argv, configs[i]); - } - - grpc_shutdown(); - - return 0; -} diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index fa32601c60..93b48c331c 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -72,7 +72,6 @@ END2END_FIXTURES = { 'h2_ssl+poll': default_secure_fixture_options._replace(platforms=['linux']), 'h2_ssl_proxy': default_secure_fixture_options._replace(includes_proxy=True, ci_mac=False), - 'h2_uchannel': default_unsecure_fixture_options._replace(fullstack=False), 'h2_uds+poll': uds_fixture_options._replace(platforms=['linux']), 'h2_uds': uds_fixture_options, } diff --git a/test/core/httpcli/format_request_test.c b/test/core/http/format_request_test.c index da850049e2..67dfd24803 100644 --- a/test/core/httpcli/format_request_test.c +++ b/test/core/http/format_request_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ * */ -#include "src/core/httpcli/format_request.h" +#include "src/core/http/format_request.h" #include <string.h> @@ -39,15 +39,15 @@ #include "test/core/util/test_config.h" static void test_format_get_request(void) { - grpc_httpcli_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; gpr_slice slice; memset(&req, 0, sizeof(req)); req.host = "example.com"; - req.path = "/index.html"; - req.hdr_count = 1; - req.hdrs = &hdr; + req.http.path = "/index.html"; + req.http.hdr_count = 1; + req.http.hdrs = &hdr; slice = grpc_httpcli_format_get_request(&req); @@ -64,7 +64,7 @@ static void test_format_get_request(void) { } static void test_format_post_request(void) { - grpc_httpcli_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; gpr_slice slice; char body_bytes[] = "fake body"; @@ -72,9 +72,9 @@ static void test_format_post_request(void) { memset(&req, 0, sizeof(req)); req.host = "example.com"; - req.path = "/index.html"; - req.hdr_count = 1; - req.hdrs = &hdr; + req.http.path = "/index.html"; + req.http.hdr_count = 1; + req.http.hdrs = &hdr; slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len); @@ -94,15 +94,15 @@ static void test_format_post_request(void) { } static void test_format_post_request_no_body(void) { - grpc_httpcli_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; gpr_slice slice; memset(&req, 0, sizeof(req)); req.host = "example.com"; - req.path = "/index.html"; - req.hdr_count = 1; - req.hdrs = &hdr; + req.http.path = "/index.html"; + req.http.hdr_count = 1; + req.http.hdrs = &hdr; slice = grpc_httpcli_format_post_request(&req, NULL, 0); @@ -119,7 +119,7 @@ static void test_format_post_request_no_body(void) { } static void test_format_post_request_content_type_override(void) { - grpc_httpcli_header hdrs[2]; + grpc_http_header hdrs[2]; grpc_httpcli_request req; gpr_slice slice; char body_bytes[] = "fake%20body"; @@ -131,9 +131,9 @@ static void test_format_post_request_content_type_override(void) { hdrs[1].value = "application/x-www-form-urlencoded"; memset(&req, 0, sizeof(req)); req.host = "example.com"; - req.path = "/index.html"; - req.hdr_count = 2; - req.hdrs = hdrs; + req.http.path = "/index.html"; + req.http.hdr_count = 2; + req.http.hdrs = hdrs; slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len); diff --git a/test/core/httpcli/httpcli_test.c b/test/core/http/httpcli_test.c index fbc5d4abe7..bdb7a02e9b 100644 --- a/test/core/httpcli/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -31,7 +31,7 @@ * */ -#include "src/core/httpcli/httpcli.h" +#include "src/core/http/httpcli.h" #include <string.h> @@ -83,7 +83,7 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.path = "/get"; + req.http.path = "/get"; req.handshaker = &grpc_httpcli_plaintext; grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15), @@ -114,7 +114,7 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.path = "/post"; + req.http.path = "/post"; req.handshaker = &grpc_httpcli_plaintext; grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5, @@ -161,7 +161,7 @@ int main(int argc, char **argv) { } else { arg_shift = 1; gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root); + gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); } /* start the server */ diff --git a/test/core/httpcli/httpscli_test.c b/test/core/http/httpscli_test.c index 04c57db286..21845b6a8e 100644 --- a/test/core/httpcli/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -31,7 +31,7 @@ * */ -#include "src/core/httpcli/httpcli.h" +#include "src/core/http/httpcli.h" #include <string.h> @@ -84,7 +84,7 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; req.ssl_host_override = "foo.test.google.fr"; - req.path = "/get"; + req.http.path = "/get"; req.handshaker = &grpc_httpcli_ssl; grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15), @@ -116,7 +116,7 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; req.ssl_host_override = "foo.test.google.fr"; - req.path = "/post"; + req.http.path = "/post"; req.handshaker = &grpc_httpcli_ssl; grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5, @@ -163,7 +163,7 @@ int main(int argc, char **argv) { } else { arg_shift = 1; gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root); + gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); } /* start the server */ diff --git a/test/core/httpcli/parser_test.c b/test/core/http/parser_test.c index a26ddd2821..338a301534 100644 --- a/test/core/httpcli/parser_test.c +++ b/test/core/http/parser_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ * */ -#include "src/core/httpcli/parser.h" +#include "src/core/http/parser.h" #include <stdarg.h> #include <string.h> @@ -43,9 +43,65 @@ #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" +static void test_request_succeeds(grpc_slice_split_mode split_mode, + char *request, char *expect_method, + grpc_http_version expect_version, + char *expect_path, char *expect_body, ...) { + grpc_http_parser parser; + gpr_slice input_slice = gpr_slice_from_copied_string(request); + size_t num_slices; + size_t i; + gpr_slice *slices; + va_list args; + + grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); + gpr_slice_unref(input_slice); + + grpc_http_parser_init(&parser); + + for (i = 0; i < num_slices; i++) { + GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i])); + gpr_slice_unref(slices[i]); + } + GPR_ASSERT(grpc_http_parser_eof(&parser)); + + GPR_ASSERT(GRPC_HTTP_REQUEST == parser.type); + GPR_ASSERT(0 == strcmp(expect_method, parser.http.request.method)); + GPR_ASSERT(0 == strcmp(expect_path, parser.http.request.path)); + GPR_ASSERT(expect_version == parser.http.request.version); + + if (expect_body != NULL) { + GPR_ASSERT(strlen(expect_body) == parser.http.request.body_length); + GPR_ASSERT(0 == memcmp(expect_body, parser.http.request.body, + parser.http.request.body_length)); + } else { + GPR_ASSERT(parser.http.request.body_length == 0); + } + + va_start(args, expect_body); + i = 0; + for (;;) { + char *expect_key; + char *expect_value; + expect_key = va_arg(args, char *); + if (!expect_key) break; + GPR_ASSERT(i < parser.http.request.hdr_count); + expect_value = va_arg(args, char *); + GPR_ASSERT(expect_value); + GPR_ASSERT(0 == strcmp(expect_key, parser.http.request.hdrs[i].key)); + GPR_ASSERT(0 == strcmp(expect_value, parser.http.request.hdrs[i].value)); + i++; + } + va_end(args); + GPR_ASSERT(i == parser.http.request.hdr_count); + + grpc_http_parser_destroy(&parser); + gpr_free(slices); +} + static void test_succeeds(grpc_slice_split_mode split_mode, char *response, int expect_status, char *expect_body, ...) { - grpc_httpcli_parser parser; + grpc_http_parser parser; gpr_slice input_slice = gpr_slice_from_copied_string(response); size_t num_slices; size_t i; @@ -55,20 +111,22 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response, grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); gpr_slice_unref(input_slice); - grpc_httpcli_parser_init(&parser); + grpc_http_parser_init(&parser); for (i = 0; i < num_slices; i++) { - GPR_ASSERT(grpc_httpcli_parser_parse(&parser, slices[i])); + GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i])); gpr_slice_unref(slices[i]); } - GPR_ASSERT(grpc_httpcli_parser_eof(&parser)); + GPR_ASSERT(grpc_http_parser_eof(&parser)); - GPR_ASSERT(expect_status == parser.r.status); + GPR_ASSERT(GRPC_HTTP_RESPONSE == parser.type); + GPR_ASSERT(expect_status == parser.http.response.status); if (expect_body != NULL) { - GPR_ASSERT(strlen(expect_body) == parser.r.body_length); - GPR_ASSERT(0 == memcmp(expect_body, parser.r.body, parser.r.body_length)); + GPR_ASSERT(strlen(expect_body) == parser.http.response.body_length); + GPR_ASSERT(0 == memcmp(expect_body, parser.http.response.body, + parser.http.response.body_length)); } else { - GPR_ASSERT(parser.r.body_length == 0); + GPR_ASSERT(parser.http.response.body_length == 0); } va_start(args, expect_body); @@ -78,22 +136,22 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response, char *expect_value; expect_key = va_arg(args, char *); if (!expect_key) break; - GPR_ASSERT(i < parser.r.hdr_count); + GPR_ASSERT(i < parser.http.response.hdr_count); expect_value = va_arg(args, char *); GPR_ASSERT(expect_value); - GPR_ASSERT(0 == strcmp(expect_key, parser.r.hdrs[i].key)); - GPR_ASSERT(0 == strcmp(expect_value, parser.r.hdrs[i].value)); + GPR_ASSERT(0 == strcmp(expect_key, parser.http.response.hdrs[i].key)); + GPR_ASSERT(0 == strcmp(expect_value, parser.http.response.hdrs[i].value)); i++; } va_end(args); - GPR_ASSERT(i == parser.r.hdr_count); + GPR_ASSERT(i == parser.http.response.hdr_count); - grpc_httpcli_parser_destroy(&parser); + grpc_http_parser_destroy(&parser); gpr_free(slices); } static void test_fails(grpc_slice_split_mode split_mode, char *response) { - grpc_httpcli_parser parser; + grpc_http_parser parser; gpr_slice input_slice = gpr_slice_from_copied_string(response); size_t num_slices; size_t i; @@ -103,20 +161,20 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response) { grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); gpr_slice_unref(input_slice); - grpc_httpcli_parser_init(&parser); + grpc_http_parser_init(&parser); for (i = 0; i < num_slices; i++) { - if (!done && !grpc_httpcli_parser_parse(&parser, slices[i])) { + if (!done && !grpc_http_parser_parse(&parser, slices[i])) { done = 1; } gpr_slice_unref(slices[i]); } - if (!done && !grpc_httpcli_parser_eof(&parser)) { + if (!done && !grpc_http_parser_eof(&parser)) { done = 1; } GPR_ASSERT(done); - grpc_httpcli_parser_destroy(&parser); + grpc_http_parser_destroy(&parser); gpr_free(slices); } @@ -145,6 +203,32 @@ int main(int argc, char **argv) { "\r\n" "hello world!", 200, "hello world!", "xyz", "abc", NULL); + test_request_succeeds(split_modes[i], + "GET / HTTP/1.0\r\n" + "\r\n", + "GET", GRPC_HTTP_HTTP10, "/", NULL, NULL); + test_request_succeeds(split_modes[i], + "GET / HTTP/1.0\r\n" + "\r\n" + "xyz", + "GET", GRPC_HTTP_HTTP10, "/", "xyz", NULL); + test_request_succeeds(split_modes[i], + "GET / HTTP/1.1\r\n" + "\r\n" + "xyz", + "GET", GRPC_HTTP_HTTP11, "/", "xyz", NULL); + test_request_succeeds(split_modes[i], + "GET / HTTP/2.0\r\n" + "\r\n" + "xyz", + "GET", GRPC_HTTP_HTTP20, "/", "xyz", NULL); + test_request_succeeds(split_modes[i], + "GET / HTTP/1.0\r\n" + "xyz: abc\r\n" + "\r\n" + "xyz", + "GET", GRPC_HTTP_HTTP10, "/", "xyz", "xyz", "abc", + NULL); test_fails(split_modes[i], "HTTP/1.0\r\n"); test_fails(split_modes[i], "HTTP/1.2\r\n"); test_fails(split_modes[i], "HTTP/1.0 000 XYX\r\n"); @@ -157,10 +241,15 @@ int main(int argc, char **argv) { " def\r\n" "\r\n" "hello world!"); + test_fails(split_modes[i], "GET\r\n"); + test_fails(split_modes[i], "GET /\r\n"); + test_fails(split_modes[i], "GET / HTTP/0.0\r\n"); + test_fails(split_modes[i], "GET / ____/1.0\r\n"); + test_fails(split_modes[i], "GET / HTTP/1.2\r\n"); - tmp1 = gpr_malloc(2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH); - memset(tmp1, 'a', 2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH - 1); - tmp1[2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH - 1] = 0; + tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH); + memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1); + tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0; gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1); test_fails(split_modes[i], tmp2); gpr_free(tmp1); diff --git a/test/core/http/request_corpus/request1.txt b/test/core/http/request_corpus/request1.txt new file mode 100644 index 0000000000..16a750fbf9 --- /dev/null +++ b/test/core/http/request_corpus/request1.txt @@ -0,0 +1,3 @@ +GET / HTTP/1.0 + + diff --git a/test/core/httpcli/fuzzer.c b/test/core/http/request_fuzzer.c index ff960484db..ff960484db 100644 --- a/test/core/httpcli/fuzzer.c +++ b/test/core/http/request_fuzzer.c diff --git a/test/core/httpcli/corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427 b/test/core/http/response_corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427 index 3d6face56a..3d6face56a 100644 --- a/test/core/httpcli/corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427 +++ b/test/core/http/response_corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427 diff --git a/test/core/httpcli/corpus/05e613853d64a9669ea3cf41b0de777dc24931ba b/test/core/http/response_corpus/05e613853d64a9669ea3cf41b0de777dc24931ba index 5cbaf2e460..5cbaf2e460 100644 --- a/test/core/httpcli/corpus/05e613853d64a9669ea3cf41b0de777dc24931ba +++ b/test/core/http/response_corpus/05e613853d64a9669ea3cf41b0de777dc24931ba diff --git a/test/core/httpcli/corpus/069352518a1d1baa05f317c677d275cefda2ac97 b/test/core/http/response_corpus/069352518a1d1baa05f317c677d275cefda2ac97 index 8831f0786b..8831f0786b 100644 --- a/test/core/httpcli/corpus/069352518a1d1baa05f317c677d275cefda2ac97 +++ b/test/core/http/response_corpus/069352518a1d1baa05f317c677d275cefda2ac97 diff --git a/test/core/httpcli/corpus/0c5b7c2569410b526605e308309a7f36574e530d b/test/core/http/response_corpus/0c5b7c2569410b526605e308309a7f36574e530d index c79e456904..c79e456904 100644 --- a/test/core/httpcli/corpus/0c5b7c2569410b526605e308309a7f36574e530d +++ b/test/core/http/response_corpus/0c5b7c2569410b526605e308309a7f36574e530d diff --git a/test/core/httpcli/corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf b/test/core/http/response_corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf index 7b979b5e10..7b979b5e10 100644 --- a/test/core/httpcli/corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf +++ b/test/core/http/response_corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf diff --git a/test/core/httpcli/corpus/1e1273f90187fdf5df3625764245610f86af6aa4 b/test/core/http/response_corpus/1e1273f90187fdf5df3625764245610f86af6aa4 index 67382b4f3a..67382b4f3a 100644 --- a/test/core/httpcli/corpus/1e1273f90187fdf5df3625764245610f86af6aa4 +++ b/test/core/http/response_corpus/1e1273f90187fdf5df3625764245610f86af6aa4 diff --git a/test/core/httpcli/corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2 b/test/core/http/response_corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2 index cce8ded71a..cce8ded71a 100644 --- a/test/core/httpcli/corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2 +++ b/test/core/http/response_corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2 diff --git a/test/core/httpcli/corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece b/test/core/http/response_corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece index 8df43e4dce..8df43e4dce 100644 --- a/test/core/httpcli/corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece +++ b/test/core/http/response_corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece diff --git a/test/core/httpcli/corpus/39b19c41ba537f37511eff7727733715db432e76 b/test/core/http/response_corpus/39b19c41ba537f37511eff7727733715db432e76 index fefa4512a8..fefa4512a8 100644 --- a/test/core/httpcli/corpus/39b19c41ba537f37511eff7727733715db432e76 +++ b/test/core/http/response_corpus/39b19c41ba537f37511eff7727733715db432e76 diff --git a/test/core/httpcli/corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac b/test/core/http/response_corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac index b967b57614..b967b57614 100644 --- a/test/core/httpcli/corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac +++ b/test/core/http/response_corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac diff --git a/test/core/httpcli/corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046 b/test/core/http/response_corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046 index 7d20266703..7d20266703 100644 --- a/test/core/httpcli/corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046 +++ b/test/core/http/response_corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046 diff --git a/test/core/httpcli/corpus/487725eb38511c79a9340bf4560a1411061fa6fa b/test/core/http/response_corpus/487725eb38511c79a9340bf4560a1411061fa6fa index c59c4d2246..c59c4d2246 100644 --- a/test/core/httpcli/corpus/487725eb38511c79a9340bf4560a1411061fa6fa +++ b/test/core/http/response_corpus/487725eb38511c79a9340bf4560a1411061fa6fa diff --git a/test/core/httpcli/corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55 b/test/core/http/response_corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55 index 49d1c8f1d2..49d1c8f1d2 100644 --- a/test/core/httpcli/corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55 +++ b/test/core/http/response_corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55 diff --git a/test/core/httpcli/corpus/5028c56a5116a186b7343ff59567b47347a0796d b/test/core/http/response_corpus/5028c56a5116a186b7343ff59567b47347a0796d index 5f2c4dfef0..5f2c4dfef0 100644 --- a/test/core/httpcli/corpus/5028c56a5116a186b7343ff59567b47347a0796d +++ b/test/core/http/response_corpus/5028c56a5116a186b7343ff59567b47347a0796d diff --git a/test/core/httpcli/corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5 b/test/core/http/response_corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5 index 9a15ab025f..9a15ab025f 100644 --- a/test/core/httpcli/corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5 +++ b/test/core/http/response_corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5 diff --git a/test/core/httpcli/corpus/657368df512ca6294b9df16adf935a3f374a8be2 b/test/core/http/response_corpus/657368df512ca6294b9df16adf935a3f374a8be2 index 1f14f69103..1f14f69103 100644 --- a/test/core/httpcli/corpus/657368df512ca6294b9df16adf935a3f374a8be2 +++ b/test/core/http/response_corpus/657368df512ca6294b9df16adf935a3f374a8be2 diff --git a/test/core/httpcli/corpus/81f59a12b458ec3604035cb962165c604d1355e6 b/test/core/http/response_corpus/81f59a12b458ec3604035cb962165c604d1355e6 index d4223ccf81..d4223ccf81 100644 --- a/test/core/httpcli/corpus/81f59a12b458ec3604035cb962165c604d1355e6 +++ b/test/core/http/response_corpus/81f59a12b458ec3604035cb962165c604d1355e6 diff --git a/test/core/httpcli/corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9 b/test/core/http/response_corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9 index 99e2c48bbd..99e2c48bbd 100644 --- a/test/core/httpcli/corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9 +++ b/test/core/http/response_corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9 diff --git a/test/core/httpcli/corpus/97e4499d450c95660de86747f527e670f2012548 b/test/core/http/response_corpus/97e4499d450c95660de86747f527e670f2012548 index b1927fbf63..b1927fbf63 100644 --- a/test/core/httpcli/corpus/97e4499d450c95660de86747f527e670f2012548 +++ b/test/core/http/response_corpus/97e4499d450c95660de86747f527e670f2012548 diff --git a/test/core/httpcli/corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441 b/test/core/http/response_corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441 index 837449dda3..837449dda3 100644 --- a/test/core/httpcli/corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441 +++ b/test/core/http/response_corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441 diff --git a/test/core/httpcli/corpus/b04fea5c041c707db0ad9c09a81672557b52cc47 b/test/core/http/response_corpus/b04fea5c041c707db0ad9c09a81672557b52cc47 index 10905bed39..10905bed39 100644 --- a/test/core/httpcli/corpus/b04fea5c041c707db0ad9c09a81672557b52cc47 +++ b/test/core/http/response_corpus/b04fea5c041c707db0ad9c09a81672557b52cc47 diff --git a/test/core/httpcli/corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8 b/test/core/http/response_corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8 index 2704e4fb39..2704e4fb39 100644 --- a/test/core/httpcli/corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8 +++ b/test/core/http/response_corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8 diff --git a/test/core/httpcli/corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2 b/test/core/http/response_corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2 index f5cbbc69e7..f5cbbc69e7 100644 --- a/test/core/httpcli/corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2 +++ b/test/core/http/response_corpus/ca5a0c00b8969310acb73d15ad0d0c602f1bd0c2 diff --git a/test/core/httpcli/corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453 b/test/core/http/response_corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453 index be33d81102..be33d81102 100644 --- a/test/core/httpcli/corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453 +++ b/test/core/http/response_corpus/d4c3e4cf5d035596433c30eaabbd2b2925f4b453 diff --git a/test/core/httpcli/corpus/d936dad71c129cf659097dc3db64550c4dd467f4 b/test/core/http/response_corpus/d936dad71c129cf659097dc3db64550c4dd467f4 index ccf918751d..ccf918751d 100644 --- a/test/core/httpcli/corpus/d936dad71c129cf659097dc3db64550c4dd467f4 +++ b/test/core/http/response_corpus/d936dad71c129cf659097dc3db64550c4dd467f4 diff --git a/test/core/httpcli/corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066 b/test/core/http/response_corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066 index 06f1a3b800..06f1a3b800 100644 --- a/test/core/httpcli/corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066 +++ b/test/core/http/response_corpus/fc5d4b9117ba9e87388174aee4f4970bdfe8d066 diff --git a/test/core/httpcli/corpus/response1.txt b/test/core/http/response_corpus/response1.txt index a17139982e..a17139982e 100644 --- a/test/core/httpcli/corpus/response1.txt +++ b/test/core/http/response_corpus/response1.txt diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.c new file mode 100644 index 0000000000..ff960484db --- /dev/null +++ b/test/core/http/response_fuzzer.c @@ -0,0 +1,50 @@ +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdint.h> +#include <string.h> + +#include <grpc/support/alloc.h> + +#include "src/core/httpcli/parser.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + grpc_httpcli_parser parser; + grpc_httpcli_parser_init(&parser); + gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); + grpc_httpcli_parser_parse(&parser, slice); + grpc_httpcli_parser_eof(&parser); + gpr_slice_unref(slice); + grpc_httpcli_parser_destroy(&parser); + return 0; +} diff --git a/test/core/httpcli/test_server.py b/test/core/http/test_server.py index dbbf5ceb3c..ecde494cc0 100755 --- a/test/core/httpcli/test_server.py +++ b/test/core/http/test_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2.7 -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index ce3c23b4bf..365b5c002b 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -34,6 +34,7 @@ #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset_posix.h" #include "src/core/iomgr/udp_server.h" +#include <grpc/grpc.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 98133ef5e5..fd9ccbf45d 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -44,7 +44,7 @@ #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include "src/core/httpcli/httpcli.h" +#include "src/core/http/httpcli.h" #include "src/core/security/json_token.h" #include "src/core/support/env.h" #include "src/core/support/tmpfile.h" @@ -536,12 +536,12 @@ static void validate_compute_engine_http_request( GPR_ASSERT(request->handshaker != &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "metadata") == 0); GPR_ASSERT( - strcmp(request->path, + strcmp(request->http.path, "/computeMetadata/v1/instance/service-accounts/default/token") == 0); - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Metadata-Flavor") == 0); - GPR_ASSERT(strcmp(request->hdrs[0].value, "Google") == 0); + GPR_ASSERT(request->http.hdr_count == 1); + GPR_ASSERT(strcmp(request->http.hdrs[0].key, "Metadata-Flavor") == 0); + GPR_ASSERT(strcmp(request->http.hdrs[0].value, "Google") == 0); } static int compute_engine_httpcli_get_success_override( @@ -639,11 +639,12 @@ static void validate_refresh_token_http_request( gpr_free(expected_body); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, GRPC_GOOGLE_OAUTH2_SERVICE_HOST) == 0); - GPR_ASSERT(strcmp(request->path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH) == 0); - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); + strcmp(request->http.path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH) == 0); + GPR_ASSERT(request->http.hdr_count == 1); + GPR_ASSERT(strcmp(request->http.hdrs[0].key, "Content-Type") == 0); + GPR_ASSERT(strcmp(request->http.hdrs[0].value, + "application/x-www-form-urlencoded") == 0); } static int refresh_token_httpcli_post_success( @@ -898,12 +899,12 @@ static int default_creds_gce_detection_httpcli_get_success_override( gpr_timespec deadline, grpc_httpcli_response_cb on_response, void *user_data) { grpc_httpcli_response response = http_response(200, ""); - grpc_httpcli_header header; + grpc_http_header header; header.key = "Metadata-Flavor"; header.value = "Google"; response.hdr_count = 1; response.hdrs = &header; - GPR_ASSERT(strcmp(request->path, "/") == 0); + GPR_ASSERT(strcmp(request->http.path, "/") == 0); GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0); on_response(exec_ctx, user_data, &response); return 1; @@ -961,7 +962,7 @@ static int default_creds_gce_detection_httpcli_get_failure_override( void *user_data) { /* No magic header. */ grpc_httpcli_response response = http_response(200, ""); - GPR_ASSERT(strcmp(request->path, "/") == 0); + GPR_ASSERT(strcmp(request->http.path, "/") == 0); GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0); on_response(exec_ctx, user_data, &response); return 1; diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index f6ec9e12ef..d2f8d1d182 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -35,7 +35,7 @@ #include <string.h> -#include "src/core/httpcli/httpcli.h" +#include "src/core/http/httpcli.h" #include "src/core/security/b64.h" #include "src/core/security/json_token.h" #include "test/core/util/test_config.h" @@ -288,7 +288,7 @@ static int httpcli_get_google_keys_for_email( grpc_httpcli_response response = http_response(200, good_google_email_keys()); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0); - GPR_ASSERT(strcmp(request->path, + GPR_ASSERT(strcmp(request->http.path, "/robot/v1/metadata/x509/" "777-abaslkan11hlb6nmim3bpspl31ud@developer." "gserviceaccount.com") == 0); @@ -336,7 +336,7 @@ static int httpcli_get_custom_keys_for_email( grpc_httpcli_response response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0); - GPR_ASSERT(strcmp(request->path, "/jwk/foo@bar.com") == 0); + GPR_ASSERT(strcmp(request->http.path, "/jwk/foo@bar.com") == 0); on_response(exec_ctx, user_data, &response); gpr_free(response.body); return 1; @@ -372,7 +372,7 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx, grpc_httpcli_response response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0); - GPR_ASSERT(strcmp(request->path, "/oauth2/v3/certs") == 0); + GPR_ASSERT(strcmp(request->http.path, "/oauth2/v3/certs") == 0); on_response(exec_ctx, user_data, &response); gpr_free(response.body); return 1; @@ -387,7 +387,7 @@ static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx, http_response(200, gpr_strdup(good_openid_config)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "accounts.google.com") == 0); - GPR_ASSERT(strcmp(request->path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0); + GPR_ASSERT(strcmp(request->http.path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0); grpc_httpcli_set_override(httpcli_get_jwk_set, httpcli_post_should_not_be_called); on_response(exec_ctx, user_data, &response); diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c index 483e79fb25..b7dd60e9b1 100644 --- a/test/core/transport/chttp2/timeout_encoding_test.c +++ b/test/core/transport/chttp2/timeout_encoding_test.c @@ -36,11 +36,11 @@ #include <stdio.h> #include <string.h> -#include "src/core/support/string.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/useful.h> +#include "src/core/support/string.h" #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) @@ -128,11 +128,10 @@ void test_decoding(void) { decode_suite('H', gpr_time_from_hours); assert_decodes_as("1000000000S", gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN)); - assert_decodes_as("1000000000000000000000u", - gpr_inf_future(GPR_CLOCK_REALTIME)); - assert_decodes_as("1000000001S", gpr_inf_future(GPR_CLOCK_REALTIME)); - assert_decodes_as("2000000001S", gpr_inf_future(GPR_CLOCK_REALTIME)); - assert_decodes_as("9999999999S", gpr_inf_future(GPR_CLOCK_REALTIME)); + assert_decodes_as("1000000000000000000000u", gpr_inf_future(GPR_TIMESPAN)); + assert_decodes_as("1000000001S", gpr_inf_future(GPR_TIMESPAN)); + assert_decodes_as("2000000001S", gpr_inf_future(GPR_TIMESPAN)); + assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN)); } void test_decoding_fails(void) { diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 5c0b2717cb..d211016267 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -49,6 +49,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include "src/core/http/httpcli.h" #include "src/core/support/env.h" #include "test/core/util/port_server_client.h" diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index 653ecb2709..c7b9d63109 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -47,7 +47,7 @@ #include <grpc/support/sync.h> #include <grpc/support/time.h> -#include "src/core/httpcli/httpcli.h" +#include "src/core/http/httpcli.h" typedef struct freereq { gpr_mu *mu; @@ -91,7 +91,7 @@ void grpc_free_port_using_server(char *server, int port) { req.host = server; gpr_asprintf(&path, "/drop/%d", port); - req.path = path; + req.http.path = path; grpc_httpcli_context_init(&context); grpc_httpcli_get(&exec_ctx, &context, pr.pollset, &req, @@ -150,7 +150,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, GPR_TIMESPAN))); pr->retries++; req.host = pr->server; - req.path = "/get"; + req.http.path = "/get"; grpc_httpcli_get(exec_ctx, pr->ctx, pr->pollset, &req, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server, pr); @@ -189,7 +189,7 @@ int grpc_pick_port_using_server(char *server) { pr.ctx = &context; req.host = server; - req.path = "/get"; + req.http.path = "/get"; grpc_httpcli_context_init(&context); grpc_httpcli_get(&exec_ctx, &context, pr.pollset, &req, diff --git a/test/core/util/port_windows.c b/test/core/util/port_windows.c index a810683440..77125dde75 100644 --- a/test/core/util/port_windows.c +++ b/test/core/util/port_windows.c @@ -47,6 +47,7 @@ #include <grpc/support/log.h> #include "src/core/support/env.h" +#include "src/core/http/httpcli.h" #include "src/core/iomgr/sockaddr_utils.h" #include "test/core/util/port_server_client.h" diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index bf672e8f67..f408048fdf 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -99,6 +99,7 @@ static void print_current_stack() { SymFromAddrW(process, (DWORD64)(callers_stack[i]), 0, symbol); fwprintf(stderr, L"*** %d: %016I64X %ls - %016I64X\n", i, (DWORD64)callers_stack[i], symbol->Name, (DWORD64)symbol->Address); + fflush(stderr); } free(symbol); @@ -154,6 +155,7 @@ static void print_stack_from_context(CONTEXT c) { fwprintf( stderr, L"*** %016I64X %ls - %016I64X\n", (DWORD64)(s.AddrPC.Offset), has_symbol ? symbol->Name : L"<<no symbol>>", (DWORD64)symbol->Address); + fflush(stderr); } free(symbol); |