diff options
author | 2015-06-08 11:20:05 -0700 | |
---|---|---|
committer | 2015-06-08 11:20:05 -0700 | |
commit | 237443faa49dce1ba4df2d74000acef2802b3bdd (patch) | |
tree | 3734ce17e23acc5e9d24f13a99c56c5c3b354caf /test/core | |
parent | 25d02d56370bfa0ead2a79203c522ce02cbe9394 (diff) | |
parent | b32c082906b9b52b89387761c3f7cb01638bcadc (diff) |
Merge branch 'master' of github.com:grpc/grpc into compression
Diffstat (limited to 'test/core')
23 files changed, 256 insertions, 56 deletions
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 4cc1ad4312..7319545c84 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -38,6 +38,7 @@ #include "src/core/iomgr/endpoint_pair.h" #include "src/core/surface/completion_queue.h" #include "src/core/surface/server.h" +#include "src/core/support/string.h" #include "src/core/transport/chttp2_transport.h" #include <grpc/support/sync.h> @@ -72,17 +73,21 @@ static grpc_transport_setup_result server_setup_transport( grpc_server_get_channel_args(a->server)); } -void grpc_run_bad_client_test(const char *name, const char *client_payload, - size_t client_payload_length, - grpc_bad_client_server_side_validator validator) { +void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, + const char *client_payload, + size_t client_payload_length, gpr_uint32 flags) { grpc_endpoint_pair sfd; thd_args a; gpr_thd_id id; + char *hex; gpr_slice slice = gpr_slice_from_copied_buffer(client_payload, client_payload_length); + hex = + gpr_hexdump(client_payload, client_payload_length, GPR_HEXDUMP_PLAINTEXT); + /* Add a debug log */ - gpr_log(GPR_INFO, "TEST: %s", name); + gpr_log(GPR_INFO, "TEST: %s", hex); /* Init grpc */ grpc_init(); @@ -126,10 +131,18 @@ void grpc_run_bad_client_test(const char *name, const char *client_payload, /* Await completion */ GPR_ASSERT( gpr_event_wait(&a.done_write, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); + + if (flags & GRPC_BAD_CLIENT_DISCONNECT) { + grpc_endpoint_destroy(sfd.client); + sfd.client = NULL; + } + GPR_ASSERT(gpr_event_wait(&a.done_thd, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); /* Shutdown */ - grpc_endpoint_destroy(sfd.client); + if (sfd.client) { + grpc_endpoint_destroy(sfd.client); + } grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index 4834e86cce..01beda60ee 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -40,13 +40,18 @@ typedef void (*grpc_bad_client_server_side_validator)( grpc_server *server, grpc_completion_queue *cq); +#define GRPC_BAD_CLIENT_DISCONNECT 1 + /* Test runner. Create a server, and send client_payload to it as bytes from a client. Execute validator in a separate thread to assert that the bytes are handled as expected. */ -void grpc_run_bad_client_test(const char *name, const char *client_payload, - size_t client_payload_length, - grpc_bad_client_server_side_validator validator); +void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, + const char *client_payload, + size_t client_payload_length, gpr_uint32 flags); + +#define GRPC_RUN_BAD_CLIENT_TEST(validator, payload, flags) \ + grpc_run_bad_client_test(validator, payload, sizeof(payload) - 1, flags) #endif /* GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H */ diff --git a/test/core/bad_client/gen_build_json.py b/test/core/bad_client/gen_build_json.py index 67969a1a12..a6fa266bec 100755 --- a/test/core/bad_client/gen_build_json.py +++ b/test/core/bad_client/gen_build_json.py @@ -41,6 +41,7 @@ default_test_options = TestOptions(False) # maps test names to options BAD_CLIENT_TESTS = { 'connection_prefix': default_test_options, + 'initial_settings_frame': default_test_options, } def main(): diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c index e8bf935710..0bd86ecf55 100644 --- a/test/core/bad_client/tests/connection_prefix.c +++ b/test/core/bad_client/tests/connection_prefix.c @@ -36,44 +36,38 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { while (grpc_server_has_open_connections(server)) { - GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20)).type == - GRPC_QUEUE_TIMEOUT); + GPR_ASSERT( + grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20)) + .type == GRPC_QUEUE_TIMEOUT); } } int main(int argc, char **argv) { grpc_test_init(argc, argv); - grpc_run_bad_client_test("conpfx_1", "X", 1, verifier); - grpc_run_bad_client_test("conpfx_2", "PX", 2, verifier); - grpc_run_bad_client_test("conpfx_3", "PRX", 3, verifier); - grpc_run_bad_client_test("conpfx_4", "PRIX", 4, verifier); - grpc_run_bad_client_test("conpfx_5", "PRI X", 5, verifier); - grpc_run_bad_client_test("conpfx_6", "PRI *X", 6, verifier); - grpc_run_bad_client_test("conpfx_7", "PRI * X", 7, verifier); - grpc_run_bad_client_test("conpfx_8", "PRI * HX", 8, verifier); - grpc_run_bad_client_test("conpfx_9", "PRI * HTX", 9, verifier); - grpc_run_bad_client_test("conpfx_10", "PRI * HTTX", 10, verifier); - grpc_run_bad_client_test("conpfx_11", "PRI * HTTPX", 11, verifier); - grpc_run_bad_client_test("conpfx_12", "PRI * HTTP/X", 12, verifier); - grpc_run_bad_client_test("conpfx_13", "PRI * HTTP/2X", 13, verifier); - grpc_run_bad_client_test("conpfx_14", "PRI * HTTP/2.X", 14, verifier); - grpc_run_bad_client_test("conpfx_15", "PRI * HTTP/2.0X", 15, verifier); - grpc_run_bad_client_test("conpfx_16", "PRI * HTTP/2.0\rX", 16, verifier); - grpc_run_bad_client_test("conpfx_17", "PRI * HTTP/2.0\r\nX", 17, verifier); - grpc_run_bad_client_test("conpfx_18", "PRI * HTTP/2.0\r\n\rX", 18, verifier); - grpc_run_bad_client_test("conpfx_19", "PRI * HTTP/2.0\r\n\r\nX", 19, - verifier); - grpc_run_bad_client_test("conpfx_20", "PRI * HTTP/2.0\r\n\r\nSX", 20, - verifier); - grpc_run_bad_client_test("conpfx_21", "PRI * HTTP/2.0\r\n\r\nSMX", 21, - verifier); - grpc_run_bad_client_test("conpfx_22", "PRI * HTTP/2.0\r\n\r\nSM\rX", 22, - verifier); - grpc_run_bad_client_test("conpfx_23", "PRI * HTTP/2.0\r\n\r\nSM\r\nX", 23, - verifier); - grpc_run_bad_client_test("conpfx_24", "PRI * HTTP/2.0\r\n\r\nSM\r\n\rX", 24, - verifier); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRIX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI *X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTPX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0X", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\rX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\nX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\rX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nSX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nSMX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nSM\rX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nSM\r\nX", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, "PRI * HTTP/2.0\r\n\r\nSM\r\n\rX", 0); return 0; } diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c new file mode 100644 index 0000000000..2075602e27 --- /dev/null +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -0,0 +1,95 @@ +/* + * + * Copyright 2015, 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/bad_client/bad_client.h" +#include "src/core/surface/server.h" + +#define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" + +static void verifier(grpc_server *server, grpc_completion_queue *cq) { + while (grpc_server_has_open_connections(server)) { + GPR_ASSERT( + grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20)) + .type == GRPC_QUEUE_TIMEOUT); + } +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + + /* various partial prefixes */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x06", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x06", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x06", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x01", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\xff", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + /* must not send frames with stream id != 0 */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00\x01", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x00\x04\x00\x40\x00\x00\x00", 0); + /* settings frame must be a multiple of six bytes long */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x01\x04\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x02\x04\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x03\x04\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x04\x04\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x05\x04\x00\x00\x00\x00\x00", 0); + + return 0; +} diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 7822d001d1..8fd6867b78 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -42,6 +42,7 @@ #include <grpc/byte_buffer.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/time.h> #include <grpc/support/useful.h> diff --git a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c index 876782df84..02aa575065 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c +++ b/test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c @@ -48,6 +48,7 @@ #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> diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c index d32dbec25e..0834987fbe 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c @@ -147,6 +147,10 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); + 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(configs[i]); } diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c index b808684cd1..e0f996993f 100644 --- a/test/core/end2end/tests/census_simple_request.c +++ b/test/core/end2end/tests/census_simple_request.c @@ -40,6 +40,7 @@ #include <grpc/byte_buffer.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/time.h> #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_stream_test.c index 41ba995544..4d9253c0ad 100644 --- a/test/core/fling/fling_stream_test.c +++ b/test/core/fling/fling_stream_test.c @@ -47,6 +47,7 @@ #include "src/core/support/string.h" #include <grpc/support/alloc.h> #include <grpc/support/host_port.h> +#include <grpc/support/string_util.h> #include "test/core/util/port.h" int main(int argc, char **argv) { diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_test.c index 6b07f83d5b..f9ba461d24 100644 --- a/test/core/fling/fling_test.c +++ b/test/core/fling/fling_test.c @@ -35,8 +35,9 @@ #include <stdio.h> #include <grpc/support/alloc.h> -#include <grpc/support/subprocess.h> #include <grpc/support/host_port.h> +#include <grpc/support/string_util.h> +#include <grpc/support/subprocess.h> #include "src/core/support/string.h" #include "test/core/util/port.h" diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c index fb2dbc00ce..76820916a1 100644 --- a/test/core/httpcli/httpcli_test.c +++ b/test/core/httpcli/httpcli_test.c @@ -36,8 +36,12 @@ #include <string.h> #include "src/core/iomgr/iomgr.h" +#include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/subprocess.h> #include <grpc/support/sync.h> +#include "test/core/util/port.h" #include "test/core/util/test_config.h" static gpr_event g_done; @@ -47,56 +51,93 @@ static gpr_timespec n_seconds_time(int seconds) { } static void on_finish(void *arg, const grpc_httpcli_response *response) { + const char *expect = + "<html><head><title>Hello world!</title></head>" + "<body><p>This is a test</p></body></html>"; GPR_ASSERT(arg == (void *)42); GPR_ASSERT(response); GPR_ASSERT(response->status == 200); + GPR_ASSERT(response->body_length == strlen(expect)); + GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length)); gpr_event_set(&g_done, (void *)1); } -static void test_get(int use_ssl) { +static void test_get(int use_ssl, int port) { grpc_httpcli_request req; + char* host; gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_get", use_ssl); + gpr_asprintf(&host, "localhost:%d", port); + gpr_log(GPR_INFO, "requesting from %s", host); + gpr_event_init(&g_done); memset(&req, 0, sizeof(req)); - req.host = "www.google.com"; - req.path = "/"; + req.host = host; + req.path = "/get"; req.use_ssl = use_ssl; grpc_httpcli_get(&req, n_seconds_time(15), on_finish, (void *)42); + gpr_free(host); GPR_ASSERT(gpr_event_wait(&g_done, n_seconds_time(20))); } -/* -static void test_post(int use_ssl) { +static void test_post(int use_ssl, int port) { grpc_httpcli_request req; + char* host; gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_post", (int)use_ssl); + gpr_asprintf(&host, "localhost:%d", port); + gpr_log(GPR_INFO, "posting to %s", host); + gpr_event_init(&g_done); memset(&req, 0, sizeof(req)); - req.host = "requestb.in"; - req.path = "/1eamwr21"; + req.host = host; + req.path = "/post"; req.use_ssl = use_ssl; - grpc_httpcli_post(&req, NULL, 0, n_seconds_time(15), on_finish, + grpc_httpcli_post(&req, "hello", 5, n_seconds_time(15), on_finish, (void *)42); GPR_ASSERT(gpr_event_wait(&g_done, n_seconds_time(20))); } -*/ int main(int argc, char **argv) { + gpr_subprocess* server; + char *me = argv[0]; + char *lslash = strrchr(me, '/'); + char* args[4]; + char root[1024]; + int port = grpc_pick_unused_port_or_die(); + + /* figure out where we are */ + if (lslash) { + memcpy(root, me, lslash - me); + root[lslash - me] = 0; + } else { + strcpy(root, "."); + } + + /* start the server */ + gpr_asprintf(&args[0], "%s/../../test/core/httpcli/test_server.py", root); + args[1] = "--port"; + gpr_asprintf(&args[2], "%d", port); + server = gpr_subprocess_create(3, (const char**)args); + GPR_ASSERT(server); + gpr_free(args[0]); + gpr_free(args[2]); + + gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); + grpc_test_init(argc, argv); grpc_iomgr_init(); - test_get(0); - test_get(1); - - /* test_post(0); */ - /* test_post(1); */ + test_get(0, port); + test_post(0, port); grpc_iomgr_shutdown(); + gpr_subprocess_destroy(server); + return 0; } diff --git a/test/core/httpcli/test_server.py b/test/core/httpcli/test_server.py new file mode 100755 index 0000000000..babfe84ddc --- /dev/null +++ b/test/core/httpcli/test_server.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +"""Server for httpcli_test""" + +import argparse +import BaseHTTPServer + +argp = argparse.ArgumentParser(description='Server for httpcli_test') +argp.add_argument('-p', '--port', default=10080, type=int) +args = argp.parse_args() + +print 'server running on port %d' % args.port + +class Handler(BaseHTTPServer.BaseHTTPRequestHandler): + def good(self): + self.send_response(200) + self.send_header('Content-Type', 'text/html') + self.end_headers() + self.wfile.write('<html><head><title>Hello world!</title></head>') + self.wfile.write('<body><p>This is a test</p></body></html>') + + def do_GET(self): + if self.path == '/get': + self.good() + + def do_POST(self): + content = self.rfile.read(int(self.headers.getheader('content-length'))) + if self.path == '/post' and content == 'hello': + self.good() + +BaseHTTPServer.HTTPServer(('', args.port), Handler).serve_forever() diff --git a/test/core/json/json_test.c b/test/core/json/json_test.c index 9a50a6929e..3033419118 100644 --- a/test/core/json/json_test.c +++ b/test/core/json/json_test.c @@ -36,6 +36,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/useful.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "src/core/json/json.h" #include "src/core/support/string.h" diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c index 7d74d0e078..78a0eef1a2 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.c +++ b/test/core/network_benchmarks/low_level_ping_pong.c @@ -238,6 +238,7 @@ static int set_socket_nonblocking(thread_args *args) { static int do_nothing(thread_args *args) { return 0; } +#ifdef __linux__ /* Special case for epoll, where we need to create the fd ahead of time. */ static int epoll_setup(thread_args *args) { int epoll_fd; @@ -258,6 +259,7 @@ static int epoll_setup(thread_args *args) { } return 0; } +#endif static void server_thread(thread_args *args) { char *buf = malloc(args->msg_size); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 9a77f88e73..69ec680c18 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -40,6 +40,7 @@ #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/time.h> #include "test/core/util/test_config.h" #include <openssl/rsa.h> diff --git a/test/core/support/murmur_hash_test.c b/test/core/support/murmur_hash_test.c index e3890a79da..2462abf7de 100644 --- a/test/core/support/murmur_hash_test.c +++ b/test/core/support/murmur_hash_test.c @@ -33,6 +33,7 @@ #include "src/core/support/murmur_hash.h" #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "test/core/util/test_config.h" #include <string.h> diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index a1692ab39f..b59082eecf 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -39,6 +39,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/useful.h> #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c index 6bc697878a..8b86e08168 100644 --- a/test/core/transport/chttp2/hpack_table_test.c +++ b/test/core/transport/chttp2/hpack_table_test.c @@ -39,6 +39,7 @@ #include "src/core/support/string.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c index 91833440cd..bf70d43e78 100644 --- a/test/core/transport/chttp2/stream_encoder_test.c +++ b/test/core/transport/chttp2/stream_encoder_test.c @@ -39,6 +39,7 @@ #include "src/core/transport/chttp2/hpack_parser.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "test/core/util/parse_hexstring.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c index daaae1d39d..5bfb9cf0ec 100644 --- a/test/core/transport/chttp2/timeout_encoding_test.c +++ b/test/core/transport/chttp2/timeout_encoding_test.c @@ -39,6 +39,7 @@ #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 "test/core/util/test_config.h" diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index 9b242c5493..89deee5a40 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -39,6 +39,7 @@ #include "src/core/transport/chttp2/bin_encoder.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/tsi/transport_security_test.c b/test/core/tsi/transport_security_test.c index e45602bab7..bba6744194 100644 --- a/test/core/tsi/transport_security_test.c +++ b/test/core/tsi/transport_security_test.c @@ -37,6 +37,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/useful.h> #include <openssl/crypto.h> |