aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/transport
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-09-19 18:05:09 +0000
committerGravatar Craig Tiller <ctiller@google.com>2017-09-19 18:05:09 +0000
commita1bb6cad29ecc534051849e0574742e30130b72b (patch)
tree1fea0d52adaf9c9da964da1cb554fc02314acc71 /test/core/transport
parent50448beab3d24bf4e097967d53aed27b90fc4858 (diff)
Fix timeout encoding test
Diffstat (limited to 'test/core/transport')
-rw-r--r--test/core/transport/timeout_encoding_test.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c
index fcd263f104..039bb33341 100644
--- a/test/core/transport/timeout_encoding_test.c
+++ b/test/core/transport/timeout_encoding_test.c
@@ -25,6 +25,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/support/murmur_hash.h"
#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
@@ -64,10 +65,14 @@ void test_encoding(void) {
static void assert_decodes_as(const char *buffer, grpc_millis expected) {
grpc_millis got;
- gpr_log(GPR_INFO, "check decoding '%s'", buffer);
+ uint32_t hash = gpr_murmur_hash3(buffer, strlen(buffer), 0);
+ gpr_log(GPR_INFO, "check decoding '%s' (hash=0x%x)", buffer, hash);
GPR_ASSERT(1 == grpc_http2_decode_timeout(
grpc_slice_from_static_string(buffer), &got));
- GPR_ASSERT(got == expected);
+ if (got != expected) {
+ gpr_log(GPR_ERROR, "got:'%"PRIdPTR"' != expected:'%"PRIdPTR"'", got, expected);
+ abort();
+ }
}
void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) {
@@ -95,8 +100,8 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) {
}
}
-static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS; }
-static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS; }
+static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); }
+static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); }
static grpc_millis millis_from_millis(int64_t x) { return x; }
static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; }
static grpc_millis millis_from_minutes(int64_t x) {