diff options
author | Craig Tiller <ctiller@google.com> | 2016-09-09 15:49:44 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-09-09 15:49:44 -0700 |
commit | 9017fd551b70eec01ff52740ca8e0228391de553 (patch) | |
tree | 772fa538d825c4f3d40396cd6180f234feb22e57 /test/core/end2end/tests | |
parent | ed9880d19fc3c6cbdb9dca21d0fcf0677aea88b9 (diff) | |
parent | d5d851baf3dbdf92b1c1946c6c46334e6d095b3d (diff) |
Merge branch 'extend_payload_test' of github.com:rjshade/grpc into fix-robbies-thing
Diffstat (limited to 'test/core/end2end/tests')
-rw-r--r-- | test/core/end2end/tests/payload.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index c71704ff61..c37d7fe41a 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -95,9 +95,25 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } +/* Creates and returns a gpr_slice containing random alphanumeric characters. */ +static gpr_slice generate_random_slice() { + size_t i; + static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; + char output[1024 * 1024]; /* 1 MB */ + for (i = 0; i < 1024 * 1024 - 1; ++i) { + output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; + } + output[1024 * 1024 - 1] = '\0'; + return gpr_slice_from_copied_string(output); +} + static void request_response_with_payload(grpc_end2end_test_fixture f) { - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + /* Create large request and response bodies. These are big enough to require + * multiple round trips to deliver to the peer, and their exact contents of + * will be verified on completion. */ + gpr_slice request_payload_slice = generate_random_slice(); + gpr_slice response_payload_slice = generate_random_slice(); + grpc_call *c; grpc_call *s; grpc_byte_buffer *request_payload = @@ -222,8 +238,9 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); GPR_ASSERT(was_cancelled == 0); - GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); - GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); + GPR_ASSERT(byte_buffer_eq_slice(request_payload_recv, request_payload_slice)); + GPR_ASSERT( + byte_buffer_eq_slice(response_payload_recv, response_payload_slice)); gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); |