aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/transport/chttp2
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-11-20 12:02:17 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-11-20 12:02:17 -0800
commitb2b4261631fcd6e43344feb7dec45eff5ddbc8a8 (patch)
treea6be9f523c8973864fbdfb3e3d3b70d7f2b129ca /test/core/transport/chttp2
parentebdef9d674b33e7bd117e2a4a2da7762c35bbdfc (diff)
Remove metadata context entirely
Diffstat (limited to 'test/core/transport/chttp2')
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.c7
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c12
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c28
3 files changed, 16 insertions, 31 deletions
diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c
index 30cb6c1d17..64ea1e3f14 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.c
+++ b/test/core/transport/chttp2/hpack_encoder_test.c
@@ -46,7 +46,6 @@
#define TEST(x) run_test(x, #x)
-grpc_mdctx *g_mdctx;
grpc_chttp2_hpack_compressor g_compressor;
int g_failure = 0;
@@ -76,7 +75,7 @@ static void verify(size_t window_available, int eof, size_t expect_window_used,
e[i - 1].next = &e[i];
e[i].prev = &e[i - 1];
}
- e[i].md = grpc_mdelem_from_strings(g_mdctx, key, value);
+ e[i].md = grpc_mdelem_from_strings(key, value);
}
e[0].prev = NULL;
e[nheaders - 1].next = NULL;
@@ -181,11 +180,9 @@ static void test_decode_table_overflow(void) {
static void run_test(void (*test)(), const char *name) {
gpr_log(GPR_INFO, "RUN TEST: %s", name);
- g_mdctx = grpc_mdctx_create_with_seed(0);
- grpc_chttp2_hpack_compressor_init(&g_compressor, g_mdctx);
+ grpc_chttp2_hpack_compressor_init(&g_compressor);
test();
grpc_chttp2_hpack_compressor_destroy(&g_compressor);
- grpc_mdctx_unref(g_mdctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index a790b461b6..3acbc06349 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -91,9 +91,8 @@ static void test_vector(grpc_chttp2_hpack_parser *parser,
static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser parser;
- grpc_mdctx *mdctx = grpc_mdctx_create();
- grpc_chttp2_hpack_parser_init(&parser, mdctx);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.2.1 */
test_vector(&parser, mode,
"400a 6375 7374 6f6d 2d6b 6579 0d63 7573"
@@ -111,7 +110,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
test_vector(&parser, mode, "82", ":method", "GET", NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&parser, mdctx);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.3.1 */
test_vector(&parser, mode,
"8286 8441 0f77 7777 2e65 7861 6d70 6c65"
@@ -131,7 +130,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&parser, mdctx);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.4.1 */
test_vector(&parser, mode,
"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4"
@@ -151,7 +150,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&parser, mdctx);
+ grpc_chttp2_hpack_parser_init(&parser);
parser.table.max_bytes = 256;
/* D.5.1 */
test_vector(&parser, mode,
@@ -184,7 +183,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&parser, mdctx);
+ grpc_chttp2_hpack_parser_init(&parser);
parser.table.max_bytes = 256;
/* D.6.1 */
test_vector(&parser, mode,
@@ -213,7 +212,6 @@ static void test_vectors(grpc_slice_split_mode mode) {
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_mdctx_unref(mdctx);
}
int main(int argc, char **argv) {
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index adc69bf314..468e93b773 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -60,10 +60,8 @@ static void assert_index(const grpc_chttp2_hptbl *tbl, gpr_uint32 idx,
static void test_static_lookup(void) {
grpc_chttp2_hptbl tbl;
- grpc_mdctx *mdctx;
- mdctx = grpc_mdctx_create();
- grpc_chttp2_hptbl_init(&tbl, mdctx);
+ grpc_chttp2_hptbl_init(&tbl);
LOG_TEST("test_static_lookup");
assert_index(&tbl, 1, ":authority", "");
@@ -129,7 +127,6 @@ static void test_static_lookup(void) {
assert_index(&tbl, 61, "www-authenticate", "");
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_unref(mdctx);
}
static void test_many_additions(void) {
@@ -137,17 +134,15 @@ static void test_many_additions(void) {
int i;
char *key;
char *value;
- grpc_mdctx *mdctx;
LOG_TEST("test_many_additions");
- mdctx = grpc_mdctx_create();
- grpc_chttp2_hptbl_init(&tbl, mdctx);
+ grpc_chttp2_hptbl_init(&tbl);
for (i = 0; i < 1000000; i++) {
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, key, value));
+ grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(key, value));
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -161,13 +156,12 @@ static void test_many_additions(void) {
}
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_unref(mdctx);
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
const char *key,
const char *value) {
- grpc_mdelem *md = grpc_mdelem_from_strings(tbl->mdctx, key, value);
+ grpc_mdelem *md = grpc_mdelem_from_strings(key, value);
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
GRPC_MDELEM_UNREF(md);
return r;
@@ -177,16 +171,14 @@ static void test_find(void) {
grpc_chttp2_hptbl tbl;
int i;
char buffer[32];
- grpc_mdctx *mdctx;
grpc_chttp2_hptbl_find_result r;
LOG_TEST("test_find");
- mdctx = grpc_mdctx_create();
- grpc_chttp2_hptbl_init(&tbl, mdctx);
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "abc", "xyz"));
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "abc", "123"));
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "x", "1"));
+ grpc_chttp2_hptbl_init(&tbl);
+ grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings("abc", "xyz"));
+ grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings("abc", "123"));
+ grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings("x", "1"));
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -235,8 +227,7 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
gpr_ltoa(i, buffer);
- grpc_chttp2_hptbl_add(&tbl,
- grpc_mdelem_from_strings(mdctx, "test", buffer));
+ grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings("test", buffer));
}
r = find_simple(&tbl, "abc", "123");
@@ -265,7 +256,6 @@ static void test_find(void) {
GPR_ASSERT(r.has_value == 0);
grpc_chttp2_hptbl_destroy(&tbl);
- grpc_mdctx_unref(mdctx);
}
int main(int argc, char **argv) {