From 109b8cedde351e3f6e913794fe4cb1c2bb03eb42 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 11 Feb 2014 16:12:26 +0900 Subject: [PATCH] Fix compile error and test failures --- tests/nghttp2_frame_test.c | 12 ++++++++---- tests/nghttp2_session_test.c | 9 ++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/nghttp2_frame_test.c b/tests/nghttp2_frame_test.c index cb1f51e6..56abc95d 100644 --- a/tests/nghttp2_frame_test.c +++ b/tests/nghttp2_frame_test.c @@ -79,6 +79,7 @@ void test_nghttp2_frame_pack_headers() nghttp2_nv *nva; ssize_t nvlen; nva_out out; + ssize_t nv_offset; nva_out_init(&out); nghttp2_hd_deflate_init(&deflater, NGHTTP2_HD_SIDE_REQUEST); @@ -102,9 +103,10 @@ void test_nghttp2_frame_pack_headers() /* We didn't include PRIORITY flag so priority is not packed */ CU_ASSERT(1 << 30 == oframe.pri); - CU_ASSERT(framelen - (ssize_t)bufoff - 8 == + nv_offset = bufoff + NGHTTP2_FRAME_HEAD_LENGTH; + CU_ASSERT(framelen - nv_offset == inflate_hd(&inflater, &out, - buf + bufoff + 8, framelen - bufoff - 8)); + buf + nv_offset, framelen - nv_offset)); CU_ASSERT(7 == out.nvlen); CU_ASSERT(nvnameeq("method", &out.nva[0])); @@ -128,8 +130,10 @@ void test_nghttp2_frame_pack_headers() 1000000007, &oframe.hd); CU_ASSERT(1 << 20 == oframe.pri); - CU_ASSERT(framelen - 12 == - inflate_hd(&inflater, &out, buf + 12, framelen - 12)); + nv_offset = bufoff + NGHTTP2_FRAME_HEAD_LENGTH + 4; + CU_ASSERT(framelen - nv_offset == + inflate_hd(&inflater, &out, + buf + nv_offset, framelen - nv_offset)); nghttp2_nv_array_sort(out.nva, out.nvlen); CU_ASSERT(nvnameeq("method", &out.nva[0])); diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 8d457e67..c4b42e4a 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -797,6 +797,7 @@ void test_nghttp2_session_recv_premature_headers(void) my_user_data ud; nghttp2_hd_deflater deflater; nghttp2_outbound_item *item; + size_t bufoff = 0; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); @@ -808,14 +809,16 @@ void test_nghttp2_session_recv_premature_headers(void) nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1, NGHTTP2_PRI_DEFAULT, nva, nvlen); framedatalen = nghttp2_frame_pack_headers(&framedata, &framedatacap, + &bufoff, &frame.headers, &deflater); nghttp2_frame_headers_free(&frame.headers); /* Intentionally feed payload cutting last 1 byte off */ - nghttp2_put_uint16be(framedata, frame.hd.length - 1); - rv = nghttp2_session_mem_recv(session, framedata, framedatalen - 1); - CU_ASSERT((ssize_t)framedatalen - 1 == rv); + nghttp2_put_uint16be(framedata + bufoff, frame.hd.length - 1); + rv = nghttp2_session_mem_recv(session, framedata + bufoff, + framedatalen - bufoff - 1); + CU_ASSERT((ssize_t)framedatalen - bufoff - 1 == rv); item = nghttp2_session_get_next_ob_item(session); CU_ASSERT(NULL != item);