aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/compression/message_compress_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/compression/message_compress_test.cc')
-rw-r--r--test/core/compression/message_compress_test.cc61
1 files changed, 34 insertions, 27 deletions
diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc
index b03ca4c4cb..bab32e0cc5 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -39,7 +39,7 @@ typedef enum {
} compressability;
static void assert_passthrough(grpc_slice value,
- grpc_compression_algorithm algorithm,
+ grpc_message_compression_algorithm algorithm,
grpc_slice_split_mode uncompressed_split_mode,
grpc_slice_split_mode compressed_split_mode,
compressability compress_result_check) {
@@ -51,7 +51,8 @@ static void assert_passthrough(grpc_slice value,
int was_compressed;
const char* algorithm_name;
- GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0);
+ GPR_ASSERT(
+ grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0);
gpr_log(GPR_INFO,
"assert_passthrough: value_length=%" PRIuPTR
" value_hash=0x%08x "
@@ -92,7 +93,8 @@ static void assert_passthrough(grpc_slice value,
{
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
- was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output));
+ was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed,
+ &output));
}
final = grpc_slice_merge(output.slices, output.count);
@@ -112,8 +114,8 @@ static grpc_slice repeated(char c, size_t length) {
}
static compressability get_compressability(
- test_value id, grpc_compression_algorithm algorithm) {
- if (algorithm == GRPC_COMPRESS_NONE) return SHOULD_NOT_COMPRESS;
+ test_value id, grpc_message_compression_algorithm algorithm) {
+ if (algorithm == GRPC_MESSAGE_COMPRESS_NONE) return SHOULD_NOT_COMPRESS;
switch (id) {
case ONE_A:
return SHOULD_NOT_COMPRESS;
@@ -150,13 +152,13 @@ static void test_tiny_data_compress(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_A));
- for (int i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
- if (i == GRPC_COMPRESS_NONE) continue;
+ for (int i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) {
+ if (i == GRPC_MESSAGE_COMPRESS_NONE) continue;
grpc_core::ExecCtx exec_ctx;
- GPR_ASSERT(0 ==
- grpc_msg_compress(static_cast<grpc_compression_algorithm>(i),
- &input, &output));
+ GPR_ASSERT(0 == grpc_msg_compress(
+ static_cast<grpc_message_compression_algorithm>(i),
+ &input, &output));
GPR_ASSERT(1 == output.count);
}
@@ -178,7 +180,7 @@ static void test_bad_decompression_data_crc(void) {
grpc_core::ExecCtx exec_ctx;
/* compress it */
- grpc_msg_compress(GRPC_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);
@@ -186,7 +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(GRPC_COMPRESS_GZIP, &corrupted, &output));
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &corrupted,
+ &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -206,7 +209,8 @@ static void test_bad_decompression_data_trailing_garbage(void) {
/* try (and fail) to decompress the invalid compresed buffer */
grpc_core::ExecCtx exec_ctx;
- GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -223,7 +227,8 @@ static void test_bad_decompression_data_stream(void) {
/* try (and fail) to decompress the invalid compresed buffer */
grpc_core::ExecCtx exec_ctx;
- GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
+ GPR_ASSERT(
+ 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -240,13 +245,14 @@ static void test_bad_compression_algorithm(void) {
&input, grpc_slice_from_copied_string("Never gonna give you up"));
grpc_core::ExecCtx exec_ctx;
- was_compressed =
- grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ was_compressed = grpc_msg_compress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_compressed);
- was_compressed = grpc_msg_compress(static_cast<grpc_compression_algorithm>(
- GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
- &input, &output);
+ was_compressed =
+ grpc_msg_compress(static_cast<grpc_message_compression_algorithm>(
+ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
+ &input, &output);
GPR_ASSERT(0 == was_compressed);
grpc_slice_buffer_destroy(&input);
@@ -264,13 +270,13 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
grpc_core::ExecCtx exec_ctx;
- was_decompressed =
- grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ was_decompressed = grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT,
+ &input, &output);
GPR_ASSERT(0 == was_decompressed);
was_decompressed =
- grpc_msg_decompress(static_cast<grpc_compression_algorithm>(
- GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
+ grpc_msg_decompress(static_cast<grpc_message_compression_algorithm>(
+ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_decompressed);
@@ -289,17 +295,18 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
+ for (i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) {
for (j = 0; j < GPR_ARRAY_SIZE(uncompressed_split_modes); j++) {
for (k = 0; k < GPR_ARRAY_SIZE(compressed_split_modes); k++) {
for (m = 0; m < TEST_VALUE_COUNT; m++) {
grpc_slice slice = create_test_value(static_cast<test_value>(m));
assert_passthrough(
- slice, static_cast<grpc_compression_algorithm>(i),
+ slice, static_cast<grpc_message_compression_algorithm>(i),
static_cast<grpc_slice_split_mode>(j),
static_cast<grpc_slice_split_mode>(k),
- get_compressability(static_cast<test_value>(m),
- static_cast<grpc_compression_algorithm>(i)));
+ get_compressability(
+ static_cast<test_value>(m),
+ static_cast<grpc_message_compression_algorithm>(i)));
grpc_slice_unref(slice);
}
}