aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/http
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-12-29 01:38:26 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2017-01-04 22:10:14 +0100
commit203860ac23b6229096c0e9d9c04f12cd607c1938 (patch)
tree43cdba091ef2ea2421a0633b4241e40135ec551a /test/core/http
parent19014deb841f25d14827147d4812b1ddcce2b693 (diff)
parentddebfa65f2bdff332902adf73606bc050014b498 (diff)
Merge remote-tracking branch 'google/master' into bazel-take-2
Diffstat (limited to 'test/core/http')
-rw-r--r--test/core/http/format_request_test.c74
-rw-r--r--test/core/http/httpcli_test.c11
-rw-r--r--test/core/http/httpscli_test.c11
-rw-r--r--test/core/http/parser_test.c32
-rw-r--r--test/core/http/request_fuzzer.c4
-rw-r--r--test/core/http/response_fuzzer.c4
6 files changed, 73 insertions, 63 deletions
diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.c
index 0d21e1200b..290990c906 100644
--- a/test/core/http/format_request_test.c
+++ b/test/core/http/format_request_test.c
@@ -41,7 +41,7 @@
static void test_format_get_request(void) {
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
- gpr_slice slice;
+ grpc_slice slice;
memset(&req, 0, sizeof(req));
req.host = "example.com";
@@ -51,22 +51,22 @@ static void test_format_get_request(void) {
slice = grpc_httpcli_format_get_request(&req);
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "GET /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "\r\n"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(slice,
+ "GET /index.html HTTP/1.0\r\n"
+ "Host: example.com\r\n"
+ "Connection: close\r\n"
+ "User-Agent: " GRPC_HTTPCLI_USER_AGENT
+ "\r\n"
+ "x-yz: abc\r\n"
+ "\r\n"));
- gpr_slice_unref(slice);
+ grpc_slice_unref(slice);
}
static void test_format_post_request(void) {
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
- gpr_slice slice;
+ grpc_slice slice;
char body_bytes[] = "fake body";
size_t body_len = 9;
@@ -78,25 +78,25 @@ static void test_format_post_request(void) {
slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "POST /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "Content-Type: text/plain\r\n"
- "Content-Length: 9\r\n"
- "\r\n"
- "fake body"));
-
- gpr_slice_unref(slice);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(slice,
+ "POST /index.html HTTP/1.0\r\n"
+ "Host: example.com\r\n"
+ "Connection: close\r\n"
+ "User-Agent: " GRPC_HTTPCLI_USER_AGENT
+ "\r\n"
+ "x-yz: abc\r\n"
+ "Content-Type: text/plain\r\n"
+ "Content-Length: 9\r\n"
+ "\r\n"
+ "fake body"));
+
+ grpc_slice_unref(slice);
}
static void test_format_post_request_no_body(void) {
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
- gpr_slice slice;
+ grpc_slice slice;
memset(&req, 0, sizeof(req));
req.host = "example.com";
@@ -106,22 +106,22 @@ static void test_format_post_request_no_body(void) {
slice = grpc_httpcli_format_post_request(&req, NULL, 0);
- GPR_ASSERT(0 == gpr_slice_str_cmp(slice,
- "POST /index.html HTTP/1.0\r\n"
- "Host: example.com\r\n"
- "Connection: close\r\n"
- "User-Agent: " GRPC_HTTPCLI_USER_AGENT
- "\r\n"
- "x-yz: abc\r\n"
- "\r\n"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(slice,
+ "POST /index.html HTTP/1.0\r\n"
+ "Host: example.com\r\n"
+ "Connection: close\r\n"
+ "User-Agent: " GRPC_HTTPCLI_USER_AGENT
+ "\r\n"
+ "x-yz: abc\r\n"
+ "\r\n"));
- gpr_slice_unref(slice);
+ grpc_slice_unref(slice);
}
static void test_format_post_request_content_type_override(void) {
grpc_http_header hdrs[2];
grpc_httpcli_request req;
- gpr_slice slice;
+ grpc_slice slice;
char body_bytes[] = "fake%20body";
size_t body_len = 11;
@@ -137,7 +137,7 @@ static void test_format_post_request_content_type_override(void) {
slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);
- GPR_ASSERT(0 == gpr_slice_str_cmp(
+ GPR_ASSERT(0 == grpc_slice_str_cmp(
slice,
"POST /index.html HTTP/1.0\r\n"
"Host: example.com\r\n"
@@ -149,7 +149,7 @@ static void test_format_post_request_content_type_override(void) {
"\r\n"
"fake%20body"));
- gpr_slice_unref(slice);
+ grpc_slice_unref(slice);
}
int main(int argc, char **argv) {
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index 38b32a3867..3e312c1dde 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -89,8 +89,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, &req, n_seconds_time(15),
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
+ n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -126,9 +129,11 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, &req, "hello", 5,
- n_seconds_time(15),
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
+ "hello", 5, n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index 359e557689..d06035149e 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -90,8 +90,11 @@ static void test_get(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, &req, n_seconds_time(15),
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get");
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
+ n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@@ -128,9 +131,11 @@ static void test_post(int port) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
- grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, &req, "hello", 5,
- n_seconds_time(15),
+ grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post");
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, resource_quota, &req,
+ "hello", 5, n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
+ grpc_resource_quota_internal_unref(&exec_ctx, resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.c
index 2fc354d9ee..4f1445d3f1 100644
--- a/test/core/http/parser_test.c
+++ b/test/core/http/parser_test.c
@@ -48,23 +48,23 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
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_text);
+ grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
- gpr_slice *slices;
+ grpc_slice *slices;
va_list args;
grpc_http_request request;
memset(&request, 0, sizeof(request));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_slice_unref(input_slice);
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) ==
GRPC_ERROR_NONE);
- gpr_slice_unref(slices[i]);
+ grpc_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE);
@@ -105,23 +105,23 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
int expect_status, char *expect_body, ...) {
grpc_http_parser parser;
- gpr_slice input_slice = gpr_slice_from_copied_string(response_text);
+ grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
- gpr_slice *slices;
+ grpc_slice *slices;
va_list args;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_slice_unref(input_slice);
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) ==
GRPC_ERROR_NONE);
- gpr_slice_unref(slices[i]);
+ grpc_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE);
@@ -158,16 +158,16 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
grpc_http_parser parser;
- gpr_slice input_slice = gpr_slice_from_copied_string(response_text);
+ grpc_slice input_slice = grpc_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
- gpr_slice *slices;
+ grpc_slice *slices;
grpc_error *error = GRPC_ERROR_NONE;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_slice_unref(input_slice);
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
@@ -175,7 +175,7 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
if (GRPC_ERROR_NONE == error) {
error = grpc_http_parser_parse(&parser, slices[i], NULL);
}
- gpr_slice_unref(slices[i]);
+ grpc_slice_unref(slices[i]);
}
if (GRPC_ERROR_NONE == error) {
error = grpc_http_parser_eof(&parser);
@@ -191,16 +191,16 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
static void test_request_fails(grpc_slice_split_mode split_mode,
char *request_text) {
grpc_http_parser parser;
- gpr_slice input_slice = gpr_slice_from_copied_string(request_text);
+ grpc_slice input_slice = grpc_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
- gpr_slice *slices;
+ grpc_slice *slices;
grpc_error *error = GRPC_ERROR_NONE;
grpc_http_request request;
memset(&request, 0, sizeof(request));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
- gpr_slice_unref(input_slice);
+ grpc_slice_unref(input_slice);
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
@@ -208,7 +208,7 @@ static void test_request_fails(grpc_slice_split_mode split_mode,
if (error == GRPC_ERROR_NONE) {
error = grpc_http_parser_parse(&parser, slices[i], NULL);
}
- gpr_slice_unref(slices[i]);
+ grpc_slice_unref(slices[i]);
}
if (error == GRPC_ERROR_NONE) {
error = grpc_http_parser_eof(&parser);
diff --git a/test/core/http/request_fuzzer.c b/test/core/http/request_fuzzer.c
index bb6cb92c0c..98e2c9680d 100644
--- a/test/core/http/request_fuzzer.c
+++ b/test/core/http/request_fuzzer.c
@@ -47,10 +47,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_http_request request;
memset(&request, 0, sizeof(request));
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
- gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size);
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL));
GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser));
- gpr_slice_unref(slice);
+ grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_request_destroy(&request);
return 0;
diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.c
index 4393840484..fff04117b2 100644
--- a/test/core/http/response_fuzzer.c
+++ b/test/core/http/response_fuzzer.c
@@ -46,10 +46,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
- gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size);
+ grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size);
GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL));
GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser));
- gpr_slice_unref(slice);
+ grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_response_destroy(&response);
return 0;