Just create 1 MB strings, no argument.

pull/7415/head
Robbie Shade 9 years ago
parent bd10faaf0f
commit 61aed92b82
  1. 21
      test/core/end2end/tests/payload.c

@ -97,26 +97,23 @@ static void end_test(grpc_end2end_test_fixture *f) {
grpc_completion_queue_destroy(f->cq); grpc_completion_queue_destroy(f->cq);
} }
/* Creates and returns a gpr_slice of specified length, containing random /* Creates and returns a gpr_slice containing random alphanumeric characters. */
* alphanumeric characters. */ static gpr_slice generate_random_slice() {
static gpr_slice generate_random_slice(size_t length_bytes) {
size_t i; size_t i;
gpr_slice slice = gpr_slice_malloc(length_bytes); static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
static const uint8_t alphanum[] = "abcdefghijklmnopqrstuvwxyz01234567890"; char output[1024 * 1024]; /* 1 MB */
for (i = 0; i < length_bytes; ++i) { for (i = 0; i < 1024 * 1024; ++i) {
*(GPR_SLICE_START_PTR(slice) + i) = output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
alphanum[rand() % (int)(sizeof(alphanum) - 1)];
} }
return slice; return gpr_slice_from_copied_string(output);
} }
static void request_response_with_payload(grpc_end2end_test_fixture f) { static void request_response_with_payload(grpc_end2end_test_fixture f) {
/* Create large request and response bodies. These are big enough to require /* 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 * multiple round trips to deliver to the peer, and their exact contents of
* will be verified on completion. */ * will be verified on completion. */
size_t payload_size_bytes = 1024 * 1024; /* 1 MB */ gpr_slice request_payload_slice = generate_random_slice();
gpr_slice request_payload_slice = generate_random_slice(payload_size_bytes); gpr_slice response_payload_slice = generate_random_slice();
gpr_slice response_payload_slice = generate_random_slice(payload_size_bytes);
grpc_call *c; grpc_call *c;
grpc_call *s; grpc_call *s;

Loading…
Cancel
Save