diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-12-02 17:11:49 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-12-02 17:11:49 -0800 |
commit | e62bf9844ce63b3075641e6a08f06dcaa627f8ed (patch) | |
tree | fc234b324c40e742907db2739b3817314a966068 | |
parent | 025bb9fa404b4acec11359eef5e2c08dea6948c8 (diff) |
Fix HPACK encoder test
-rw-r--r-- | src/core/transport/metadata.c | 10 | ||||
-rw-r--r-- | src/core/transport/metadata.h | 6 | ||||
-rw-r--r-- | test/core/transport/chttp2/hpack_encoder_test.c | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c index a76d1ad3a5..d6fb255eb6 100644 --- a/src/core/transport/metadata.c +++ b/src/core/transport/metadata.c @@ -132,6 +132,7 @@ typedef struct mdtab_shard { /* hash seed: decided at initialization time */ static gpr_uint32 g_hash_seed; +static int g_forced_hash_seed = 0; /* linearly probed hash tables for static element lookup */ static grpc_mdstr *g_static_strtab[GRPC_STATIC_MDSTR_COUNT * 2]; @@ -144,9 +145,16 @@ static mdtab_shard g_mdtab_shard[MDTAB_SHARD_COUNT]; static void gc_mdtab(mdtab_shard *shard); +void grpc_test_only_set_metadata_hash_seed(gpr_uint32 seed) { + g_hash_seed = seed; + g_forced_hash_seed = 1; +} + void grpc_mdctx_global_init(void) { size_t i, j; - g_hash_seed = (gpr_uint32)gpr_now(GPR_CLOCK_REALTIME).tv_nsec; + if (!g_forced_hash_seed) { + g_hash_seed = (gpr_uint32)gpr_now(GPR_CLOCK_REALTIME).tv_nsec; + } g_static_strtab_maxprobe = 0; g_static_mdtab_maxprobe = 0; /* build static tables */ diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h index c1071e4e16..3d3efc682d 100644 --- a/src/core/transport/metadata.h +++ b/src/core/transport/metadata.h @@ -86,11 +86,7 @@ struct grpc_mdelem { /* there is a private part to this in metadata.c */ }; -/* Test only accessors to internal state - only for testing this code - do not - rely on it outside of metadata_test.c */ -size_t grpc_mdctx_get_mdtab_capacity_test_only(void); -size_t grpc_mdctx_get_mdtab_count_test_only(void); -size_t grpc_mdctx_get_mdtab_free_test_only(void); +void grpc_test_only_set_metadata_hash_seed(gpr_uint32 seed); /* Constructors for grpc_mdstr instances; take a variety of data types that clients may have handy */ diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c index 64ea1e3f14..4a9d143640 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.c +++ b/test/core/transport/chttp2/hpack_encoder_test.c @@ -37,6 +37,7 @@ #include "src/core/support/string.h" #include "src/core/transport/chttp2/hpack_parser.h" +#include "src/core/transport/metadata.h" #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> @@ -187,6 +188,7 @@ static void run_test(void (*test)(), const char *name) { int main(int argc, char **argv) { size_t i; + grpc_test_only_set_metadata_hash_seed(0); grpc_test_init(argc, argv); grpc_init(); TEST(test_basic_headers); |