aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/compression
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-12-08 14:02:18 -0800
committerGravatar Muxi Yan <mxyan@google.com>2017-12-08 14:02:18 -0800
commit99024d64367b62c98f03dda5c800c7418bcbf123 (patch)
treec1fdbd9705d483107279770f2860342405ae2bbd /test/core/compression
parent5c5bafff5a7974b54cb16cbf2222580bc0349e77 (diff)
parent94e676e10f8c739289924b8458a246699e3623ce (diff)
Merge remote-tracking branch 'upstream/master' into fix-stream-compression-config-interface
Diffstat (limited to 'test/core/compression')
-rw-r--r--test/core/compression/algorithm_test.cc12
-rw-r--r--test/core/compression/compression_test.cc72
-rw-r--r--test/core/compression/message_compress_test.cc61
3 files changed, 66 insertions, 79 deletions
diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc
index 275b60b08f..1699d27142 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -41,7 +41,7 @@ static void test_algorithm_mesh(void) {
grpc_compression_algorithm parsed;
grpc_slice mdstr;
grpc_mdelem mdelem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));
GPR_ASSERT(grpc_compression_algorithm_parse(
@@ -70,9 +70,8 @@ static void test_algorithm_mesh(void) {
GPR_ASSERT(
grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING));
}
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
+ GRPC_MDELEM_UNREF(mdelem);
}
/* test failure */
@@ -81,7 +80,7 @@ static void test_algorithm_mesh(void) {
}
static void test_algorithm_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_slice mdstr;
gpr_log(GPR_DEBUG, "test_algorithm_failure");
@@ -102,8 +101,7 @@ static void test_algorithm_failure(void) {
grpc_compression_algorithm_slice(static_cast<grpc_compression_algorithm>(
static_cast<int>(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)),
grpc_empty_slice()));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
}
int main(int argc, char** argv) {
diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc
index 092798655d..e49a93a4b6 100644
--- a/test/core/compression/compression_test.cc
+++ b/test/core/compression/compression_test.cc
@@ -94,16 +94,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
{
@@ -117,16 +117,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
{
@@ -140,16 +140,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
{
@@ -164,16 +164,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
{
@@ -187,16 +187,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
{
@@ -212,16 +212,16 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_LOW, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_MED, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
- grpc_compression_algorithm_for_level(
- GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings));
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ accepted_encodings));
}
}
diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc
index 6fa3a4d2c3..9934af84f2 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -71,10 +71,8 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed =
- grpc_msg_compress(&exec_ctx, algorithm, &input, &compressed_raw);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
}
GPR_ASSERT(input.count > 0);
@@ -93,11 +91,10 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slice_buffer(compressed_split_mode, &compressed_raw, &compressed);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
- &exec_ctx, was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE,
- &compressed, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed,
+ &output));
}
final = grpc_slice_merge(output.slices, output.count);
@@ -157,12 +154,11 @@ static void test_tiny_data_compress(void) {
for (int i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_MESSAGE_COMPRESS_NONE) continue;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(0 == grpc_msg_compress(
- &exec_ctx,
+
static_cast<grpc_message_compression_algorithm>(i),
&input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == output.count);
}
@@ -182,9 +178,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
/* compress it */
- grpc_msg_compress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted);
+ grpc_msg_compress(GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
@@ -192,9 +188,8 @@ static void test_bad_decompression_data_crc(void) {
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP,
- &corrupted, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &corrupted,
+ &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -213,10 +208,9 @@ static void test_bad_decompression_data_trailing_garbage(void) {
"\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE,
- &input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -232,10 +226,9 @@ static void test_bad_decompression_data_stream(void) {
grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE,
- &input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -251,18 +244,16 @@ static void test_bad_compression_algorithm(void) {
grpc_slice_buffer_add(
&input, grpc_slice_from_copied_string("Never gonna give you up"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed = grpc_msg_compress(
- &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_core::ExecCtx exec_ctx;
+ was_compressed = grpc_msg_compress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_compressed);
was_compressed =
- grpc_msg_compress(&exec_ctx,
- static_cast<grpc_message_compression_algorithm>(
+ grpc_msg_compress(static_cast<grpc_message_compression_algorithm>(
GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_compressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -278,18 +269,16 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_buffer_add(&input,
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_decompressed = grpc_msg_decompress(
- &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_core::ExecCtx exec_ctx;
+ was_decompressed = grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_decompressed);
was_decompressed =
- grpc_msg_decompress(&exec_ctx,
- static_cast<grpc_message_compression_algorithm>(
+ grpc_msg_decompress(static_cast<grpc_message_compression_algorithm>(
GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_decompressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);