aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/bad_client/tests
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:48:19 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:48:19 -0800
commitc7342a01bb069fcff6df0e22f6c2a403010998a1 (patch)
treed938c40ce9d880c13be1e928c1e3bc5de65ca1b9 /test/core/bad_client/tests
parenta60b31d0a4f24ec061cc3dd9129f93a0319f1429 (diff)
parent5e01e2ac977655aa074faf7fde0a74298f5e4c55 (diff)
Merge branch 'revert-8842-metadata_filter' of github.com:grpc/grpc into rollfwd
Diffstat (limited to 'test/core/bad_client/tests')
-rw-r--r--test/core/bad_client/tests/large_metadata.c59
-rw-r--r--test/core/bad_client/tests/simple_request.c4
2 files changed, 34 insertions, 29 deletions
diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c
index f672776a9f..9c804e78c1 100644
--- a/test/core/bad_client/tests/large_metadata.c
+++ b/test/core/bad_client/tests/large_metadata.c
@@ -126,8 +126,8 @@ static void server_verifier(grpc_server *server, grpc_completion_queue *cq,
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost"));
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar"));
+ GPR_ASSERT(0 == strcmp(call_details.host, "localhost"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar"));
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_details_destroy(&call_details);
@@ -153,14 +153,16 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server,
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost"));
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar"));
+ GPR_ASSERT(0 == strcmp(call_details.host, "localhost"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar"));
const size_t metadata_value_size = 16 * 1024;
grpc_metadata meta;
- meta.key = grpc_slice_from_static_string("key");
- meta.value = grpc_slice_malloc(metadata_value_size);
- memset(GRPC_SLICE_START_PTR(meta.value), 'a', metadata_value_size);
+ meta.key = "key";
+ meta.value = gpr_malloc(metadata_value_size + 1);
+ memset((char *)meta.value, 'a', metadata_value_size);
+ ((char *)meta.value)[metadata_value_size] = 0;
+ meta.value_length = metadata_value_size;
grpc_op op;
memset(&op, 0, sizeof(op));
@@ -174,7 +176,7 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server,
CQ_EXPECT_COMPLETION(cqv, tag(102), 0); // Operation fails.
cq_verify(cqv);
- grpc_slice_unref(meta.value);
+ gpr_free((char *)meta.value);
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_details_destroy(&call_details);
grpc_call_destroy(s);
@@ -188,26 +190,29 @@ static void client_validator(grpc_slice_buffer *incoming) {
grpc_slice_buffer_trim_end(incoming, 13, &last_frame_buffer);
GPR_ASSERT(last_frame_buffer.count == 1);
grpc_slice last_frame = last_frame_buffer.slices[0];
- const uint8_t *p = GRPC_SLICE_START_PTR(last_frame);
- // Length = 4
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 4);
- // Frame type (RST_STREAM)
- GPR_ASSERT(*p++ == 3);
- // Flags
- GPR_ASSERT(*p++ == 0);
+ // Construct expected frame.
+ grpc_slice expected = grpc_slice_malloc(13);
+ uint8_t *p = GRPC_SLICE_START_PTR(expected);
+ // Length.
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 4;
+ // Frame type (RST_STREAM).
+ *p++ = 3;
+ // Flags.
+ *p++ = 0;
// Stream ID.
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 1);
- // Payload (error code)
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p++ == 0);
- GPR_ASSERT(*p == 0 || *p == 11);
-
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 1;
+ // Payload (error code).
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 11;
+ // Compare actual and expected.
+ GPR_ASSERT(grpc_slice_cmp(last_frame, expected) == 0);
grpc_slice_buffer_destroy(&last_frame_buffer);
}
diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c
index db31ba6fb3..c08aa40a0a 100644
--- a/test/core/bad_client/tests/simple_request.c
+++ b/test/core/bad_client/tests/simple_request.c
@@ -117,8 +117,8 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq,
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost"));
- GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar"));
+ GPR_ASSERT(0 == strcmp(call_details.host, "localhost"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo/bar"));
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_details_destroy(&call_details);