aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/compression/compression_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/compression/compression_test.c')
-rw-r--r--test/core/compression/compression_test.c178
1 files changed, 149 insertions, 29 deletions
diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c
index 4b6026ec77..4b300e18d3 100644
--- a/test/core/compression/compression_test.c
+++ b/test/core/compression/compression_test.c
@@ -28,9 +28,9 @@
static void test_compression_algorithm_parse(void) {
size_t i;
- const char *valid_names[] = {"identity", "gzip", "deflate"};
+ const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"};
gpr_log(GPR_DEBUG, "test_compression_algorithm_parse");
@@ -59,9 +59,9 @@ static void test_compression_algorithm_name(void) {
int success;
char *name;
size_t i;
- const char *valid_names[] = {"identity", "gzip", "deflate"};
+ const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
gpr_log(GPR_DEBUG, "test_compression_algorithm_name");
@@ -90,15 +90,27 @@ static void test_compression_algorithm_for_level(void) {
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
accepted_encodings));
}
@@ -106,22 +118,34 @@ static void test_compression_algorithm_for_level(void) {
/* accept only gzip */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
accepted_encodings));
}
@@ -129,22 +153,34 @@ static void test_compression_algorithm_for_level(void) {
/* accept only deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
accepted_encodings));
}
@@ -152,23 +188,107 @@ static void test_compression_algorithm_for_level(void) {
/* accept gzip and deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_GZIP ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
+ accepted_encodings));
+ }
+
+ {
+ /* accept stream gzip */
+ uint32_t accepted_encodings = 0;
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP);
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
+ accepted_encodings));
+ }
+
+ {
+ /* accept all algorithms */
+ uint32_t accepted_encodings = 0;
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP);
+
+ GPR_ASSERT(GRPC_COMPRESS_NONE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH,
+ accepted_encodings));
+
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
- grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
+ GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP ==
+ grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH,
accepted_encodings));
}
}