From 82e249b8165dbe2ddb6d76bf938a677d85341a8f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 11 Nov 2015 01:14:39 +0000 Subject: Small fixes --- test/core/transport/chttp2/hpack_parser_test.c | 7 ++++--- test/core/transport/chttp2/hpack_table_test.c | 27 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'test/core/transport') diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index e4cabeae3b..c6b35fba79 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -151,8 +151,8 @@ static void test_vectors(grpc_slice_split_mode mode) { grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser, mdctx); -grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256); -grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); + grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256); + grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); /* D.5.1 */ test_vector(&parser, mode, "4803 3330 3258 0770 7269 7661 7465 611d" @@ -185,7 +185,8 @@ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); grpc_chttp2_hpack_parser_destroy(&parser); grpc_chttp2_hpack_parser_init(&parser, mdctx); - parser.table.max_bytes = 256; + grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256); + grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256); /* D.6.1 */ test_vector(&parser, mode, "4882 6402 5885 aec3 771a 4b61 96d0 7abe" diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c index 5bdeeafb67..5eb52d6d9a 100644 --- a/test/core/transport/chttp2/hpack_table_test.c +++ b/test/core/transport/chttp2/hpack_table_test.c @@ -143,10 +143,12 @@ static void test_many_additions(void) { grpc_chttp2_hptbl_init(&tbl, mdctx); for (i = 0; i < 1000000; i++) { + grpc_mdelem *elem; gpr_asprintf(&key, "K:%d", i); gpr_asprintf(&value, "VALUE:%d", i); - GPR_ASSERT(grpc_chttp2_hptbl_add( - &tbl, grpc_mdelem_from_strings(mdctx, key, value))); + elem = grpc_mdelem_from_strings(mdctx, key, value); + GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem)); + GRPC_MDELEM_UNREF(elem); assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value); gpr_free(key); gpr_free(value); @@ -177,18 +179,22 @@ static void test_find(void) { gpr_uint32 i; char buffer[32]; grpc_mdctx *mdctx; + grpc_mdelem *elem; grpc_chttp2_hptbl_find_result r; LOG_TEST("test_find"); mdctx = grpc_mdctx_create(); grpc_chttp2_hptbl_init(&tbl, mdctx); - GPR_ASSERT(grpc_chttp2_hptbl_add( - &tbl, grpc_mdelem_from_strings(mdctx, "abc", "xyz"))); - GPR_ASSERT(grpc_chttp2_hptbl_add( - &tbl, grpc_mdelem_from_strings(mdctx, "abc", "123"))); - GPR_ASSERT( - grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "x", "1"))); + elem = grpc_mdelem_from_strings(mdctx, "abc", "xyz"); + GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem)); + GRPC_MDELEM_UNREF(elem); + elem = grpc_mdelem_from_strings(mdctx, "abc", "123"); + GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem)); + GRPC_MDELEM_UNREF(elem); + elem = grpc_mdelem_from_strings(mdctx, "x", "1"); + GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem)); + GRPC_MDELEM_UNREF(elem); r = find_simple(&tbl, "abc", "123"); GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY); @@ -237,8 +243,9 @@ static void test_find(void) { /* overflow the string buffer, check find still works */ for (i = 0; i < 10000; i++) { gpr_ltoa(i, buffer); - GPR_ASSERT(grpc_chttp2_hptbl_add( - &tbl, grpc_mdelem_from_strings(mdctx, "test", buffer))); + elem = grpc_mdelem_from_strings(mdctx, "test", buffer); + GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem)); + GRPC_MDELEM_UNREF(elem); } r = find_simple(&tbl, "abc", "123"); -- cgit v1.2.3