mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-08 19:18:53 +08:00
tests: Use nghttp2_mem instead of raw malloc()/free()
Fixes GH-170
This commit is contained in:
@@ -66,12 +66,12 @@ void test_nghttp2_hd_deflate(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva1, out.nva, 3);
|
||||
assert_nv_equal(nva1, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Second headers */
|
||||
@@ -80,12 +80,12 @@ void test_nghttp2_hd_deflate(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva2, out.nva, 2);
|
||||
assert_nv_equal(nva2, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Third headers, including same header field name, but value is not
|
||||
@@ -95,12 +95,12 @@ void test_nghttp2_hd_deflate(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva3, out.nva, 3);
|
||||
assert_nv_equal(nva3, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Fourth headers, including duplicate header fields. */
|
||||
@@ -109,12 +109,12 @@ void test_nghttp2_hd_deflate(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva4, out.nva, 3);
|
||||
assert_nv_equal(nva4, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Fifth headers includes empty value */
|
||||
@@ -123,12 +123,12 @@ void test_nghttp2_hd_deflate(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva5, out.nva, 2);
|
||||
assert_nv_equal(nva5, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Cleanup */
|
||||
@@ -162,12 +162,12 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva1, out.nva, 2);
|
||||
assert_nv_equal(nva1, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Encode 3 same headers. This time, emits 3 index reprs. */
|
||||
@@ -176,12 +176,12 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen == 3);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva2, out.nva, 3);
|
||||
assert_nv_equal(nva2, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Cleanup */
|
||||
@@ -209,13 +209,13 @@ void test_nghttp2_hd_inflate_indexed(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(1 == blocklen);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* index = 0 is error */
|
||||
@@ -224,7 +224,8 @@ void test_nghttp2_hd_inflate_indexed(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(1 == blocklen);
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
|
||||
inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -254,13 +255,13 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv[i], out.nva, 1);
|
||||
assert_nv_equal(&nv[i], out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
@@ -287,17 +288,17 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
assert_nv_equal(
|
||||
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
|
||||
inflater.ctx.hd_table.len - 1)->nv,
|
||||
1);
|
||||
1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
@@ -332,14 +333,14 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(4 == out.nvlen);
|
||||
CU_ASSERT(14 == out.nva[0].namelen);
|
||||
CU_ASSERT(0 == memcmp("accept-charset", out.nva[0].name, out.nva[0].namelen));
|
||||
CU_ASSERT(sizeof(value) == out.nva[0].valuelen);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
CU_ASSERT(3 == inflater.ctx.hd_table.len);
|
||||
@@ -375,13 +376,13 @@ void test_nghttp2_hd_inflate_newname_noinc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv[i], out.nva, 1);
|
||||
assert_nv_equal(&nv[i], out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
@@ -408,17 +409,17 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
assert_nv_equal(
|
||||
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
|
||||
inflater.ctx.hd_table.len - 1)->nv,
|
||||
1);
|
||||
1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
@@ -452,22 +453,22 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
|
||||
/* Do it again */
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* This time, 4096 bytes space required, which is just fits in the
|
||||
@@ -479,13 +480,13 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
|
||||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
@@ -514,7 +515,7 @@ void test_nghttp2_hd_inflate_zero_length_huffman(void) {
|
||||
/* ptr[3] = 0x80; */
|
||||
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
CU_ASSERT(4 == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(4 == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
CU_ASSERT(1 == out.nva[0].namelen);
|
||||
@@ -522,7 +523,7 @@ void test_nghttp2_hd_inflate_zero_length_huffman(void) {
|
||||
CU_ASSERT(NULL == out.nva[0].value);
|
||||
CU_ASSERT(0 == out.nva[0].valuelen);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
@@ -546,7 +547,7 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
||||
nv.name = (uint8_t *)"a";
|
||||
nv.namelen = strlen((const char *)nv.name);
|
||||
nv.valuelen = 4;
|
||||
nv.value = malloc(nv.valuelen);
|
||||
nv.value = mem->malloc(nv.valuelen, NULL);
|
||||
memset(nv.value, 0, nv.valuelen);
|
||||
|
||||
nghttp2_hd_deflate_init2(&deflater, 8000, mem);
|
||||
@@ -563,12 +564,12 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
@@ -576,7 +577,7 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
nghttp2_hd_deflate_free(&deflater);
|
||||
|
||||
free(nv.value);
|
||||
mem->free(nv.value, NULL);
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_change_table_size(void) {
|
||||
@@ -616,12 +617,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* inflater changes header table size to 1024 */
|
||||
@@ -641,12 +642,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* inflater changes header table size to 0 */
|
||||
@@ -668,12 +669,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(0 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
@@ -703,12 +704,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 16383));
|
||||
@@ -727,21 +728,22 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8192 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Lastly, check the error condition */
|
||||
|
||||
rv = nghttp2_hd_emit_table_size(&bufs, 25600);
|
||||
CU_ASSERT(rv == 0);
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
|
||||
inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -763,12 +765,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(4096 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -787,11 +789,11 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(UINT32_MAX == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(UINT32_MAX == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(UINT32_MAX == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -817,11 +819,11 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(UINT32_MAX == deflater.min_hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(3000 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(3000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -832,7 +834,8 @@ void test_nghttp2_hd_change_table_size(void) {
|
||||
|
||||
static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
|
||||
nghttp2_hd_inflater *inflater,
|
||||
nghttp2_nv *nva, size_t nvlen) {
|
||||
nghttp2_nv *nva, size_t nvlen,
|
||||
nghttp2_mem *mem) {
|
||||
nghttp2_bufs bufs;
|
||||
ssize_t blocklen;
|
||||
nva_out out;
|
||||
@@ -847,12 +850,12 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen >= 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(nvlen == out.nvlen);
|
||||
assert_nv_equal(nva, out.nva, nvlen);
|
||||
assert_nv_equal(nva, out.nva, nvlen, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
}
|
||||
|
||||
@@ -999,16 +1002,16 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
||||
nghttp2_hd_deflate_init(&deflater, mem);
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
|
||||
check_deflate_inflate(&deflater, &inflater, nv1, ARRLEN(nv1));
|
||||
check_deflate_inflate(&deflater, &inflater, nv2, ARRLEN(nv2));
|
||||
check_deflate_inflate(&deflater, &inflater, nv3, ARRLEN(nv3));
|
||||
check_deflate_inflate(&deflater, &inflater, nv4, ARRLEN(nv4));
|
||||
check_deflate_inflate(&deflater, &inflater, nv5, ARRLEN(nv5));
|
||||
check_deflate_inflate(&deflater, &inflater, nv6, ARRLEN(nv6));
|
||||
check_deflate_inflate(&deflater, &inflater, nv7, ARRLEN(nv7));
|
||||
check_deflate_inflate(&deflater, &inflater, nv8, ARRLEN(nv8));
|
||||
check_deflate_inflate(&deflater, &inflater, nv9, ARRLEN(nv9));
|
||||
check_deflate_inflate(&deflater, &inflater, nv10, ARRLEN(nv10));
|
||||
check_deflate_inflate(&deflater, &inflater, nv1, ARRLEN(nv1), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv2, ARRLEN(nv2), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv3, ARRLEN(nv3), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv4, ARRLEN(nv4), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv5, ARRLEN(nv5), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv6, ARRLEN(nv6), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv7, ARRLEN(nv7), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv8, ARRLEN(nv8), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv9, ARRLEN(nv9), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv10, ARRLEN(nv10), mem);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
nghttp2_hd_deflate_free(&deflater);
|
||||
@@ -1048,17 +1051,17 @@ void test_nghttp2_hd_no_index(void) {
|
||||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(ARRLEN(nva) == out.nvlen);
|
||||
assert_nv_equal(nva, out.nva, ARRLEN(nva));
|
||||
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
|
||||
|
||||
CU_ASSERT(out.nva[0].flags == NGHTTP2_NV_FLAG_NONE);
|
||||
for (i = 1; i < ARRLEN(nva); ++i) {
|
||||
CU_ASSERT(out.nva[i].flags == NGHTTP2_NV_FLAG_NO_INDEX);
|
||||
}
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
@@ -1119,7 +1122,7 @@ void test_nghttp2_hd_public_api(void) {
|
||||
nghttp2_bufs_wrap_init(&bufs, buf, blocklen, mem);
|
||||
bufs.head->buf.last += blocklen;
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0, mem));
|
||||
|
||||
nghttp2_bufs_wrap_free(&bufs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user