diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 08:52:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 08:52:22 +0000 |
commit | 6a7eecec57783a042d12f895d5ae148c44f4d074 (patch) | |
tree | 77a2c3c5612655f1dd15e9a2ddf14e13bab90b1f /tests | |
parent | Releasing progress-linux version 1.59.0-1~progress7.99u1. (diff) | |
download | nghttp2-6a7eecec57783a042d12f895d5ae148c44f4d074.tar.xz nghttp2-6a7eecec57783a042d12f895d5ae148c44f4d074.zip |
Merging upstream version 1.60.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
34 files changed, 4801 insertions, 4626 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b20ccf7..852cb10 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,55 +1,52 @@ # XXX testdata/: EXTRA_DIST = cacert.pem index.html privkey.pem -if(HAVE_CUNIT) - string(REPLACE " " ";" c_flags "${WARNCFLAGS}") - add_compile_options(${c_flags}) +string(REPLACE " " ";" c_flags "${WARNCFLAGS}") +add_compile_options(${c_flags}) - include_directories( - "${CMAKE_SOURCE_DIR}/lib/includes" - "${CMAKE_SOURCE_DIR}/lib" - "${CMAKE_BINARY_DIR}/lib/includes" - ${CUNIT_INCLUDE_DIRS} - ) +include_directories( + "${CMAKE_SOURCE_DIR}/lib/includes" + "${CMAKE_SOURCE_DIR}/lib" + "${CMAKE_SOURCE_DIR}/tests/munit" + "${CMAKE_BINARY_DIR}/lib/includes" +) + +set(MAIN_SOURCES + main.c nghttp2_pq_test.c nghttp2_map_test.c nghttp2_queue_test.c + nghttp2_test_helper.c + nghttp2_frame_test.c + nghttp2_stream_test.c + nghttp2_session_test.c + nghttp2_hd_test.c + nghttp2_alpn_test.c + nghttp2_helper_test.c + nghttp2_buf_test.c + nghttp2_http_test.c + nghttp2_extpri_test.c + nghttp2_ratelim_test.c + munit/munit.c +) + +add_executable(main EXCLUDE_FROM_ALL + ${MAIN_SOURCES} +) +target_link_libraries(main + nghttp2_static +) +add_test(main main) +add_dependencies(check main) - set(MAIN_SOURCES - main.c nghttp2_pq_test.c nghttp2_map_test.c nghttp2_queue_test.c +if(ENABLE_FAILMALLOC) + set(FAILMALLOC_SOURCES + failmalloc.c failmalloc_test.c + malloc_wrapper.c nghttp2_test_helper.c - nghttp2_frame_test.c - nghttp2_stream_test.c - nghttp2_session_test.c - nghttp2_hd_test.c - nghttp2_alpn_test.c - nghttp2_helper_test.c - nghttp2_buf_test.c - nghttp2_http_test.c - nghttp2_extpri_test.c - nghttp2_ratelim_test.c + munit/munit.c ) - - add_executable(main EXCLUDE_FROM_ALL - ${MAIN_SOURCES} + add_executable(failmalloc EXCLUDE_FROM_ALL + ${FAILMALLOC_SOURCES} ) - target_include_directories(main PRIVATE ${CUNIT_INCLUDE_DIRS}) - target_link_libraries(main + target_link_libraries(failmalloc nghttp2_static - ${CUNIT_LIBRARIES} ) - add_test(main main) - add_dependencies(check main) - - if(ENABLE_FAILMALLOC) - set(FAILMALLOC_SOURCES - failmalloc.c failmalloc_test.c - malloc_wrapper.c - nghttp2_test_helper.c - ) - add_executable(failmalloc EXCLUDE_FROM_ALL - ${FAILMALLOC_SOURCES} - ) - target_link_libraries(failmalloc - nghttp2_static - ${CUNIT_LIBRARIES} - ) - add_test(failmalloc failmalloc) - add_dependencies(check failmalloc) - endif() + add_test(failmalloc failmalloc) + add_dependencies(check failmalloc) endif() diff --git a/tests/Makefile.am b/tests/Makefile.am index 1c506d8..456f65f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,9 +22,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SUBDIRS = testdata -EXTRA_DIST = CMakeLists.txt - -if HAVE_CUNIT +EXTRA_DIST = CMakeLists.txt munit/COPYING check_PROGRAMS = main @@ -43,17 +41,20 @@ OBJECTS = main.c nghttp2_pq_test.c nghttp2_map_test.c nghttp2_queue_test.c \ nghttp2_buf_test.c \ nghttp2_http_test.c \ nghttp2_extpri_test.c \ - nghttp2_ratelim_test.c + nghttp2_ratelim_test.c \ + munit/munit.c HFILES = nghttp2_pq_test.h nghttp2_map_test.h nghttp2_queue_test.h \ nghttp2_session_test.h \ nghttp2_frame_test.h nghttp2_stream_test.h nghttp2_hd_test.h \ nghttp2_alpn_test.h nghttp2_helper_test.h \ + nghttp2_assertion.h \ nghttp2_test_helper.h \ nghttp2_buf_test.h \ nghttp2_http_test.h \ nghttp2_extpri_test.h \ - nghttp2_ratelim_test.h + nghttp2_ratelim_test.h \ + munit/munit.h main_SOURCES = $(HFILES) $(OBJECTS) @@ -65,13 +66,14 @@ else main_LDADD = ${top_builddir}/lib/.libs/*.o endif -main_LDADD += @CUNIT_LIBS@ @TESTLDADD@ +main_LDADD += @TESTLDADD@ main_LDFLAGS = -static if ENABLE_FAILMALLOC failmalloc_SOURCES = failmalloc.c failmalloc_test.c failmalloc_test.h \ malloc_wrapper.c malloc_wrapper.h \ - nghttp2_test_helper.c nghttp2_test_helper.h + nghttp2_test_helper.c nghttp2_test_helper.h \ + munit/munit.c munit/munit.h failmalloc_LDADD = $(main_LDADD) failmalloc_LDFLAGS = $(main_LDFLAGS) endif # ENABLE_FAILMALLOC @@ -79,15 +81,14 @@ endif # ENABLE_FAILMALLOC AM_CFLAGS = $(WARNCFLAGS) \ -I${top_srcdir}/lib \ -I${top_srcdir}/lib/includes \ + -I${top_srcdir}/tests/munit \ -I${top_builddir}/lib/includes \ -DBUILDING_NGHTTP2 \ -DNGHTTP2_STATICLIB \ - @CUNIT_CFLAGS@ @DEFS@ + @DEFS@ TESTS = main if ENABLE_FAILMALLOC TESTS += failmalloc endif # ENABLE_FAILMALLOC - -endif # HAVE_CUNIT diff --git a/tests/failmalloc.c b/tests/failmalloc.c index 6294cff..b491deb 100644 --- a/tests/failmalloc.c +++ b/tests/failmalloc.c @@ -26,54 +26,20 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -#include <stdio.h> -#include <string.h> -#include <CUnit/Basic.h> +#include "munit.h" + /* include test cases' include files here */ #include "failmalloc_test.h" -static int init_suite1(void) { return 0; } - -static int clean_suite1(void) { return 0; } - -int main(void) { - CU_pSuite pSuite = NULL; - unsigned int num_tests_failed; - - /* initialize the CUnit test registry */ - if (CUE_SUCCESS != CU_initialize_registry()) - return (int)CU_get_error(); - - /* add a suite to the registry */ - pSuite = CU_add_suite("libnghttp2_TestSuite", init_suite1, clean_suite1); - if (NULL == pSuite) { - CU_cleanup_registry(); - return (int)CU_get_error(); - } - - /* add the tests to the suite */ - if (!CU_add_test(pSuite, "failmalloc_session_send", - test_nghttp2_session_send) || - !CU_add_test(pSuite, "failmalloc_session_send_server", - test_nghttp2_session_send_server) || - !CU_add_test(pSuite, "failmalloc_session_recv", - test_nghttp2_session_recv) || - !CU_add_test(pSuite, "failmalloc_frame", test_nghttp2_frame) || - !CU_add_test(pSuite, "failmalloc_hd", test_nghttp2_hd)) { - CU_cleanup_registry(); - return (int)CU_get_error(); - } +int main(int argc, char *argv[]) { + const MunitSuite suites[] = { + failmalloc_suite, + {NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE}, + }; + const MunitSuite suite = { + "", NULL, suites, 1, MUNIT_SUITE_OPTION_NONE, + }; - /* Run all tests using the CUnit Basic interface */ - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - num_tests_failed = CU_get_number_of_tests_failed(); - CU_cleanup_registry(); - if (CU_get_error() == CUE_SUCCESS) { - return (int)num_tests_failed; - } else { - printf("CUnit Error: %s\n", CU_get_error_msg()); - return (int)CU_get_error(); - } + return munit_suite_main(&suite, NULL, argc, argv); } diff --git a/tests/failmalloc_test.c b/tests/failmalloc_test.c index 594bc72..5b204fe 100644 --- a/tests/failmalloc_test.c +++ b/tests/failmalloc_test.c @@ -27,7 +27,7 @@ #include <stdio.h> #include <assert.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_session.h" #include "nghttp2_stream.h" @@ -36,6 +36,19 @@ #include "malloc_wrapper.h" #include "nghttp2_test_helper.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_session_send), + munit_void_test(test_nghttp2_session_send_server), + munit_void_test(test_nghttp2_session_recv), + munit_void_test(test_nghttp2_frame), + munit_void_test(test_nghttp2_hd), + munit_test_end(), +}; + +const MunitSuite failmalloc_suite = { + "/failmalloc", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + typedef struct { uint8_t data[8192]; uint8_t *datamark, *datalimit; @@ -59,18 +72,20 @@ static void data_feed_init(data_feed *df, nghttp2_bufs *bufs) { df->datalimit = df->data + data_length; } -static ssize_t null_send_callback(nghttp2_session *session, const uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize null_send_callback(nghttp2_session *session, + const uint8_t *data, size_t len, + int flags, void *user_data) { (void)session; (void)data; (void)flags; (void)user_data; - return (ssize_t)len; + return (nghttp2_ssize)len; } -static ssize_t data_feed_recv_callback(nghttp2_session *session, uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize data_feed_recv_callback(nghttp2_session *session, + uint8_t *data, size_t len, + int flags, void *user_data) { data_feed *df = ((my_user_data *)user_data)->df; size_t avail = (size_t)(df->datalimit - df->datamark); size_t wlen = nghttp2_min(avail, len); @@ -79,10 +94,10 @@ static ssize_t data_feed_recv_callback(nghttp2_session *session, uint8_t *data, memcpy(data, df->datamark, wlen); df->datamark += wlen; - return (ssize_t)wlen; + return (nghttp2_ssize)wlen; } -static ssize_t fixed_length_data_source_read_callback( +static nghttp2_ssize fixed_length_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { my_user_data *ud = (my_user_data *)user_data; @@ -101,7 +116,7 @@ static ssize_t fixed_length_data_source_read_callback( if (ud->data_source_length == 0) { *data_flags = NGHTTP2_DATA_FLAG_EOF; } - return (ssize_t)wlen; + return (nghttp2_ssize)wlen; } #define TEST_FAILMALLOC_RUN(FUN) \ @@ -129,12 +144,12 @@ static void run_nghttp2_session_send(void) { nghttp2_session_callbacks callbacks; nghttp2_nv nv[] = {MAKE_NV(":host", "example.org"), MAKE_NV(":scheme", "https")}; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_settings_entry iv[2]; my_user_data ud; int rv; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 64 * 1024; @@ -149,7 +164,7 @@ static void run_nghttp2_session_send(void) { if (rv != 0) { goto client_new_fail; } - rv = nghttp2_submit_request(session, NULL, nv, ARRLEN(nv), &data_prd, NULL); + rv = nghttp2_submit_request2(session, NULL, nv, ARRLEN(nv), &data_prd, NULL); if (rv < 0) { goto fail; } @@ -169,7 +184,7 @@ static void run_nghttp2_session_send(void) { if (rv != 0) { goto fail; } - rv = nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 3, &data_prd); + rv = nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 3, &data_prd); if (rv != 0) { goto fail; } @@ -221,7 +236,7 @@ static void run_nghttp2_session_send_server(void) { nghttp2_session_callbacks *callbacks; int rv; const uint8_t *txdata; - ssize_t txdatalen; + nghttp2_ssize txdatalen; const uint8_t origin[] = "nghttp2.org"; const uint8_t altsvc_field_value[] = "h2=\":443\""; static const uint8_t nghttp2[] = "https://nghttp2.org"; @@ -256,7 +271,7 @@ static void run_nghttp2_session_send_server(void) { goto fail; } - txdatalen = nghttp2_session_mem_send(session, &txdata); + txdatalen = nghttp2_session_mem_send2(session, &txdata); if (txdatalen < 0) { goto fail; @@ -296,7 +311,7 @@ static void run_nghttp2_session_recv(void) { } memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.recv_callback = data_feed_recv_callback; + callbacks.recv_callback2 = data_feed_recv_callback; ud.df = &df; nghttp2_failmalloc_pause(); diff --git a/tests/failmalloc_test.h b/tests/failmalloc_test.h index 576932a..9664480 100644 --- a/tests/failmalloc_test.h +++ b/tests/failmalloc_test.h @@ -29,10 +29,16 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_session_send(void); -void test_nghttp2_session_send_server(void); -void test_nghttp2_session_recv(void); -void test_nghttp2_frame(void); -void test_nghttp2_hd(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite failmalloc_suite; + +munit_void_test_decl(test_nghttp2_session_send); +munit_void_test_decl(test_nghttp2_session_send_server); +munit_void_test_decl(test_nghttp2_session_recv); +munit_void_test_decl(test_nghttp2_frame); +munit_void_test_decl(test_nghttp2_hd); #endif /* FAILMALLOC_TEST_H */ diff --git a/tests/main.c b/tests/main.c index 6827daf..ebee3de 100644 --- a/tests/main.c +++ b/tests/main.c @@ -26,9 +26,8 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -#include <stdio.h> -#include <string.h> -#include <CUnit/Basic.h> +#include "munit.h" + /* include test cases' include files here */ #include "nghttp2_pq_test.h" #include "nghttp2_map_test.h" @@ -46,428 +45,27 @@ extern int nghttp2_enable_strict_preface; -static int init_suite1(void) { return 0; } - -static int clean_suite1(void) { return 0; } - -int main(void) { - CU_pSuite pSuite = NULL; - unsigned int num_tests_failed; +int main(int argc, char *argv[]) { + const MunitSuite suites[] = { + pq_suite, + map_suite, + queue_suite, + frame_suite, + session_suite, + hd_suite, + alpn_suite, + helper_suite, + buf_suite, + http_suite, + extpri_suite, + ratelim_suite, + {NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE}, + }; + const MunitSuite suite = { + "", NULL, suites, 1, MUNIT_SUITE_OPTION_NONE, + }; nghttp2_enable_strict_preface = 0; - /* initialize the CUnit test registry */ - if (CUE_SUCCESS != CU_initialize_registry()) - return (int)CU_get_error(); - - /* add a suite to the registry */ - pSuite = CU_add_suite("libnghttp2_TestSuite", init_suite1, clean_suite1); - if (NULL == pSuite) { - CU_cleanup_registry(); - return (int)CU_get_error(); - } - - /* add the tests to the suite */ - if (!CU_add_test(pSuite, "pq", test_nghttp2_pq) || - !CU_add_test(pSuite, "pq_update", test_nghttp2_pq_update) || - !CU_add_test(pSuite, "pq_remove", test_nghttp2_pq_remove) || - !CU_add_test(pSuite, "map", test_nghttp2_map) || - !CU_add_test(pSuite, "map_functional", test_nghttp2_map_functional) || - !CU_add_test(pSuite, "map_each_free", test_nghttp2_map_each_free) || - !CU_add_test(pSuite, "queue", test_nghttp2_queue) || - !CU_add_test(pSuite, "alpn", test_nghttp2_alpn) || - !CU_add_test(pSuite, "session_recv", test_nghttp2_session_recv) || - !CU_add_test(pSuite, "session_recv_invalid_stream_id", - test_nghttp2_session_recv_invalid_stream_id) || - !CU_add_test(pSuite, "session_recv_invalid_frame", - test_nghttp2_session_recv_invalid_frame) || - !CU_add_test(pSuite, "session_recv_eof", test_nghttp2_session_recv_eof) || - !CU_add_test(pSuite, "session_recv_data", - test_nghttp2_session_recv_data) || - !CU_add_test(pSuite, "session_recv_data_no_auto_flow_control", - test_nghttp2_session_recv_data_no_auto_flow_control) || - !CU_add_test(pSuite, "session_recv_continuation", - test_nghttp2_session_recv_continuation) || - !CU_add_test(pSuite, "session_recv_headers_with_priority", - test_nghttp2_session_recv_headers_with_priority) || - !CU_add_test(pSuite, "session_recv_headers_with_padding", - test_nghttp2_session_recv_headers_with_padding) || - !CU_add_test(pSuite, "session_recv_headers_early_response", - test_nghttp2_session_recv_headers_early_response) || - !CU_add_test(pSuite, "session_recv_headers_for_closed_stream", - test_nghttp2_session_recv_headers_for_closed_stream) || - !CU_add_test(pSuite, "session_recv_headers_with_extpri", - test_nghttp2_session_recv_headers_with_extpri) || - !CU_add_test(pSuite, "session_server_recv_push_response", - test_nghttp2_session_server_recv_push_response) || - !CU_add_test(pSuite, "session_recv_premature_headers", - test_nghttp2_session_recv_premature_headers) || - !CU_add_test(pSuite, "session_recv_unknown_frame", - test_nghttp2_session_recv_unknown_frame) || - !CU_add_test(pSuite, "session_recv_unexpected_continuation", - test_nghttp2_session_recv_unexpected_continuation) || - !CU_add_test(pSuite, "session_recv_settings_header_table_size", - test_nghttp2_session_recv_settings_header_table_size) || - !CU_add_test(pSuite, "session_recv_too_large_frame_length", - test_nghttp2_session_recv_too_large_frame_length) || - !CU_add_test(pSuite, "session_recv_extension", - test_nghttp2_session_recv_extension) || - !CU_add_test(pSuite, "session_recv_altsvc", - test_nghttp2_session_recv_altsvc) || - !CU_add_test(pSuite, "session_recv_origin", - test_nghttp2_session_recv_origin) || - !CU_add_test(pSuite, "session_recv_priority_update", - test_nghttp2_session_recv_priority_update) || - !CU_add_test(pSuite, "session_continue", test_nghttp2_session_continue) || - !CU_add_test(pSuite, "session_add_frame", - test_nghttp2_session_add_frame) || - !CU_add_test(pSuite, "session_on_request_headers_received", - test_nghttp2_session_on_request_headers_received) || - !CU_add_test(pSuite, "session_on_response_headers_received", - test_nghttp2_session_on_response_headers_received) || - !CU_add_test(pSuite, "session_on_headers_received", - test_nghttp2_session_on_headers_received) || - !CU_add_test(pSuite, "session_on_push_response_headers_received", - test_nghttp2_session_on_push_response_headers_received) || - !CU_add_test(pSuite, "session_on_priority_received", - test_nghttp2_session_on_priority_received) || - !CU_add_test(pSuite, "session_on_rst_stream_received", - test_nghttp2_session_on_rst_stream_received) || - !CU_add_test(pSuite, "session_on_settings_received", - test_nghttp2_session_on_settings_received) || - !CU_add_test(pSuite, "session_on_push_promise_received", - test_nghttp2_session_on_push_promise_received) || - !CU_add_test(pSuite, "session_on_ping_received", - test_nghttp2_session_on_ping_received) || - !CU_add_test(pSuite, "session_on_goaway_received", - test_nghttp2_session_on_goaway_received) || - !CU_add_test(pSuite, "session_on_window_update_received", - test_nghttp2_session_on_window_update_received) || - !CU_add_test(pSuite, "session_on_data_received", - test_nghttp2_session_on_data_received) || - !CU_add_test(pSuite, "session_on_data_received_fail_fast", - test_nghttp2_session_on_data_received_fail_fast) || - !CU_add_test(pSuite, "session_on_altsvc_received", - test_nghttp2_session_on_altsvc_received) || - !CU_add_test(pSuite, "session_send_headers_start_stream", - test_nghttp2_session_send_headers_start_stream) || - !CU_add_test(pSuite, "session_send_headers_reply", - test_nghttp2_session_send_headers_reply) || - !CU_add_test(pSuite, "session_send_headers_frame_size_error", - test_nghttp2_session_send_headers_frame_size_error) || - !CU_add_test(pSuite, "session_send_headers_push_reply", - test_nghttp2_session_send_headers_push_reply) || - !CU_add_test(pSuite, "session_send_rst_stream", - test_nghttp2_session_send_rst_stream) || - !CU_add_test(pSuite, "session_send_push_promise", - test_nghttp2_session_send_push_promise) || - !CU_add_test(pSuite, "session_is_my_stream_id", - test_nghttp2_session_is_my_stream_id) || - !CU_add_test(pSuite, "session_upgrade2", test_nghttp2_session_upgrade2) || - !CU_add_test(pSuite, "session_reprioritize_stream", - test_nghttp2_session_reprioritize_stream) || - !CU_add_test( - pSuite, "session_reprioritize_stream_with_idle_stream_dep", - test_nghttp2_session_reprioritize_stream_with_idle_stream_dep) || - !CU_add_test(pSuite, "submit_data", test_nghttp2_submit_data) || - !CU_add_test(pSuite, "submit_data_read_length_too_large", - test_nghttp2_submit_data_read_length_too_large) || - !CU_add_test(pSuite, "submit_data_read_length_smallest", - test_nghttp2_submit_data_read_length_smallest) || - !CU_add_test(pSuite, "submit_data_twice", - test_nghttp2_submit_data_twice) || - !CU_add_test(pSuite, "submit_request_with_data", - test_nghttp2_submit_request_with_data) || - !CU_add_test(pSuite, "submit_request_without_data", - test_nghttp2_submit_request_without_data) || - !CU_add_test(pSuite, "submit_response_with_data", - test_nghttp2_submit_response_with_data) || - !CU_add_test(pSuite, "submit_response_without_data", - test_nghttp2_submit_response_without_data) || - !CU_add_test(pSuite, "Submit_response_push_response", - test_nghttp2_submit_response_push_response) || - !CU_add_test(pSuite, "submit_trailer", test_nghttp2_submit_trailer) || - !CU_add_test(pSuite, "submit_headers_start_stream", - test_nghttp2_submit_headers_start_stream) || - !CU_add_test(pSuite, "submit_headers_reply", - test_nghttp2_submit_headers_reply) || - !CU_add_test(pSuite, "submit_headers_push_reply", - test_nghttp2_submit_headers_push_reply) || - !CU_add_test(pSuite, "submit_headers", test_nghttp2_submit_headers) || - !CU_add_test(pSuite, "submit_headers_continuation", - test_nghttp2_submit_headers_continuation) || - !CU_add_test(pSuite, "submit_headers_continuation_extra_large", - test_nghttp2_submit_headers_continuation_extra_large) || - !CU_add_test(pSuite, "submit_priority", test_nghttp2_submit_priority) || - !CU_add_test(pSuite, "session_submit_settings", - test_nghttp2_submit_settings) || - !CU_add_test(pSuite, "session_submit_settings_update_local_window_size", - test_nghttp2_submit_settings_update_local_window_size) || - !CU_add_test(pSuite, "session_submit_settings_multiple_times", - test_nghttp2_submit_settings_multiple_times) || - !CU_add_test(pSuite, "session_submit_push_promise", - test_nghttp2_submit_push_promise) || - !CU_add_test(pSuite, "submit_window_update", - test_nghttp2_submit_window_update) || - !CU_add_test(pSuite, "submit_window_update_local_window_size", - test_nghttp2_submit_window_update_local_window_size) || - !CU_add_test(pSuite, "submit_shutdown_notice", - test_nghttp2_submit_shutdown_notice) || - !CU_add_test(pSuite, "submit_invalid_nv", - test_nghttp2_submit_invalid_nv) || - !CU_add_test(pSuite, "submit_extension", test_nghttp2_submit_extension) || - !CU_add_test(pSuite, "submit_altsvc", test_nghttp2_submit_altsvc) || - !CU_add_test(pSuite, "submit_origin", test_nghttp2_submit_origin) || - !CU_add_test(pSuite, "submit_priority_update", - test_nghttp2_submit_priority_update) || - !CU_add_test(pSuite, "submit_rst_stream", - test_nghttp2_submit_rst_stream) || - !CU_add_test(pSuite, "session_open_stream", - test_nghttp2_session_open_stream) || - !CU_add_test(pSuite, "session_open_stream_with_idle_stream_dep", - test_nghttp2_session_open_stream_with_idle_stream_dep) || - !CU_add_test(pSuite, "session_get_next_ob_item", - test_nghttp2_session_get_next_ob_item) || - !CU_add_test(pSuite, "session_pop_next_ob_item", - test_nghttp2_session_pop_next_ob_item) || - !CU_add_test(pSuite, "session_reply_fail", - test_nghttp2_session_reply_fail) || - !CU_add_test(pSuite, "session_max_concurrent_streams", - test_nghttp2_session_max_concurrent_streams) || - !CU_add_test(pSuite, "session_stop_data_with_rst_stream", - test_nghttp2_session_stop_data_with_rst_stream) || - !CU_add_test(pSuite, "session_defer_data", - test_nghttp2_session_defer_data) || - !CU_add_test(pSuite, "session_flow_control", - test_nghttp2_session_flow_control) || - !CU_add_test(pSuite, "session_flow_control_data_recv", - test_nghttp2_session_flow_control_data_recv) || - !CU_add_test(pSuite, "session_flow_control_data_with_padding_recv", - test_nghttp2_session_flow_control_data_with_padding_recv) || - !CU_add_test(pSuite, "session_data_read_temporal_failure", - test_nghttp2_session_data_read_temporal_failure) || - !CU_add_test(pSuite, "session_on_stream_close", - test_nghttp2_session_on_stream_close) || - !CU_add_test(pSuite, "session_on_ctrl_not_send", - test_nghttp2_session_on_ctrl_not_send) || - !CU_add_test(pSuite, "session_get_outbound_queue_size", - test_nghttp2_session_get_outbound_queue_size) || - !CU_add_test(pSuite, "session_get_effective_local_window_size", - test_nghttp2_session_get_effective_local_window_size) || - !CU_add_test(pSuite, "session_set_option", - test_nghttp2_session_set_option) || - !CU_add_test(pSuite, "session_data_backoff_by_high_pri_frame", - test_nghttp2_session_data_backoff_by_high_pri_frame) || - !CU_add_test(pSuite, "session_pack_data_with_padding", - test_nghttp2_session_pack_data_with_padding) || - !CU_add_test(pSuite, "session_pack_headers_with_padding", - test_nghttp2_session_pack_headers_with_padding) || - !CU_add_test(pSuite, "pack_settings_payload", - test_nghttp2_pack_settings_payload) || - !CU_add_test(pSuite, "session_stream_dep_add", - test_nghttp2_session_stream_dep_add) || - !CU_add_test(pSuite, "session_stream_dep_remove", - test_nghttp2_session_stream_dep_remove) || - !CU_add_test(pSuite, "session_stream_dep_add_subtree", - test_nghttp2_session_stream_dep_add_subtree) || - !CU_add_test(pSuite, "session_stream_dep_remove_subtree", - test_nghttp2_session_stream_dep_remove_subtree) || - !CU_add_test( - pSuite, "session_stream_dep_all_your_stream_are_belong_to_us", - test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us) || - !CU_add_test(pSuite, "session_stream_attach_item", - test_nghttp2_session_stream_attach_item) || - !CU_add_test(pSuite, "session_stream_attach_item_subtree", - test_nghttp2_session_stream_attach_item_subtree) || - !CU_add_test(pSuite, "session_stream_get_state", - test_nghttp2_session_stream_get_state) || - !CU_add_test(pSuite, "session_stream_get_something", - test_nghttp2_session_stream_get_something) || - !CU_add_test(pSuite, "session_find_stream", - test_nghttp2_session_find_stream) || - !CU_add_test(pSuite, "session_keep_closed_stream", - test_nghttp2_session_keep_closed_stream) || - !CU_add_test(pSuite, "session_keep_idle_stream", - test_nghttp2_session_keep_idle_stream) || - !CU_add_test(pSuite, "session_detach_idle_stream", - test_nghttp2_session_detach_idle_stream) || - !CU_add_test(pSuite, "session_large_dep_tree", - test_nghttp2_session_large_dep_tree) || - !CU_add_test(pSuite, "session_graceful_shutdown", - test_nghttp2_session_graceful_shutdown) || - !CU_add_test(pSuite, "session_on_header_temporal_failure", - test_nghttp2_session_on_header_temporal_failure) || - !CU_add_test(pSuite, "session_recv_client_magic", - test_nghttp2_session_recv_client_magic) || - !CU_add_test(pSuite, "session_delete_data_item", - test_nghttp2_session_delete_data_item) || - !CU_add_test(pSuite, "session_open_idle_stream", - test_nghttp2_session_open_idle_stream) || - !CU_add_test(pSuite, "session_cancel_reserved_remote", - test_nghttp2_session_cancel_reserved_remote) || - !CU_add_test(pSuite, "session_reset_pending_headers", - test_nghttp2_session_reset_pending_headers) || - !CU_add_test(pSuite, "session_send_data_callback", - test_nghttp2_session_send_data_callback) || - !CU_add_test(pSuite, "session_on_begin_headers_temporal_failure", - test_nghttp2_session_on_begin_headers_temporal_failure) || - !CU_add_test(pSuite, "session_defer_then_close", - test_nghttp2_session_defer_then_close) || - !CU_add_test(pSuite, "session_detach_item_from_closed_stream", - test_nghttp2_session_detach_item_from_closed_stream) || - !CU_add_test(pSuite, "session_flooding", test_nghttp2_session_flooding) || - !CU_add_test(pSuite, "session_change_stream_priority", - test_nghttp2_session_change_stream_priority) || - !CU_add_test(pSuite, "session_change_extpri_stream_priority", - test_nghttp2_session_change_extpri_stream_priority) || - !CU_add_test(pSuite, "session_create_idle_stream", - test_nghttp2_session_create_idle_stream) || - !CU_add_test(pSuite, "session_repeated_priority_change", - test_nghttp2_session_repeated_priority_change) || - !CU_add_test(pSuite, "session_repeated_priority_submission", - test_nghttp2_session_repeated_priority_submission) || - !CU_add_test(pSuite, "session_set_local_window_size", - test_nghttp2_session_set_local_window_size) || - !CU_add_test(pSuite, "session_cancel_from_before_frame_send", - test_nghttp2_session_cancel_from_before_frame_send) || - !CU_add_test(pSuite, "session_too_many_settings", - test_nghttp2_session_too_many_settings) || - !CU_add_test(pSuite, "session_removed_closed_stream", - test_nghttp2_session_removed_closed_stream) || - !CU_add_test(pSuite, "session_pause_data", - test_nghttp2_session_pause_data) || - !CU_add_test(pSuite, "session_no_closed_streams", - test_nghttp2_session_no_closed_streams) || - !CU_add_test(pSuite, "session_set_stream_user_data", - test_nghttp2_session_set_stream_user_data) || - !CU_add_test(pSuite, "session_no_rfc7540_priorities", - test_nghttp2_session_no_rfc7540_priorities) || - !CU_add_test(pSuite, "session_server_fallback_rfc7540_priorities", - test_nghttp2_session_server_fallback_rfc7540_priorities) || - !CU_add_test(pSuite, "session_stream_reset_ratelim", - test_nghttp2_session_stream_reset_ratelim) || - !CU_add_test(pSuite, "http_mandatory_headers", - test_nghttp2_http_mandatory_headers) || - !CU_add_test(pSuite, "http_content_length", - test_nghttp2_http_content_length) || - !CU_add_test(pSuite, "http_content_length_mismatch", - test_nghttp2_http_content_length_mismatch) || - !CU_add_test(pSuite, "http_non_final_response", - test_nghttp2_http_non_final_response) || - !CU_add_test(pSuite, "http_trailer_headers", - test_nghttp2_http_trailer_headers) || - !CU_add_test(pSuite, "http_ignore_regular_header", - test_nghttp2_http_ignore_regular_header) || - !CU_add_test(pSuite, "http_ignore_content_length", - test_nghttp2_http_ignore_content_length) || - !CU_add_test(pSuite, "http_record_request_method", - test_nghttp2_http_record_request_method) || - !CU_add_test(pSuite, "http_push_promise", - test_nghttp2_http_push_promise) || - !CU_add_test(pSuite, "http_head_method_upgrade_workaround", - test_nghttp2_http_head_method_upgrade_workaround) || - !CU_add_test( - pSuite, "http_no_rfc9113_leading_and_trailing_ws_validation", - test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation) || - !CU_add_test(pSuite, "frame_pack_headers", - test_nghttp2_frame_pack_headers) || - !CU_add_test(pSuite, "frame_pack_headers_frame_too_large", - test_nghttp2_frame_pack_headers_frame_too_large) || - !CU_add_test(pSuite, "frame_pack_priority", - test_nghttp2_frame_pack_priority) || - !CU_add_test(pSuite, "frame_pack_rst_stream", - test_nghttp2_frame_pack_rst_stream) || - !CU_add_test(pSuite, "frame_pack_settings", - test_nghttp2_frame_pack_settings) || - !CU_add_test(pSuite, "frame_pack_push_promise", - test_nghttp2_frame_pack_push_promise) || - !CU_add_test(pSuite, "frame_pack_ping", test_nghttp2_frame_pack_ping) || - !CU_add_test(pSuite, "frame_pack_goaway", - test_nghttp2_frame_pack_goaway) || - !CU_add_test(pSuite, "frame_pack_window_update", - test_nghttp2_frame_pack_window_update) || - !CU_add_test(pSuite, "frame_pack_altsvc", - test_nghttp2_frame_pack_altsvc) || - !CU_add_test(pSuite, "frame_pack_origin", - test_nghttp2_frame_pack_origin) || - !CU_add_test(pSuite, "frame_pack_priority_update", - test_nghttp2_frame_pack_priority_update) || - !CU_add_test(pSuite, "nv_array_copy", test_nghttp2_nv_array_copy) || - !CU_add_test(pSuite, "iv_check", test_nghttp2_iv_check) || - !CU_add_test(pSuite, "hd_deflate", test_nghttp2_hd_deflate) || - !CU_add_test(pSuite, "hd_deflate_same_indexed_repr", - test_nghttp2_hd_deflate_same_indexed_repr) || - !CU_add_test(pSuite, "hd_inflate_indexed", - test_nghttp2_hd_inflate_indexed) || - !CU_add_test(pSuite, "hd_inflate_indname_noinc", - test_nghttp2_hd_inflate_indname_noinc) || - !CU_add_test(pSuite, "hd_inflate_indname_inc", - test_nghttp2_hd_inflate_indname_inc) || - !CU_add_test(pSuite, "hd_inflate_indname_inc_eviction", - test_nghttp2_hd_inflate_indname_inc_eviction) || - !CU_add_test(pSuite, "hd_inflate_newname_noinc", - test_nghttp2_hd_inflate_newname_noinc) || - !CU_add_test(pSuite, "hd_inflate_newname_inc", - test_nghttp2_hd_inflate_newname_inc) || - !CU_add_test(pSuite, "hd_inflate_clearall_inc", - test_nghttp2_hd_inflate_clearall_inc) || - !CU_add_test(pSuite, "hd_inflate_zero_length_huffman", - test_nghttp2_hd_inflate_zero_length_huffman) || - !CU_add_test(pSuite, "hd_inflate_expect_table_size_update", - test_nghttp2_hd_inflate_expect_table_size_update) || - !CU_add_test(pSuite, "hd_inflate_unexpected_table_size_update", - test_nghttp2_hd_inflate_unexpected_table_size_update) || - !CU_add_test(pSuite, "hd_ringbuf_reserve", - test_nghttp2_hd_ringbuf_reserve) || - !CU_add_test(pSuite, "hd_change_table_size", - test_nghttp2_hd_change_table_size) || - !CU_add_test(pSuite, "hd_deflate_inflate", - test_nghttp2_hd_deflate_inflate) || - !CU_add_test(pSuite, "hd_no_index", test_nghttp2_hd_no_index) || - !CU_add_test(pSuite, "hd_deflate_bound", test_nghttp2_hd_deflate_bound) || - !CU_add_test(pSuite, "hd_public_api", test_nghttp2_hd_public_api) || - !CU_add_test(pSuite, "hd_deflate_hd_vec", - test_nghttp2_hd_deflate_hd_vec) || - !CU_add_test(pSuite, "hd_decode_length", test_nghttp2_hd_decode_length) || - !CU_add_test(pSuite, "hd_huff_encode", test_nghttp2_hd_huff_encode) || - !CU_add_test(pSuite, "hd_huff_decode", test_nghttp2_hd_huff_decode) || - !CU_add_test(pSuite, "adjust_local_window_size", - test_nghttp2_adjust_local_window_size) || - !CU_add_test(pSuite, "check_header_name", - test_nghttp2_check_header_name) || - !CU_add_test(pSuite, "check_header_value", - test_nghttp2_check_header_value) || - !CU_add_test(pSuite, "check_header_value_rfc9113", - test_nghttp2_check_header_value_rfc9113) || - !CU_add_test(pSuite, "bufs_add", test_nghttp2_bufs_add) || - !CU_add_test(pSuite, "bufs_add_stack_buffer_overflow_bug", - test_nghttp2_bufs_add_stack_buffer_overflow_bug) || - !CU_add_test(pSuite, "bufs_addb", test_nghttp2_bufs_addb) || - !CU_add_test(pSuite, "bufs_orb", test_nghttp2_bufs_orb) || - !CU_add_test(pSuite, "bufs_remove", test_nghttp2_bufs_remove) || - !CU_add_test(pSuite, "bufs_reset", test_nghttp2_bufs_reset) || - !CU_add_test(pSuite, "bufs_advance", test_nghttp2_bufs_advance) || - !CU_add_test(pSuite, "bufs_next_present", - test_nghttp2_bufs_next_present) || - !CU_add_test(pSuite, "bufs_realloc", test_nghttp2_bufs_realloc) || - !CU_add_test(pSuite, "http_parse_priority", - test_nghttp2_http_parse_priority) || - !CU_add_test(pSuite, "extpri_to_uint8", test_nghttp2_extpri_to_uint8) || - !CU_add_test(pSuite, "ratelim_update", test_nghttp2_ratelim_update) || - !CU_add_test(pSuite, "ratelim_drain", test_nghttp2_ratelim_drain)) { - CU_cleanup_registry(); - return (int)CU_get_error(); - } - - /* Run all tests using the CUnit Basic interface */ - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - num_tests_failed = CU_get_number_of_tests_failed(); - CU_cleanup_registry(); - if (CU_get_error() == CUE_SUCCESS) { - return (int)num_tests_failed; - } else { - printf("CUnit Error: %s\n", CU_get_error_msg()); - return (int)CU_get_error(); - } + return munit_suite_main(&suite, NULL, argc, argv); } diff --git a/tests/nghttp2_alpn_test.c b/tests/nghttp2_alpn_test.c index d471d5f..805a23e 100644 --- a/tests/nghttp2_alpn_test.c +++ b/tests/nghttp2_alpn_test.c @@ -27,25 +27,36 @@ #include <stdio.h> #include <string.h> -#include <CUnit/CUnit.h> +#include "munit.h" + #include <nghttp2/nghttp2.h> +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_alpn), + munit_test_end(), +}; + +const MunitSuite alpn_suite = { + "/alpn", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + static void http2(void) { const unsigned char p[] = {8, 'h', 't', 't', 'p', '/', '1', '.', '1', 2, 'h', '2', 6, 's', 'p', 'd', 'y', '/', '3'}; unsigned char outlen; const unsigned char *out; - CU_ASSERT(1 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen, - p, sizeof(p))); - CU_ASSERT(NGHTTP2_PROTO_VERSION_ID_LEN == outlen); - CU_ASSERT(memcmp(NGHTTP2_PROTO_VERSION_ID, out, outlen) == 0); + assert_int(1, ==, + nghttp2_select_next_protocol((unsigned char **)&out, &outlen, p, + sizeof(p))); + assert_uchar(NGHTTP2_PROTO_VERSION_ID_LEN, ==, outlen); + assert_memory_equal(outlen, NGHTTP2_PROTO_VERSION_ID, out); outlen = 0; out = NULL; - CU_ASSERT(1 == nghttp2_select_alpn(&out, &outlen, p, sizeof(p))); - CU_ASSERT(NGHTTP2_PROTO_VERSION_ID_LEN == outlen); - CU_ASSERT(memcmp(NGHTTP2_PROTO_VERSION_ID, out, outlen) == 0); + assert_int(1, ==, nghttp2_select_alpn(&out, &outlen, p, sizeof(p))); + assert_uchar(NGHTTP2_PROTO_VERSION_ID_LEN, ==, outlen); + assert_memory_equal(outlen, NGHTTP2_PROTO_VERSION_ID, out); } static void http11(void) { @@ -55,17 +66,18 @@ static void http11(void) { }; unsigned char outlen; const unsigned char *out; - CU_ASSERT(0 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen, - spdy, sizeof(spdy))); - CU_ASSERT(8 == outlen); - CU_ASSERT(memcmp("http/1.1", out, outlen) == 0); + assert_int(0, ==, + nghttp2_select_next_protocol((unsigned char **)&out, &outlen, spdy, + sizeof(spdy))); + assert_uchar(8, ==, outlen); + assert_memory_equal(outlen, "http/1.1", out); outlen = 0; out = NULL; - CU_ASSERT(0 == nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy))); - CU_ASSERT(8 == outlen); - CU_ASSERT(memcmp("http/1.1", out, outlen) == 0); + assert_int(0, ==, nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy))); + assert_uchar(8, ==, outlen); + assert_memory_equal(outlen, "http/1.1", out); } static void no_overlap(void) { @@ -75,17 +87,18 @@ static void no_overlap(void) { }; unsigned char outlen = 0; const unsigned char *out = NULL; - CU_ASSERT(-1 == nghttp2_select_next_protocol((unsigned char **)&out, &outlen, - spdy, sizeof(spdy))); - CU_ASSERT(0 == outlen); - CU_ASSERT(NULL == out); + assert_int(-1, ==, + nghttp2_select_next_protocol((unsigned char **)&out, &outlen, spdy, + sizeof(spdy))); + assert_uchar(0, ==, outlen); + assert_null(out); outlen = 0; out = NULL; - CU_ASSERT(-1 == nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy))); - CU_ASSERT(0 == outlen); - CU_ASSERT(NULL == out); + assert_int(-1, ==, nghttp2_select_alpn(&out, &outlen, spdy, sizeof(spdy))); + assert_uchar(0, ==, outlen); + assert_null(out); } void test_nghttp2_alpn(void) { diff --git a/tests/nghttp2_alpn_test.h b/tests/nghttp2_alpn_test.h index f797f9e..a375701 100644 --- a/tests/nghttp2_alpn_test.h +++ b/tests/nghttp2_alpn_test.h @@ -29,6 +29,12 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_alpn(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite alpn_suite; + +munit_void_test_decl(test_nghttp2_alpn); #endif /* NGHTTP2_ALPN_TEST_H */ diff --git a/tests/nghttp2_assertion.h b/tests/nghttp2_assertion.h new file mode 100644 index 0000000..28d6929 --- /dev/null +++ b/tests/nghttp2_assertion.h @@ -0,0 +1,56 @@ +/* + * nghttp2 - HTTP/2 C Library + * + * Copyright (c) 2024 nghttp2 contributors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef NGHTTP2_ASSERTION_H +#define NGHTTP2_ASSERTION_H + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include "munit.h" + +#include "nghttp2_frame.h" + +#define assert_nv_equal(A, B, len, mem) \ + do { \ + size_t alloclen = sizeof(nghttp2_nv) * (len); \ + const nghttp2_nv *sa = (A), *sb = (B); \ + nghttp2_nv *a = (mem)->malloc(alloclen, NULL); \ + nghttp2_nv *b = (mem)->malloc(alloclen, NULL); \ + size_t i_; \ + memcpy(a, sa, alloclen); \ + memcpy(b, sb, alloclen); \ + nghttp2_nv_array_sort(a, (len)); \ + nghttp2_nv_array_sort(b, (len)); \ + for (i_ = 0; i_ < (size_t)(len); ++i_) { \ + assert_memn_equal(a[i_].name, a[i_].namelen, b[i_].name, b[i_].namelen); \ + assert_memn_equal(a[i_].value, a[i_].valuelen, b[i_].value, \ + b[i_].valuelen); \ + } \ + (mem)->free(b, NULL); \ + (mem)->free(a, NULL); \ + } while (0); + +#endif /* NGHTTP2_ASSERTION_H */ diff --git a/tests/nghttp2_buf_test.c b/tests/nghttp2_buf_test.c index e3e8a14..43d53f6 100644 --- a/tests/nghttp2_buf_test.c +++ b/tests/nghttp2_buf_test.c @@ -26,11 +26,28 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_buf.h" #include "nghttp2_test_helper.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_bufs_add), + munit_void_test(test_nghttp2_bufs_add_stack_buffer_overflow_bug), + munit_void_test(test_nghttp2_bufs_addb), + munit_void_test(test_nghttp2_bufs_orb), + munit_void_test(test_nghttp2_bufs_remove), + munit_void_test(test_nghttp2_bufs_reset), + munit_void_test(test_nghttp2_bufs_advance), + munit_void_test(test_nghttp2_bufs_next_present), + munit_void_test(test_nghttp2_bufs_realloc), + munit_test_end(), +}; + +const MunitSuite buf_suite = { + "/buf", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_bufs_add(void) { int rv; nghttp2_bufs bufs; @@ -40,27 +57,27 @@ void test_nghttp2_bufs_add(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 1000, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(bufs.cur->buf.pos == bufs.cur->buf.last); + assert_ptr_equal(bufs.cur->buf.pos, bufs.cur->buf.last); rv = nghttp2_bufs_add(&bufs, data, 493); - CU_ASSERT(0 == rv); - CU_ASSERT(493 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(493 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(507 == nghttp2_bufs_cur_avail(&bufs)); + assert_int(0, ==, rv); + assert_size(493, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(493, ==, nghttp2_bufs_len(&bufs)); + assert_size(507, ==, nghttp2_bufs_cur_avail(&bufs)); rv = nghttp2_bufs_add(&bufs, data, 507); - CU_ASSERT(0 == rv); - CU_ASSERT(1000 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1000 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(bufs.cur == bufs.head); + assert_int(0, ==, rv); + assert_size(1000, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1000, ==, nghttp2_bufs_len(&bufs)); + assert_ptr_equal(bufs.cur, bufs.head); rv = nghttp2_bufs_add(&bufs, data, 1); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1001 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(bufs.cur == bufs.head->next); + assert_int(0, ==, rv); + assert_size(1, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1001, ==, nghttp2_bufs_len(&bufs)); + assert_ptr_equal(bufs.cur, bufs.head->next); nghttp2_bufs_free(&bufs); } @@ -75,12 +92,12 @@ void test_nghttp2_bufs_add_stack_buffer_overflow_bug(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 100, 200, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_add(&bufs, data, sizeof(data)); - CU_ASSERT(0 == rv); - CU_ASSERT(sizeof(data) == nghttp2_bufs_len(&bufs)); + assert_int(0, ==, rv); + assert_size(sizeof(data), ==, nghttp2_bufs_len(&bufs)); nghttp2_bufs_free(&bufs); } @@ -88,65 +105,65 @@ void test_nghttp2_bufs_add_stack_buffer_overflow_bug(void) { void test_nghttp2_bufs_addb(void) { int rv; nghttp2_bufs bufs; - ssize_t i; + size_t i; nghttp2_mem *mem; mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 1000, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_addb(&bufs, 14); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(14 == *bufs.cur->buf.pos); + assert_int(0, ==, rv); + assert_size(1, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(14, ==, *bufs.cur->buf.pos); for (i = 0; i < 999; ++i) { rv = nghttp2_bufs_addb(&bufs, 254); - CU_ASSERT(0 == rv); - CU_ASSERT((size_t)(i + 2) == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT((size_t)(i + 2) == nghttp2_bufs_len(&bufs)); - CU_ASSERT(254 == *(bufs.cur->buf.last - 1)); - CU_ASSERT(bufs.cur == bufs.head); + assert_int(0, ==, rv); + assert_size(i + 2, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(i + 2, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(254, ==, *(bufs.cur->buf.last - 1)); + assert_ptr_equal(bufs.cur, bufs.head); } rv = nghttp2_bufs_addb(&bufs, 253); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1001 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(253 == *(bufs.cur->buf.last - 1)); - CU_ASSERT(bufs.cur == bufs.head->next); + assert_int(0, ==, rv); + assert_size(1, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1001, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(253, ==, *(bufs.cur->buf.last - 1)); + assert_ptr_equal(bufs.cur, bufs.head->next); rv = nghttp2_bufs_addb_hold(&bufs, 15); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1001 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(15 == *(bufs.cur->buf.last)); + assert_int(0, ==, rv); + assert_size(1, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1001, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(15, ==, *(bufs.cur->buf.last)); /* test fast version */ nghttp2_bufs_fast_addb(&bufs, 240); - CU_ASSERT(2 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1002 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(240 == *(bufs.cur->buf.last - 1)); + assert_size(2, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1002, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(240, ==, *(bufs.cur->buf.last - 1)); nghttp2_bufs_fast_addb_hold(&bufs, 113); - CU_ASSERT(2 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1002 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(113 == *(bufs.cur->buf.last)); + assert_size(2, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1002, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(113, ==, *(bufs.cur->buf.last)); /* addb_hold when last == end */ bufs.cur->buf.last = bufs.cur->buf.end; rv = nghttp2_bufs_addb_hold(&bufs, 19); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(2000 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(19 == *(bufs.cur->buf.last)); + assert_int(0, ==, rv); + assert_size(0, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(2000, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(19, ==, *(bufs.cur->buf.last)); nghttp2_bufs_free(&bufs); } @@ -159,28 +176,28 @@ void test_nghttp2_bufs_orb(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 1000, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); *(bufs.cur->buf.last) = 0; rv = nghttp2_bufs_orb_hold(&bufs, 15); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(0 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(15 == *(bufs.cur->buf.last)); + assert_int(0, ==, rv); + assert_size(0, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(0, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(15, ==, *(bufs.cur->buf.last)); rv = nghttp2_bufs_orb(&bufs, 240); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == nghttp2_buf_len(&bufs.cur->buf)); - CU_ASSERT(1 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(255 == *(bufs.cur->buf.last - 1)); + assert_int(0, ==, rv); + assert_size(1, ==, nghttp2_buf_len(&bufs.cur->buf)); + assert_size(1, ==, nghttp2_bufs_len(&bufs)); + assert_uint8(255, ==, *(bufs.cur->buf.last - 1)); *(bufs.cur->buf.last) = 0; nghttp2_bufs_fast_orb_hold(&bufs, 240); - CU_ASSERT(240 == *(bufs.cur->buf.last)); + assert_uint8(240, ==, *(bufs.cur->buf.last)); nghttp2_bufs_fast_orb(&bufs, 15); - CU_ASSERT(255 == *(bufs.cur->buf.last - 1)); + assert_uint8(255, ==, *(bufs.cur->buf.last - 1)); nghttp2_bufs_free(&bufs); } @@ -191,36 +208,36 @@ void test_nghttp2_bufs_remove(void) { nghttp2_buf_chain *chain; int i; uint8_t *out; - ssize_t outlen; + nghttp2_ssize outlen; nghttp2_mem *mem; mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 1000, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_buf_shift_right(&bufs.cur->buf, 10); rv = nghttp2_bufs_add(&bufs, "hello ", 6); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); for (i = 0; i < 2; ++i) { chain = bufs.cur; rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(chain->next == bufs.cur); + assert_ptr_equal(chain->next, bufs.cur); } rv = nghttp2_bufs_add(&bufs, "world", 5); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); outlen = nghttp2_bufs_remove(&bufs, &out); - CU_ASSERT(11 == outlen); + assert_ptrdiff(11, ==, outlen); - CU_ASSERT(0 == memcmp("hello world", out, (size_t)outlen)); - CU_ASSERT(11 == nghttp2_bufs_len(&bufs)); + assert_memory_equal((size_t)outlen, "hello world", out); + assert_size(11, ==, nghttp2_bufs_len(&bufs)); mem->free(out, NULL); nghttp2_bufs_free(&bufs); @@ -236,30 +253,30 @@ void test_nghttp2_bufs_reset(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init3(&bufs, 250, 3, 1, offset, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_add(&bufs, "foo", 3); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_add(&bufs, "bar", 3); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(6 == nghttp2_bufs_len(&bufs)); + assert_size(6, ==, nghttp2_bufs_len(&bufs)); nghttp2_bufs_reset(&bufs); - CU_ASSERT(0 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(bufs.cur == bufs.head); + assert_size(0, ==, nghttp2_bufs_len(&bufs)); + assert_ptr_equal(bufs.cur, bufs.head); for (ci = bufs.head; ci; ci = ci->next) { - CU_ASSERT((ssize_t)offset == ci->buf.pos - ci->buf.begin); - CU_ASSERT(ci->buf.pos == ci->buf.last); + assert_ptrdiff((ptrdiff_t)offset, ==, ci->buf.pos - ci->buf.begin); + assert_ptr_equal(ci->buf.pos, ci->buf.last); } - CU_ASSERT(bufs.head->next == NULL); + assert_null(bufs.head->next); nghttp2_bufs_free(&bufs); } @@ -273,15 +290,15 @@ void test_nghttp2_bufs_advance(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 250, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); for (i = 0; i < 2; ++i) { rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); } rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(NGHTTP2_ERR_BUFFER_ERROR == rv); + assert_int(NGHTTP2_ERR_BUFFER_ERROR, ==, rv); nghttp2_bufs_free(&bufs); } @@ -294,25 +311,25 @@ void test_nghttp2_bufs_next_present(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init(&bufs, 250, 3, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(0 == nghttp2_bufs_next_present(&bufs)); + assert_false(nghttp2_bufs_next_present(&bufs)); rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_bufs_rewind(&bufs); - CU_ASSERT(0 == nghttp2_bufs_next_present(&bufs)); + assert_false(nghttp2_bufs_next_present(&bufs)); bufs.cur = bufs.head->next; rv = nghttp2_bufs_addb(&bufs, 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_bufs_rewind(&bufs); - CU_ASSERT(0 != nghttp2_bufs_next_present(&bufs)); + assert_true(nghttp2_bufs_next_present(&bufs)); nghttp2_bufs_free(&bufs); } @@ -325,20 +342,20 @@ void test_nghttp2_bufs_realloc(void) { mem = nghttp2_mem_default(); rv = nghttp2_bufs_init3(&bufs, 266, 3, 1, 10, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); /* Create new buffer to see that these buffers are deallocated on realloc */ rv = nghttp2_bufs_advance(&bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_bufs_realloc(&bufs, 522); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(512 == nghttp2_bufs_cur_avail(&bufs)); + assert_size(512, ==, nghttp2_bufs_cur_avail(&bufs)); rv = nghttp2_bufs_realloc(&bufs, 9); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); nghttp2_bufs_free(&bufs); } diff --git a/tests/nghttp2_buf_test.h b/tests/nghttp2_buf_test.h index 714b89f..0bbab89 100644 --- a/tests/nghttp2_buf_test.h +++ b/tests/nghttp2_buf_test.h @@ -29,14 +29,20 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_bufs_add(void); -void test_nghttp2_bufs_add_stack_buffer_overflow_bug(void); -void test_nghttp2_bufs_addb(void); -void test_nghttp2_bufs_orb(void); -void test_nghttp2_bufs_remove(void); -void test_nghttp2_bufs_reset(void); -void test_nghttp2_bufs_advance(void); -void test_nghttp2_bufs_next_present(void); -void test_nghttp2_bufs_realloc(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite buf_suite; + +munit_void_test_decl(test_nghttp2_bufs_add); +munit_void_test_decl(test_nghttp2_bufs_add_stack_buffer_overflow_bug); +munit_void_test_decl(test_nghttp2_bufs_addb); +munit_void_test_decl(test_nghttp2_bufs_orb); +munit_void_test_decl(test_nghttp2_bufs_remove); +munit_void_test_decl(test_nghttp2_bufs_reset); +munit_void_test_decl(test_nghttp2_bufs_advance); +munit_void_test_decl(test_nghttp2_bufs_next_present); +munit_void_test_decl(test_nghttp2_bufs_realloc); #endif /* NGHTTP2_BUF_TEST_H */ diff --git a/tests/nghttp2_extpri_test.c b/tests/nghttp2_extpri_test.c index 0ef59b7..a589b93 100644 --- a/tests/nghttp2_extpri_test.c +++ b/tests/nghttp2_extpri_test.c @@ -27,26 +27,35 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_extpri.h" #include "nghttp2_test_helper.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_extpri_to_uint8), + munit_test_end(), +}; + +const MunitSuite extpri_suite = { + "/extpri", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_extpri_to_uint8(void) { { nghttp2_extpri pri = {1, 0}; - CU_ASSERT(1 == nghttp2_extpri_to_uint8(&pri)); + assert_uint8(1, ==, nghttp2_extpri_to_uint8(&pri)); } { nghttp2_extpri pri = {1, 1}; - CU_ASSERT((0x80 | 1) == nghttp2_extpri_to_uint8(&pri)); + assert_uint8((0x80 | 1), ==, nghttp2_extpri_to_uint8(&pri)); } { nghttp2_extpri pri = {7, 1}; - CU_ASSERT((0x80 | 7) == nghttp2_extpri_to_uint8(&pri)); + assert_uint8((0x80 | 7), ==, nghttp2_extpri_to_uint8(&pri)); } { nghttp2_extpri pri = {7, 0}; - CU_ASSERT(7 == nghttp2_extpri_to_uint8(&pri)); + assert_uint8(7, ==, nghttp2_extpri_to_uint8(&pri)); } } diff --git a/tests/nghttp2_extpri_test.h b/tests/nghttp2_extpri_test.h index a8a93b9..8735882 100644 --- a/tests/nghttp2_extpri_test.h +++ b/tests/nghttp2_extpri_test.h @@ -30,6 +30,12 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_extpri_to_uint8(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite extpri_suite; + +munit_void_test_decl(test_nghttp2_extpri_to_uint8); #endif /* NGHTTP2_EXTPRI_TEST_H */ diff --git a/tests/nghttp2_frame_test.c b/tests/nghttp2_frame_test.c index 7ce98dd..474f154 100644 --- a/tests/nghttp2_frame_test.c +++ b/tests/nghttp2_frame_test.c @@ -27,13 +27,35 @@ #include <assert.h> #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_frame.h" #include "nghttp2_helper.h" #include "nghttp2_test_helper.h" #include "nghttp2_priority_spec.h" +static MunitTest tests[] = { + munit_void_test(test_nghttp2_frame_pack_headers), + munit_void_test(test_nghttp2_frame_pack_headers_frame_too_large), + munit_void_test(test_nghttp2_frame_pack_priority), + munit_void_test(test_nghttp2_frame_pack_rst_stream), + munit_void_test(test_nghttp2_frame_pack_settings), + munit_void_test(test_nghttp2_frame_pack_push_promise), + munit_void_test(test_nghttp2_frame_pack_ping), + munit_void_test(test_nghttp2_frame_pack_goaway), + munit_void_test(test_nghttp2_frame_pack_window_update), + munit_void_test(test_nghttp2_frame_pack_altsvc), + munit_void_test(test_nghttp2_frame_pack_origin), + munit_void_test(test_nghttp2_frame_pack_priority_update), + munit_void_test(test_nghttp2_nv_array_copy), + munit_void_test(test_nghttp2_iv_check), + munit_test_end(), +}; + +const MunitSuite frame_suite = { + "/frame", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + static nghttp2_nv make_nv(const char *name, const char *value) { nghttp2_nv nv; nv.name = (uint8_t *)name; @@ -61,11 +83,11 @@ static nghttp2_nv *headers(nghttp2_mem *mem) { static void check_frame_header(size_t length, uint8_t type, uint8_t flags, int32_t stream_id, nghttp2_frame_hd *hd) { - CU_ASSERT(length == hd->length); - CU_ASSERT(type == hd->type); - CU_ASSERT(flags == hd->flags); - CU_ASSERT(stream_id == hd->stream_id); - CU_ASSERT(0 == hd->reserved); + assert_size(length, ==, hd->length); + assert_uint8(type, ==, hd->type); + assert_uint8(flags, ==, hd->flags); + assert_int32(stream_id, ==, hd->stream_id); + assert_uint8(0, ==, hd->reserved); } void test_nghttp2_frame_pack_headers(void) { @@ -100,24 +122,24 @@ void test_nghttp2_frame_pack_headers(void) { nghttp2_bufs_rewind(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN, NGHTTP2_HEADERS, NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS, 1000000007, &oframe.hd); /* We did not include PRIORITY flag */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == oframe.pri_spec.weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, oframe.pri_spec.weight); hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN; - CU_ASSERT((ssize_t)hdblocklen == - inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem)); + assert_ptrdiff((nghttp2_ssize)hdblocklen, ==, + inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem)); - CU_ASSERT(7 == out.nvlen); - CU_ASSERT(nvnameeq("method", &out.nva[0])); - CU_ASSERT(nvvalueeq("GET", &out.nva[0])); + assert_size(7, ==, out.nvlen); + assert_true(nvnameeq("method", &out.nva[0])); + assert_true(nvvalueeq("GET", &out.nva[0])); nghttp2_frame_headers_free(&oframe, mem); nva_out_reset(&out, mem); @@ -130,9 +152,9 @@ void test_nghttp2_frame_pack_headers(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN, NGHTTP2_HEADERS, @@ -140,20 +162,20 @@ void test_nghttp2_frame_pack_headers(void) { NGHTTP2_FLAG_PRIORITY, 1000000007, &oframe.hd); - CU_ASSERT(1000000009 == oframe.pri_spec.stream_id); - CU_ASSERT(12 == oframe.pri_spec.weight); - CU_ASSERT(1 == oframe.pri_spec.exclusive); + assert_int32(1000000009, ==, oframe.pri_spec.stream_id); + assert_int32(12, ==, oframe.pri_spec.weight); + assert_true(oframe.pri_spec.exclusive); hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN - nghttp2_frame_priority_len(oframe.hd.flags); - CU_ASSERT((ssize_t)hdblocklen == - inflate_hd(&inflater, &out, &bufs, - NGHTTP2_FRAME_HDLEN + - nghttp2_frame_priority_len(oframe.hd.flags), - mem)); + assert_ptrdiff((nghttp2_ssize)hdblocklen, ==, + inflate_hd(&inflater, &out, &bufs, + NGHTTP2_FRAME_HDLEN + + nghttp2_frame_priority_len(oframe.hd.flags), + mem)); nghttp2_nv_array_sort(out.nva, out.nvlen); - CU_ASSERT(nvnameeq("method", &out.nva[0])); + assert_true(nvnameeq("method", &out.nva[0])); nghttp2_frame_headers_free(&oframe, mem); nva_out_reset(&out, mem); @@ -196,7 +218,7 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void) { &frame, NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS, 1000000007, NGHTTP2_HCAT_REQUEST, NULL, nva, big_hdslen); rv = nghttp2_frame_pack_headers(&bufs, &frame, &deflater); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == rv); + assert_int(NGHTTP2_ERR_HEADER_COMP, ==, rv); nghttp2_frame_headers_free(&frame, mem); nghttp2_bufs_free(&bufs); @@ -219,14 +241,14 @@ void test_nghttp2_frame_pack_priority(void) { nghttp2_frame_priority_init(&frame, 1000000007, &pri_spec); nghttp2_frame_pack_priority(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 5 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + 5, ==, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(5, NGHTTP2_PRIORITY, NGHTTP2_FLAG_NONE, 1000000007, &oframe.hd); - CU_ASSERT(1000000009 == oframe.pri_spec.stream_id); - CU_ASSERT(12 == oframe.pri_spec.weight); - CU_ASSERT(1 == oframe.pri_spec.exclusive); + assert_int32(1000000009, ==, oframe.pri_spec.stream_id); + assert_int32(12, ==, oframe.pri_spec.weight); + assert_true(oframe.pri_spec.exclusive); nghttp2_frame_priority_free(&oframe); nghttp2_bufs_reset(&bufs); @@ -244,11 +266,11 @@ void test_nghttp2_frame_pack_rst_stream(void) { nghttp2_frame_rst_stream_init(&frame, 1000000007, NGHTTP2_PROTOCOL_ERROR); nghttp2_frame_pack_rst_stream(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + 4, ==, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE, 1000000007, &oframe.hd); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == oframe.error_code); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, oframe.error_code); nghttp2_frame_rst_stream_free(&oframe); nghttp2_bufs_reset(&bufs); @@ -257,12 +279,12 @@ void test_nghttp2_frame_pack_rst_stream(void) { frame.error_code = 1000000009; nghttp2_frame_pack_rst_stream(&bufs, &frame); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE, 1000000007, &oframe.hd); - CU_ASSERT(1000000009 == oframe.error_code); + assert_uint32(1000000009, ==, oframe.error_code); nghttp2_frame_rst_stream_free(&oframe); @@ -288,17 +310,17 @@ void test_nghttp2_frame_pack_settings(void) { nghttp2_frame_iv_copy(iv, 3, mem), 3); rv = nghttp2_frame_pack_settings(&bufs, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 3 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH == - nghttp2_bufs_len(&bufs)); + assert_int(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN + 3 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH, ==, + nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(3 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH, NGHTTP2_SETTINGS, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(3 == oframe.niv); + assert_size(3, ==, oframe.niv); for (i = 0; i < 3; ++i) { - CU_ASSERT(iv[i].settings_id == oframe.iv[i].settings_id); - CU_ASSERT(iv[i].value == oframe.iv[i].value); + assert_int32(iv[i].settings_id, ==, oframe.iv[i].settings_id); + assert_uint32(iv[i].value, ==, oframe.iv[i].value); } nghttp2_bufs_free(&bufs); @@ -331,22 +353,23 @@ void test_nghttp2_frame_pack_push_promise(void) { (1U << 31) - 1, nva, nvlen); rv = nghttp2_frame_pack_push_promise(&bufs, &frame, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN, NGHTTP2_PUSH_PROMISE, NGHTTP2_FLAG_END_HEADERS, 1000000007, &oframe.hd); - CU_ASSERT((1U << 31) - 1 == oframe.promised_stream_id); + assert_int32((1U << 31) - 1, ==, oframe.promised_stream_id); hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN - 4; - CU_ASSERT((ssize_t)hdblocklen == - inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN + 4, mem)); + assert_ptrdiff( + (nghttp2_ssize)hdblocklen, ==, + inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN + 4, mem)); - CU_ASSERT(7 == out.nvlen); - CU_ASSERT(nvnameeq("method", &out.nva[0])); - CU_ASSERT(nvvalueeq("GET", &out.nva[0])); + assert_size(7, ==, out.nvlen); + assert_true(nvnameeq("method", &out.nva[0])); + assert_true(nvvalueeq("GET", &out.nva[0])); nva_out_reset(&out, mem); nghttp2_bufs_free(&bufs); @@ -366,11 +389,10 @@ void test_nghttp2_frame_pack_ping(void) { nghttp2_frame_ping_init(&frame, NGHTTP2_FLAG_ACK, opaque_data); nghttp2_frame_pack_ping(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 8 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + 8, ==, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(8, NGHTTP2_PING, NGHTTP2_FLAG_ACK, 0, &oframe.hd); - CU_ASSERT(memcmp(opaque_data, oframe.opaque_data, sizeof(opaque_data) - 1) == - 0); + assert_memory_equal(sizeof(opaque_data) - 1, opaque_data, oframe.opaque_data); nghttp2_bufs_free(&bufs); nghttp2_frame_ping_free(&oframe); @@ -394,16 +416,16 @@ void test_nghttp2_frame_pack_goaway(void) { opaque_data, opaque_data_len); rv = nghttp2_frame_pack_goaway(&bufs, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 8 + opaque_data_len == - nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN + 8 + opaque_data_len, ==, + nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(24, NGHTTP2_GOAWAY, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(1000000007 == oframe.last_stream_id); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == oframe.error_code); + assert_int32(1000000007, ==, oframe.last_stream_id); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, oframe.error_code); - CU_ASSERT(opaque_data_len == oframe.opaque_data_len); - CU_ASSERT(memcmp(opaque_data, oframe.opaque_data, opaque_data_len) == 0); + assert_size(opaque_data_len, ==, oframe.opaque_data_len); + assert_memory_equal(opaque_data_len, opaque_data, oframe.opaque_data); nghttp2_frame_goaway_free(&oframe, mem); nghttp2_bufs_reset(&bufs); @@ -413,10 +435,10 @@ void test_nghttp2_frame_pack_goaway(void) { rv = nghttp2_frame_pack_goaway(&bufs, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_int(0, ==, rv); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(24, NGHTTP2_GOAWAY, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(1000000009 == oframe.error_code); + assert_uint32(1000000009, ==, oframe.error_code); nghttp2_frame_goaway_free(&oframe, mem); @@ -434,11 +456,11 @@ void test_nghttp2_frame_pack_window_update(void) { nghttp2_frame_window_update_init(&frame, NGHTTP2_FLAG_NONE, 1000000007, 4096); nghttp2_frame_pack_window_update(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4 == nghttp2_bufs_len(&bufs)); - CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + 4, ==, nghttp2_bufs_len(&bufs)); + assert_int(0, ==, unpack_framebuf((nghttp2_frame *)&oframe, &bufs)); check_frame_header(4, NGHTTP2_WINDOW_UPDATE, NGHTTP2_FLAG_NONE, 1000000007, &oframe.hd); - CU_ASSERT(4096 == oframe.window_size_increment); + assert_int32(4096, ==, oframe.window_size_increment); nghttp2_bufs_free(&bufs); nghttp2_frame_window_update_free(&oframe); @@ -478,20 +500,20 @@ void test_nghttp2_frame_pack_altsvc(void) { nghttp2_frame_pack_altsvc(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + payloadlen == nghttp2_bufs_len(&bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + payloadlen, ==, nghttp2_bufs_len(&bufs)); rv = unpack_framebuf((nghttp2_frame *)&oframe, &bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); check_frame_header(payloadlen, NGHTTP2_ALTSVC, NGHTTP2_FLAG_NONE, 1000000007, &oframe.hd); - CU_ASSERT(sizeof(origin) - 1 == oaltsvc.origin_len); - CU_ASSERT(0 == memcmp(origin, oaltsvc.origin, sizeof(origin) - 1)); - CU_ASSERT(sizeof(field_value) - 1 == oaltsvc.field_value_len); - CU_ASSERT(0 == - memcmp(field_value, oaltsvc.field_value, sizeof(field_value) - 1)); + assert_size(sizeof(origin) - 1, ==, oaltsvc.origin_len); + assert_memory_equal(sizeof(origin) - 1, origin, oaltsvc.origin); + assert_size(sizeof(field_value) - 1, ==, oaltsvc.field_value_len); + assert_memory_equal(sizeof(field_value) - 1, field_value, + oaltsvc.field_value); nghttp2_frame_altsvc_free(&oframe, mem); nghttp2_frame_altsvc_free(&frame, mem); @@ -536,21 +558,21 @@ void test_nghttp2_frame_pack_origin(void) { rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + payloadlen == nghttp2_bufs_len(&bufs)); + assert_int(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN + payloadlen, ==, nghttp2_bufs_len(&bufs)); rv = unpack_framebuf((nghttp2_frame *)&oframe, &bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); check_frame_header(payloadlen, NGHTTP2_ORIGIN, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(2 == oorigin.nov); - CU_ASSERT(sizeof(example) - 1 == oorigin.ov[0].origin_len); - CU_ASSERT(0 == memcmp(example, oorigin.ov[0].origin, sizeof(example) - 1)); - CU_ASSERT(sizeof(nghttp2) - 1 == oorigin.ov[1].origin_len); - CU_ASSERT(0 == memcmp(nghttp2, oorigin.ov[1].origin, sizeof(nghttp2) - 1)); + assert_size(2, ==, oorigin.nov); + assert_size(sizeof(example) - 1, ==, oorigin.ov[0].origin_len); + assert_memory_equal(sizeof(example) - 1, example, oorigin.ov[0].origin); + assert_size(sizeof(nghttp2) - 1, ==, oorigin.ov[1].origin_len); + assert_memory_equal(sizeof(nghttp2) - 1, nghttp2, oorigin.ov[1].origin); nghttp2_frame_origin_free(&oframe, mem); @@ -561,7 +583,7 @@ void test_nghttp2_frame_pack_origin(void) { rv = unpack_framebuf((nghttp2_frame *)&oframe, &bufs); - CU_ASSERT(NGHTTP2_ERR_FRAME_SIZE_ERROR == rv); + assert_int(NGHTTP2_ERR_FRAME_SIZE_ERROR, ==, rv); nghttp2_bufs_reset(&bufs); memset(&oframe, 0, sizeof(oframe)); @@ -573,17 +595,17 @@ void test_nghttp2_frame_pack_origin(void) { rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_FRAME_HDLEN == nghttp2_bufs_len(&bufs)); + assert_int(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN, ==, nghttp2_bufs_len(&bufs)); rv = unpack_framebuf((nghttp2_frame *)&oframe, &bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); check_frame_header(0, NGHTTP2_ORIGIN, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(0 == oorigin.nov); - CU_ASSERT(NULL == oorigin.ov); + assert_size(0, ==, oorigin.nov); + assert_null(oorigin.ov); nghttp2_frame_origin_free(&oframe, mem); @@ -610,25 +632,25 @@ void test_nghttp2_frame_pack_priority_update(void) { nghttp2_frame_pack_priority_update(&bufs, &frame); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + payloadlen == nghttp2_bufs_len(&bufs)); + assert_size(NGHTTP2_FRAME_HDLEN + payloadlen, ==, nghttp2_bufs_len(&bufs)); rv = unpack_framebuf((nghttp2_frame *)&oframe, &bufs); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); check_frame_header(payloadlen, NGHTTP2_PRIORITY_UPDATE, NGHTTP2_FLAG_NONE, 0, &oframe.hd); - CU_ASSERT(sizeof(field_value) - 1 == opriority_update.field_value_len); - CU_ASSERT(0 == memcmp(field_value, opriority_update.field_value, - sizeof(field_value) - 1)); + assert_size(sizeof(field_value) - 1, ==, opriority_update.field_value_len); + assert_memory_equal(sizeof(field_value) - 1, field_value, + opriority_update.field_value); nghttp2_bufs_free(&bufs); } void test_nghttp2_nv_array_copy(void) { nghttp2_nv *nva; - ssize_t rv; + int rv; nghttp2_nv emptynv[] = {MAKE_NV("", ""), MAKE_NV("", "")}; nghttp2_nv nv[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")}; nghttp2_nv bignv; @@ -644,34 +666,34 @@ void test_nghttp2_nv_array_copy(void) { memset(bignv.value, '0', bignv.valuelen); rv = nghttp2_nv_array_copy(&nva, NULL, 0, mem); - CU_ASSERT(0 == rv); - CU_ASSERT(NULL == nva); + assert_int(0, ==, rv); + assert_null(nva); rv = nghttp2_nv_array_copy(&nva, emptynv, ARRLEN(emptynv), mem); - CU_ASSERT(0 == rv); - CU_ASSERT(nva[0].namelen == 0); - CU_ASSERT(nva[0].valuelen == 0); - CU_ASSERT(nva[1].namelen == 0); - CU_ASSERT(nva[1].valuelen == 0); + assert_int(0, ==, rv); + assert_size(0, ==, nva[0].namelen); + assert_size(0, ==, nva[0].valuelen); + assert_size(0, ==, nva[1].namelen); + assert_size(0, ==, nva[1].valuelen); nghttp2_nv_array_del(nva, mem); rv = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv), mem); - CU_ASSERT(0 == rv); - CU_ASSERT(nva[0].namelen == 5); - CU_ASSERT(0 == memcmp("alpha", nva[0].name, 5)); - CU_ASSERT(nva[0].valuelen == 5); - CU_ASSERT(0 == memcmp("bravo", nva[0].value, 5)); - CU_ASSERT(nva[1].namelen == 7); - CU_ASSERT(0 == memcmp("charlie", nva[1].name, 7)); - CU_ASSERT(nva[1].valuelen == 5); - CU_ASSERT(0 == memcmp("delta", nva[1].value, 5)); + assert_int(0, ==, rv); + assert_size(5, ==, nva[0].namelen); + assert_memory_equal(5, "alpha", nva[0].name); + assert_size(5, ==, nva[0].valuelen); + assert_memory_equal(5, "bravo", nva[0].value); + assert_size(7, ==, nva[1].namelen); + assert_memory_equal(7, "charlie", nva[1].name); + assert_size(5, ==, nva[1].valuelen); + assert_memory_equal(5, "delta", nva[1].value); nghttp2_nv_array_del(nva, mem); /* Large header field is acceptable */ rv = nghttp2_nv_array_copy(&nva, &bignv, 1, mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_nv_array_del(nva, mem); @@ -686,50 +708,50 @@ void test_nghttp2_iv_check(void) { iv[1].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[1].value = 1024; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; iv[1].value = NGHTTP2_MAX_WINDOW_SIZE; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); /* Too large window size */ iv[1].value = (uint32_t)NGHTTP2_MAX_WINDOW_SIZE + 1; - CU_ASSERT(0 == nghttp2_iv_check(iv, 2)); + assert_false(nghttp2_iv_check(iv, 2)); /* ENABLE_PUSH only allows 0 or 1 */ iv[1].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; iv[1].value = 0; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); iv[1].value = 1; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); iv[1].value = 3; - CU_ASSERT(!nghttp2_iv_check(iv, 2)); + assert_false(nghttp2_iv_check(iv, 2)); /* Undefined SETTINGS ID is allowed */ iv[1].settings_id = 1000000009; iv[1].value = 0; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); /* Full size SETTINGS_HEADER_TABLE_SIZE (UINT32_MAX) must be accepted */ iv[1].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[1].value = UINT32_MAX; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); /* Too small SETTINGS_MAX_FRAME_SIZE */ iv[0].settings_id = NGHTTP2_SETTINGS_MAX_FRAME_SIZE; iv[0].value = NGHTTP2_MAX_FRAME_SIZE_MIN - 1; - CU_ASSERT(!nghttp2_iv_check(iv, 1)); + assert_false(nghttp2_iv_check(iv, 1)); /* Too large SETTINGS_MAX_FRAME_SIZE */ iv[0].settings_id = NGHTTP2_SETTINGS_MAX_FRAME_SIZE; iv[0].value = NGHTTP2_MAX_FRAME_SIZE_MAX + 1; - CU_ASSERT(!nghttp2_iv_check(iv, 1)); + assert_false(nghttp2_iv_check(iv, 1)); /* Max and min SETTINGS_MAX_FRAME_SIZE */ iv[0].settings_id = NGHTTP2_SETTINGS_MAX_FRAME_SIZE; iv[0].value = NGHTTP2_MAX_FRAME_SIZE_MIN; iv[1].settings_id = NGHTTP2_SETTINGS_MAX_FRAME_SIZE; iv[1].value = NGHTTP2_MAX_FRAME_SIZE_MAX; - CU_ASSERT(nghttp2_iv_check(iv, 2)); + assert_true(nghttp2_iv_check(iv, 2)); } diff --git a/tests/nghttp2_frame_test.h b/tests/nghttp2_frame_test.h index dc07625..ae7842c 100644 --- a/tests/nghttp2_frame_test.h +++ b/tests/nghttp2_frame_test.h @@ -29,19 +29,25 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_frame_pack_headers(void); -void test_nghttp2_frame_pack_headers_frame_too_large(void); -void test_nghttp2_frame_pack_priority(void); -void test_nghttp2_frame_pack_rst_stream(void); -void test_nghttp2_frame_pack_settings(void); -void test_nghttp2_frame_pack_push_promise(void); -void test_nghttp2_frame_pack_ping(void); -void test_nghttp2_frame_pack_goaway(void); -void test_nghttp2_frame_pack_window_update(void); -void test_nghttp2_frame_pack_altsvc(void); -void test_nghttp2_frame_pack_origin(void); -void test_nghttp2_frame_pack_priority_update(void); -void test_nghttp2_nv_array_copy(void); -void test_nghttp2_iv_check(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite frame_suite; + +munit_void_test_decl(test_nghttp2_frame_pack_headers); +munit_void_test_decl(test_nghttp2_frame_pack_headers_frame_too_large); +munit_void_test_decl(test_nghttp2_frame_pack_priority); +munit_void_test_decl(test_nghttp2_frame_pack_rst_stream); +munit_void_test_decl(test_nghttp2_frame_pack_settings); +munit_void_test_decl(test_nghttp2_frame_pack_push_promise); +munit_void_test_decl(test_nghttp2_frame_pack_ping); +munit_void_test_decl(test_nghttp2_frame_pack_goaway); +munit_void_test_decl(test_nghttp2_frame_pack_window_update); +munit_void_test_decl(test_nghttp2_frame_pack_altsvc); +munit_void_test_decl(test_nghttp2_frame_pack_origin); +munit_void_test_decl(test_nghttp2_frame_pack_priority_update); +munit_void_test_decl(test_nghttp2_nv_array_copy); +munit_void_test_decl(test_nghttp2_iv_check); #endif /* NGHTTP2_FRAME_TEST_H */ diff --git a/tests/nghttp2_hd_test.c b/tests/nghttp2_hd_test.c index 657d895..d57127f 100644 --- a/tests/nghttp2_hd_test.c +++ b/tests/nghttp2_hd_test.c @@ -27,11 +27,42 @@ #include <stdio.h> #include <assert.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_hd.h" #include "nghttp2_frame.h" #include "nghttp2_test_helper.h" +#include "nghttp2_assertion.h" + +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_hd_deflate), + munit_void_test(test_nghttp2_hd_deflate_same_indexed_repr), + munit_void_test(test_nghttp2_hd_inflate_indexed), + munit_void_test(test_nghttp2_hd_inflate_indname_noinc), + munit_void_test(test_nghttp2_hd_inflate_indname_inc), + munit_void_test(test_nghttp2_hd_inflate_indname_inc_eviction), + munit_void_test(test_nghttp2_hd_inflate_newname_noinc), + munit_void_test(test_nghttp2_hd_inflate_newname_inc), + munit_void_test(test_nghttp2_hd_inflate_clearall_inc), + munit_void_test(test_nghttp2_hd_inflate_zero_length_huffman), + munit_void_test(test_nghttp2_hd_inflate_expect_table_size_update), + munit_void_test(test_nghttp2_hd_inflate_unexpected_table_size_update), + munit_void_test(test_nghttp2_hd_ringbuf_reserve), + munit_void_test(test_nghttp2_hd_change_table_size), + munit_void_test(test_nghttp2_hd_deflate_inflate), + munit_void_test(test_nghttp2_hd_no_index), + munit_void_test(test_nghttp2_hd_deflate_bound), + munit_void_test(test_nghttp2_hd_public_api), + munit_void_test(test_nghttp2_hd_deflate_hd_vec), + munit_void_test(test_nghttp2_hd_decode_length), + munit_void_test(test_nghttp2_hd_huff_encode), + munit_void_test(test_nghttp2_hd_huff_decode), + munit_test_end(), +}; + +const MunitSuite hd_suite = { + "/hd", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; void test_nghttp2_hd_deflate(void) { nghttp2_hd_deflater deflater; @@ -47,7 +78,7 @@ void test_nghttp2_hd_deflate(void) { nghttp2_nv nva5[] = {MAKE_NV(":path", "/style.css"), MAKE_NV("x-nghttp2", "")}; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nva_out out; int rv; nghttp2_mem *mem; @@ -56,17 +87,17 @@ void test_nghttp2_hd_deflate(void) { frame_pack_bufs_init(&bufs); nva_out_init(&out); - CU_ASSERT(0 == nghttp2_hd_deflate_init(&deflater, mem)); - CU_ASSERT(0 == nghttp2_hd_inflate_init(&inflater, mem)); + assert_int(0, ==, nghttp2_hd_deflate_init(&deflater, mem)); + assert_int(0, ==, nghttp2_hd_inflate_init(&inflater, mem)); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(3 == out.nvlen); + assert_size(3, ==, out.nvlen); assert_nv_equal(nva1, out.nva, 3, mem); nva_out_reset(&out, mem); @@ -74,13 +105,13 @@ void test_nghttp2_hd_deflate(void) { /* Second headers */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(2 == out.nvlen); + assert_size(2, ==, out.nvlen); assert_nv_equal(nva2, out.nva, 2, mem); nva_out_reset(&out, mem); @@ -89,13 +120,13 @@ void test_nghttp2_hd_deflate(void) { /* Third headers, including same header field name, but value is not the same. */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva3, ARRLEN(nva3)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(3 == out.nvlen); + assert_size(3, ==, out.nvlen); assert_nv_equal(nva3, out.nva, 3, mem); nva_out_reset(&out, mem); @@ -103,13 +134,13 @@ void test_nghttp2_hd_deflate(void) { /* Fourth headers, including duplicate header fields. */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva4, ARRLEN(nva4)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(3 == out.nvlen); + assert_size(3, ==, out.nvlen); assert_nv_equal(nva4, out.nva, 3, mem); nva_out_reset(&out, mem); @@ -117,13 +148,13 @@ void test_nghttp2_hd_deflate(void) { /* Fifth headers includes empty value */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva5, ARRLEN(nva5)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(2 == out.nvlen); + assert_size(2, ==, out.nvlen); assert_nv_equal(nva5, out.nva, 2, mem); nva_out_reset(&out, mem); @@ -142,7 +173,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) { nghttp2_nv nva2[] = {MAKE_NV("host", "alpha"), MAKE_NV("host", "alpha"), MAKE_NV("host", "alpha")}; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nva_out out; int rv; nghttp2_mem *mem; @@ -151,18 +182,18 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) { frame_pack_bufs_init(&bufs); nva_out_init(&out); - CU_ASSERT(0 == nghttp2_hd_deflate_init(&deflater, mem)); - CU_ASSERT(0 == nghttp2_hd_inflate_init(&inflater, mem)); + assert_int(0, ==, nghttp2_hd_deflate_init(&deflater, mem)); + assert_int(0, ==, nghttp2_hd_inflate_init(&inflater, mem)); /* Encode 2 same headers. Emit 1 literal reprs and 1 index repr. */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(2 == out.nvlen); + assert_size(2, ==, out.nvlen); assert_nv_equal(nva1, out.nva, 2, mem); nva_out_reset(&out, mem); @@ -170,13 +201,13 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) { /* Encode 3 same headers. This time, emits 3 index reprs. */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen == 3); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(3, ==, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(3 == out.nvlen); + assert_size(3, ==, out.nvlen); assert_nv_equal(nva2, out.nva, 3, mem); nva_out_reset(&out, mem); @@ -191,7 +222,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) { void test_nghttp2_hd_inflate_indexed(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv = MAKE_NV(":path", "/"); nva_out out; nghttp2_mem *mem; @@ -204,12 +235,12 @@ void test_nghttp2_hd_inflate_indexed(void) { nghttp2_bufs_addb(&bufs, (1 << 7) | 4); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(1 == blocklen); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(1, ==, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); @@ -219,11 +250,11 @@ void test_nghttp2_hd_inflate_indexed(void) { /* index = 0 is error */ nghttp2_bufs_addb(&bufs, 1 << 7); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(1 == blocklen); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(1, ==, blocklen); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nghttp2_bufs_free(&bufs); nghttp2_hd_inflate_free(&inflater); @@ -232,7 +263,7 @@ void test_nghttp2_hd_inflate_indexed(void) { void test_nghttp2_hd_inflate_indname_noinc(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv[] = {/* Huffman */ MAKE_NV("user-agent", "nghttp2"), /* Expecting no huffman */ @@ -248,18 +279,19 @@ void test_nghttp2_hd_inflate_indname_noinc(void) { nghttp2_hd_inflate_init(&inflater, mem); for (i = 0; i < ARRLEN(nv); ++i) { - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv[i], - NGHTTP2_HD_WITHOUT_INDEXING)); + assert_int(0, ==, + nghttp2_hd_emit_indname_block(&bufs, 57, &nv[i], + NGHTTP2_HD_WITHOUT_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv[i], out.nva, 1, mem); - CU_ASSERT(0 == inflater.ctx.hd_table.len); - CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(0, ==, inflater.ctx.hd_table.len); + assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -272,7 +304,7 @@ void test_nghttp2_hd_inflate_indname_noinc(void) { void test_nghttp2_hd_inflate_indname_inc(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv = MAKE_NV("user-agent", "nghttp2"); nva_out out; nghttp2_mem *mem; @@ -283,18 +315,19 @@ void test_nghttp2_hd_inflate_indname_inc(void) { nva_out_init(&out); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv, - NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_indname_block(&bufs, 57, &nv, NGHTTP2_HD_WITH_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); - CU_ASSERT(1 == inflater.ctx.hd_table.len); - CU_ASSERT(62 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(1, ==, inflater.ctx.hd_table.len); + assert_size(62, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); assert_nv_equal( &nv, nghttp2_hd_inflate_get_table_entry( @@ -309,7 +342,7 @@ void test_nghttp2_hd_inflate_indname_inc(void) { void test_nghttp2_hd_inflate_indname_inc_eviction(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; uint8_t value[1025]; nva_out out; nghttp2_nv nv; @@ -328,31 +361,35 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) { nv.flags = NGHTTP2_NV_FLAG_NONE; - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 14, &nv, - NGHTTP2_HD_WITH_INDEXING)); - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 15, &nv, - NGHTTP2_HD_WITH_INDEXING)); - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 16, &nv, - NGHTTP2_HD_WITH_INDEXING)); - CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 17, &nv, - NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_indname_block(&bufs, 14, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_indname_block(&bufs, 15, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_indname_block(&bufs, 16, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_indname_block(&bufs, 17, &nv, NGHTTP2_HD_WITH_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, <, blocklen); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(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) - 1 == out.nva[0].valuelen); + assert_size(4, ==, out.nvlen); + assert_size(14, ==, out.nva[0].namelen); + assert_memory_equal(out.nva[0].namelen, "accept-charset", out.nva[0].name); + assert_size(sizeof(value) - 1, ==, out.nva[0].valuelen); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); - CU_ASSERT(3 == inflater.ctx.hd_table.len); - CU_ASSERT(64 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(3, ==, inflater.ctx.hd_table.len); + assert_size(64, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); nghttp2_bufs_free(&bufs); nghttp2_hd_inflate_free(&inflater); @@ -361,7 +398,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) { void test_nghttp2_hd_inflate_newname_noinc(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv[] = {/* Expecting huffman for both */ MAKE_NV("my-long-content-length", "nghttp2"), /* Expecting no huffman for both */ @@ -380,17 +417,18 @@ void test_nghttp2_hd_inflate_newname_noinc(void) { nva_out_init(&out); nghttp2_hd_inflate_init(&inflater, mem); for (i = 0; i < ARRLEN(nv); ++i) { - CU_ASSERT(0 == nghttp2_hd_emit_newname_block(&bufs, &nv[i], - NGHTTP2_HD_WITHOUT_INDEXING)); + assert_int(0, ==, + nghttp2_hd_emit_newname_block(&bufs, &nv[i], + NGHTTP2_HD_WITHOUT_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv[i], out.nva, 1, mem); - CU_ASSERT(0 == inflater.ctx.hd_table.len); + assert_size(0, ==, inflater.ctx.hd_table.len); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -403,7 +441,7 @@ void test_nghttp2_hd_inflate_newname_noinc(void) { void test_nghttp2_hd_inflate_newname_inc(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv = MAKE_NV("x-rel", "nghttp2"); nva_out out; nghttp2_mem *mem; @@ -414,17 +452,18 @@ void test_nghttp2_hd_inflate_newname_inc(void) { nva_out_init(&out); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT( - 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); - CU_ASSERT(1 == inflater.ctx.hd_table.len); + assert_size(1, ==, inflater.ctx.hd_table.len); assert_nv_equal( &nv, nghttp2_hd_inflate_get_table_entry( @@ -439,7 +478,7 @@ void test_nghttp2_hd_inflate_newname_inc(void) { void test_nghttp2_hd_inflate_clearall_inc(void) { nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nv; uint8_t value[4061]; nva_out out; @@ -461,26 +500,27 @@ void test_nghttp2_hd_inflate_clearall_inc(void) { nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT( - 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); - CU_ASSERT(0 == inflater.ctx.hd_table.len); + assert_size(0, ==, inflater.ctx.hd_table.len); nva_out_reset(&out, mem); /* Do it again */ - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); - CU_ASSERT(0 == inflater.ctx.hd_table.len); + assert_size(0, ==, inflater.ctx.hd_table.len); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -489,17 +529,18 @@ void test_nghttp2_hd_inflate_clearall_inc(void) { header table */ nv.valuelen = sizeof(value) - 2; - CU_ASSERT( - 0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); + assert_int( + 0, ==, + nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); - CU_ASSERT(1 == inflater.ctx.hd_table.len); + assert_size(1, ==, inflater.ctx.hd_table.len); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -530,13 +571,13 @@ 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, mem)); + assert_ptrdiff(4, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); - CU_ASSERT(1 == out.nva[0].namelen); - CU_ASSERT('x' == out.nva[0].name[0]); - CU_ASSERT(NULL == out.nva[0].value); - CU_ASSERT(0 == out.nva[0].valuelen); + assert_size(1, ==, out.nvlen); + assert_size(1, ==, out.nva[0].namelen); + assert_uint8('x', ==, out.nva[0].name[0]); + assert_null(out.nva[0].value); + assert_size(0, ==, out.nva[0].valuelen); nva_out_reset(&out, mem); nghttp2_bufs_free(&bufs); @@ -561,8 +602,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { inflation. */ nghttp2_hd_inflate_change_table_size(&inflater, 4095); nghttp2_hd_inflate_change_table_size(&inflater, 4096); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -571,8 +612,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { * size is not changed. */ nghttp2_hd_inflate_init(&inflater, mem); nghttp2_hd_inflate_change_table_size(&inflater, 4096); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -581,8 +622,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { new size is larger than current size. */ nghttp2_hd_inflate_init(&inflater, mem); nghttp2_hd_inflate_change_table_size(&inflater, 4097); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -595,8 +636,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { nghttp2_bufs_reset(&bufs); nghttp2_hd_emit_table_size(&bufs, 112); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -610,8 +651,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { nghttp2_hd_emit_table_size(&bufs, 111); nghttp2_hd_emit_table_size(&bufs, 4096); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -625,8 +666,8 @@ void test_nghttp2_hd_inflate_expect_table_size_update(void) { nghttp2_hd_emit_table_size(&bufs, 111); nghttp2_hd_emit_table_size(&bufs, 4096); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_hd_inflate_free(&inflater); @@ -649,8 +690,8 @@ void test_nghttp2_hd_inflate_unexpected_table_size_update(void) { nghttp2_bufs_add(&bufs, data, sizeof(data)); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == - inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_bufs_free(&bufs); @@ -664,8 +705,8 @@ void test_nghttp2_hd_ringbuf_reserve(void) { nghttp2_bufs bufs; nva_out out; int i; - ssize_t rv; - ssize_t blocklen; + nghttp2_ssize rv; + nghttp2_ssize blocklen; nghttp2_mem *mem; mem = nghttp2_mem_default(); @@ -688,14 +729,14 @@ void test_nghttp2_hd_ringbuf_reserve(void) { for (i = 0; i < 150; ++i) { memcpy(nv.value, &i, sizeof(i)); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, &nv, 1); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, ==, rv); + assert_ptrdiff(0, <, blocklen); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(1 == out.nvlen); + assert_size(1, ==, out.nvlen); assert_nv_equal(&nv, out.nva, 1, mem); nva_out_reset(&out, mem); @@ -715,9 +756,9 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_nv nva[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")}; nghttp2_nv nva2[] = {MAKE_NV(":path", "/")}; nghttp2_bufs bufs; - ssize_t rv; + int rv; nva_out out; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_mem *mem; mem = nghttp2_mem_default(); @@ -729,87 +770,87 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_hd_inflate_init(&inflater, mem); /* inflater changes notifies 8000 max header table size */ - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 8000)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 8000)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 8000)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 8000)); - CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max); + assert_size(4096, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max); + assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(8000, ==, inflater.settings_hd_table_bufsize_max); /* This will emit encoding context update with header table size 4096 */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(2 == deflater.ctx.hd_table.len); - CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater)); - CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(2, ==, deflater.ctx.hd_table.len); + assert_size(63, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater)); + assert_size(4096, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(2 == inflater.ctx.hd_table.len); - CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); - CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(2, ==, inflater.ctx.hd_table.len); + assert_size(63, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(8000, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); /* inflater changes header table size to 1024 */ - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 1024)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 1024)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 1024)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 1024)); - CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max); + assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max); + assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(1024, ==, inflater.settings_hd_table_bufsize_max); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(2 == deflater.ctx.hd_table.len); - CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater)); - CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(2, ==, deflater.ctx.hd_table.len); + assert_size(63, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater)); + assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(2 == inflater.ctx.hd_table.len); - CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); - CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(2, ==, inflater.ctx.hd_table.len); + assert_size(63, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(1024, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); /* inflater changes header table size to 0 */ - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 0)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 0)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 0)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 0)); - CU_ASSERT(0 == deflater.ctx.hd_table.len); - CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater)); - CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max); + assert_size(0, ==, deflater.ctx.hd_table.len); + assert_size(61, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater)); + assert_size(0, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(0 == inflater.ctx.hd_table.len); - CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); - CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max); + assert_size(0, ==, inflater.ctx.hd_table.len); + assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(0, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(0, ==, inflater.settings_hd_table_bufsize_max); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(0 == deflater.ctx.hd_table.len); - CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater)); - CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(0, ==, deflater.ctx.hd_table.len); + assert_size(61, ==, nghttp2_hd_deflate_get_num_table_entries(&deflater)); + assert_size(0, ==, deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(0 == inflater.ctx.hd_table.len); - CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater)); - CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(0, ==, inflater.ctx.hd_table.len); + assert_size(61, ==, nghttp2_hd_inflate_get_num_table_entries(&inflater)); + assert_size(0, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(0, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -825,53 +866,57 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_hd_inflate_init(&inflater, mem); /* First inflater changes header table size to 8000 */ - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 8000)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 8000)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 8000)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 8000)); - CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(8000 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater)); - CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(4096 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater)); - CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max); + assert_size(8000, ==, deflater.ctx.hd_table_bufsize_max); + assert_size(8000, ==, + nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater)); + assert_size(4096, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(4096, ==, + nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater)); + assert_size(8000, ==, inflater.settings_hd_table_bufsize_max); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(2 == deflater.ctx.hd_table.len); - CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(2, ==, deflater.ctx.hd_table.len); + assert_size(8000, ==, deflater.ctx.hd_table_bufsize_max); - 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); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(2, ==, inflater.ctx.hd_table.len); + assert_size(8000, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(8000, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 16383)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 16383)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 16383)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 16383)); - CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(8192 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater)); + assert_size(8192, ==, deflater.ctx.hd_table_bufsize_max); + assert_size(8192, ==, + nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater)); - CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(8000 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater)); - CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max); + assert_size(8000, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(8000, ==, + nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater)); + assert_size(16383, ==, inflater.settings_hd_table_bufsize_max); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(2 == deflater.ctx.hd_table.len); - CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(2, ==, deflater.ctx.hd_table.len); + assert_size(8192, ==, deflater.ctx.hd_table_bufsize_max); - 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); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(2, ==, inflater.ctx.hd_table.len); + assert_size(8192, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(16383, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -879,9 +924,9 @@ void test_nghttp2_hd_change_table_size(void) { /* 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, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, + inflate_hd(&inflater, &out, &bufs, 0, mem)); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -894,21 +939,21 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_hd_deflate_init2(&deflater, 1024, mem); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max); + assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max); /* This emits context update with buffer size 1024 */ rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(2 == deflater.ctx.hd_table.len); - CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_size(2, ==, deflater.ctx.hd_table.len); + assert_size(1024, ==, deflater.ctx.hd_table_bufsize_max); - 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); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(2, ==, inflater.ctx.hd_table.len); + assert_size(1024, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(4096, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -920,18 +965,20 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_hd_deflate_init2(&deflater, UINT32_MAX, mem); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, UINT32_MAX)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, UINT32_MAX)); + assert_int(0, ==, + nghttp2_hd_inflate_change_table_size(&inflater, UINT32_MAX)); + assert_int(0, ==, + nghttp2_hd_deflate_change_table_size(&deflater, UINT32_MAX)); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(UINT32_MAX == deflater.ctx.hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_size(UINT32_MAX, ==, deflater.ctx.hd_table_bufsize_max); - 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); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(UINT32_MAX, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(UINT32_MAX, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -943,25 +990,25 @@ void test_nghttp2_hd_change_table_size(void) { nghttp2_hd_deflate_init2(&deflater, 4096, mem); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 0)); - CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 3000)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 0)); - CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 3000)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 0)); + assert_int(0, ==, nghttp2_hd_inflate_change_table_size(&inflater, 3000)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 0)); + assert_int(0, ==, nghttp2_hd_deflate_change_table_size(&deflater, 3000)); - CU_ASSERT(0 == deflater.min_hd_table_bufsize_max); - CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max); + assert_size(0, ==, deflater.min_hd_table_bufsize_max); + assert_size(3000, ==, deflater.ctx.hd_table_bufsize_max); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, 1); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(3 < blocklen); - CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(UINT32_MAX == deflater.min_hd_table_bufsize_max); + assert_int(0, ==, rv); + assert_ptrdiff(3, <, blocklen); + assert_size(3000, ==, deflater.ctx.hd_table_bufsize_max); + assert_size(UINT32_MAX, ==, deflater.min_hd_table_bufsize_max); - 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); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_size(3000, ==, inflater.ctx.hd_table_bufsize_max); + assert_size(3000, ==, inflater.settings_hd_table_bufsize_max); nva_out_reset(&out, mem); nghttp2_bufs_reset(&bufs); @@ -977,7 +1024,7 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater, nghttp2_nv *nva, size_t nvlen, nghttp2_mem *mem) { nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nva_out out; int rv; @@ -985,14 +1032,14 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater, nva_out_init(&out); rv = nghttp2_hd_deflate_hd_bufs(deflater, &bufs, nva, nvlen); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen >= 0); + assert_int(0, ==, rv); + assert_ptrdiff(0, <=, blocklen); - CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem)); - CU_ASSERT(nvlen == out.nvlen); + assert_size(nvlen, ==, out.nvlen); assert_nv_equal(nva, out.nva, nvlen, mem); nva_out_reset(&out, mem); @@ -1161,7 +1208,7 @@ void test_nghttp2_hd_no_index(void) { nghttp2_hd_deflater deflater; nghttp2_hd_inflater inflater; nghttp2_bufs bufs; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_nv nva[] = { MAKE_NV(":method", "GET"), MAKE_NV(":method", "POST"), MAKE_NV(":path", "/foo"), MAKE_NV("version", "HTTP/1.1"), @@ -1187,18 +1234,18 @@ void test_nghttp2_hd_no_index(void) { nghttp2_hd_inflate_init(&inflater, mem); rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, ARRLEN(nva)); - blocklen = (ssize_t)nghttp2_bufs_len(&bufs); + blocklen = (nghttp2_ssize)nghttp2_bufs_len(&bufs); - CU_ASSERT(0 == rv); - CU_ASSERT(blocklen > 0); - CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem)); + assert_int(0, ==, rv); + assert_ptrdiff(0, <, blocklen); + assert_ptrdiff(blocklen, ==, inflate_hd(&inflater, &out, &bufs, 0, mem)); - CU_ASSERT(ARRLEN(nva) == out.nvlen); + assert_size(ARRLEN(nva), ==, out.nvlen); assert_nv_equal(nva, out.nva, ARRLEN(nva), mem); - CU_ASSERT(out.nva[0].flags == NGHTTP2_NV_FLAG_NONE); + assert_uint8(NGHTTP2_NV_FLAG_NONE, ==, out.nva[0].flags); for (i = 1; i < ARRLEN(nva); ++i) { - CU_ASSERT(out.nva[i].flags == NGHTTP2_NV_FLAG_NO_INDEX); + assert_uint8(NGHTTP2_NV_FLAG_NO_INDEX, ==, out.nva[i].flags); } nva_out_reset(&out, mem); @@ -1222,17 +1269,17 @@ void test_nghttp2_hd_deflate_bound(void) { bound = nghttp2_hd_deflate_bound(&deflater, nva, ARRLEN(nva)); - CU_ASSERT(12 + 6 * 2 * 2 + nva[0].namelen + nva[0].valuelen + nva[1].namelen + - nva[1].valuelen == - bound); + assert_size(12 + 6 * 2 * 2 + nva[0].namelen + nva[0].valuelen + + nva[1].namelen + nva[1].valuelen, + ==, bound); nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, ARRLEN(nva)); - CU_ASSERT(bound > (size_t)nghttp2_bufs_len(&bufs)); + assert_size((size_t)nghttp2_bufs_len(&bufs), <, bound); bound2 = nghttp2_hd_deflate_bound(&deflater, nva, ARRLEN(nva)); - CU_ASSERT(bound == bound2); + assert_size(bound, ==, bound2); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -1244,25 +1291,25 @@ void test_nghttp2_hd_public_api(void) { nghttp2_nv nva[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")}; uint8_t buf[4096]; size_t buflen; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_bufs bufs; nghttp2_mem *mem; mem = nghttp2_mem_default(); - CU_ASSERT(0 == nghttp2_hd_deflate_new(&deflater, 4096)); - CU_ASSERT(0 == nghttp2_hd_inflate_new(&inflater)); + assert_int(0, ==, nghttp2_hd_deflate_new(&deflater, 4096)); + assert_int(0, ==, nghttp2_hd_inflate_new(&inflater)); buflen = nghttp2_hd_deflate_bound(deflater, nva, ARRLEN(nva)); - blocklen = nghttp2_hd_deflate_hd(deflater, buf, buflen, nva, ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd2(deflater, buf, buflen, nva, ARRLEN(nva)); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, <, blocklen); nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem); bufs.head->buf.last += blocklen; - CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0, mem)); + assert_ptrdiff(blocklen, ==, inflate_hd(inflater, NULL, &bufs, 0, mem)); nghttp2_bufs_wrap_free(&bufs); @@ -1270,12 +1317,12 @@ void test_nghttp2_hd_public_api(void) { nghttp2_hd_deflate_del(deflater); /* See NGHTTP2_ERR_INSUFF_BUFSIZE */ - CU_ASSERT(0 == nghttp2_hd_deflate_new(&deflater, 4096)); + assert_int(0, ==, nghttp2_hd_deflate_new(&deflater, 4096)); - blocklen = nghttp2_hd_deflate_hd(deflater, buf, (size_t)(blocklen - 1), nva, - ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd2(deflater, buf, (size_t)(blocklen - 1), nva, + ARRLEN(nva)); - CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen); + assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen); nghttp2_hd_deflate_del(deflater); } @@ -1292,7 +1339,7 @@ void test_nghttp2_hd_deflate_hd_vec(void) { MAKE_NV("content-length", "1000000007"), }; uint8_t buf[4096]; - ssize_t blocklen; + nghttp2_ssize blocklen; nghttp2_mem *mem; nghttp2_vec vec[256]; size_t buflen; @@ -1314,16 +1361,16 @@ void test_nghttp2_hd_deflate_hd_vec(void) { vec[1].base = &buf[buflen / 2]; vec[1].len = buflen / 2; - blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva)); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, <, blocklen); nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem); bufs.head->buf.last += blocklen; - CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem)); + assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem)); - CU_ASSERT(ARRLEN(nva) == out.nvlen); + assert_size(ARRLEN(nva), ==, out.nvlen); assert_nv_equal(nva, out.nva, ARRLEN(nva), mem); nghttp2_bufs_wrap_free(&bufs); @@ -1336,9 +1383,9 @@ void test_nghttp2_hd_deflate_hd_vec(void) { nghttp2_hd_deflate_new(&deflater, 4096); nghttp2_hd_inflate_new(&inflater); - blocklen = nghttp2_hd_deflate_hd_vec(deflater, NULL, 0, nva, ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd_vec2(deflater, NULL, 0, nva, ARRLEN(nva)); - CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen); + assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen); nghttp2_hd_inflate_del(inflater); nghttp2_hd_deflate_del(deflater); @@ -1352,9 +1399,9 @@ void test_nghttp2_hd_deflate_hd_vec(void) { nghttp2_hd_deflate_new(&deflater, 4096); nghttp2_hd_inflate_new(&inflater); - blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva)); - CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen); + assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, blocklen); nghttp2_hd_inflate_del(inflater); nghttp2_hd_deflate_del(deflater); @@ -1370,15 +1417,15 @@ void test_nghttp2_hd_deflate_hd_vec(void) { vec[1].base = &buf[buflen / 2]; vec[1].len = (buflen / 2) + 1; - blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, 2, nva, ARRLEN(nva)); + blocklen = nghttp2_hd_deflate_hd_vec2(deflater, vec, 2, nva, ARRLEN(nva)); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, <, blocklen); nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem); bufs.head->buf.last += blocklen; - CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem)); - CU_ASSERT(ARRLEN(nva) == out.nvlen); + assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem)); + assert_size(ARRLEN(nva), ==, out.nvlen); assert_nv_equal(nva, out.nva, ARRLEN(nva), mem); nghttp2_bufs_wrap_free(&bufs); @@ -1400,15 +1447,16 @@ void test_nghttp2_hd_deflate_hd_vec(void) { vec[i].len = 1; } - blocklen = nghttp2_hd_deflate_hd_vec(deflater, vec, buflen, nva, ARRLEN(nva)); + blocklen = + nghttp2_hd_deflate_hd_vec2(deflater, vec, buflen, nva, ARRLEN(nva)); - CU_ASSERT(blocklen > 0); + assert_ptrdiff(0, <, blocklen); nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem); bufs.head->buf.last += blocklen; - CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem)); - CU_ASSERT(ARRLEN(nva) == out.nvlen); + assert_ptrdiff(blocklen, ==, inflate_hd(inflater, &out, &bufs, 0, mem)); + assert_size(ARRLEN(nva), ==, out.nvlen); assert_nv_equal(nva, out.nva, ARRLEN(nva), mem); nghttp2_bufs_wrap_free(&bufs); @@ -1453,7 +1501,7 @@ void test_nghttp2_hd_decode_length(void) { uint8_t buf[16]; uint8_t *bufp; size_t len; - ssize_t rv; + nghttp2_ssize rv; size_t i; memset(buf, 0, sizeof(buf)); @@ -1461,9 +1509,9 @@ void test_nghttp2_hd_decode_length(void) { rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7); - CU_ASSERT((ssize_t)len == rv); - CU_ASSERT(0 != fin); - CU_ASSERT(UINT32_MAX == out); + assert_ptrdiff((nghttp2_ssize)len, ==, rv); + assert_true(fin); + assert_uint32(UINT32_MAX, ==, out); /* Make sure that we can decode integer if we feed 1 byte at a time */ @@ -1476,16 +1524,16 @@ void test_nghttp2_hd_decode_length(void) { rv = nghttp2_hd_decode_length(&out, &shift, &fin, out, shift, bufp, bufp + 1, 7); - CU_ASSERT(rv == 1); + assert_ptrdiff(1, ==, rv); if (fin) { break; } } - CU_ASSERT(i == len - 1); - CU_ASSERT(0 != fin); - CU_ASSERT(UINT32_MAX == out); + assert_size(len - 1, ==, i); + assert_true(fin); + assert_size(UINT32_MAX, ==, out); /* Check overflow case */ memset(buf, 0, sizeof(buf)); @@ -1493,7 +1541,7 @@ void test_nghttp2_hd_decode_length(void) { rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7); - CU_ASSERT(-1 == rv); + assert_ptrdiff(-1, ==, rv); /* Check the case that shift goes beyond 32 bits */ buf[0] = 255; @@ -1506,12 +1554,12 @@ void test_nghttp2_hd_decode_length(void) { rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + 7, 8); - CU_ASSERT(-1 == rv); + assert_ptrdiff(-1, ==, rv); } void test_nghttp2_hd_huff_encode(void) { int rv; - ssize_t len; + nghttp2_ssize len; nghttp2_buf outbuf; nghttp2_bufs bufs; nghttp2_hd_huff_decode_context ctx; @@ -1524,17 +1572,17 @@ void test_nghttp2_hd_huff_encode(void) { rv = nghttp2_hd_huff_encode(&bufs, t1, sizeof(t1)); - CU_ASSERT(rv == 0); + assert_int(0, ==, rv); nghttp2_hd_huff_decode_context_init(&ctx); len = nghttp2_hd_huff_decode(&ctx, &outbuf, bufs.cur->buf.pos, nghttp2_bufs_len(&bufs), 1); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == len); - CU_ASSERT((ssize_t)sizeof(t1) == nghttp2_buf_len(&outbuf)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, len); + assert_size(sizeof(t1), ==, nghttp2_buf_len(&outbuf)); - CU_ASSERT(0 == memcmp(t1, outbuf.pos, sizeof(t1))); + assert_memory_equal(sizeof(t1), t1, outbuf.pos); nghttp2_bufs_free(&bufs); } @@ -1544,34 +1592,34 @@ void test_nghttp2_hd_huff_decode(void) { nghttp2_hd_huff_decode_context ctx; nghttp2_buf outbuf; uint8_t b[256]; - ssize_t len; + nghttp2_ssize len; nghttp2_buf_wrap_init(&outbuf, b, sizeof(b)); nghttp2_hd_huff_decode_context_init(&ctx); len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 1, 1); - CU_ASSERT(1 == len); - CU_ASSERT(0 == memcmp("a", outbuf.pos, 1)); + assert_ptrdiff(1, ==, len); + assert_memory_equal(1, "a", outbuf.pos); /* Premature sequence must elicit decoding error */ nghttp2_buf_wrap_init(&outbuf, b, sizeof(b)); nghttp2_hd_huff_decode_context_init(&ctx); len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 2, 1); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == len); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, len); /* Fully decoding EOS is error */ nghttp2_buf_wrap_init(&outbuf, b, sizeof(b)); nghttp2_hd_huff_decode_context_init(&ctx); len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 2, 6); - CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == len); + assert_ptrdiff(NGHTTP2_ERR_HEADER_COMP, ==, len); /* Check failure state */ nghttp2_buf_wrap_init(&outbuf, b, sizeof(b)); nghttp2_hd_huff_decode_context_init(&ctx); len = nghttp2_hd_huff_decode(&ctx, &outbuf, e, 5, 0); - CU_ASSERT(5 == len); - CU_ASSERT(nghttp2_hd_huff_decode_failure_state(&ctx)); + assert_ptrdiff(5, ==, len); + assert_true(nghttp2_hd_huff_decode_failure_state(&ctx)); } diff --git a/tests/nghttp2_hd_test.h b/tests/nghttp2_hd_test.h index ab0117c..9d5ec8f 100644 --- a/tests/nghttp2_hd_test.h +++ b/tests/nghttp2_hd_test.h @@ -29,27 +29,33 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_hd_deflate(void); -void test_nghttp2_hd_deflate_same_indexed_repr(void); -void test_nghttp2_hd_inflate_indexed(void); -void test_nghttp2_hd_inflate_indname_noinc(void); -void test_nghttp2_hd_inflate_indname_inc(void); -void test_nghttp2_hd_inflate_indname_inc_eviction(void); -void test_nghttp2_hd_inflate_newname_noinc(void); -void test_nghttp2_hd_inflate_newname_inc(void); -void test_nghttp2_hd_inflate_clearall_inc(void); -void test_nghttp2_hd_inflate_zero_length_huffman(void); -void test_nghttp2_hd_inflate_expect_table_size_update(void); -void test_nghttp2_hd_inflate_unexpected_table_size_update(void); -void test_nghttp2_hd_ringbuf_reserve(void); -void test_nghttp2_hd_change_table_size(void); -void test_nghttp2_hd_deflate_inflate(void); -void test_nghttp2_hd_no_index(void); -void test_nghttp2_hd_deflate_bound(void); -void test_nghttp2_hd_public_api(void); -void test_nghttp2_hd_deflate_hd_vec(void); -void test_nghttp2_hd_decode_length(void); -void test_nghttp2_hd_huff_encode(void); -void test_nghttp2_hd_huff_decode(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite hd_suite; + +munit_void_test_decl(test_nghttp2_hd_deflate); +munit_void_test_decl(test_nghttp2_hd_deflate_same_indexed_repr); +munit_void_test_decl(test_nghttp2_hd_inflate_indexed); +munit_void_test_decl(test_nghttp2_hd_inflate_indname_noinc); +munit_void_test_decl(test_nghttp2_hd_inflate_indname_inc); +munit_void_test_decl(test_nghttp2_hd_inflate_indname_inc_eviction); +munit_void_test_decl(test_nghttp2_hd_inflate_newname_noinc); +munit_void_test_decl(test_nghttp2_hd_inflate_newname_inc); +munit_void_test_decl(test_nghttp2_hd_inflate_clearall_inc); +munit_void_test_decl(test_nghttp2_hd_inflate_zero_length_huffman); +munit_void_test_decl(test_nghttp2_hd_inflate_expect_table_size_update); +munit_void_test_decl(test_nghttp2_hd_inflate_unexpected_table_size_update); +munit_void_test_decl(test_nghttp2_hd_ringbuf_reserve); +munit_void_test_decl(test_nghttp2_hd_change_table_size); +munit_void_test_decl(test_nghttp2_hd_deflate_inflate); +munit_void_test_decl(test_nghttp2_hd_no_index); +munit_void_test_decl(test_nghttp2_hd_deflate_bound); +munit_void_test_decl(test_nghttp2_hd_public_api); +munit_void_test_decl(test_nghttp2_hd_deflate_hd_vec); +munit_void_test_decl(test_nghttp2_hd_decode_length); +munit_void_test_decl(test_nghttp2_hd_huff_encode); +munit_void_test_decl(test_nghttp2_hd_huff_decode); #endif /* NGHTTP2_HD_TEST_H */ diff --git a/tests/nghttp2_helper_test.c b/tests/nghttp2_helper_test.c index 377f49d..8c3f116 100644 --- a/tests/nghttp2_helper_test.c +++ b/tests/nghttp2_helper_test.c @@ -26,10 +26,22 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_helper.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_adjust_local_window_size), + munit_void_test(test_nghttp2_check_header_name), + munit_void_test(test_nghttp2_check_header_value), + munit_void_test(test_nghttp2_check_header_value_rfc9113), + munit_test_end(), +}; + +const MunitSuite helper_suite = { + "/helper", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_adjust_local_window_size(void) { int32_t local_window_size = 100; int32_t recv_window_size = 50; @@ -37,123 +49,132 @@ void test_nghttp2_adjust_local_window_size(void) { int32_t delta; delta = 0; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(50 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(0 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(50, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(0, ==, delta); delta = 49; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(1 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(49 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(1, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(49, ==, delta); delta = 1; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(0 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(1 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(0, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(1, ==, delta); delta = 1; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(101 == local_window_size); - CU_ASSERT(0 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(1 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(101, ==, local_window_size); + assert_int32(0, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(1, ==, delta); delta = -1; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(-1 == recv_window_size); - CU_ASSERT(1 == recv_reduction); - CU_ASSERT(0 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(-1, ==, recv_window_size); + assert_int32(1, ==, recv_reduction); + assert_int32(0, ==, delta); delta = 1; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(101 == local_window_size); - CU_ASSERT(0 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(0 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(101, ==, local_window_size); + assert_int32(0, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(0, ==, delta); delta = 100; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(201 == local_window_size); - CU_ASSERT(0 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(100 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(201, ==, local_window_size); + assert_int32(0, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(100, ==, delta); delta = -3; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(198 == local_window_size); - CU_ASSERT(-3 == recv_window_size); - CU_ASSERT(3 == recv_reduction); - CU_ASSERT(0 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(198, ==, local_window_size); + assert_int32(-3, ==, recv_window_size); + assert_int32(3, ==, recv_reduction); + assert_int32(0, ==, delta); recv_window_size += 3; delta = 3; - CU_ASSERT(0 == nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, - &recv_reduction, &delta)); - CU_ASSERT(201 == local_window_size); - CU_ASSERT(3 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(0 == delta); + assert_int(0, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(201, ==, local_window_size); + assert_int32(3, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(0, ==, delta); local_window_size = 100; recv_window_size = 50; recv_reduction = 0; delta = INT32_MAX; - CU_ASSERT(NGHTTP2_ERR_FLOW_CONTROL == - nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, &recv_reduction, - &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(50 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(INT32_MAX == delta); + assert_int(NGHTTP2_ERR_FLOW_CONTROL, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(50, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(INT32_MAX, ==, delta); delta = INT32_MIN; - CU_ASSERT(NGHTTP2_ERR_FLOW_CONTROL == - nghttp2_adjust_local_window_size(&local_window_size, - &recv_window_size, &recv_reduction, - &delta)); - CU_ASSERT(100 == local_window_size); - CU_ASSERT(50 == recv_window_size); - CU_ASSERT(0 == recv_reduction); - CU_ASSERT(INT32_MIN == delta); + assert_int(NGHTTP2_ERR_FLOW_CONTROL, ==, + nghttp2_adjust_local_window_size(&local_window_size, + &recv_window_size, + &recv_reduction, &delta)); + assert_int32(100, ==, local_window_size); + assert_int32(50, ==, recv_window_size); + assert_int32(0, ==, recv_reduction); + assert_int32(INT32_MIN, ==, delta); } #define check_header_name(S) \ nghttp2_check_header_name((const uint8_t *)S, sizeof(S) - 1) void test_nghttp2_check_header_name(void) { - CU_ASSERT(check_header_name(":path")); - CU_ASSERT(check_header_name("path")); - CU_ASSERT(check_header_name("!#$%&'*+-.^_`|~")); - CU_ASSERT(!check_header_name(":PATH")); - CU_ASSERT(!check_header_name("path:")); - CU_ASSERT(!check_header_name("")); - CU_ASSERT(!check_header_name(":")); + assert_true(check_header_name(":path")); + assert_true(check_header_name("path")); + assert_true(check_header_name("!#$%&'*+-.^_`|~")); + assert_false(check_header_name(":PATH")); + assert_false(check_header_name("path:")); + assert_false(check_header_name("")); + assert_false(check_header_name(":")); } #define check_header_value(S) \ @@ -164,13 +185,13 @@ void test_nghttp2_check_header_value(void) { uint8_t badval1[] = {'a', 0x1fu, 'b'}; uint8_t badval2[] = {'a', 0x7fu, 'b'}; - CU_ASSERT(check_header_value(" !|}~")); - CU_ASSERT(check_header_value(goodval)); - CU_ASSERT(!check_header_value(badval1)); - CU_ASSERT(!check_header_value(badval2)); - CU_ASSERT(check_header_value("")); - CU_ASSERT(check_header_value(" ")); - CU_ASSERT(check_header_value("\t")); + assert_true(check_header_value(" !|}~")); + assert_true(check_header_value(goodval)); + assert_false(check_header_value(badval1)); + assert_false(check_header_value(badval2)); + assert_true(check_header_value("")); + assert_true(check_header_value(" ")); + assert_true(check_header_value("\t")); } #define check_header_value_rfc9113(S) \ @@ -181,15 +202,15 @@ void test_nghttp2_check_header_value_rfc9113(void) { uint8_t badval1[] = {'a', 0x1fu, 'b'}; uint8_t badval2[] = {'a', 0x7fu, 'b'}; - CU_ASSERT(check_header_value_rfc9113("!|}~")); - CU_ASSERT(!check_header_value_rfc9113(" !|}~")); - CU_ASSERT(!check_header_value_rfc9113("!|}~ ")); - CU_ASSERT(!check_header_value_rfc9113("\t!|}~")); - CU_ASSERT(!check_header_value_rfc9113("!|}~\t")); - CU_ASSERT(check_header_value_rfc9113(goodval)); - CU_ASSERT(!check_header_value_rfc9113(badval1)); - CU_ASSERT(!check_header_value_rfc9113(badval2)); - CU_ASSERT(check_header_value_rfc9113("")); - CU_ASSERT(!check_header_value_rfc9113(" ")); - CU_ASSERT(!check_header_value_rfc9113("\t")); + assert_true(check_header_value_rfc9113("!|}~")); + assert_false(check_header_value_rfc9113(" !|}~")); + assert_false(check_header_value_rfc9113("!|}~ ")); + assert_false(check_header_value_rfc9113("\t!|}~")); + assert_false(check_header_value_rfc9113("!|}~\t")); + assert_true(check_header_value_rfc9113(goodval)); + assert_false(check_header_value_rfc9113(badval1)); + assert_false(check_header_value_rfc9113(badval2)); + assert_true(check_header_value_rfc9113("")); + assert_false(check_header_value_rfc9113(" ")); + assert_false(check_header_value_rfc9113("\t")); } diff --git a/tests/nghttp2_helper_test.h b/tests/nghttp2_helper_test.h index 8790dcf..b81c7b3 100644 --- a/tests/nghttp2_helper_test.h +++ b/tests/nghttp2_helper_test.h @@ -29,9 +29,15 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_adjust_local_window_size(void); -void test_nghttp2_check_header_name(void); -void test_nghttp2_check_header_value(void); -void test_nghttp2_check_header_value_rfc9113(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite helper_suite; + +munit_void_test_decl(test_nghttp2_adjust_local_window_size); +munit_void_test_decl(test_nghttp2_check_header_name); +munit_void_test_decl(test_nghttp2_check_header_value); +munit_void_test_decl(test_nghttp2_check_header_value_rfc9113); #endif /* NGHTTP2_HELPER_TEST_H */ diff --git a/tests/nghttp2_http_test.c b/tests/nghttp2_http_test.c index 19f345b..86880d5 100644 --- a/tests/nghttp2_http_test.c +++ b/tests/nghttp2_http_test.c @@ -28,11 +28,20 @@ #include <stdio.h> #include <assert.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_http.h" #include "nghttp2_test_helper.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_http_parse_priority), + munit_test_end(), +}; + +const MunitSuite http_suite = { + "/http", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_http_parse_priority(void) { int rv; @@ -42,9 +51,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)-1 == pri.urgency); - CU_ASSERT(-1 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)-1, ==, pri.urgency); + assert_int(-1, ==, pri.inc); } { @@ -53,9 +62,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)7 == pri.urgency); - CU_ASSERT(1 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)7, ==, pri.urgency); + assert_int(1, ==, pri.inc); } { @@ -64,9 +73,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)0 == pri.urgency); - CU_ASSERT(0 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)0, ==, pri.urgency); + assert_int(0, ==, pri.inc); } { @@ -75,9 +84,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)3 == pri.urgency); - CU_ASSERT(1 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)3, ==, pri.urgency); + assert_int(1, ==, pri.inc); } { @@ -86,9 +95,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)6 == pri.urgency); - CU_ASSERT(0 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)6, ==, pri.urgency); + assert_int(0, ==, pri.inc); } { @@ -97,7 +106,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -106,7 +115,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -115,7 +124,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -124,7 +133,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -133,9 +142,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)-1 == pri.urgency); - CU_ASSERT(1 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)-1, ==, pri.urgency); + assert_int(1, ==, pri.inc); } { @@ -144,7 +153,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -153,7 +162,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -162,7 +171,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -171,7 +180,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -180,7 +189,7 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } { @@ -190,9 +199,9 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v) - 1); - CU_ASSERT(0 == rv); - CU_ASSERT((uint32_t)2 == pri.urgency); - CU_ASSERT(1 == pri.inc); + assert_int(0, ==, rv); + assert_uint32((uint32_t)2, ==, pri.urgency); + assert_int(1, ==, pri.inc); } { @@ -201,6 +210,6 @@ void test_nghttp2_http_parse_priority(void) { rv = nghttp2_http_parse_priority(&pri, v, sizeof(v)); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); } } diff --git a/tests/nghttp2_http_test.h b/tests/nghttp2_http_test.h index e616cdc..b258905 100644 --- a/tests/nghttp2_http_test.h +++ b/tests/nghttp2_http_test.h @@ -30,6 +30,12 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_http_parse_priority(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite http_suite; + +munit_void_test_decl(test_nghttp2_http_parse_priority); #endif /* NGHTTP2_HTTP_TEST_H */ diff --git a/tests/nghttp2_map_test.c b/tests/nghttp2_map_test.c index 7ba9bd6..3b79b8a 100644 --- a/tests/nghttp2_map_test.c +++ b/tests/nghttp2_map_test.c @@ -27,10 +27,22 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_map.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_map), + munit_void_test(test_nghttp2_map_functional), + munit_void_test(test_nghttp2_map_each_free), + munit_void_test(test_nghttp2_map_clear), + munit_test_end(), +}; + +const MunitSuite map_suite = { + "/map", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + typedef struct strentry { nghttp2_map_key_type key; const char *str; @@ -53,43 +65,43 @@ void test_nghttp2_map(void) { strentry_init(&baz, 3, "baz"); strentry_init(&shrubbery, 4, "shrubbery"); - CU_ASSERT(0 == nghttp2_map_insert(&map, foo.key, &foo)); - CU_ASSERT(strcmp("foo", ((strentry *)nghttp2_map_find(&map, 1))->str) == 0); - CU_ASSERT(1 == nghttp2_map_size(&map)); + assert_int(0, ==, nghttp2_map_insert(&map, foo.key, &foo)); + assert_string_equal("foo", ((strentry *)nghttp2_map_find(&map, 1))->str); + assert_size(1, ==, nghttp2_map_size(&map)); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_map_insert(&map, FOO.key, &FOO)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_map_insert(&map, FOO.key, &FOO)); - CU_ASSERT(1 == nghttp2_map_size(&map)); - CU_ASSERT(strcmp("foo", ((strentry *)nghttp2_map_find(&map, 1))->str) == 0); + assert_size(1, ==, nghttp2_map_size(&map)); + assert_string_equal("foo", ((strentry *)nghttp2_map_find(&map, 1))->str); - CU_ASSERT(0 == nghttp2_map_insert(&map, bar.key, &bar)); - CU_ASSERT(2 == nghttp2_map_size(&map)); + assert_int(0, ==, nghttp2_map_insert(&map, bar.key, &bar)); + assert_size(2, ==, nghttp2_map_size(&map)); - CU_ASSERT(0 == nghttp2_map_insert(&map, baz.key, &baz)); - CU_ASSERT(3 == nghttp2_map_size(&map)); + assert_int(0, ==, nghttp2_map_insert(&map, baz.key, &baz)); + assert_size(3, ==, nghttp2_map_size(&map)); - CU_ASSERT(0 == nghttp2_map_insert(&map, shrubbery.key, &shrubbery)); - CU_ASSERT(4 == nghttp2_map_size(&map)); + assert_int(0, ==, nghttp2_map_insert(&map, shrubbery.key, &shrubbery)); + assert_size(4, ==, nghttp2_map_size(&map)); - CU_ASSERT(strcmp("baz", ((strentry *)nghttp2_map_find(&map, 3))->str) == 0); + assert_string_equal("baz", ((strentry *)nghttp2_map_find(&map, 3))->str); nghttp2_map_remove(&map, 3); - CU_ASSERT(3 == nghttp2_map_size(&map)); - CU_ASSERT(NULL == nghttp2_map_find(&map, 3)); + assert_size(3, ==, nghttp2_map_size(&map)); + assert_null(nghttp2_map_find(&map, 3)); nghttp2_map_remove(&map, 1); - CU_ASSERT(2 == nghttp2_map_size(&map)); - CU_ASSERT(NULL == nghttp2_map_find(&map, 1)); + assert_size(2, ==, nghttp2_map_size(&map)); + assert_null(nghttp2_map_find(&map, 1)); /* Erasing non-existent entry */ nghttp2_map_remove(&map, 1); - CU_ASSERT(2 == nghttp2_map_size(&map)); - CU_ASSERT(NULL == nghttp2_map_find(&map, 1)); + assert_size(2, ==, nghttp2_map_size(&map)); + assert_null(nghttp2_map_find(&map, 1)); - CU_ASSERT(strcmp("bar", ((strentry *)nghttp2_map_find(&map, 2))->str) == 0); - CU_ASSERT(strcmp("shrubbery", ((strentry *)nghttp2_map_find(&map, 4))->str) == - 0); + assert_string_equal("bar", ((strentry *)nghttp2_map_find(&map, 2))->str); + assert_string_equal("shrubbery", + ((strentry *)nghttp2_map_find(&map, 4))->str); nghttp2_map_free(&map); } @@ -129,21 +141,21 @@ void test_nghttp2_map_functional(void) { shuffle(order, NUM_ENT); for (i = 0; i < NUM_ENT; ++i) { ent = &arr[order[i] - 1]; - CU_ASSERT(0 == nghttp2_map_insert(&map, ent->key, ent)); + assert_int(0, ==, nghttp2_map_insert(&map, ent->key, ent)); } - CU_ASSERT(NUM_ENT == nghttp2_map_size(&map)); + assert_size(NUM_ENT, ==, nghttp2_map_size(&map)); /* traverse */ nghttp2_map_each(&map, eachfun, NULL); /* find */ shuffle(order, NUM_ENT); for (i = 0; i < NUM_ENT; ++i) { - CU_ASSERT(NULL != nghttp2_map_find(&map, (nghttp2_map_key_type)order[i])); + assert_not_null(nghttp2_map_find(&map, (nghttp2_map_key_type)order[i])); } /* remove */ for (i = 0; i < NUM_ENT; ++i) { - CU_ASSERT(0 == nghttp2_map_remove(&map, (nghttp2_map_key_type)order[i])); + assert_int(0, ==, nghttp2_map_remove(&map, (nghttp2_map_key_type)order[i])); } /* each_free (but no op function for testing purpose) */ @@ -153,7 +165,7 @@ void test_nghttp2_map_functional(void) { /* insert once again */ for (i = 0; i < NUM_ENT; ++i) { ent = &arr[i]; - CU_ASSERT(0 == nghttp2_map_insert(&map, ent->key, ent)); + assert_int(0, ==, nghttp2_map_insert(&map, ent->key, ent)); } nghttp2_map_each_free(&map, eachfun, NULL); nghttp2_map_free(&map); @@ -198,11 +210,11 @@ void test_nghttp2_map_clear(void) { nghttp2_map_init(&map, mem); - CU_ASSERT(0 == nghttp2_map_insert(&map, foo.key, &foo)); + assert_int(0, ==, nghttp2_map_insert(&map, foo.key, &foo)); nghttp2_map_clear(&map); - CU_ASSERT(0 == nghttp2_map_size(&map)); + assert_size(0, ==, nghttp2_map_size(&map)); nghttp2_map_free(&map); } diff --git a/tests/nghttp2_map_test.h b/tests/nghttp2_map_test.h index 235624d..ba06175 100644 --- a/tests/nghttp2_map_test.h +++ b/tests/nghttp2_map_test.h @@ -30,9 +30,15 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_map(void); -void test_nghttp2_map_functional(void); -void test_nghttp2_map_each_free(void); -void test_nghttp2_map_clear(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite map_suite; + +munit_void_test_decl(test_nghttp2_map); +munit_void_test_decl(test_nghttp2_map_functional); +munit_void_test_decl(test_nghttp2_map_each_free); +munit_void_test_decl(test_nghttp2_map_clear); #endif /* NGHTTP2_MAP_TEST_H */ diff --git a/tests/nghttp2_pq_test.c b/tests/nghttp2_pq_test.c index 90db26d..aa84af1 100644 --- a/tests/nghttp2_pq_test.c +++ b/tests/nghttp2_pq_test.c @@ -26,10 +26,19 @@ #include <stdio.h> -#include <CUnit/CUnit.h> - #include "nghttp2_pq.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_pq), + munit_void_test(test_nghttp2_pq_update), + munit_void_test(test_nghttp2_pq_remove), + munit_test_end(), +}; + +const MunitSuite pq_suite = { + "/pq", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + typedef struct { nghttp2_pq_entry ent; const char *s; @@ -59,59 +68,59 @@ void test_nghttp2_pq(void) { string_entry *top; nghttp2_pq_init(&pq, pq_less, nghttp2_mem_default()); - CU_ASSERT(nghttp2_pq_empty(&pq)); - CU_ASSERT(0 == nghttp2_pq_size(&pq)); - CU_ASSERT(0 == nghttp2_pq_push(&pq, &string_entry_new("foo")->ent)); - CU_ASSERT(0 == nghttp2_pq_empty(&pq)); - CU_ASSERT(1 == nghttp2_pq_size(&pq)); + assert_true(nghttp2_pq_empty(&pq)); + assert_size(0, ==, nghttp2_pq_size(&pq)); + assert_int(0, ==, nghttp2_pq_push(&pq, &string_entry_new("foo")->ent)); + assert_false(nghttp2_pq_empty(&pq)); + assert_size(1, ==, nghttp2_pq_size(&pq)); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("foo", top->s) == 0); - CU_ASSERT(0 == nghttp2_pq_push(&pq, &string_entry_new("bar")->ent)); + assert_string_equal("foo", top->s); + assert_int(0, ==, nghttp2_pq_push(&pq, &string_entry_new("bar")->ent)); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("bar", top->s) == 0); - CU_ASSERT(0 == nghttp2_pq_push(&pq, &string_entry_new("baz")->ent)); + assert_string_equal("bar", top->s); + assert_int(0, ==, nghttp2_pq_push(&pq, &string_entry_new("baz")->ent)); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("bar", top->s) == 0); - CU_ASSERT(0 == nghttp2_pq_push(&pq, &string_entry_new("C")->ent)); - CU_ASSERT(4 == nghttp2_pq_size(&pq)); + assert_string_equal("bar", top->s); + assert_int(0, ==, nghttp2_pq_push(&pq, &string_entry_new("C")->ent)); + assert_size(4, ==, nghttp2_pq_size(&pq)); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("C", top->s) == 0); + assert_string_equal("C", top->s); string_entry_del(top); nghttp2_pq_pop(&pq); - CU_ASSERT(3 == nghttp2_pq_size(&pq)); + assert_size(3, ==, nghttp2_pq_size(&pq)); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("bar", top->s) == 0); + assert_string_equal("bar", top->s); nghttp2_pq_pop(&pq); string_entry_del(top); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("baz", top->s) == 0); + assert_string_equal("baz", top->s); nghttp2_pq_pop(&pq); string_entry_del(top); top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(strcmp("foo", top->s) == 0); + assert_string_equal("foo", top->s); nghttp2_pq_pop(&pq); string_entry_del(top); - CU_ASSERT(nghttp2_pq_empty(&pq)); - CU_ASSERT(0 == nghttp2_pq_size(&pq)); - CU_ASSERT(NULL == nghttp2_pq_top(&pq)); + assert_true(nghttp2_pq_empty(&pq)); + assert_size(0, ==, nghttp2_pq_size(&pq)); + assert_null(nghttp2_pq_top(&pq)); /* Add bunch of entry to see realloc works */ for (i = 0; i < 10000; ++i) { - CU_ASSERT(0 == nghttp2_pq_push(&pq, &string_entry_new("foo")->ent)); - CU_ASSERT((size_t)(i + 1) == nghttp2_pq_size(&pq)); + assert_int(0, ==, nghttp2_pq_push(&pq, &string_entry_new("foo")->ent)); + assert_size((size_t)(i + 1), ==, nghttp2_pq_size(&pq)); } for (i = 10000; i > 0; --i) { top = (string_entry *)nghttp2_pq_top(&pq); - CU_ASSERT(NULL != top); + assert_not_null(top); nghttp2_pq_pop(&pq); string_entry_del(top); - CU_ASSERT((size_t)(i - 1) == nghttp2_pq_size(&pq)); + assert_size((size_t)(i - 1), ==, nghttp2_pq_size(&pq)); } nghttp2_pq_free(&pq); @@ -160,7 +169,7 @@ void test_nghttp2_pq_update(void) { for (i = 0; i < (int)(sizeof(nodes) / sizeof(nodes[0])); ++i) { nd = (node *)nghttp2_pq_top(&pq); - CU_ASSERT(ans[i] == nd->key); + assert_int(ans[i], ==, nd->key); nghttp2_pq_pop(&pq); } @@ -180,8 +189,8 @@ static void check_nodes(nghttp2_pq *pq, size_t n, int *ans_key, int *ans_val) { size_t i; for (i = 0; i < n; ++i) { node *nd = (node *)nghttp2_pq_top(pq); - CU_ASSERT(ans_key[i] == nd->key); - CU_ASSERT(ans_val[i] == nd->val); + assert_int(ans_key[i], ==, nd->key); + assert_int(ans_val[i], ==, nd->val); nghttp2_pq_pop(pq); } } diff --git a/tests/nghttp2_pq_test.h b/tests/nghttp2_pq_test.h index 969662a..1386528 100644 --- a/tests/nghttp2_pq_test.h +++ b/tests/nghttp2_pq_test.h @@ -29,8 +29,14 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_pq(void); -void test_nghttp2_pq_update(void); -void test_nghttp2_pq_remove(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite pq_suite; + +munit_void_test_decl(test_nghttp2_pq); +munit_void_test_decl(test_nghttp2_pq_update); +munit_void_test_decl(test_nghttp2_pq_remove); #endif /* NGHTTP2_PQ_TEST_H */ diff --git a/tests/nghttp2_queue_test.c b/tests/nghttp2_queue_test.c index cb993a8..9837b61 100644 --- a/tests/nghttp2_queue_test.c +++ b/tests/nghttp2_queue_test.c @@ -26,25 +26,34 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_queue.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_queue), + munit_test_end(), +}; + +const MunitSuite queue_suite = { + "/queue", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_queue(void) { int ints[] = {1, 2, 3, 4, 5}; int i; nghttp2_queue queue; nghttp2_queue_init(&queue); - CU_ASSERT(nghttp2_queue_empty(&queue)); + assert_true(nghttp2_queue_empty(&queue)); for (i = 0; i < 5; ++i) { nghttp2_queue_push(&queue, &ints[i]); - CU_ASSERT_EQUAL(ints[0], *(int *)(nghttp2_queue_front(&queue))); - CU_ASSERT(!nghttp2_queue_empty(&queue)); + assert_int(ints[0], ==, *(int *)(nghttp2_queue_front(&queue))); + assert_false(nghttp2_queue_empty(&queue)); } for (i = 0; i < 5; ++i) { - CU_ASSERT_EQUAL(ints[i], *(int *)(nghttp2_queue_front(&queue))); + assert_int(ints[i], ==, *(int *)(nghttp2_queue_front(&queue))); nghttp2_queue_pop(&queue); } - CU_ASSERT(nghttp2_queue_empty(&queue)); + assert_true(nghttp2_queue_empty(&queue)); nghttp2_queue_free(&queue); } diff --git a/tests/nghttp2_queue_test.h b/tests/nghttp2_queue_test.h index 64f8ce8..ba33d38 100644 --- a/tests/nghttp2_queue_test.h +++ b/tests/nghttp2_queue_test.h @@ -29,6 +29,12 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_queue(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite queue_suite; + +munit_void_test_decl(test_nghttp2_queue); #endif /* NGHTTP2_QUEUE_TEST_H */ diff --git a/tests/nghttp2_ratelim_test.c b/tests/nghttp2_ratelim_test.c index 6abece9..5be2f22 100644 --- a/tests/nghttp2_ratelim_test.c +++ b/tests/nghttp2_ratelim_test.c @@ -26,67 +26,77 @@ #include <stdio.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_ratelim.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_ratelim_update), + munit_void_test(test_nghttp2_ratelim_drain), + munit_test_end(), +}; + +const MunitSuite ratelim_suite = { + "/ratelim", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + void test_nghttp2_ratelim_update(void) { nghttp2_ratelim rl; nghttp2_ratelim_init(&rl, 1000, 21); - CU_ASSERT(1000 == rl.val); - CU_ASSERT(1000 == rl.burst); - CU_ASSERT(21 == rl.rate); - CU_ASSERT(0 == rl.tstamp); + assert_uint64(1000, ==, rl.val); + assert_uint64(1000, ==, rl.burst); + assert_uint64(21, ==, rl.rate); + assert_uint64(0, ==, rl.tstamp); nghttp2_ratelim_update(&rl, 999); - CU_ASSERT(1000 == rl.val); - CU_ASSERT(999 == rl.tstamp); + assert_uint64(1000, ==, rl.val); + assert_uint64(999, ==, rl.tstamp); nghttp2_ratelim_drain(&rl, 100); - CU_ASSERT(900 == rl.val); + assert_uint64(900, ==, rl.val); nghttp2_ratelim_update(&rl, 1000); - CU_ASSERT(921 == rl.val); + assert_uint64(921, ==, rl.val); nghttp2_ratelim_update(&rl, 1002); - CU_ASSERT(963 == rl.val); + assert_uint64(963, ==, rl.val); nghttp2_ratelim_update(&rl, 1004); - CU_ASSERT(1000 == rl.val); - CU_ASSERT(1004 == rl.tstamp); + assert_uint64(1000, ==, rl.val); + assert_uint64(1004, ==, rl.tstamp); /* timer skew */ nghttp2_ratelim_init(&rl, 1000, 21); nghttp2_ratelim_update(&rl, 1); - CU_ASSERT(1000 == rl.val); + assert_uint64(1000, ==, rl.val); nghttp2_ratelim_update(&rl, 0); - CU_ASSERT(1000 == rl.val); + assert_uint64(1000, ==, rl.val); /* rate * duration overflow */ nghttp2_ratelim_init(&rl, 1000, 100); nghttp2_ratelim_drain(&rl, 999); - CU_ASSERT(1 == rl.val); + assert_uint64(1, ==, rl.val); nghttp2_ratelim_update(&rl, UINT64_MAX); - CU_ASSERT(1000 == rl.val); + assert_uint64(1000, ==, rl.val); /* val + rate * duration overflow */ nghttp2_ratelim_init(&rl, UINT64_MAX - 1, 2); nghttp2_ratelim_update(&rl, 1); - CU_ASSERT(UINT64_MAX - 1 == rl.val); + assert_uint64(UINT64_MAX - 1, ==, rl.val); } void test_nghttp2_ratelim_drain(void) { @@ -94,8 +104,8 @@ void test_nghttp2_ratelim_drain(void) { nghttp2_ratelim_init(&rl, 100, 7); - CU_ASSERT(-1 == nghttp2_ratelim_drain(&rl, 101)); - CU_ASSERT(0 == nghttp2_ratelim_drain(&rl, 51)); - CU_ASSERT(0 == nghttp2_ratelim_drain(&rl, 49)); - CU_ASSERT(-1 == nghttp2_ratelim_drain(&rl, 1)); + assert_int(-1, ==, nghttp2_ratelim_drain(&rl, 101)); + assert_int(0, ==, nghttp2_ratelim_drain(&rl, 51)); + assert_int(0, ==, nghttp2_ratelim_drain(&rl, 49)); + assert_int(-1, ==, nghttp2_ratelim_drain(&rl, 1)); } diff --git a/tests/nghttp2_ratelim_test.h b/tests/nghttp2_ratelim_test.h index 02b2f2b..fe10fe1 100644 --- a/tests/nghttp2_ratelim_test.h +++ b/tests/nghttp2_ratelim_test.h @@ -29,7 +29,13 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_ratelim_update(void); -void test_nghttp2_ratelim_drain(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite ratelim_suite; + +munit_void_test_decl(test_nghttp2_ratelim_update); +munit_void_test_decl(test_nghttp2_ratelim_drain); #endif /* NGHTTP2_RATELIM_TEST_H */ diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 9f6a667..c155102 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -27,16 +27,179 @@ #include <stdio.h> #include <assert.h> -#include <CUnit/CUnit.h> +#include "munit.h" #include "nghttp2_session.h" #include "nghttp2_stream.h" #include "nghttp2_net.h" #include "nghttp2_helper.h" #include "nghttp2_test_helper.h" +#include "nghttp2_assertion.h" #include "nghttp2_priority_spec.h" #include "nghttp2_extpri.h" +static const MunitTest tests[] = { + munit_void_test(test_nghttp2_session_recv), + munit_void_test(test_nghttp2_session_recv_invalid_stream_id), + munit_void_test(test_nghttp2_session_recv_invalid_frame), + munit_void_test(test_nghttp2_session_recv_eof), + munit_void_test(test_nghttp2_session_recv_data), + munit_void_test(test_nghttp2_session_recv_data_no_auto_flow_control), + munit_void_test(test_nghttp2_session_recv_continuation), + munit_void_test(test_nghttp2_session_recv_headers_with_priority), + munit_void_test(test_nghttp2_session_recv_headers_with_padding), + munit_void_test(test_nghttp2_session_recv_headers_early_response), + munit_void_test(test_nghttp2_session_recv_headers_for_closed_stream), + munit_void_test(test_nghttp2_session_recv_headers_with_extpri), + munit_void_test(test_nghttp2_session_server_recv_push_response), + munit_void_test(test_nghttp2_session_recv_premature_headers), + munit_void_test(test_nghttp2_session_recv_unknown_frame), + munit_void_test(test_nghttp2_session_recv_unexpected_continuation), + munit_void_test(test_nghttp2_session_recv_settings_header_table_size), + munit_void_test(test_nghttp2_session_recv_too_large_frame_length), + munit_void_test(test_nghttp2_session_recv_extension), + munit_void_test(test_nghttp2_session_recv_altsvc), + munit_void_test(test_nghttp2_session_recv_origin), + munit_void_test(test_nghttp2_session_recv_priority_update), + munit_void_test(test_nghttp2_session_continue), + munit_void_test(test_nghttp2_session_add_frame), + munit_void_test(test_nghttp2_session_on_request_headers_received), + munit_void_test(test_nghttp2_session_on_response_headers_received), + munit_void_test(test_nghttp2_session_on_headers_received), + munit_void_test(test_nghttp2_session_on_push_response_headers_received), + munit_void_test(test_nghttp2_session_on_priority_received), + munit_void_test(test_nghttp2_session_on_rst_stream_received), + munit_void_test(test_nghttp2_session_on_settings_received), + munit_void_test(test_nghttp2_session_on_push_promise_received), + munit_void_test(test_nghttp2_session_on_ping_received), + munit_void_test(test_nghttp2_session_on_goaway_received), + munit_void_test(test_nghttp2_session_on_window_update_received), + munit_void_test(test_nghttp2_session_on_data_received), + munit_void_test(test_nghttp2_session_on_data_received_fail_fast), + munit_void_test(test_nghttp2_session_on_altsvc_received), + munit_void_test(test_nghttp2_session_send_headers_start_stream), + munit_void_test(test_nghttp2_session_send_headers_reply), + munit_void_test(test_nghttp2_session_send_headers_frame_size_error), + munit_void_test(test_nghttp2_session_send_headers_push_reply), + munit_void_test(test_nghttp2_session_send_rst_stream), + munit_void_test(test_nghttp2_session_send_push_promise), + munit_void_test(test_nghttp2_session_is_my_stream_id), + munit_void_test(test_nghttp2_session_upgrade2), + munit_void_test(test_nghttp2_session_reprioritize_stream), + munit_void_test( + test_nghttp2_session_reprioritize_stream_with_idle_stream_dep), + munit_void_test(test_nghttp2_submit_data), + munit_void_test(test_nghttp2_submit_data_read_length_too_large), + munit_void_test(test_nghttp2_submit_data_read_length_smallest), + munit_void_test(test_nghttp2_submit_data_twice), + munit_void_test(test_nghttp2_submit_request_with_data), + munit_void_test(test_nghttp2_submit_request_without_data), + munit_void_test(test_nghttp2_submit_response_with_data), + munit_void_test(test_nghttp2_submit_response_without_data), + munit_void_test(test_nghttp2_submit_response_push_response), + munit_void_test(test_nghttp2_submit_trailer), + munit_void_test(test_nghttp2_submit_headers_start_stream), + munit_void_test(test_nghttp2_submit_headers_reply), + munit_void_test(test_nghttp2_submit_headers_push_reply), + munit_void_test(test_nghttp2_submit_headers), + munit_void_test(test_nghttp2_submit_headers_continuation), + munit_void_test(test_nghttp2_submit_headers_continuation_extra_large), + munit_void_test(test_nghttp2_submit_priority), + munit_void_test(test_nghttp2_submit_settings), + munit_void_test(test_nghttp2_submit_settings_update_local_window_size), + munit_void_test(test_nghttp2_submit_settings_multiple_times), + munit_void_test(test_nghttp2_submit_push_promise), + munit_void_test(test_nghttp2_submit_window_update), + munit_void_test(test_nghttp2_submit_window_update_local_window_size), + munit_void_test(test_nghttp2_submit_shutdown_notice), + munit_void_test(test_nghttp2_submit_invalid_nv), + munit_void_test(test_nghttp2_submit_extension), + munit_void_test(test_nghttp2_submit_altsvc), + munit_void_test(test_nghttp2_submit_origin), + munit_void_test(test_nghttp2_submit_priority_update), + munit_void_test(test_nghttp2_submit_rst_stream), + munit_void_test(test_nghttp2_session_open_stream), + munit_void_test(test_nghttp2_session_open_stream_with_idle_stream_dep), + munit_void_test(test_nghttp2_session_get_next_ob_item), + munit_void_test(test_nghttp2_session_pop_next_ob_item), + munit_void_test(test_nghttp2_session_reply_fail), + munit_void_test(test_nghttp2_session_max_concurrent_streams), + munit_void_test(test_nghttp2_session_stop_data_with_rst_stream), + munit_void_test(test_nghttp2_session_defer_data), + munit_void_test(test_nghttp2_session_flow_control), + munit_void_test(test_nghttp2_session_flow_control_data_recv), + munit_void_test(test_nghttp2_session_flow_control_data_with_padding_recv), + munit_void_test(test_nghttp2_session_data_read_temporal_failure), + munit_void_test(test_nghttp2_session_on_stream_close), + munit_void_test(test_nghttp2_session_on_ctrl_not_send), + munit_void_test(test_nghttp2_session_get_outbound_queue_size), + munit_void_test(test_nghttp2_session_get_effective_local_window_size), + munit_void_test(test_nghttp2_session_set_option), + munit_void_test(test_nghttp2_session_data_backoff_by_high_pri_frame), + munit_void_test(test_nghttp2_session_pack_data_with_padding), + munit_void_test(test_nghttp2_session_pack_headers_with_padding), + munit_void_test(test_nghttp2_pack_settings_payload), + munit_void_test(test_nghttp2_session_stream_dep_add), + munit_void_test(test_nghttp2_session_stream_dep_remove), + munit_void_test(test_nghttp2_session_stream_dep_add_subtree), + munit_void_test(test_nghttp2_session_stream_dep_remove_subtree), + munit_void_test( + test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us), + munit_void_test(test_nghttp2_session_stream_attach_item), + munit_void_test(test_nghttp2_session_stream_attach_item_subtree), + munit_void_test(test_nghttp2_session_stream_get_state), + munit_void_test(test_nghttp2_session_stream_get_something), + munit_void_test(test_nghttp2_session_find_stream), + munit_void_test(test_nghttp2_session_keep_closed_stream), + munit_void_test(test_nghttp2_session_keep_idle_stream), + munit_void_test(test_nghttp2_session_detach_idle_stream), + munit_void_test(test_nghttp2_session_large_dep_tree), + munit_void_test(test_nghttp2_session_graceful_shutdown), + munit_void_test(test_nghttp2_session_on_header_temporal_failure), + munit_void_test(test_nghttp2_session_recv_client_magic), + munit_void_test(test_nghttp2_session_delete_data_item), + munit_void_test(test_nghttp2_session_open_idle_stream), + munit_void_test(test_nghttp2_session_cancel_reserved_remote), + munit_void_test(test_nghttp2_session_reset_pending_headers), + munit_void_test(test_nghttp2_session_send_data_callback), + munit_void_test(test_nghttp2_session_on_begin_headers_temporal_failure), + munit_void_test(test_nghttp2_session_defer_then_close), + munit_void_test(test_nghttp2_session_detach_item_from_closed_stream), + munit_void_test(test_nghttp2_session_flooding), + munit_void_test(test_nghttp2_session_change_stream_priority), + munit_void_test(test_nghttp2_session_change_extpri_stream_priority), + munit_void_test(test_nghttp2_session_create_idle_stream), + munit_void_test(test_nghttp2_session_repeated_priority_change), + munit_void_test(test_nghttp2_session_repeated_priority_submission), + munit_void_test(test_nghttp2_session_set_local_window_size), + munit_void_test(test_nghttp2_session_cancel_from_before_frame_send), + munit_void_test(test_nghttp2_session_too_many_settings), + munit_void_test(test_nghttp2_session_removed_closed_stream), + munit_void_test(test_nghttp2_session_pause_data), + munit_void_test(test_nghttp2_session_no_closed_streams), + munit_void_test(test_nghttp2_session_set_stream_user_data), + munit_void_test(test_nghttp2_session_no_rfc7540_priorities), + munit_void_test(test_nghttp2_session_server_fallback_rfc7540_priorities), + munit_void_test(test_nghttp2_session_stream_reset_ratelim), + munit_void_test(test_nghttp2_http_mandatory_headers), + munit_void_test(test_nghttp2_http_content_length), + munit_void_test(test_nghttp2_http_content_length_mismatch), + munit_void_test(test_nghttp2_http_non_final_response), + munit_void_test(test_nghttp2_http_trailer_headers), + munit_void_test(test_nghttp2_http_ignore_regular_header), + munit_void_test(test_nghttp2_http_ignore_content_length), + munit_void_test(test_nghttp2_http_record_request_method), + munit_void_test(test_nghttp2_http_push_promise), + munit_void_test(test_nghttp2_http_head_method_upgrade_workaround), + munit_void_test( + test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation), + munit_test_end(), +}; + +const MunitSuite session_suite = { + "/session", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE, +}; + typedef struct { uint8_t buf[65535]; size_t length; @@ -121,18 +284,20 @@ static void scripted_data_feed_init2(scripted_data_feed *df, df->feedseq[0] = len; } -static ssize_t null_send_callback(nghttp2_session *session, const uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize null_send_callback(nghttp2_session *session, + const uint8_t *data, size_t len, + int flags, void *user_data) { (void)session; (void)data; (void)flags; (void)user_data; - return (ssize_t)len; + return (nghttp2_ssize)len; } -static ssize_t fail_send_callback(nghttp2_session *session, const uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize fail_send_callback(nghttp2_session *session, + const uint8_t *data, size_t len, + int flags, void *user_data) { (void)session; (void)data; (void)len; @@ -142,19 +307,20 @@ static ssize_t fail_send_callback(nghttp2_session *session, const uint8_t *data, return NGHTTP2_ERR_CALLBACK_FAILURE; } -static ssize_t fixed_bytes_send_callback(nghttp2_session *session, - const uint8_t *data, size_t len, - int flags, void *user_data) { +static nghttp2_ssize fixed_bytes_send_callback(nghttp2_session *session, + const uint8_t *data, size_t len, + int flags, void *user_data) { size_t fixed_sendlen = ((my_user_data *)user_data)->fixed_sendlen; (void)session; (void)data; (void)flags; - return (ssize_t)(fixed_sendlen < len ? fixed_sendlen : len); + return (nghttp2_ssize)(fixed_sendlen < len ? fixed_sendlen : len); } -static ssize_t scripted_recv_callback(nghttp2_session *session, uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize scripted_recv_callback(nghttp2_session *session, + uint8_t *data, size_t len, + int flags, void *user_data) { scripted_data_feed *df = ((my_user_data *)user_data)->df; size_t wlen = df->feedseq[df->seqidx] > len ? len : df->feedseq[df->seqidx]; (void)session; @@ -166,11 +332,11 @@ static ssize_t scripted_recv_callback(nghttp2_session *session, uint8_t *data, if (df->feedseq[df->seqidx] == 0) { ++df->seqidx; } - return (ssize_t)wlen; + return (nghttp2_ssize)wlen; } -static ssize_t eof_recv_callback(nghttp2_session *session, uint8_t *data, - size_t len, int flags, void *user_data) { +static nghttp2_ssize eof_recv_callback(nghttp2_session *session, uint8_t *data, + size_t len, int flags, void *user_data) { (void)session; (void)data; (void)len; @@ -180,9 +346,9 @@ static ssize_t eof_recv_callback(nghttp2_session *session, uint8_t *data, return NGHTTP2_ERR_EOF; } -static ssize_t accumulator_send_callback(nghttp2_session *session, - const uint8_t *buf, size_t len, - int flags, void *user_data) { +static nghttp2_ssize accumulator_send_callback(nghttp2_session *session, + const uint8_t *buf, size_t len, + int flags, void *user_data) { accumulator *acc = ((my_user_data *)user_data)->acc; (void)session; (void)flags; @@ -190,7 +356,7 @@ static ssize_t accumulator_send_callback(nghttp2_session *session, assert(acc->length + len < sizeof(acc->buf)); memcpy(acc->buf + acc->length, buf, len); acc->length += len; - return (ssize_t)len; + return (nghttp2_ssize)len; } static int on_begin_frame_callback(nghttp2_session *session, @@ -290,16 +456,18 @@ static int pause_on_data_chunk_recv_callback(nghttp2_session *session, return NGHTTP2_ERR_PAUSE; } -static ssize_t select_padding_callback(nghttp2_session *session, - const nghttp2_frame *frame, - size_t max_payloadlen, void *user_data) { +static nghttp2_ssize select_padding_callback(nghttp2_session *session, + const nghttp2_frame *frame, + size_t max_payloadlen, + void *user_data) { my_user_data *ud = (my_user_data *)user_data; (void)session; - return (ssize_t)nghttp2_min(max_payloadlen, frame->hd.length + ud->padlen); + return (nghttp2_ssize)nghttp2_min(max_payloadlen, + frame->hd.length + ud->padlen); } -static ssize_t too_large_data_source_length_callback( +static nghttp2_ssize too_large_data_source_length_callback( nghttp2_session *session, uint8_t frame_type, int32_t stream_id, int32_t session_remote_window_size, int32_t stream_remote_window_size, uint32_t remote_max_frame_size, void *user_data) { @@ -314,7 +482,7 @@ static ssize_t too_large_data_source_length_callback( return NGHTTP2_MAX_FRAME_SIZE_MAX + 1; } -static ssize_t smallest_length_data_source_length_callback( +static nghttp2_ssize smallest_length_data_source_length_callback( nghttp2_session *session, uint8_t frame_type, int32_t stream_id, int32_t session_remote_window_size, int32_t stream_remote_window_size, uint32_t remote_max_frame_size, void *user_data) { @@ -329,7 +497,7 @@ static ssize_t smallest_length_data_source_length_callback( return 1; } -static ssize_t fixed_length_data_source_read_callback( +static nghttp2_ssize fixed_length_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { my_user_data *ud = (my_user_data *)user_data; @@ -348,10 +516,10 @@ static ssize_t fixed_length_data_source_read_callback( if (ud->data_source_length == 0) { *data_flags |= NGHTTP2_DATA_FLAG_EOF; } - return (ssize_t)wlen; + return (nghttp2_ssize)wlen; } -static ssize_t temporal_failure_data_source_read_callback( +static nghttp2_ssize temporal_failure_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { (void)session; @@ -365,11 +533,10 @@ static ssize_t temporal_failure_data_source_read_callback( return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } -static ssize_t fail_data_source_read_callback(nghttp2_session *session, - int32_t stream_id, uint8_t *buf, - size_t len, uint32_t *data_flags, - nghttp2_data_source *source, - void *user_data) { +static nghttp2_ssize +fail_data_source_read_callback(nghttp2_session *session, int32_t stream_id, + uint8_t *buf, size_t len, uint32_t *data_flags, + nghttp2_data_source *source, void *user_data) { (void)session; (void)stream_id; (void)buf; @@ -381,7 +548,7 @@ static ssize_t fail_data_source_read_callback(nghttp2_session *session, return NGHTTP2_ERR_CALLBACK_FAILURE; } -static ssize_t no_end_stream_data_source_read_callback( +static nghttp2_ssize no_end_stream_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { (void)session; @@ -395,7 +562,7 @@ static ssize_t no_end_stream_data_source_read_callback( return 0; } -static ssize_t no_copy_data_source_read_callback( +static nghttp2_ssize no_copy_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { my_user_data *ud = (my_user_data *)user_data; @@ -418,7 +585,7 @@ static ssize_t no_copy_data_source_read_callback( if (ud->data_source_length == 0) { *data_flags |= NGHTTP2_DATA_FLAG_EOF; } - return (ssize_t)wlen; + return (nghttp2_ssize)wlen; } static int send_data_callback(nghttp2_session *session, nghttp2_frame *frame, @@ -444,9 +611,9 @@ static int send_data_callback(nghttp2_session *session, nghttp2_frame *frame, return 0; } -static ssize_t block_count_send_callback(nghttp2_session *session, - const uint8_t *data, size_t len, - int flags, void *user_data) { +static nghttp2_ssize block_count_send_callback(nghttp2_session *session, + const uint8_t *data, size_t len, + int flags, void *user_data) { my_user_data *ud = (my_user_data *)user_data; (void)session; (void)data; @@ -457,7 +624,7 @@ static ssize_t block_count_send_callback(nghttp2_session *session, } --ud->block_count; - return (ssize_t)len; + return (nghttp2_ssize)len; } static int on_header_callback(nghttp2_session *session, @@ -555,11 +722,10 @@ static int temporal_failure_on_begin_headers_callback( return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } -static ssize_t defer_data_source_read_callback(nghttp2_session *session, - int32_t stream_id, uint8_t *buf, - size_t len, uint32_t *data_flags, - nghttp2_data_source *source, - void *user_data) { +static nghttp2_ssize +defer_data_source_read_callback(nghttp2_session *session, int32_t stream_id, + uint8_t *buf, size_t len, uint32_t *data_flags, + nghttp2_data_source *source, void *user_data) { (void)session; (void)stream_id; (void)buf; @@ -593,9 +759,10 @@ static int fatal_error_on_stream_close_callback(nghttp2_session *session, return NGHTTP2_ERR_CALLBACK_FAILURE; } -static ssize_t pack_extension_callback(nghttp2_session *session, uint8_t *buf, - size_t len, const nghttp2_frame *frame, - void *user_data) { +static nghttp2_ssize pack_extension_callback(nghttp2_session *session, + uint8_t *buf, size_t len, + const nghttp2_frame *frame, + void *user_data) { nghttp2_buf *p = frame->ext.payload; (void)session; (void)len; @@ -603,7 +770,7 @@ static ssize_t pack_extension_callback(nghttp2_session *session, uint8_t *buf, memcpy(buf, p->pos, nghttp2_buf_len(p)); - return (ssize_t)nghttp2_buf_len(p); + return (nghttp2_ssize)nghttp2_buf_len(p); } static int on_extension_chunk_recv_callback(nghttp2_session *session, @@ -686,8 +853,8 @@ void test_nghttp2_session_recv(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; - callbacks.recv_callback = scripted_recv_callback; + callbacks.send_callback2 = null_send_callback; + callbacks.recv_callback2 = scripted_recv_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; callbacks.on_begin_frame_callback = on_begin_frame_callback; @@ -702,7 +869,7 @@ void test_nghttp2_session_recv(void) { NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); scripted_data_feed_init2(&df, &bufs); @@ -719,10 +886,10 @@ void test_nghttp2_session_recv(void) { user_data.begin_frame_cb_called = 0; while (df.seqidx < framelen) { - CU_ASSERT(0 == nghttp2_session_recv(session)); + assert_int(0, ==, nghttp2_session_recv(session)); } - CU_ASSERT(1 == user_data.frame_recv_cb_called); - CU_ASSERT(1 == user_data.begin_frame_cb_called); + assert_int(1, ==, user_data.frame_recv_cb_called); + assert_int(1, ==, user_data.begin_frame_cb_called); nghttp2_bufs_reset(&bufs); @@ -738,9 +905,9 @@ void test_nghttp2_session_recv(void) { user_data.frame_recv_cb_called = 0; user_data.begin_frame_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_recv(session)); - CU_ASSERT(1 == user_data.frame_recv_cb_called); - CU_ASSERT(1 == user_data.begin_frame_cb_called); + assert_int(0, ==, nghttp2_session_recv(session)); + assert_int(1, ==, user_data.frame_recv_cb_called); + assert_int(1, ==, user_data.begin_frame_cb_called); nghttp2_bufs_reset(&bufs); @@ -770,14 +937,14 @@ void test_nghttp2_session_recv(void) { user_data.frame_recv_cb_called = 0; user_data.begin_frame_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_recv(session)); - CU_ASSERT(0 == user_data.frame_recv_cb_called); - CU_ASSERT(0 == user_data.begin_frame_cb_called); + assert_int(0, ==, nghttp2_session_recv(session)); + assert_int(0, ==, user_data.frame_recv_cb_called); + assert_int(0, ==, user_data.begin_frame_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_FRAME_SIZE_ERROR == item->frame.goaway.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_FRAME_SIZE_ERROR, ==, item->frame.goaway.error_code); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_free(&bufs); nghttp2_session_del(session); @@ -800,7 +967,7 @@ void test_nghttp2_session_recv_invalid_stream_id(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.recv_callback = scripted_recv_callback; + callbacks.recv_callback2 = scripted_recv_callback; callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback; user_data.df = &df; @@ -814,14 +981,14 @@ void test_nghttp2_session_recv_invalid_stream_id(void) { NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_int(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); scripted_data_feed_init2(&df, &bufs); nghttp2_frame_headers_free(&frame.headers, mem); - CU_ASSERT(0 == nghttp2_session_recv(session)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); + assert_int(0, ==, nghttp2_session_recv(session)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -845,8 +1012,8 @@ void test_nghttp2_session_recv_invalid_frame(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.recv_callback = scripted_recv_callback; - callbacks.send_callback = null_send_callback; + callbacks.recv_callback2 = scripted_recv_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; user_data.df = &df; @@ -859,23 +1026,23 @@ void test_nghttp2_session_recv_invalid_frame(void) { NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_int(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); scripted_data_feed_init2(&df, &bufs); - CU_ASSERT(0 == nghttp2_session_recv(session)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == user_data.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_recv(session)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, user_data.frame_send_cb_called); /* Receive exactly same bytes of HEADERS is treated as error, because it has * pseudo headers and without END_STREAM flag set */ scripted_data_feed_init2(&df, &bufs); - CU_ASSERT(0 == nghttp2_session_recv(session)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == user_data.frame_send_cb_called); - CU_ASSERT(NGHTTP2_RST_STREAM == user_data.sent_frame_type); + assert_int(0, ==, nghttp2_session_recv(session)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, user_data.frame_send_cb_called); + assert_uint8(NGHTTP2_RST_STREAM, ==, user_data.sent_frame_type); nghttp2_bufs_free(&bufs); nghttp2_frame_headers_free(&frame.headers, mem); @@ -889,11 +1056,11 @@ void test_nghttp2_session_recv_eof(void) { nghttp2_session_callbacks callbacks; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; - callbacks.recv_callback = eof_recv_callback; + callbacks.send_callback2 = null_send_callback; + callbacks.recv_callback2 = eof_recv_callback; nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_EOF == nghttp2_session_recv(session)); + assert_int(NGHTTP2_ERR_EOF, ==, nghttp2_session_recv(session)); nghttp2_session_del(session); } @@ -903,14 +1070,14 @@ void test_nghttp2_session_recv_data(void) { nghttp2_session_callbacks callbacks; my_user_data ud; uint8_t data[8092]; - ssize_t rv; + nghttp2_ssize rv; nghttp2_outbound_item *item; nghttp2_stream *stream; nghttp2_frame_hd hd; int i; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_data_chunk_recv_callback = on_data_chunk_recv_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; callbacks.on_frame_send_callback = on_frame_send_callback; @@ -929,13 +1096,13 @@ void test_nghttp2_session_recv_data(void) { error. This is not mandated by the spec */ ud.data_chunk_recv_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); - CU_ASSERT(0 == ud.data_chunk_recv_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, ud.data_chunk_recv_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); @@ -950,40 +1117,40 @@ void test_nghttp2_session_recv_data(void) { ud.data_chunk_recv_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); - CU_ASSERT(0 == ud.data_chunk_recv_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, ud.data_chunk_recv_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL == item); + assert_null(item); /* This is normal case. DATA is acceptable. */ stream->state = NGHTTP2_STREAM_OPENED; ud.data_chunk_recv_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); - CU_ASSERT(1 == ud.data_chunk_recv_cb_called); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_int(1, ==, ud.data_chunk_recv_cb_called); + assert_int(1, ==, ud.frame_recv_cb_called); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); ud.data_chunk_recv_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); /* Now we got data more than initial-window-size / 2, WINDOW_UPDATE must be queued */ - CU_ASSERT(1 == ud.data_chunk_recv_cb_called); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_int(1, ==, ud.data_chunk_recv_cb_called); + assert_int(1, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(1 == item->frame.window_update.hd.stream_id); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.window_update.hd.stream_id); + assert_int(0, ==, nghttp2_session_send(session)); /* Set initial window size to 1MiB, so that we can check connection flow control individually */ @@ -993,13 +1160,13 @@ void test_nghttp2_session_recv_data(void) { DATA. Additional 4 DATA frames, connection flow control will kick in. */ for (i = 0; i < 5; ++i) { - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); } item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(0 == item->frame.window_update.hd.stream_id); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.window_update.hd.stream_id); + assert_int(0, ==, nghttp2_session_send(session)); /* Reception of DATA with stream ID = 0 causes connection error */ hd.length = 4096; @@ -1010,14 +1177,14 @@ void test_nghttp2_session_recv_data(void) { ud.data_chunk_recv_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); - CU_ASSERT(0 == ud.data_chunk_recv_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, ud.data_chunk_recv_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); nghttp2_session_del(session); @@ -1036,20 +1203,20 @@ void test_nghttp2_session_recv_data(void) { it triggers first WINDOW_UPDATE of window_size_increment 32767. */ for (i = 0; i < 7; ++i) { - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); } hd.length = 4095; nghttp2_frame_pack_frame_hd(data, &hd); - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4095); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4095 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4095); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4095, ==, rv); /* Now 2 WINDOW_UPDATEs for session and stream should be queued. */ - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(1 == stream->window_update_queued); - CU_ASSERT(1 == session->window_update_queued); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(0, ==, session->recv_window_size); + assert_true(stream->window_update_queued); + assert_true(session->window_update_queued); /* Then send 32768 bytes of DATA. Since we have not sent queued WINDOW_UDPATE frame, recv_window_size should not be decreased */ @@ -1057,29 +1224,29 @@ void test_nghttp2_session_recv_data(void) { nghttp2_frame_pack_frame_hd(data, &hd); for (i = 0; i < 8; ++i) { - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); } /* WINDOW_UPDATE is blocked for session and stream, so recv_window_size must not be decreased. */ - CU_ASSERT(32768 == stream->recv_window_size); - CU_ASSERT(32768 == session->recv_window_size); - CU_ASSERT(1 == stream->window_update_queued); - CU_ASSERT(1 == session->window_update_queued); + assert_int32(32768, ==, stream->recv_window_size); + assert_int32(32768, ==, session->recv_window_size); + assert_true(stream->window_update_queued); + assert_true(session->window_update_queued); ud.frame_send_cb_called = 0; /* This sends queued WINDOW_UPDATES. And then check recv_window_size, and queue WINDOW_UPDATEs for both session and stream, and send them at once. */ - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(4 == ud.frame_send_cb_called); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(0 == stream->window_update_queued); - CU_ASSERT(0 == session->window_update_queued); + assert_int(4, ==, ud.frame_send_cb_called); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(0, ==, session->recv_window_size); + assert_false(stream->window_update_queued); + assert_false(session->window_update_queued); nghttp2_session_del(session); } @@ -1092,13 +1259,13 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) { nghttp2_frame_hd hd; size_t padlen; uint8_t data[8192]; - ssize_t rv; + nghttp2_ssize rv; size_t sendlen; nghttp2_stream *stream; size_t i; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; nghttp2_option_new(&option); @@ -1122,11 +1289,11 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) { /* Receive first 100 bytes */ sendlen = 100; - rv = nghttp2_session_mem_recv(session, data, sendlen); - CU_ASSERT((ssize_t)sendlen == rv); + rv = nghttp2_session_mem_recv2(session, data, sendlen); + assert_ptrdiff((nghttp2_ssize)sendlen, ==, rv); /* We consumed pad length field (1 byte) */ - CU_ASSERT(1 == session->consumed_size); + assert_int32(1, ==, session->consumed_size); /* close stream here */ nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_NO_ERROR); @@ -1134,13 +1301,14 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) { /* stream 1 has been closed, and we disabled auto flow-control, so data must be immediately consumed for connection. */ - rv = nghttp2_session_mem_recv(session, data + sendlen, - NGHTTP2_FRAME_HDLEN + hd.length - sendlen); - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen) == rv); + rv = nghttp2_session_mem_recv2(session, data + sendlen, + NGHTTP2_FRAME_HDLEN + hd.length - sendlen); + assert_ptrdiff((nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen), ==, + rv); /* We already consumed pad length field (1 byte), so do +1 here */ - CU_ASSERT((int32_t)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen + 1) == - session->consumed_size); + assert_int32((int32_t)(NGHTTP2_FRAME_HDLEN + hd.length - sendlen + 1), ==, + session->consumed_size); nghttp2_session_del(session); @@ -1153,12 +1321,13 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) { stream = open_recv_stream(session, 1); stream->http_flags |= NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE; - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + hd.length); - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length) == rv); + rv = + nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + hd.length); + assert_ptrdiff((nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + hd.length), ==, rv); /* Whole payload must be consumed now because HTTP messaging rule was not honored. */ - CU_ASSERT((int32_t)hd.length == session->consumed_size); + assert_int32((int32_t)hd.length, ==, session->consumed_size); nghttp2_session_del(session); @@ -1175,57 +1344,57 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) { /* Receive up to 65535 bytes of DATA */ for (i = 0; i < 15; ++i) { - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4096); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4096 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4096); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4096, ==, rv); } hd.length = 4095; nghttp2_frame_pack_frame_hd(data, &hd); - rv = nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 4095); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 4095 == rv); + rv = nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 4095); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 4095, ==, rv); - CU_ASSERT(65535 == session->recv_window_size); - CU_ASSERT(65535 == stream->recv_window_size); + assert_int32(65535, ==, session->recv_window_size); + assert_int32(65535, ==, stream->recv_window_size); /* The first call of nghttp2_session_consume_connection() will queue WINDOW_UPDATE. Next call does not. */ nghttp2_session_consume_connection(session, 32767); nghttp2_session_consume_connection(session, 32768); - CU_ASSERT(32768 == session->recv_window_size); - CU_ASSERT(65535 == stream->recv_window_size); - CU_ASSERT(1 == session->window_update_queued); - CU_ASSERT(0 == stream->window_update_queued); + assert_int32(32768, ==, session->recv_window_size); + assert_int32(65535, ==, stream->recv_window_size); + assert_true(session->window_update_queued); + assert_false(stream->window_update_queued); ud.frame_send_cb_called = 0; /* This will send WINDOW_UPDATE, and check whether we should send WINDOW_UPDATE, and queue and send it at once. */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(65535 == stream->recv_window_size); - CU_ASSERT(0 == session->window_update_queued); - CU_ASSERT(0 == stream->window_update_queued); - CU_ASSERT(2 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(0, ==, session->recv_window_size); + assert_int32(65535, ==, stream->recv_window_size); + assert_false(session->window_update_queued); + assert_false(stream->window_update_queued); + assert_int(2, ==, ud.frame_send_cb_called); /* Do the same for stream */ nghttp2_session_consume_stream(session, 1, 32767); nghttp2_session_consume_stream(session, 1, 32768); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(32768 == stream->recv_window_size); - CU_ASSERT(0 == session->window_update_queued); - CU_ASSERT(1 == stream->window_update_queued); + assert_int32(0, ==, session->recv_window_size); + assert_int32(32768, ==, stream->recv_window_size); + assert_false(session->window_update_queued); + assert_true(stream->window_update_queued); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(0 == session->window_update_queued); - CU_ASSERT(0 == stream->window_update_queued); - CU_ASSERT(2 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(0, ==, session->recv_window_size); + assert_int32(0, ==, stream->recv_window_size); + assert_false(session->window_update_queued); + assert_false(stream->window_update_queued); + assert_int(2, ==, ud.frame_send_cb_called); nghttp2_session_del(session); nghttp2_option_del(option); @@ -1239,7 +1408,7 @@ void test_nghttp2_session_recv_continuation(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_hd_deflater deflater; uint8_t data[1024]; @@ -1267,8 +1436,8 @@ void test_nghttp2_session_recv_continuation(void) { NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); /* make sure that all data is in the first buf */ buf = &bufs.head->buf; @@ -1305,15 +1474,15 @@ void test_nghttp2_session_recv_continuation(void) { datalen += cont_hd.length; buf->pos += cont_hd.length; - CU_ASSERT(0 == nghttp2_buf_len(buf)); + assert_size(0, ==, nghttp2_buf_len(buf)); ud.header_cb_called = 0; ud.begin_frame_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, datalen); - CU_ASSERT((ssize_t)datalen == rv); - CU_ASSERT(4 == ud.header_cb_called); - CU_ASSERT(3 == ud.begin_frame_cb_called); + rv = nghttp2_session_mem_recv2(session, data, datalen); + assert_ptrdiff((nghttp2_ssize)datalen, ==, rv); + assert_int(4, ==, ud.header_cb_called); + assert_int(3, ==, ud.begin_frame_cb_called); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -1331,7 +1500,7 @@ void test_nghttp2_session_recv_continuation(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1361,16 +1530,16 @@ void test_nghttp2_session_recv_continuation(void) { datalen += cont_hd.length; buf->pos += cont_hd.length; - CU_ASSERT(0 == nghttp2_buf_len(buf)); + assert_size(0, ==, nghttp2_buf_len(buf)); ud.header_cb_called = 0; ud.begin_frame_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, datalen); + rv = nghttp2_session_mem_recv2(session, data, datalen); - CU_ASSERT((ssize_t)datalen == rv); - CU_ASSERT(4 == ud.header_cb_called); - CU_ASSERT(2 == ud.begin_frame_cb_called); + assert_ptrdiff((nghttp2_ssize)datalen, ==, rv); + assert_int(4, ==, ud.header_cb_called); + assert_int(2, ==, ud.begin_frame_cb_called); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -1388,8 +1557,8 @@ void test_nghttp2_session_recv_continuation(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1408,18 +1577,18 @@ void test_nghttp2_session_recv_continuation(void) { nghttp2_frame_pack_priority(&bufs, &frame.priority); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_size(0, <, nghttp2_bufs_len(&bufs)); memcpy(data + datalen, buf->pos, nghttp2_buf_len(buf)); datalen += nghttp2_buf_len(buf); ud.begin_headers_cb_called = 0; - rv = nghttp2_session_mem_recv(session, data, datalen); - CU_ASSERT((ssize_t)datalen == rv); + rv = nghttp2_session_mem_recv2(session, data, datalen); + assert_ptrdiff((nghttp2_ssize)datalen, ==, rv); - CU_ASSERT(1 == ud.begin_headers_cb_called); - CU_ASSERT(NGHTTP2_GOAWAY == - nghttp2_session_get_next_ob_item(session)->frame.hd.type); + assert_int(1, ==, ud.begin_headers_cb_called); + assert_uint8(NGHTTP2_GOAWAY, ==, + nghttp2_session_get_next_ob_item(session)->frame.hd.type); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -1434,7 +1603,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_hd_deflater deflater; nghttp2_outbound_item *item; @@ -1466,8 +1635,8 @@ void test_nghttp2_session_recv_headers_with_priority(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1476,15 +1645,15 @@ void test_nghttp2_session_recv_headers_with_priority(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); stream = nghttp2_session_get_stream(session, 3); - CU_ASSERT(99 == stream->weight); - CU_ASSERT(1 == stream->dep_prev->stream_id); + assert_int32(99, ==, stream->weight); + assert_int32(1, ==, stream->dep_prev->stream_id); nghttp2_bufs_reset(&bufs); @@ -1501,8 +1670,8 @@ void test_nghttp2_session_recv_headers_with_priority(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > NGHTTP2_FRAME_HDLEN + 5); + assert_ptrdiff(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN + 5, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1513,19 +1682,19 @@ void test_nghttp2_session_recv_headers_with_priority(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); stream = nghttp2_session_get_stream(session, 5); - CU_ASSERT(NULL == stream); + assert_null(stream); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_FRAME_SIZE_ERROR == item->frame.goaway.error_code); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_FRAME_SIZE_ERROR, ==, item->frame.goaway.error_code); nghttp2_bufs_reset(&bufs); @@ -1548,8 +1717,8 @@ void test_nghttp2_session_recv_headers_with_priority(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1558,19 +1727,19 @@ void test_nghttp2_session_recv_headers_with_priority(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NULL == stream); + assert_null(stream); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); nghttp2_bufs_reset(&bufs); @@ -1587,13 +1756,13 @@ void test_nghttp2_session_recv_headers_with_padding(void) { nghttp2_frame_hd hd; nghttp2_outbound_item *item; my_user_data ud; - ssize_t rv; + nghttp2_ssize rv; frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_recv_callback = on_frame_recv_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* HEADERS: Wrong padding length */ nghttp2_session_server_new(&session, &callbacks, &ud); @@ -1618,15 +1787,15 @@ void test_nghttp2_session_recv_headers_with_padding(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_bufs_reset(&bufs); nghttp2_session_del(session); @@ -1653,15 +1822,15 @@ void test_nghttp2_session_recv_headers_with_padding(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_bufs_free(&bufs); nghttp2_session_del(session); @@ -1677,10 +1846,10 @@ static int response_on_begin_frame_callback(nghttp2_session *session, return 0; } - rv = nghttp2_submit_response(session, hd->stream_id, resnv, ARRLEN(resnv), - NULL); + rv = nghttp2_submit_response2(session, hd->stream_id, resnv, ARRLEN(resnv), + NULL); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); return 0; } @@ -1695,14 +1864,14 @@ void test_nghttp2_session_recv_headers_early_response(void) { nghttp2_nv *nva; size_t nvlen; nghttp2_frame frame; - ssize_t rv; + nghttp2_ssize rv; nghttp2_stream *stream; mem = nghttp2_mem_default(); frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_begin_frame_callback = response_on_begin_frame_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -1717,7 +1886,7 @@ void test_nghttp2_session_recv_headers_early_response(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1725,22 +1894,22 @@ void test_nghttp2_session_recv_headers_early_response(void) { /* Only receive 9 bytes headers, and invoke on_begin_frame_callback */ - rv = nghttp2_session_mem_recv(session, buf->pos, 9); + rv = nghttp2_session_mem_recv2(session, buf->pos, 9); - CU_ASSERT(9 == rv); + assert_ptrdiff(9, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = - nghttp2_session_mem_recv(session, buf->pos + 9, nghttp2_buf_len(buf) - 9); + rv = nghttp2_session_mem_recv2(session, buf->pos + 9, + nghttp2_buf_len(buf) - 9); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) - 9 == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf) - 9, ==, rv); stream = nghttp2_session_get_stream_raw(session, 1); - CU_ASSERT(stream->flags & NGHTTP2_STREAM_FLAG_CLOSED); + assert_true(stream->flags & NGHTTP2_STREAM_FLAG_CLOSED); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -1755,7 +1924,7 @@ void test_nghttp2_session_recv_headers_for_closed_stream(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_hd_deflater deflater; nghttp2_stream *stream; @@ -1783,8 +1952,8 @@ void test_nghttp2_session_recv_headers_for_closed_stream(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1794,38 +1963,39 @@ void test_nghttp2_session_recv_headers_for_closed_stream(void) { ud.header_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, NGHTTP2_FRAME_HDLEN); + rv = nghttp2_session_mem_recv2(session, buf->pos, NGHTTP2_FRAME_HDLEN); - CU_ASSERT(NGHTTP2_FRAME_HDLEN == rv); - CU_ASSERT(0 == ud.header_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN, ==, rv); + assert_int(0, ==, ud.header_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NULL != stream); + assert_not_null(stream); rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_send(session, &data); + rv = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(rv > 0); + assert_ptrdiff(0, <, rv); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NULL == stream); + assert_null(stream); ud.header_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos + NGHTTP2_FRAME_HDLEN, - nghttp2_buf_len(buf) - NGHTTP2_FRAME_HDLEN); + rv = nghttp2_session_mem_recv2(session, buf->pos + NGHTTP2_FRAME_HDLEN, + nghttp2_buf_len(buf) - NGHTTP2_FRAME_HDLEN); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) - NGHTTP2_FRAME_HDLEN == rv); - CU_ASSERT(0 == ud.header_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf) - NGHTTP2_FRAME_HDLEN, ==, + rv); + assert_int(0, ==, ud.header_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -1840,7 +2010,7 @@ void test_nghttp2_session_recv_headers_with_extpri(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; nghttp2_hd_deflater deflater; nghttp2_stream *stream; nghttp2_mem *mem; @@ -1873,20 +2043,20 @@ void test_nghttp2_session_recv_headers_with_extpri(void) { rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); buf = &bufs.head->buf; assert(nghttp2_bufs_len(&bufs) == nghttp2_buf_len(buf)); - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(2 == nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_uint32(2, ==, nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -1911,22 +2081,22 @@ void test_nghttp2_session_recv_headers_with_extpri(void) { rv = nghttp2_frame_pack_push_promise(&bufs, &frame.push_promise, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_push_promise_free(&frame.push_promise, mem); buf = &bufs.head->buf; assert(nghttp2_bufs_len(&bufs) == nghttp2_buf_len(buf)); - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY == - nghttp2_extpri_uint8_urgency(stream->http_extpri)); - CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY == - nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_uint32(NGHTTP2_EXTPRI_DEFAULT_URGENCY, ==, + nghttp2_extpri_uint8_urgency(stream->http_extpri)); + assert_uint32(NGHTTP2_EXTPRI_DEFAULT_URGENCY, ==, + nghttp2_extpri_uint8_urgency(stream->extpri)); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -1938,7 +2108,7 @@ void test_nghttp2_session_server_recv_push_response(void) { nghttp2_session_callbacks callbacks; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_mem *mem; nghttp2_frame frame; @@ -1965,8 +2135,8 @@ void test_nghttp2_session_server_recv_push_response(void) { nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -1974,10 +2144,10 @@ void test_nghttp2_session_server_recv_push_response(void) { ud.invalid_frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == ud.invalid_frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(1, ==, ud.invalid_frame_recv_cb_called); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -1989,7 +2159,7 @@ void test_nghttp2_session_recv_premature_headers(void) { nghttp2_session_callbacks callbacks; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_hd_deflater deflater; nghttp2_outbound_item *item; @@ -2000,7 +2170,7 @@ void test_nghttp2_session_recv_premature_headers(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); @@ -2013,17 +2183,18 @@ void test_nghttp2_session_recv_premature_headers(void) { /* Intentionally feed payload cutting last 1 byte off */ payloadlen = nghttp2_get_uint32(buf->pos) >> 8; nghttp2_put_uint32be(buf->pos, ((payloadlen - 1) << 8) + buf->pos[3]); - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf) - 1); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf) - 1); - CU_ASSERT((ssize_t)(nghttp2_buf_len(buf) - 1) == rv); + assert_ptrdiff((nghttp2_ssize)(nghttp2_buf_len(buf) - 1), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_COMPRESSION_ERROR == item->frame.rst_stream.error_code); - CU_ASSERT(1 == item->frame.hd.stream_id); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_not_null(item); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_COMPRESSION_ERROR, ==, + item->frame.rst_stream.error_code); + assert_int32(1, ==, item->frame.hd.stream_id); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -2039,23 +2210,24 @@ void test_nghttp2_session_recv_premature_headers(void) { rv = pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 2, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); buf = &bufs.head->buf; payloadlen = nghttp2_get_uint32(buf->pos) >> 8; /* Intentionally feed payload cutting last 1 byte off */ nghttp2_put_uint32be(buf->pos, ((payloadlen - 1) << 8) + buf->pos[3]); - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf) - 1); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf) - 1); - CU_ASSERT((ssize_t)(nghttp2_buf_len(buf) - 1) == rv); + assert_ptrdiff((nghttp2_ssize)(nghttp2_buf_len(buf) - 1), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_COMPRESSION_ERROR == item->frame.rst_stream.error_code); - CU_ASSERT(2 == item->frame.hd.stream_id); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_not_null(item); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_COMPRESSION_ERROR, ==, + item->frame.rst_stream.error_code); + assert_int32(2, ==, item->frame.hd.stream_id); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -2069,7 +2241,7 @@ void test_nghttp2_session_recv_unknown_frame(void) { uint8_t data[16384]; size_t datalen; nghttp2_frame_hd hd; - ssize_t rv; + nghttp2_ssize rv; nghttp2_frame_hd_init(&hd, 16000, 99, NGHTTP2_FLAG_NONE, 0); @@ -2084,11 +2256,11 @@ void test_nghttp2_session_recv_unknown_frame(void) { ud.frame_recv_cb_called = 0; /* Unknown frame must be ignored */ - rv = nghttp2_session_mem_recv(session, data, datalen); + rv = nghttp2_session_mem_recv2(session, data, datalen); - CU_ASSERT(rv == (ssize_t)datalen); - CU_ASSERT(0 == ud.frame_recv_cb_called); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_ptrdiff(rv, ==, (nghttp2_ssize)datalen); + assert_int(0, ==, ud.frame_recv_cb_called); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_session_del(session); } @@ -2100,7 +2272,7 @@ void test_nghttp2_session_recv_unexpected_continuation(void) { uint8_t data[16384]; size_t datalen; nghttp2_frame_hd hd; - ssize_t rv; + nghttp2_ssize rv; nghttp2_outbound_item *item; nghttp2_frame_hd_init(&hd, 16000, NGHTTP2_CONTINUATION, @@ -2119,14 +2291,14 @@ void test_nghttp2_session_recv_unexpected_continuation(void) { ud.frame_recv_cb_called = 0; /* unexpected CONTINUATION must be treated as connection error */ - rv = nghttp2_session_mem_recv(session, data, datalen); + rv = nghttp2_session_mem_recv2(session, data, datalen); - CU_ASSERT(rv == (ssize_t)datalen); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff(rv, ==, (nghttp2_ssize)datalen); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); } @@ -2137,7 +2309,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_settings_entry iv[3]; nghttp2_nv nv = MAKE_NV(":authority", "example.org"); @@ -2148,7 +2320,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_recv_callback = on_frame_recv_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, &ud); @@ -2163,8 +2335,8 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -2173,13 +2345,13 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); - CU_ASSERT(3000 == session->remote_settings.header_table_size); - CU_ASSERT(16384 == session->remote_settings.initial_window_size); + assert_uint32(3000, ==, session->remote_settings.header_table_size); + assert_uint32(16384, ==, session->remote_settings.initial_window_size); nghttp2_bufs_reset(&bufs); @@ -2198,8 +2370,8 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -2208,23 +2380,23 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)(nghttp2_buf_len(buf)) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)(nghttp2_buf_len(buf)), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); - CU_ASSERT(3001 == session->remote_settings.header_table_size); - CU_ASSERT(16383 == session->remote_settings.initial_window_size); + assert_uint32(3001, ==, session->remote_settings.header_table_size); + assert_uint32(16383, ==, session->remote_settings.initial_window_size); nghttp2_bufs_reset(&bufs); /* 2 SETTINGS_HEADER_TABLE_SIZE; first entry clears dynamic header table. */ - nghttp2_submit_request(session, NULL, &nv, 1, NULL, NULL); + nghttp2_submit_request2(session, NULL, &nv, 1, NULL, NULL); nghttp2_session_send(session); - CU_ASSERT(0 < session->hd_deflater.ctx.hd_table.len); + assert_size(0, <, session->hd_deflater.ctx.hd_table.len); iv[0].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[0].value = 0; @@ -2240,8 +2412,8 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -2250,24 +2422,24 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); - CU_ASSERT(4096 == session->remote_settings.header_table_size); - CU_ASSERT(16382 == session->remote_settings.initial_window_size); - CU_ASSERT(0 == session->hd_deflater.ctx.hd_table.len); + assert_uint32(4096, ==, session->remote_settings.header_table_size); + assert_uint32(16382, ==, session->remote_settings.initial_window_size); + assert_size(0, ==, session->hd_deflater.ctx.hd_table.len); nghttp2_bufs_reset(&bufs); /* 2 SETTINGS_HEADER_TABLE_SIZE; second entry clears dynamic header table. */ - nghttp2_submit_request(session, NULL, &nv, 1, NULL, NULL); + nghttp2_submit_request2(session, NULL, &nv, 1, NULL, NULL); nghttp2_session_send(session); - CU_ASSERT(0 < session->hd_deflater.ctx.hd_table.len); + assert_size(0, <, session->hd_deflater.ctx.hd_table.len); iv[0].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[0].value = 3000; @@ -2283,8 +2455,8 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -2293,14 +2465,14 @@ void test_nghttp2_session_recv_settings_header_table_size(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); - CU_ASSERT(0 == session->remote_settings.header_table_size); - CU_ASSERT(16381 == session->remote_settings.initial_window_size); - CU_ASSERT(0 == session->hd_deflater.ctx.hd_table.len); + assert_uint32(0, ==, session->remote_settings.header_table_size); + assert_uint32(16381, ==, session->remote_settings.initial_window_size); + assert_size(0, ==, session->hd_deflater.ctx.hd_table.len); nghttp2_bufs_reset(&bufs); @@ -2325,12 +2497,13 @@ void test_nghttp2_session_recv_too_large_frame_length(void) { nghttp2_frame_pack_frame_hd(buf, &hd); - CU_ASSERT(sizeof(buf) == nghttp2_session_mem_recv(session, buf, sizeof(buf))); + assert_ptrdiff(sizeof(buf), ==, + nghttp2_session_mem_recv2(session, buf, sizeof(buf))); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item != NULL); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); } @@ -2343,7 +2516,7 @@ void test_nghttp2_session_recv_extension(void) { nghttp2_frame_hd hd; nghttp2_mem *mem; const char data[] = "Hello World!"; - ssize_t rv; + nghttp2_ssize rv; nghttp2_option *option; mem = nghttp2_mem_default(); @@ -2368,13 +2541,13 @@ void test_nghttp2_session_recv_extension(void) { nghttp2_session_client_new2(&session, &callbacks, &ud, option); nghttp2_frame_hd_init(&ud.recv_frame_hd, 0, 0, 0, 0); - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + hd.length == (size_t)rv); - CU_ASSERT(111 == ud.recv_frame_hd.type); - CU_ASSERT(0xab == ud.recv_frame_hd.flags); - CU_ASSERT(1000000007 == ud.recv_frame_hd.stream_id); - CU_ASSERT(0 == memcmp(data, ud.scratchbuf.pos, sizeof(data))); + assert_size(NGHTTP2_FRAME_HDLEN + hd.length, ==, (size_t)rv); + assert_uint8(111, ==, ud.recv_frame_hd.type); + assert_uint8(0xab, ==, ud.recv_frame_hd.flags); + assert_int32(1000000007, ==, ud.recv_frame_hd.stream_id); + assert_memory_equal(sizeof(data), data, ud.scratchbuf.pos); nghttp2_session_del(session); @@ -2387,10 +2560,10 @@ void test_nghttp2_session_recv_extension(void) { nghttp2_session_server_new2(&session, &callbacks, &ud, option); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + hd.length == (size_t)rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_size(NGHTTP2_FRAME_HDLEN + hd.length, ==, (size_t)rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -2403,10 +2576,10 @@ void test_nghttp2_session_recv_extension(void) { nghttp2_session_server_new2(&session, &callbacks, &ud, option); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + hd.length == (size_t)rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_size(NGHTTP2_FRAME_HDLEN + hd.length, ==, (size_t)rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -2423,7 +2596,7 @@ void test_nghttp2_session_recv_altsvc(void) { nghttp2_buf buf; nghttp2_frame_hd hd; nghttp2_mem *mem; - ssize_t rv; + nghttp2_ssize rv; nghttp2_option *option; static const uint8_t origin[] = "nghttp2.org"; static const uint8_t field_value[] = "h2=\":443\""; @@ -2453,13 +2626,13 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, field_value, sizeof(field_value) - 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_ALTSVC == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == ud.recv_frame_hd.flags); - CU_ASSERT(0 == ud.recv_frame_hd.stream_id); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_ALTSVC, ==, ud.recv_frame_hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, ud.recv_frame_hd.flags); + assert_int32(0, ==, ud.recv_frame_hd.stream_id); nghttp2_session_del(session); @@ -2477,10 +2650,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, origin, sizeof(origin) - 1 - 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -2498,10 +2671,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, origin, sizeof(origin) - 1); ud.invalid_frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(1 == ud.invalid_frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(1, ==, ud.invalid_frame_recv_cb_called); nghttp2_session_del(session); @@ -2522,10 +2695,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, field_value, sizeof(field_value) - 1); ud.invalid_frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(1 == ud.invalid_frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(1, ==, ud.invalid_frame_recv_cb_called); nghttp2_session_del(session); @@ -2543,10 +2716,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, field_value, sizeof(field_value) - 1); ud.invalid_frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(1 == ud.invalid_frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(1, ==, ud.invalid_frame_recv_cb_called); nghttp2_session_del(session); @@ -2566,12 +2739,12 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last += nghttp2_buf_avail(&buf); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_ALTSVC == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_MAX_FRAME_SIZE_MIN == ud.recv_frame_hd.length); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_ALTSVC, ==, ud.recv_frame_hd.type); + assert_size(NGHTTP2_MAX_FRAME_SIZE_MIN, ==, ud.recv_frame_hd.length); nghttp2_session_del(session); @@ -2593,10 +2766,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last += nghttp2_buf_avail(&buf); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -2615,10 +2788,10 @@ void test_nghttp2_session_recv_altsvc(void) { buf.last = nghttp2_cpymem(buf.last, field_value, sizeof(field_value) - 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf.pos, nghttp2_buf_len(&buf)); + rv = nghttp2_session_mem_recv2(session, buf.pos, nghttp2_buf_len(&buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -2631,7 +2804,7 @@ void test_nghttp2_session_recv_origin(void) { nghttp2_session_callbacks callbacks; my_user_data ud; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; nghttp2_option *option; nghttp2_extension frame; nghttp2_ext_origin origin; @@ -2658,17 +2831,17 @@ void test_nghttp2_session_recv_origin(void) { rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_ORIGIN == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == ud.recv_frame_hd.flags); - CU_ASSERT(0 == ud.recv_frame_hd.stream_id); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_ORIGIN, ==, ud.recv_frame_hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, ud.recv_frame_hd.flags); + assert_int32(0, ==, ud.recv_frame_hd.stream_id); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2679,17 +2852,17 @@ void test_nghttp2_session_recv_origin(void) { nghttp2_frame_origin_init(&frame, &ov, 1); rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_put_uint16be(bufs.head->buf.pos + NGHTTP2_FRAME_HDLEN, (uint16_t)sizeof(nghttp2)); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2702,14 +2875,14 @@ void test_nghttp2_session_recv_origin(void) { frame.hd.stream_id = 1; rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2721,14 +2894,14 @@ void test_nghttp2_session_recv_origin(void) { frame.hd.flags = 0xf0; rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2739,14 +2912,14 @@ void test_nghttp2_session_recv_origin(void) { nghttp2_frame_origin_init(&frame, &ov, 1); rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2757,15 +2930,15 @@ void test_nghttp2_session_recv_origin(void) { nghttp2_frame_origin_init(&frame, NULL, 0); rv = nghttp2_frame_pack_origin(&bufs, &frame); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_ORIGIN == ud.recv_frame_hd.type); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_ORIGIN, ==, ud.recv_frame_hd.type); nghttp2_session_del(session); @@ -2778,7 +2951,7 @@ void test_nghttp2_session_recv_priority_update(void) { nghttp2_session_callbacks callbacks; my_user_data ud; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; nghttp2_option *option; nghttp2_extension frame; nghttp2_ext_priority_update priority_update; @@ -2820,19 +2993,19 @@ void test_nghttp2_session_recv_priority_update(void) { open_recv_stream(session, 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_PRIORITY_UPDATE == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == ud.recv_frame_hd.flags); - CU_ASSERT(0 == ud.recv_frame_hd.stream_id); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_PRIORITY_UPDATE, ==, ud.recv_frame_hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, ud.recv_frame_hd.flags); + assert_int32(0, ==, ud.recv_frame_hd.stream_id); stream = nghttp2_session_get_stream_raw(session, 1); - CU_ASSERT(2 == nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_uint32(2, ==, nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2849,38 +3022,38 @@ void test_nghttp2_session_recv_priority_update(void) { nghttp2_frame_pack_priority_update(&bufs, &frame); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_PRIORITY_UPDATE == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == ud.recv_frame_hd.flags); - CU_ASSERT(0 == ud.recv_frame_hd.stream_id); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_PRIORITY_UPDATE, ==, ud.recv_frame_hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, ud.recv_frame_hd.flags); + assert_int32(0, ==, ud.recv_frame_hd.stream_id); stream = nghttp2_session_get_stream_raw(session, 1); - CU_ASSERT(NGHTTP2_STREAM_IDLE == stream->state); - CU_ASSERT(2 == nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, stream->state); + assert_uint32(2, ==, nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); nghttp2_hd_deflate_init(&deflater, mem); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.recv_frame_hd.type); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); - CU_ASSERT(2 == nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.recv_frame_hd.type); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); + assert_uint32(2, ==, nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); nghttp2_hd_deflate_free(&deflater); @@ -2900,15 +3073,15 @@ void test_nghttp2_session_recv_priority_update(void) { open_recv_stream(session, 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); stream = nghttp2_session_get_stream_raw(session, 1); - CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY == stream->extpri); + assert_uint32(NGHTTP2_EXTPRI_DEFAULT_URGENCY, ==, stream->extpri); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2926,15 +3099,15 @@ void test_nghttp2_session_recv_priority_update(void) { open_sent_stream(session, 1); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); nghttp2_session_del(session); nghttp2_bufs_reset(&bufs); @@ -2953,23 +3126,23 @@ void test_nghttp2_session_recv_priority_update(void) { nghttp2_frame_pack_priority_update(&bufs, &frame); ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); if (i < 100) { - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_PRIORITY_UPDATE == ud.recv_frame_hd.type); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_uint8(NGHTTP2_PRIORITY_UPDATE, ==, ud.recv_frame_hd.type); } else { - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); } nghttp2_bufs_reset(&bufs); } item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); nghttp2_session_del(session); nghttp2_option_del(option); @@ -2986,7 +3159,7 @@ void test_nghttp2_session_continue(void) { nghttp2_bufs bufs; nghttp2_buf *buf; size_t framelen1, framelen2; - ssize_t rv; + nghttp2_ssize rv; uint8_t buffer[4096]; nghttp2_buf databuf; nghttp2_frame frame; @@ -3002,7 +3175,7 @@ void test_nghttp2_session_continue(void) { nghttp2_buf_wrap_init(&databuf, buffer, sizeof(buffer)); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; callbacks.on_data_chunk_recv_callback = pause_on_data_chunk_recv_callback; callbacks.on_header_callback = pause_on_header_callback; @@ -3021,8 +3194,8 @@ void test_nghttp2_session_continue(void) { NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3039,8 +3212,8 @@ void test_nghttp2_session_continue(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3052,80 +3225,80 @@ void test_nghttp2_session_continue(void) { /* Receive 1st HEADERS and pause */ user_data.begin_headers_cb_called = 0; user_data.header_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(rv >= 0); + assert_ptrdiff(0, <=, rv); databuf.pos += rv; recv_frame = user_data.frame; - CU_ASSERT(NGHTTP2_HEADERS == recv_frame->hd.type); - CU_ASSERT(framelen1 - NGHTTP2_FRAME_HDLEN == recv_frame->hd.length); + assert_uint8(NGHTTP2_HEADERS, ==, recv_frame->hd.type); + assert_size(framelen1 - NGHTTP2_FRAME_HDLEN, ==, recv_frame->hd.length); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.header_cb_called); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.header_cb_called); - CU_ASSERT(nghttp2_nv_equal(&nv1[0], &user_data.nv)); + assert_true(nghttp2_nv_equal(&nv1[0], &user_data.nv)); /* get 2nd header field */ user_data.begin_headers_cb_called = 0; user_data.header_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(rv >= 0); + assert_ptrdiff(0, <=, rv); databuf.pos += rv; - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.header_cb_called); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.header_cb_called); - CU_ASSERT(nghttp2_nv_equal(&nv1[1], &user_data.nv)); + assert_true(nghttp2_nv_equal(&nv1[1], &user_data.nv)); /* will call end_headers_callback and receive 2nd HEADERS and pause */ user_data.begin_headers_cb_called = 0; user_data.header_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(rv >= 0); + assert_ptrdiff(0, <=, rv); databuf.pos += rv; recv_frame = user_data.frame; - CU_ASSERT(NGHTTP2_HEADERS == recv_frame->hd.type); - CU_ASSERT(framelen2 - NGHTTP2_FRAME_HDLEN == recv_frame->hd.length); + assert_uint8(NGHTTP2_HEADERS, ==, recv_frame->hd.type); + assert_size(framelen2 - NGHTTP2_FRAME_HDLEN, ==, recv_frame->hd.length); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.header_cb_called); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.header_cb_called); - CU_ASSERT(nghttp2_nv_equal(&nv2[0], &user_data.nv)); + assert_true(nghttp2_nv_equal(&nv2[0], &user_data.nv)); /* get 2nd header field */ user_data.begin_headers_cb_called = 0; user_data.header_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(rv >= 0); + assert_ptrdiff(0, <=, rv); databuf.pos += rv; - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.header_cb_called); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.header_cb_called); - CU_ASSERT(nghttp2_nv_equal(&nv2[1], &user_data.nv)); + assert_true(nghttp2_nv_equal(&nv2[1], &user_data.nv)); /* No input data, frame_recv_callback is called */ user_data.begin_headers_cb_called = 0; user_data.header_cb_called = 0; user_data.frame_recv_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(rv >= 0); + assert_ptrdiff(0, <=, rv); databuf.pos += rv; - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == user_data.header_cb_called); - CU_ASSERT(1 == user_data.frame_recv_cb_called); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(0, ==, user_data.header_cb_called); + assert_int(1, ==, user_data.frame_recv_cb_called); /* Receive DATA */ nghttp2_frame_hd_init(&data_hd, 16, NGHTTP2_DATA, NGHTTP2_FLAG_NONE, 1); @@ -3138,26 +3311,26 @@ void test_nghttp2_session_continue(void) { databuf.last = databuf.end; user_data.frame_recv_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); - CU_ASSERT(16 + NGHTTP2_FRAME_HDLEN == rv); - CU_ASSERT(0 == user_data.frame_recv_cb_called); + assert_ptrdiff(16 + NGHTTP2_FRAME_HDLEN, ==, rv); + assert_int(0, ==, user_data.frame_recv_cb_called); - /* Next nghttp2_session_mem_recv invokes on_frame_recv_callback and + /* Next nghttp2_session_mem_recv2 invokes on_frame_recv_callback and pause again in on_data_chunk_recv_callback since we pass same DATA frame. */ user_data.frame_recv_cb_called = 0; - rv = - nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); - CU_ASSERT(16 + NGHTTP2_FRAME_HDLEN == rv); - CU_ASSERT(1 == user_data.frame_recv_cb_called); + rv = nghttp2_session_mem_recv2(session, databuf.pos, + nghttp2_buf_len(&databuf)); + assert_ptrdiff(16 + NGHTTP2_FRAME_HDLEN, ==, rv); + assert_int(1, ==, user_data.frame_recv_cb_called); /* And finally call on_frame_recv_callback with 0 size input */ user_data.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, NULL, 0); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == user_data.frame_recv_cb_called); + rv = nghttp2_session_mem_recv2(session, NULL, 0); + assert_ptrdiff(0, ==, rv); + assert_int(1, ==, user_data.frame_recv_cb_called); nghttp2_bufs_free(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -3177,12 +3350,13 @@ void test_nghttp2_session_add_frame(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; + callbacks.send_callback2 = accumulator_send_callback; acc.length = 0; user_data.acc = &acc; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &user_data)); + assert_int(0, ==, + nghttp2_session_client_new(&session, &callbacks, &user_data)); item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); @@ -3199,13 +3373,14 @@ void test_nghttp2_session_add_frame(void) { session->next_stream_id += 2; - CU_ASSERT(0 == nghttp2_session_add_item(session, item)); - CU_ASSERT(NULL != nghttp2_outbound_queue_top(&session->ob_syn)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_HEADERS == acc.buf[3]); - CU_ASSERT((NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY) == acc.buf[4]); + assert_int(0, ==, nghttp2_session_add_item(session, item)); + assert_not_null(nghttp2_outbound_queue_top(&session->ob_syn)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_HEADERS, ==, acc.buf[3]); + assert_uint8((NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY), ==, + acc.buf[4]); /* check stream id */ - CU_ASSERT(1 == nghttp2_get_uint32(&acc.buf[5])); + assert_uint32(1, ==, nghttp2_get_uint32(&acc.buf[5])); nghttp2_session_del(session); } @@ -3239,11 +3414,12 @@ void test_nghttp2_session_on_request_headers_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); + assert_int(0, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.begin_headers_cb_called); stream = nghttp2_session_get_stream(session, stream_id); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); - CU_ASSERT(255 == stream->weight); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); + assert_int32(255, ==, stream->weight); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3253,10 +3429,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY, 3, NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); session->local_settings.max_concurrent_streams = @@ -3268,10 +3444,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY, 3, NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3281,10 +3457,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY, 2, NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_true(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3300,9 +3476,10 @@ void test_nghttp2_session_on_request_headers_received(void) { 1, NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen); user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); + assert_int(0, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3316,10 +3493,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_HCAT_REQUEST, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_true(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3332,10 +3509,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_HCAT_REQUEST, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_true(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3352,10 +3529,10 @@ void test_nghttp2_session_on_request_headers_received(void) { NGHTTP2_HCAT_REQUEST, NULL, NULL, 0); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3369,7 +3546,8 @@ void test_nghttp2_session_on_request_headers_received(void) { nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 3, NGHTTP2_HCAT_REQUEST, NULL, NULL, 0); - CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(0, ==, + nghttp2_session_on_request_headers_received(session, &frame)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3379,10 +3557,10 @@ void test_nghttp2_session_on_request_headers_received(void) { session->goaway_flags |= NGHTTP2_GOAWAY_SENT; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3398,9 +3576,9 @@ void test_nghttp2_session_on_request_headers_received(void) { nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1, NGHTTP2_HCAT_REQUEST, NULL, NULL, 0); - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); - CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); + assert_true(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3428,10 +3606,11 @@ void test_nghttp2_session_on_response_headers_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_response_headers_received(session, &frame, - stream)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); + assert_int( + 0, ==, + nghttp2_session_on_response_headers_received(session, &frame, stream)); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); nghttp2_frame_headers_free(&frame.headers, mem); nghttp2_session_del(session); @@ -3459,26 +3638,28 @@ void test_nghttp2_session_on_headers_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); + assert_int(0, ==, + nghttp2_session_on_headers_received(session, &frame, stream)); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); /* stream closed */ frame.hd.flags |= NGHTTP2_FLAG_END_STREAM; - CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream)); - CU_ASSERT(2 == user_data.begin_headers_cb_called); + assert_int(0, ==, + nghttp2_session_on_headers_received(session, &frame, stream)); + assert_int(2, ==, user_data.begin_headers_cb_called); /* Check to see when NGHTTP2_STREAM_CLOSING, incoming HEADERS is discarded. */ stream = open_sent_stream2(session, 3, NGHTTP2_STREAM_CLOSING); frame.hd.stream_id = 3; frame.hd.flags = NGHTTP2_FLAG_END_HEADERS; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_headers_received(session, &frame, stream)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_headers_received(session, &frame, stream)); /* See no counters are updated */ - CU_ASSERT(2 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); + assert_int(2, ==, user_data.begin_headers_cb_called); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); /* Server initiated stream */ stream = open_recv_stream(session, 2); @@ -3486,16 +3667,17 @@ void test_nghttp2_session_on_headers_received(void) { frame.hd.flags = NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM; frame.hd.stream_id = 2; - CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream)); - CU_ASSERT(3 == user_data.begin_headers_cb_called); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); + assert_int(0, ==, + nghttp2_session_on_headers_received(session, &frame, stream)); + assert_int(3, ==, user_data.begin_headers_cb_called); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD); /* Further reception of HEADERS is subject to stream error */ - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_headers_received(session, &frame, stream)); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_headers_received(session, &frame, stream)); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); nghttp2_frame_headers_free(&frame.headers, mem); @@ -3513,7 +3695,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_begin_headers_callback = on_begin_headers_callback; callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback; @@ -3528,31 +3710,32 @@ void test_nghttp2_session_on_push_response_headers_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(1 == session->num_incoming_reserved_streams); - CU_ASSERT(0 == nghttp2_session_on_push_response_headers_received( - session, &frame, stream)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == session->num_incoming_reserved_streams); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(0 == (stream->flags & NGHTTP2_STREAM_FLAG_PUSH)); + assert_size(1, ==, session->num_incoming_reserved_streams); + assert_int(0, ==, + nghttp2_session_on_push_response_headers_received(session, &frame, + stream)); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_size(0, ==, session->num_incoming_reserved_streams); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); + assert_size(1, ==, session->num_incoming_streams); + assert_false(stream->flags & NGHTTP2_STREAM_FLAG_PUSH); /* If un-ACKed max concurrent streams limit is exceeded, RST_STREAMed */ session->pending_local_max_concurrent_stream = 1; stream = open_recv_stream2(session, 4, NGHTTP2_STREAM_RESERVED); frame.hd.stream_id = 4; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_response_headers_received(session, &frame, - stream)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_response_headers_received(session, &frame, + stream)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_REFUSED_STREAM == item->frame.rst_stream.error_code); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_REFUSED_STREAM, ==, item->frame.rst_stream.error_code); + assert_size(1, ==, session->num_incoming_streams); + assert_size(1, ==, session->num_incoming_reserved_streams); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == session->num_incoming_streams); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(1, ==, session->num_incoming_streams); /* If ACKed max concurrent streams limit is exceeded, GOAWAY is issued */ @@ -3561,14 +3744,14 @@ void test_nghttp2_session_on_push_response_headers_received(void) { stream = open_recv_stream2(session, 6, NGHTTP2_STREAM_RESERVED); frame.hd.stream_id = 6; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_response_headers_received(session, &frame, - stream)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_response_headers_received(session, &frame, + stream)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); + assert_size(1, ==, session->num_incoming_streams); + assert_size(1, ==, session->num_incoming_reserved_streams); nghttp2_frame_headers_free(&frame.headers, mem); nghttp2_session_del(session); @@ -3595,9 +3778,9 @@ void test_nghttp2_session_on_priority_received(void) { nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); /* depend on stream 0 */ - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); - CU_ASSERT(2 == stream->weight); + assert_int32(2, ==, stream->weight); stream = open_sent_stream(session, 2); dep_stream = open_recv_stream(session, 3); @@ -3607,19 +3790,19 @@ void test_nghttp2_session_on_priority_received(void) { /* using dependency stream */ nghttp2_priority_spec_init(&frame.priority.pri_spec, 3, 1, 0); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); - CU_ASSERT(dep_stream == stream->dep_prev); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); + assert_ptr_equal(dep_stream, stream->dep_prev); /* PRIORITY against idle stream */ frame.hd.stream_id = 100; - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); stream = nghttp2_session_get_stream_raw(session, frame.hd.stream_id); - CU_ASSERT(NGHTTP2_STREAM_IDLE == stream->state); - CU_ASSERT(dep_stream == stream->dep_prev); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, stream->state); + assert_ptr_equal(dep_stream, stream->dep_prev); nghttp2_frame_priority_free(&frame.priority); nghttp2_session_del(session); @@ -3632,11 +3815,11 @@ void test_nghttp2_session_on_priority_received(void) { nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_frame_priority_free(&frame.priority); nghttp2_session_del(session); @@ -3648,11 +3831,11 @@ void test_nghttp2_session_on_priority_received(void) { nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_frame_priority_free(&frame.priority); nghttp2_session_del(session); @@ -3669,8 +3852,8 @@ void test_nghttp2_session_on_rst_stream_received(void) { nghttp2_frame_rst_stream_init(&frame.rst_stream, 1, NGHTTP2_PROTOCOL_ERROR); - CU_ASSERT(0 == nghttp2_session_on_rst_stream_received(session, &frame)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 1)); + assert_int(0, ==, nghttp2_session_on_rst_stream_received(session, &frame)); + assert_null(nghttp2_session_get_stream(session, 1)); nghttp2_frame_rst_stream_free(&frame.rst_stream); nghttp2_session_del(session); @@ -3691,7 +3874,7 @@ void test_nghttp2_session_on_settings_received(void) { uint8_t data[2048]; nghttp2_frame_hd hd; int rv; - ssize_t nread; + nghttp2_ssize nread; nghttp2_stream *stream; mem = nghttp2_mem_default(); @@ -3712,7 +3895,7 @@ void test_nghttp2_session_on_settings_received(void) { iv[4].value = 0; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, &user_data); session->remote_settings.initial_window_size = 16 * 1024; @@ -3728,26 +3911,29 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, dup_iv(iv, niv), niv); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); - CU_ASSERT(1000000009 == session->remote_settings.max_concurrent_streams); - CU_ASSERT(64 * 1024 == session->remote_settings.initial_window_size); - CU_ASSERT(1024 == session->remote_settings.header_table_size); - CU_ASSERT(0 == session->remote_settings.enable_push); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); + assert_uint32(1000000009, ==, + session->remote_settings.max_concurrent_streams); + assert_uint32(64 * 1024, ==, session->remote_settings.initial_window_size); + assert_uint32(1024, ==, session->remote_settings.header_table_size); + assert_uint32(0, ==, session->remote_settings.enable_push); - CU_ASSERT(64 * 1024 == stream1->remote_window_size); - CU_ASSERT(0 == stream2->remote_window_size); + assert_int32(64 * 1024, ==, stream1->remote_window_size); + assert_int32(0, ==, stream2->remote_window_size); frame.settings.iv[2].value = 16 * 1024; - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); - CU_ASSERT(16 * 1024 == stream1->remote_window_size); - CU_ASSERT(-48 * 1024 == stream2->remote_window_size); + assert_int32(16 * 1024, ==, stream1->remote_window_size); + assert_int32(-48 * 1024, ==, stream2->remote_window_size); - CU_ASSERT(16 * 1024 == nghttp2_session_get_stream_remote_window_size( - session, stream1->stream_id)); - CU_ASSERT(0 == nghttp2_session_get_stream_remote_window_size( - session, stream2->stream_id)); + assert_int32(16 * 1024, ==, + nghttp2_session_get_stream_remote_window_size( + session, stream1->stream_id)); + assert_int32(0, ==, + nghttp2_session_get_stream_remote_window_size( + session, stream2->stream_id)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -3757,10 +3943,10 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_session_server_new(&session, &callbacks, NULL); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_ACK, dup_iv(iv, 1), 1); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item != NULL); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_frame_settings_free(&frame.settings, mem); nghttp2_session_del(session); @@ -3769,10 +3955,10 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_session_server_new(&session, &callbacks, NULL); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_ACK, NULL, 0); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item != NULL); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_frame_settings_free(&frame.settings, mem); nghttp2_session_del(session); @@ -3781,11 +3967,11 @@ void test_nghttp2_session_on_settings_received(void) { and header table size is once cleared to 0. */ nghttp2_session_client_new(&session, &callbacks, NULL); - nghttp2_submit_request(session, NULL, &nv, 1, NULL, NULL); + nghttp2_submit_request2(session, NULL, &nv, 1, NULL, NULL); nghttp2_session_send(session); - CU_ASSERT(session->hd_deflater.ctx.hd_table.len > 0); + assert_size(0, <, session->hd_deflater.ctx.hd_table.len); iv[0].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[0].value = 0; @@ -3796,11 +3982,11 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, dup_iv(iv, 2), 2); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); - CU_ASSERT(0 == session->hd_deflater.ctx.hd_table.len); - CU_ASSERT(2048 == session->hd_deflater.ctx.hd_table_bufsize_max); - CU_ASSERT(2048 == session->remote_settings.header_table_size); + assert_size(0, ==, session->hd_deflater.ctx.hd_table.len); + assert_size(2048, ==, session->hd_deflater.ctx.hd_table_bufsize_max); + assert_uint32(2048, ==, session->remote_settings.header_table_size); nghttp2_frame_settings_free(&frame.settings, mem); nghttp2_session_del(session); @@ -3811,12 +3997,12 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_option_new(&option); nghttp2_option_set_peer_max_concurrent_streams(option, 1000); nghttp2_session_client_new2(&session, &callbacks, NULL, option); - CU_ASSERT(1000 == session->remote_settings.max_concurrent_streams); + assert_uint32(1000, ==, session->remote_settings.max_concurrent_streams); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, NULL, 0); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); - CU_ASSERT(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS == - session->remote_settings.max_concurrent_streams); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); + assert_uint32(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS, ==, + session->remote_settings.max_concurrent_streams); nghttp2_frame_settings_free(&frame.settings, mem); nghttp2_session_del(session); @@ -3831,12 +4017,12 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, dup_iv(iv, 1), 1); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item != NULL); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_frame_settings_free(&frame.settings, mem); nghttp2_session_del(session); @@ -3850,7 +4036,7 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_window_update_init(&frame.window_update, NGHTTP2_FLAG_NONE, 1, 1); - CU_ASSERT(0 == nghttp2_session_on_window_update_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_window_update_received(session, &frame)); nghttp2_frame_window_update_free(&frame.window_update); @@ -3862,20 +4048,20 @@ void test_nghttp2_session_on_settings_received(void) { /* Now window size gets NGHTTP2_MAX_WINDOW_SIZE + 1, which is unacceptable situation in protocol spec. */ - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); nghttp2_frame_settings_free(&frame.settings, mem); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_SETTINGS == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_SETTINGS, ==, item->frame.hd.type); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_STREAM_CLOSING == stream1->state); + assert_not_null(item); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_CLOSING, ==, stream1->state); nghttp2_session_del(session); @@ -3891,14 +4077,14 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, dup_iv(iv, 1), 1); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); nghttp2_frame_settings_free(&frame.settings, mem); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); @@ -3915,11 +4101,11 @@ void test_nghttp2_session_on_settings_received(void) { rv = nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream = open_recv_stream(session, 1); @@ -3931,31 +4117,31 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_pack_frame_hd(data, &hd); nread = - nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + hd.length); + nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + hd.length); - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length) == nread); + assert_ptrdiff((nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + hd.length), ==, nread); rv = nghttp2_session_consume(session, 1, hd.length); - CU_ASSERT(0 == rv); - CU_ASSERT((int32_t)hd.length == stream->recv_window_size); - CU_ASSERT((int32_t)hd.length == stream->consumed_size); + assert_int(0, ==, rv); + assert_int32((int32_t)hd.length, ==, stream->recv_window_size); + assert_int32((int32_t)hd.length, ==, stream->consumed_size); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_ACK, NULL, 0); rv = nghttp2_session_on_settings_received(session, &frame, 0); - CU_ASSERT(0 == rv); - CU_ASSERT(1024 == stream->local_window_size); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(0 == stream->consumed_size); + assert_int(0, ==, rv); + assert_int32(1024, ==, stream->local_window_size); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(0, ==, stream->consumed_size); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT((int32_t)hd.length == - item->frame.window_update.window_size_increment); + assert_not_null(item); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32((int32_t)hd.length, ==, + item->frame.window_update.window_size_increment); nghttp2_session_del(session); nghttp2_option_del(option); @@ -3972,14 +4158,14 @@ void test_nghttp2_session_on_settings_received(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, dup_iv(iv, 1), 1); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); nghttp2_frame_settings_free(&frame.settings, mem); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); } @@ -3999,7 +4185,7 @@ void test_nghttp2_session_on_push_promise_received(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_begin_headers_callback = on_begin_headers_callback; callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback; @@ -4013,13 +4199,14 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); promised_stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_RESERVED == promised_stream->state); - CU_ASSERT(2 == session->last_recv_stream_id); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_RESERVED, ==, + promised_stream->state); + assert_int32(2, ==, session->last_recv_stream_id); /* Attempt to PUSH_PROMISE against half close (remote) */ nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD); @@ -4027,18 +4214,18 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 4)); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); + assert_null(nghttp2_session_get_stream(session, 4)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_STREAM_CLOSED == item->frame.goaway.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(4 == session->last_recv_stream_id); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_STREAM_CLOSED, ==, item->frame.goaway.error_code); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(4, ==, session->last_recv_stream_id); nghttp2_session_del(session); @@ -4052,17 +4239,17 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 6)); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_size(0, ==, session->num_incoming_reserved_streams); + assert_null(nghttp2_session_get_stream(session, 6)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(6 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_CANCEL == item->frame.rst_stream.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(6, ==, item->frame.hd.stream_id); + assert_uint32(NGHTTP2_CANCEL, ==, item->frame.rst_stream.error_code); + assert_int(0, ==, nghttp2_session_send(session)); /* Attempt to PUSH_PROMISE against idle stream */ frame.hd.stream_id = 3; @@ -4070,17 +4257,17 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 8)); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_size(0, ==, session->num_incoming_reserved_streams); + assert_null(nghttp2_session_get_stream(session, 8)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(0 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.hd.stream_id); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_session_del(session); @@ -4094,37 +4281,37 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 2)); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); + assert_not_null(nghttp2_session_get_stream(session, 2)); user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 8)); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); + assert_null(nghttp2_session_get_stream(session, 8)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); + assert_int(0, ==, nghttp2_session_send(session)); /* After GOAWAY, PUSH_PROMISE will be discarded */ frame.push_promise.promised_stream_id = 10; user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 10)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); + assert_null(nghttp2_session_get_stream(session, 10)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4139,12 +4326,12 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_size(1, ==, session->num_incoming_reserved_streams); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4161,12 +4348,12 @@ void test_nghttp2_session_on_push_promise_received(void) { user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == user_data.begin_headers_cb_called); - CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); - CU_ASSERT(0 == session->num_incoming_reserved_streams); + assert_int(0, ==, user_data.begin_headers_cb_called); + assert_int(1, ==, user_data.invalid_frame_recv_cb_called); + assert_size(0, ==, session->num_incoming_reserved_streams); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4182,10 +4369,10 @@ void test_nghttp2_session_on_push_promise_received(void) { 1, 2, nva, nvlen); user_data.begin_headers_cb_called = 0; user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(1 == user_data.begin_headers_cb_called); - CU_ASSERT(0 == user_data.invalid_frame_recv_cb_called); + assert_int(1, ==, user_data.begin_headers_cb_called); + assert_int(0, ==, user_data.invalid_frame_recv_cb_called); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4202,10 +4389,10 @@ void test_nghttp2_session_on_push_promise_received(void) { nghttp2_frame_push_promise_init(&frame.push_promise, NGHTTP2_FLAG_END_HEADERS, 1, 2, NULL, 0); - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(0 == session->num_incoming_reserved_streams); + assert_size(0, ==, session->num_incoming_reserved_streams); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4217,20 +4404,20 @@ void test_nghttp2_session_on_push_promise_received(void) { open_sent_stream(session, 1); open_recv_stream2(session, 2, NGHTTP2_STREAM_RESERVED); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_size(1, ==, session->num_incoming_reserved_streams); nghttp2_frame_push_promise_init(&frame.push_promise, NGHTTP2_FLAG_END_HEADERS, 1, 4, NULL, 0); - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_push_promise_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_push_promise_received(session, &frame)); - CU_ASSERT(1 == session->num_incoming_reserved_streams); + assert_size(1, ==, session->num_incoming_reserved_streams); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_CANCEL == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_CANCEL, ==, item->frame.rst_stream.error_code); nghttp2_frame_push_promise_free(&frame.push_promise, mem); nghttp2_session_del(session); @@ -4255,22 +4442,22 @@ void test_nghttp2_session_on_ping_received(void) { nghttp2_session_client_new(&session, &callbacks, &user_data); nghttp2_frame_ping_init(&frame.ping, NGHTTP2_FLAG_ACK, opaque_data); - CU_ASSERT(0 == nghttp2_session_on_ping_received(session, &frame)); - CU_ASSERT(1 == user_data.frame_recv_cb_called); + assert_int(0, ==, nghttp2_session_on_ping_received(session, &frame)); + assert_int(1, ==, user_data.frame_recv_cb_called); /* Since this ping frame has ACK flag set, no further action is performed. */ - CU_ASSERT(NULL == nghttp2_outbound_queue_top(&session->ob_urgent)); + assert_null(nghttp2_outbound_queue_top(&session->ob_urgent)); /* Clear the flag, and receive it again */ frame.hd.flags = NGHTTP2_FLAG_NONE; - CU_ASSERT(0 == nghttp2_session_on_ping_received(session, &frame)); - CU_ASSERT(2 == user_data.frame_recv_cb_called); + assert_int(0, ==, nghttp2_session_on_ping_received(session, &frame)); + assert_int(2, ==, user_data.frame_recv_cb_called); top = nghttp2_outbound_queue_top(&session->ob_urgent); - CU_ASSERT(NGHTTP2_PING == top->frame.hd.type); - CU_ASSERT(NGHTTP2_FLAG_ACK == top->frame.hd.flags); - CU_ASSERT(memcmp(opaque_data, top->frame.ping.opaque_data, 8) == 0); + assert_uint8(NGHTTP2_PING, ==, top->frame.hd.type); + assert_uint8(NGHTTP2_FLAG_ACK, ==, top->frame.hd.flags); + assert_memory_equal(8, opaque_data, top->frame.ping.opaque_data); nghttp2_frame_ping_free(&frame.ping); nghttp2_session_del(session); @@ -4284,9 +4471,9 @@ void test_nghttp2_session_on_ping_received(void) { user_data.frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_ping_received(session, &frame)); - CU_ASSERT(1 == user_data.frame_recv_cb_called); - CU_ASSERT(NULL == nghttp2_outbound_queue_top(&session->ob_urgent)); + assert_int(0, ==, nghttp2_session_on_ping_received(session, &frame)); + assert_int(1, ==, user_data.frame_recv_cb_called); + assert_null(nghttp2_outbound_queue_top(&session->ob_urgent)); nghttp2_frame_ping_free(&frame.ping); nghttp2_session_del(session); @@ -4301,7 +4488,7 @@ void test_nghttp2_session_on_goaway_received(void) { int i; nghttp2_mem *mem; const uint8_t *data; - ssize_t datalen; + nghttp2_ssize datalen; mem = nghttp2_mem_default(); user_data.frame_recv_cb_called = 0; @@ -4326,20 +4513,20 @@ void test_nghttp2_session_on_goaway_received(void) { user_data.stream_close_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_goaway_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_goaway_received(session, &frame)); - CU_ASSERT(1 == user_data.frame_recv_cb_called); - CU_ASSERT(3 == session->remote_last_stream_id); + assert_int(1, ==, user_data.frame_recv_cb_called); + assert_int32(3, ==, session->remote_last_stream_id); /* on_stream_close should be callsed for 2 times (stream 5 and 7) */ - CU_ASSERT(2 == user_data.stream_close_cb_called); + assert_int(2, ==, user_data.stream_close_cb_called); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 1)); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 2)); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 3)); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 4)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 5)); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 6)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 7)); + assert_not_null(nghttp2_session_get_stream(session, 1)); + assert_not_null(nghttp2_session_get_stream(session, 2)); + assert_not_null(nghttp2_session_get_stream(session, 3)); + assert_not_null(nghttp2_session_get_stream(session, 4)); + assert_null(nghttp2_session_get_stream(session, 5)); + assert_not_null(nghttp2_session_get_stream(session, 6)); + assert_null(nghttp2_session_get_stream(session, 7)); nghttp2_frame_goaway_free(&frame.goaway, mem); nghttp2_session_del(session); @@ -4355,14 +4542,14 @@ void test_nghttp2_session_on_goaway_received(void) { nghttp2_frame_goaway_init(&frame.goaway, 0, NGHTTP2_NO_ERROR, NULL, 0); - CU_ASSERT(0 == nghttp2_session_on_goaway_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_goaway_received(session, &frame)); - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - datalen = nghttp2_session_mem_send(session, &data); + datalen = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(NGHTTP2_ERR_CALLBACK_FAILURE == datalen); - CU_ASSERT(1 == user_data.stream_close_cb_called); + assert_ptrdiff(NGHTTP2_ERR_CALLBACK_FAILURE, ==, datalen); + assert_int(1, ==, user_data.stream_close_cb_called); nghttp2_frame_goaway_free(&frame.goaway, mem); nghttp2_session_del(session); @@ -4391,23 +4578,23 @@ void test_nghttp2_session_on_window_update_received(void) { data_item = create_data_ob_item(mem); - CU_ASSERT(0 == nghttp2_stream_attach_item(stream, data_item)); + assert_int(0, ==, nghttp2_stream_attach_item(stream, data_item)); nghttp2_frame_window_update_init(&frame.window_update, NGHTTP2_FLAG_NONE, 1, 16 * 1024); - CU_ASSERT(0 == nghttp2_session_on_window_update_received(session, &frame)); - CU_ASSERT(1 == user_data.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 16 * 1024 == - stream->remote_window_size); + assert_int(0, ==, nghttp2_session_on_window_update_received(session, &frame)); + assert_int(1, ==, user_data.frame_recv_cb_called); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 16 * 1024, ==, + stream->remote_window_size); nghttp2_stream_defer_item(stream, NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL); - CU_ASSERT(0 == nghttp2_session_on_window_update_received(session, &frame)); - CU_ASSERT(2 == user_data.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 16 * 1024 * 2 == - stream->remote_window_size); - CU_ASSERT(0 == (stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL)); + assert_int(0, ==, nghttp2_session_on_window_update_received(session, &frame)); + assert_int(2, ==, user_data.frame_recv_cb_called); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 16 * 1024 * 2, ==, + stream->remote_window_size); + assert_false(stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL); nghttp2_frame_window_update_free(&frame.window_update); @@ -4418,9 +4605,9 @@ void test_nghttp2_session_on_window_update_received(void) { nghttp2_frame_window_update_init(&frame.window_update, NGHTTP2_FLAG_NONE, 2, 4096); - CU_ASSERT(!(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); - CU_ASSERT(0 == nghttp2_session_on_window_update_received(session, &frame)); - CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); + assert_int(0, ==, nghttp2_session_on_window_update_received(session, &frame)); + assert_true(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); nghttp2_frame_window_update_free(&frame.window_update); @@ -4434,10 +4621,11 @@ void test_nghttp2_session_on_window_update_received(void) { nghttp2_frame_window_update_init(&frame.window_update, NGHTTP2_FLAG_NONE, 2, 4096); - CU_ASSERT(0 == nghttp2_session_on_window_update_received(session, &frame)); - CU_ASSERT(!(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND)); + assert_int(0, ==, nghttp2_session_on_window_update_received(session, &frame)); + assert_false(session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 4096 == stream->remote_window_size); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 4096, ==, + stream->remote_window_size); nghttp2_frame_window_update_free(&frame.window_update); @@ -4459,13 +4647,13 @@ void test_nghttp2_session_on_data_received(void) { nghttp2_frame_hd_init(&frame.hd, 4096, NGHTTP2_DATA, NGHTTP2_FLAG_NONE, 2); - CU_ASSERT(0 == nghttp2_session_on_data_received(session, &frame)); - CU_ASSERT(0 == stream->shut_flags); + assert_int(0, ==, nghttp2_session_on_data_received(session, &frame)); + assert_uint8(0, ==, stream->shut_flags); frame.hd.flags = NGHTTP2_FLAG_END_STREAM; - CU_ASSERT(0 == nghttp2_session_on_data_received(session, &frame)); - CU_ASSERT(NGHTTP2_SHUT_RD == stream->shut_flags); + assert_int(0, ==, nghttp2_session_on_data_received(session, &frame)); + assert_uint8(NGHTTP2_SHUT_RD, ==, stream->shut_flags); /* If NGHTTP2_STREAM_CLOSING state, DATA frame is discarded. */ open_sent_stream2(session, 1, NGHTTP2_STREAM_CLOSING); @@ -4473,18 +4661,18 @@ void test_nghttp2_session_on_data_received(void) { frame.hd.flags = NGHTTP2_FLAG_NONE; frame.hd.stream_id = 1; - CU_ASSERT(0 == nghttp2_session_on_data_received(session, &frame)); - CU_ASSERT(NULL == nghttp2_outbound_queue_top(&session->ob_reg)); + assert_int(0, ==, nghttp2_session_on_data_received(session, &frame)); + assert_null(nghttp2_outbound_queue_top(&session->ob_reg)); /* Check INVALID_STREAM case: DATA frame with stream ID which does not exist. */ frame.hd.stream_id = 3; - CU_ASSERT(0 == nghttp2_session_on_data_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_data_received(session, &frame)); top = nghttp2_outbound_queue_top(&session->ob_reg); /* DATA against nonexistent stream is just ignored for now. */ - CU_ASSERT(top == NULL); + assert_null(top); nghttp2_session_del(session); } @@ -4508,13 +4696,13 @@ void test_nghttp2_session_on_data_received_fail_fast(void) { stream = open_recv_stream(session, 1); nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD); - CU_ASSERT((ssize_t)sizeof(buf) == - nghttp2_session_mem_recv(session, buf, sizeof(buf))); + assert_ptrdiff((nghttp2_ssize)sizeof(buf), ==, + nghttp2_session_mem_recv2(session, buf, sizeof(buf))); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); @@ -4525,13 +4713,13 @@ void test_nghttp2_session_on_data_received_fail_fast(void) { nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD); nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR); - CU_ASSERT((ssize_t)sizeof(buf) == - nghttp2_session_mem_recv(session, buf, sizeof(buf))); + assert_ptrdiff((nghttp2_ssize)sizeof(buf), ==, + nghttp2_session_mem_recv2(session, buf, sizeof(buf))); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_not_null(item); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_session_del(session); } @@ -4564,8 +4752,8 @@ void test_nghttp2_session_on_altsvc_received(void) { ud.frame_recv_cb_called = 0; rv = nghttp2_session_on_altsvc_received(session, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_int(0, ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -4580,8 +4768,8 @@ void test_nghttp2_session_on_altsvc_received(void) { ud.frame_recv_cb_called = 0; rv = nghttp2_session_on_altsvc_received(session, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -4598,8 +4786,8 @@ void test_nghttp2_session_on_altsvc_received(void) { ud.frame_recv_cb_called = 0; rv = nghttp2_session_on_altsvc_received(session, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -4616,8 +4804,8 @@ void test_nghttp2_session_on_altsvc_received(void) { ud.frame_recv_cb_called = 0; rv = nghttp2_session_on_altsvc_received(session, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == ud.frame_recv_cb_called); + assert_int(0, ==, rv); + assert_int(1, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -4632,8 +4820,8 @@ void test_nghttp2_session_on_altsvc_received(void) { ud.frame_recv_cb_called = 0; rv = nghttp2_session_on_altsvc_received(session, &frame); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); nghttp2_session_del(session); @@ -4651,7 +4839,7 @@ void test_nghttp2_session_send_headers_start_stream(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -4667,9 +4855,9 @@ void test_nghttp2_session_send_headers_start_stream(void) { session->next_stream_id += 2; nghttp2_session_add_item(session, item); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); nghttp2_session_del(session); } @@ -4685,9 +4873,9 @@ void test_nghttp2_session_send_headers_reply(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, NULL)); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); @@ -4699,9 +4887,9 @@ void test_nghttp2_session_send_headers_reply(void) { nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS, 1, NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); nghttp2_session_add_item(session, item); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); nghttp2_session_del(session); } @@ -4733,7 +4921,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) { } memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; nghttp2_session_client_new(&session, &callbacks, &ud); @@ -4756,11 +4944,11 @@ void test_nghttp2_session_send_headers_frame_size_error(void) { ud.frame_not_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_FRAME_SIZE_ERROR == ud.not_sent_error); + assert_int(1, ==, ud.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.not_sent_frame_type); + assert_int(NGHTTP2_ERR_FRAME_SIZE_ERROR, ==, ud.not_sent_error); for (i = 0; i < nnv; ++i) { mem->free(nv[i].value, NULL); @@ -4779,9 +4967,9 @@ void test_nghttp2_session_send_headers_push_reply(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, NULL)); open_sent_stream2(session, 2, NGHTTP2_STREAM_RESERVED); item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); @@ -4793,12 +4981,12 @@ void test_nghttp2_session_send_headers_push_reply(void) { nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS, 2, NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); nghttp2_session_add_item(session, item); - CU_ASSERT(0 == session->num_outgoing_streams); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == session->num_outgoing_streams); + assert_size(0, ==, session->num_outgoing_streams); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(1, ==, session->num_outgoing_streams); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); - CU_ASSERT(0 == (stream->flags & NGHTTP2_STREAM_FLAG_PUSH)); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); + assert_false(stream->flags & NGHTTP2_STREAM_FLAG_PUSH); nghttp2_session_del(session); } @@ -4813,7 +5001,7 @@ void test_nghttp2_session_send_rst_stream(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, &user_data); open_sent_stream(session, 1); @@ -4825,9 +5013,9 @@ void test_nghttp2_session_send_rst_stream(void) { nghttp2_frame_rst_stream_init(&frame->rst_stream, 1, NGHTTP2_PROTOCOL_ERROR); nghttp2_session_add_item(session, item); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 1)); + assert_null(nghttp2_session_get_stream(session, 1)); nghttp2_session_del(session); } @@ -4844,7 +5032,7 @@ void test_nghttp2_session_send_push_promise(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); @@ -4864,9 +5052,9 @@ void test_nghttp2_session_send_push_promise(void) { nghttp2_session_add_item(session, item); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_RESERVED == stream->state); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_RESERVED, ==, stream->state); /* Received ENABLE_PUSH = 0 */ iv.settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; @@ -4889,11 +5077,11 @@ void test_nghttp2_session_send_push_promise(void) { nghttp2_session_add_item(session, item); ud.frame_not_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_PUSH_PROMISE == ud.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_PUSH_DISABLED == ud.not_sent_error); + assert_int(1, ==, ud.frame_not_send_cb_called); + assert_uint8(NGHTTP2_PUSH_PROMISE, ==, ud.not_sent_frame_type); + assert_int(NGHTTP2_ERR_PUSH_DISABLED, ==, ud.not_sent_error); nghttp2_session_del(session); @@ -4910,8 +5098,8 @@ void test_nghttp2_session_send_push_promise(void) { NGHTTP2_FLAG_END_HEADERS, 1, -1, NULL, 0); nghttp2_session_add_item(session, item); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 3)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_null(nghttp2_session_get_stream(session, 3)); nghttp2_session_del(session); } @@ -4922,17 +5110,17 @@ void test_nghttp2_session_is_my_stream_id(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); nghttp2_session_server_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_is_my_stream_id(session, 0)); - CU_ASSERT(0 == nghttp2_session_is_my_stream_id(session, 1)); - CU_ASSERT(1 == nghttp2_session_is_my_stream_id(session, 2)); + assert_false(nghttp2_session_is_my_stream_id(session, 0)); + assert_false(nghttp2_session_is_my_stream_id(session, 1)); + assert_true(nghttp2_session_is_my_stream_id(session, 2)); nghttp2_session_del(session); nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_is_my_stream_id(session, 0)); - CU_ASSERT(1 == nghttp2_session_is_my_stream_id(session, 1)); - CU_ASSERT(0 == nghttp2_session_is_my_stream_id(session, 2)); + assert_false(nghttp2_session_is_my_stream_id(session, 0)); + assert_true(nghttp2_session_is_my_stream_id(session, 1)); + assert_false(nghttp2_session_is_my_stream_id(session, 2)); nghttp2_session_del(session); } @@ -4945,7 +5133,7 @@ void test_nghttp2_session_upgrade2(void) { nghttp2_settings_entry iv[16]; nghttp2_stream *stream; nghttp2_outbound_item *item; - ssize_t rv; + nghttp2_ssize rv; nghttp2_bufs bufs; nghttp2_buf *buf; nghttp2_hd_deflater deflater; @@ -4955,61 +5143,63 @@ void test_nghttp2_session_upgrade2(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; iv[0].value = 1; iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; iv[1].value = 4095; - settings_payloadlen = (size_t)nghttp2_pack_settings_payload( + settings_payloadlen = (size_t)nghttp2_pack_settings_payload2( settings_payload, sizeof(settings_payload), iv, 2); /* Check client side */ nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, &callbacks)); - CU_ASSERT(1 == session->last_sent_stream_id); + assert_int(0, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, &callbacks)); + assert_int32(1, ==, session->last_sent_stream_id); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(stream != NULL); - CU_ASSERT(&callbacks == stream->stream_user_data); - CU_ASSERT(NGHTTP2_SHUT_WR == stream->shut_flags); + assert_not_null(stream); + assert_ptr_equal(&callbacks, stream->stream_user_data); + assert_uint8(NGHTTP2_SHUT_WR, ==, stream->shut_flags); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_SETTINGS == item->frame.hd.type); - CU_ASSERT(2 == item->frame.settings.niv); - CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == - item->frame.settings.iv[0].settings_id); - CU_ASSERT(1 == item->frame.settings.iv[0].value); - CU_ASSERT(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE == - item->frame.settings.iv[1].settings_id); - CU_ASSERT(4095 == item->frame.settings.iv[1].value); + assert_uint8(NGHTTP2_SETTINGS, ==, item->frame.hd.type); + assert_size(2, ==, item->frame.settings.niv); + assert_int32(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ==, + item->frame.settings.iv[0].settings_id); + assert_uint32(1, ==, item->frame.settings.iv[0].value); + assert_int32(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, ==, + item->frame.settings.iv[1].settings_id); + assert_uint32(4095, ==, item->frame.settings.iv[1].value); /* Call nghttp2_session_upgrade2() again is error */ - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, &callbacks)); + assert_int(NGHTTP2_ERR_PROTO, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, &callbacks)); nghttp2_session_del(session); /* Make sure that response from server can be received */ nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, &callbacks)); + assert_int(0, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, &callbacks)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); nghttp2_hd_deflate_init(&deflater, mem); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, resnv, ARRLEN(resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT(rv == (ssize_t)nghttp2_buf_len(buf)); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -5018,29 +5208,31 @@ void test_nghttp2_session_upgrade2(void) { /* Check server side */ nghttp2_session_server_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, &callbacks)); - CU_ASSERT(1 == session->last_recv_stream_id); + assert_int(0, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, &callbacks)); + assert_int32(1, ==, session->last_recv_stream_id); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(stream != NULL); - CU_ASSERT(NULL == stream->stream_user_data); - CU_ASSERT(NGHTTP2_SHUT_RD == stream->shut_flags); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(1 == session->remote_settings.max_concurrent_streams); - CU_ASSERT(4095 == session->remote_settings.initial_window_size); + assert_not_null(stream); + assert_null(stream->stream_user_data); + assert_uint8(NGHTTP2_SHUT_RD, ==, stream->shut_flags); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_uint32(1, ==, session->remote_settings.max_concurrent_streams); + assert_uint32(4095, ==, session->remote_settings.initial_window_size); /* Call nghttp2_session_upgrade2() again is error */ - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, &callbacks)); + assert_int(NGHTTP2_ERR_PROTO, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, &callbacks)); nghttp2_session_del(session); /* Empty SETTINGS is OK */ - settings_payloadlen = (size_t)nghttp2_pack_settings_payload( + settings_payloadlen = (size_t)nghttp2_pack_settings_payload2( settings_payload, sizeof(settings_payload), NULL, 0); nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(0 == nghttp2_session_upgrade2(session, settings_payload, - settings_payloadlen, 0, NULL)); + assert_int(0, ==, + nghttp2_session_upgrade2(session, settings_payload, + settings_payloadlen, 0, NULL)); nghttp2_session_del(session); nghttp2_bufs_free(&bufs); } @@ -5054,7 +5246,7 @@ void test_nghttp2_session_reprioritize_stream(void) { int rv; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -5064,9 +5256,9 @@ void test_nghttp2_session_reprioritize_stream(void) { rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(10 == stream->weight); - CU_ASSERT(&session->root == stream->dep_prev); + assert_int(0, ==, rv); + assert_int32(10, ==, stream->weight); + assert_ptr_equal(&session->root, stream->dep_prev); /* If dependency to idle stream which is not in dependency tree yet */ @@ -5074,13 +5266,13 @@ void test_nghttp2_session_reprioritize_stream(void) { rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(99 == stream->weight); - CU_ASSERT(3 == stream->dep_prev->stream_id); + assert_int(0, ==, rv); + assert_int32(99, ==, stream->weight); + assert_int32(3, ==, stream->dep_prev->stream_id); dep_stream = nghttp2_session_get_stream_raw(session, 3); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == dep_stream->weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, dep_stream->weight); dep_stream = open_recv_stream(session, 3); @@ -5089,19 +5281,19 @@ void test_nghttp2_session_reprioritize_stream(void) { rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(128 == stream->weight); - CU_ASSERT(dep_stream == stream->dep_prev); + assert_int(0, ==, rv); + assert_int32(128, ==, stream->weight); + assert_ptr_equal(dep_stream, stream->dep_prev); /* Change weight again to test short-path case */ pri_spec.weight = 100; rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(100 == stream->weight); - CU_ASSERT(dep_stream == stream->dep_prev); - CU_ASSERT(100 == dep_stream->sum_dep_weight); + assert_int(0, ==, rv); + assert_int32(100, ==, stream->weight); + assert_ptr_equal(dep_stream, stream->dep_prev); + assert_int32(100, ==, dep_stream->sum_dep_weight); /* Test circular dependency; stream 1 is first removed and becomes root. Then stream 3 depends on it. */ @@ -5109,9 +5301,9 @@ void test_nghttp2_session_reprioritize_stream(void) { rv = nghttp2_session_reprioritize_stream(session, dep_stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(1 == dep_stream->weight); - CU_ASSERT(stream == dep_stream->dep_prev); + assert_int(0, ==, rv); + assert_int32(1, ==, dep_stream->weight); + assert_ptr_equal(stream, dep_stream->dep_prev); /* Making priority to closed stream will result in default priority */ @@ -5121,8 +5313,8 @@ void test_nghttp2_session_reprioritize_stream(void) { rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); + assert_int(0, ==, rv); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); nghttp2_session_del(session); @@ -5141,20 +5333,20 @@ void test_nghttp2_session_reprioritize_stream(void) { stream = nghttp2_session_get_stream(session, 3); rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(7 == stream->dep_prev->stream_id); + assert_int(0, ==, rv); + assert_int32(7, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 7); - CU_ASSERT(1 == stream->dep_prev->stream_id); + assert_int32(1, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 9); - CU_ASSERT(3 == stream->dep_prev->stream_id); + assert_int32(3, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 5); - CU_ASSERT(3 == stream->dep_prev->stream_id); + assert_int32(3, ==, stream->dep_prev->stream_id); nghttp2_session_del(session); @@ -5173,20 +5365,20 @@ void test_nghttp2_session_reprioritize_stream(void) { stream = nghttp2_session_get_stream(session, 3); rv = nghttp2_session_reprioritize_stream(session, stream, &pri_spec); - CU_ASSERT(0 == rv); - CU_ASSERT(7 == stream->dep_prev->stream_id); + assert_int(0, ==, rv); + assert_int32(7, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 7); - CU_ASSERT(1 == stream->dep_prev->stream_id); + assert_int32(1, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 9); - CU_ASSERT(7 == stream->dep_prev->stream_id); + assert_int32(7, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream(session, 5); - CU_ASSERT(3 == stream->dep_prev->stream_id); + assert_int32(3, ==, stream->dep_prev->stream_id); nghttp2_session_del(session); } @@ -5198,7 +5390,7 @@ void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void) { nghttp2_priority_spec pri_spec; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -5212,12 +5404,12 @@ void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void) { /* idle stream is not counteed to max concurrent streams */ - CU_ASSERT(10 == stream->weight); - CU_ASSERT(101 == stream->dep_prev->stream_id); + assert_int32(10, ==, stream->weight); + assert_int32(101, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream_raw(session, 101); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); nghttp2_session_del(session); } @@ -5225,7 +5417,7 @@ void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void) { void test_nghttp2_submit_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_frame *frame; nghttp2_frame_hd hd; @@ -5234,30 +5426,31 @@ void test_nghttp2_submit_data(void) { nghttp2_buf *buf; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = NGHTTP2_DATA_PAYLOADLEN * 2; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); aob = &session->aob; framebufs = &aob->framebufs; open_sent_stream(session, 1); - CU_ASSERT( - 0 == nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); ud.block_count = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); frame = &aob->item->frame; buf = &framebufs->head->buf; nghttp2_frame_unpack_frame_hd(&hd, buf->pos); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); - CU_ASSERT(NGHTTP2_FLAG_NONE == frame->hd.flags); + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); + assert_uint8(NGHTTP2_FLAG_NONE, ==, frame->hd.flags); /* aux_data.data.flags has these flags */ - CU_ASSERT(NGHTTP2_FLAG_END_STREAM == aob->item->aux_data.data.flags); + assert_uint8(NGHTTP2_FLAG_END_STREAM, ==, aob->item->aux_data.data.flags); nghttp2_session_del(session); } @@ -5265,7 +5458,7 @@ void test_nghttp2_submit_data(void) { void test_nghttp2_submit_data_read_length_too_large(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_frame *frame; nghttp2_frame_hd hd; @@ -5275,37 +5468,38 @@ void test_nghttp2_submit_data_read_length_too_large(void) { size_t payloadlen; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; - callbacks.read_length_callback = too_large_data_source_length_callback; + callbacks.send_callback2 = block_count_send_callback; + callbacks.read_length_callback2 = too_large_data_source_length_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = NGHTTP2_DATA_PAYLOADLEN * 2; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); aob = &session->aob; framebufs = &aob->framebufs; open_sent_stream(session, 1); - CU_ASSERT( - 0 == nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); ud.block_count = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); frame = &aob->item->frame; buf = &framebufs->head->buf; nghttp2_frame_unpack_frame_hd(&hd, buf->pos); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); - CU_ASSERT(NGHTTP2_FLAG_NONE == frame->hd.flags); - CU_ASSERT(16384 == hd.length) + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); + assert_uint8(NGHTTP2_FLAG_NONE, ==, frame->hd.flags); + assert_size(16384, ==, hd.length); /* aux_data.data.flags has these flags */ - CU_ASSERT(NGHTTP2_FLAG_END_STREAM == aob->item->aux_data.data.flags); + assert_uint8(NGHTTP2_FLAG_END_STREAM, ==, aob->item->aux_data.data.flags); nghttp2_session_del(session); /* Check that buffers are expanded */ - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); ud.data_source_length = NGHTTP2_MAX_FRAME_SIZE_MAX; @@ -5313,11 +5507,12 @@ void test_nghttp2_submit_data_read_length_too_large(void) { open_sent_stream(session, 1); - CU_ASSERT( - 0 == nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); ud.block_count = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); aob = &session->aob; @@ -5331,13 +5526,13 @@ void test_nghttp2_submit_data_read_length_too_large(void) { payloadlen = nghttp2_min(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE, NGHTTP2_INITIAL_WINDOW_SIZE); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + 1 + payloadlen == - (size_t)nghttp2_buf_cap(buf)); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); - CU_ASSERT(NGHTTP2_FLAG_NONE == frame->hd.flags); - CU_ASSERT(payloadlen == hd.length); + assert_size(NGHTTP2_FRAME_HDLEN + 1 + payloadlen, ==, + (size_t)nghttp2_buf_cap(buf)); + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); + assert_uint8(NGHTTP2_FLAG_NONE, ==, frame->hd.flags); + assert_size(payloadlen, ==, hd.length); /* aux_data.data.flags has these flags */ - CU_ASSERT(NGHTTP2_FLAG_END_STREAM == aob->item->aux_data.data.flags); + assert_uint8(NGHTTP2_FLAG_END_STREAM, ==, aob->item->aux_data.data.flags); nghttp2_session_del(session); } @@ -5345,7 +5540,7 @@ void test_nghttp2_submit_data_read_length_too_large(void) { void test_nghttp2_submit_data_read_length_smallest(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_frame *frame; nghttp2_frame_hd hd; @@ -5354,37 +5549,38 @@ void test_nghttp2_submit_data_read_length_smallest(void) { nghttp2_buf *buf; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; - callbacks.read_length_callback = smallest_length_data_source_length_callback; + callbacks.send_callback2 = block_count_send_callback; + callbacks.read_length_callback2 = smallest_length_data_source_length_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = NGHTTP2_DATA_PAYLOADLEN * 2; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); aob = &session->aob; framebufs = &aob->framebufs; open_sent_stream(session, 1); - CU_ASSERT( - 0 == nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); ud.block_count = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); frame = &aob->item->frame; buf = &framebufs->head->buf; nghttp2_frame_unpack_frame_hd(&hd, buf->pos); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); - CU_ASSERT(NGHTTP2_FLAG_NONE == frame->hd.flags); - CU_ASSERT(1 == hd.length) + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); + assert_uint8(NGHTTP2_FLAG_NONE, ==, frame->hd.flags); + assert_size(1, ==, hd.length); /* aux_data.data.flags has these flags */ - CU_ASSERT(NGHTTP2_FLAG_END_STREAM == aob->item->aux_data.data.flags); + assert_uint8(NGHTTP2_FLAG_END_STREAM, ==, aob->item->aux_data.data.flags); nghttp2_session_del(session); } -static ssize_t submit_data_twice_data_source_read_callback( +static nghttp2_ssize submit_data_twice_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { (void)session; @@ -5394,7 +5590,7 @@ static ssize_t submit_data_twice_data_source_read_callback( (void)user_data; *data_flags |= NGHTTP2_DATA_FLAG_EOF; - return (ssize_t)nghttp2_min(len, 16); + return (nghttp2_ssize)nghttp2_min(len, 16); } static int submit_data_twice_on_frame_send_callback(nghttp2_session *session, @@ -5402,7 +5598,7 @@ static int submit_data_twice_on_frame_send_callback(nghttp2_session *session, void *user_data) { static int called = 0; int rv; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; (void)user_data; if (called == 0) { @@ -5410,9 +5606,9 @@ static int submit_data_twice_on_frame_send_callback(nghttp2_session *session, data_prd.read_callback = submit_data_twice_data_source_read_callback; - rv = nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, - frame->hd.stream_id, &data_prd); - CU_ASSERT(0 == rv); + rv = nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, + frame->hd.stream_id, &data_prd); + assert_int(0, ==, rv); } return 0; @@ -5421,12 +5617,12 @@ static int submit_data_twice_on_frame_send_callback(nghttp2_session *session, void test_nghttp2_submit_data_twice(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; accumulator acc; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; + callbacks.send_callback2 = accumulator_send_callback; callbacks.on_frame_send_callback = submit_data_twice_on_frame_send_callback; data_prd.read_callback = submit_data_twice_data_source_read_callback; @@ -5434,15 +5630,16 @@ void test_nghttp2_submit_data_twice(void) { acc.length = 0; ud.acc = &acc; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); open_sent_stream(session, 1); - CU_ASSERT(0 == nghttp2_submit_data(session, NGHTTP2_FLAG_NONE, 1, &data_prd)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_NONE, 1, &data_prd)); + assert_int(0, ==, nghttp2_session_send(session)); /* We should have sent 2 DATA frame with 16 bytes payload each */ - CU_ASSERT(NGHTTP2_FRAME_HDLEN * 2 + 16 * 2 == acc.length); + assert_size(NGHTTP2_FRAME_HDLEN * 2 + 16 * 2, ==, acc.length); nghttp2_session_del(session); } @@ -5450,7 +5647,7 @@ void test_nghttp2_submit_data_twice(void) { void test_nghttp2_submit_request_with_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_outbound_item *item; nghttp2_mem *mem; @@ -5458,28 +5655,29 @@ void test_nghttp2_submit_request_with_data(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 64 * 1024 - 1; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); - CU_ASSERT(1 == nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), - &data_prd, NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int32(1, ==, + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), + &data_prd, NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(reqnv), ==, item->frame.headers.nvlen); assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(0, ==, ud.data_source_length); nghttp2_session_del(session); - /* nghttp2_submit_request() with server session is error */ + /* nghttp2_submit_request2() with server session is error */ nghttp2_session_server_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_PROTO == nghttp2_submit_request(session, NULL, reqnv, - ARRLEN(reqnv), NULL, - NULL)); + assert_int32( + NGHTTP2_ERR_PROTO, ==, + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL)); nghttp2_session_del(session); } @@ -5488,7 +5686,7 @@ void test_nghttp2_submit_request_without_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; accumulator acc; - nghttp2_data_provider data_prd = {{-1}, NULL}; + nghttp2_data_provider2 data_prd = {{-1}, NULL}; nghttp2_outbound_item *item; my_user_data ud; nghttp2_frame frame; @@ -5505,25 +5703,26 @@ void test_nghttp2_submit_request_without_data(void) { acc.length = 0; ud.acc = &acc; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + callbacks.send_callback2 = accumulator_send_callback; + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(1 == nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), - &data_prd, NULL)); + assert_int32(1, ==, + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), + &data_prd, NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(reqnv), ==, item->frame.headers.nvlen); assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); + assert_true(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, unpack_frame(&frame, acc.buf, acc.length)); nghttp2_bufs_add(&bufs, acc.buf, acc.length); inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem); - CU_ASSERT(ARRLEN(reqnv) == out.nvlen); + assert_size(ARRLEN(reqnv), ==, out.nvlen); assert_nv_equal(reqnv, out.nva, out.nvlen, mem); nghttp2_frame_headers_free(&frame.headers, mem); nva_out_reset(&out, mem); @@ -5535,9 +5734,9 @@ void test_nghttp2_submit_request_without_data(void) { nghttp2_priority_spec_init(&pri_spec, (int32_t)session->next_stream_id, 16, 0); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_request(session, &pri_spec, reqnv, ARRLEN(reqnv), - NULL, NULL)); + assert_int32(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_request2(session, &pri_spec, reqnv, ARRLEN(reqnv), + NULL, NULL)); nghttp2_session_del(session); } @@ -5545,7 +5744,7 @@ void test_nghttp2_submit_request_without_data(void) { void test_nghttp2_submit_response_with_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_outbound_item *item; nghttp2_mem *mem; @@ -5553,33 +5752,34 @@ void test_nghttp2_submit_response_with_data(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 64 * 1024 - 1; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), - &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), &data_prd)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(resnv), ==, item->frame.headers.nvlen); assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(0, ==, ud.data_source_length); nghttp2_session_del(session); /* Various error cases */ nghttp2_session_client_new(&session, &callbacks, NULL); - /* Calling nghttp2_submit_response() with client session is error */ - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), NULL)); + /* Calling nghttp2_submit_response2() with client session is error */ + assert_int(NGHTTP2_ERR_PROTO, ==, + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), NULL)); /* Stream ID <= 0 is error */ - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_response(session, 0, resnv, ARRLEN(resnv), NULL)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_response2(session, 0, resnv, ARRLEN(resnv), NULL)); nghttp2_session_del(session); } @@ -5588,7 +5788,7 @@ void test_nghttp2_submit_response_without_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; accumulator acc; - nghttp2_data_provider data_prd = {{-1}, NULL}; + nghttp2_data_provider2 data_prd = {{-1}, NULL}; nghttp2_outbound_item *item; my_user_data ud; nghttp2_frame frame; @@ -5604,26 +5804,27 @@ void test_nghttp2_submit_response_without_data(void) { acc.length = 0; ud.acc = &acc; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + callbacks.send_callback2 = accumulator_send_callback; + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); nghttp2_hd_inflate_init(&inflater, mem); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), - &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), &data_prd)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(resnv), ==, item->frame.headers.nvlen); assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); + assert_true(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, unpack_frame(&frame, acc.buf, acc.length)); nghttp2_bufs_add(&bufs, acc.buf, acc.length); inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem); - CU_ASSERT(ARRLEN(resnv) == out.nvlen); + assert_size(ARRLEN(resnv), ==, out.nvlen); assert_nv_equal(resnv, out.nva, out.nvlen, mem); nva_out_reset(&out, mem); @@ -5639,7 +5840,7 @@ void test_nghttp2_submit_response_push_response(void) { my_user_data ud; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); @@ -5648,13 +5849,13 @@ void test_nghttp2_submit_response_push_response(void) { session->goaway_flags |= NGHTTP2_GOAWAY_RECV; - CU_ASSERT(0 == - nghttp2_submit_response(session, 2, resnv, ARRLEN(resnv), NULL)); + assert_int(0, ==, + nghttp2_submit_response2(session, 2, resnv, ARRLEN(resnv), NULL)); ud.frame_not_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_not_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_not_send_cb_called); nghttp2_session_del(session); } @@ -5663,7 +5864,7 @@ void test_nghttp2_submit_trailer(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; accumulator acc; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_outbound_item *item; my_user_data ud; nghttp2_frame frame; @@ -5680,32 +5881,34 @@ void test_nghttp2_submit_trailer(void) { acc.length = 0; ud.acc = &acc; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + callbacks.send_callback2 = null_send_callback; + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); nghttp2_hd_inflate_init(&inflater, mem); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), - &data_prd)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int( + 0, ==, + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), &data_prd)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(0 == - nghttp2_submit_trailer(session, 1, trailernv, ARRLEN(trailernv))); + assert_int(0, ==, + nghttp2_submit_trailer(session, 1, trailernv, ARRLEN(trailernv))); - session->callbacks.send_callback = accumulator_send_callback; + session->callbacks.send_callback2 = accumulator_send_callback; item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT(NGHTTP2_HCAT_HEADERS == item->frame.headers.cat); - CU_ASSERT(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_enum(nghttp2_headers_category, NGHTTP2_HCAT_HEADERS, ==, + item->frame.headers.cat); + assert_true(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, unpack_frame(&frame, acc.buf, acc.length)); nghttp2_bufs_add(&bufs, acc.buf, acc.length); inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem); - CU_ASSERT(ARRLEN(trailernv) == out.nvlen); + assert_size(ARRLEN(trailernv), ==, out.nvlen); assert_nv_equal(trailernv, out.nva, out.nvlen, mem); nva_out_reset(&out, mem); @@ -5718,11 +5921,11 @@ void test_nghttp2_submit_trailer(void) { nghttp2_session_server_new(&session, &callbacks, NULL); open_recv_stream(session, 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_trailer(session, 0, trailernv, ARRLEN(trailernv))); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_trailer(session, 0, trailernv, ARRLEN(trailernv))); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_trailer(session, -1, trailernv, ARRLEN(trailernv))); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_trailer(session, -1, trailernv, ARRLEN(trailernv))); nghttp2_session_del(session); } @@ -5736,16 +5939,17 @@ void test_nghttp2_submit_headers_start_stream(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); - CU_ASSERT(1 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, - NULL, reqnv, ARRLEN(reqnv), NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_int32(1, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, + NULL, reqnv, ARRLEN(reqnv), NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(reqnv), ==, item->frame.headers.nvlen); assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT((NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM) == - item->frame.hd.flags); - CU_ASSERT(0 == (item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY)); + assert_uint8((NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM), ==, + item->frame.hd.flags); + assert_false(item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY); nghttp2_session_del(session); } @@ -5761,34 +5965,36 @@ void test_nghttp2_submit_headers_reply(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, resnv, ARRLEN(resnv), NULL)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + resnv, ARRLEN(resnv), NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(resnv), ==, item->frame.headers.nvlen); assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) == - item->frame.hd.flags); + assert_uint8((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS), ==, + item->frame.hd.flags); ud.frame_send_cb_called = 0; ud.sent_frame_type = 0; /* The transimission will be canceled because the stream 1 is not open. */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, ud.frame_send_cb_called); stream = open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, resnv, ARRLEN(resnv), NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type); - CU_ASSERT(stream->shut_flags & NGHTTP2_SHUT_WR); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + resnv, ARRLEN(resnv), NULL)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.sent_frame_type); + assert_true(stream->shut_flags & NGHTTP2_SHUT_WR); nghttp2_session_del(session); } @@ -5801,35 +6007,37 @@ void test_nghttp2_submit_headers_push_reply(void) { int foo; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); stream = open_sent_stream2(session, 2, NGHTTP2_STREAM_RESERVED); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 2, NULL, - resnv, ARRLEN(resnv), &foo)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 2, NULL, + resnv, ARRLEN(resnv), &foo)); ud.frame_send_cb_called = 0; ud.sent_frame_type = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); - CU_ASSERT(&foo == stream->stream_user_data); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.sent_frame_type); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); + assert_ptr_equal(&foo, stream->stream_user_data); nghttp2_session_del(session); /* Sending HEADERS from client against stream in reserved state is error */ - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); open_recv_stream2(session, 2, NGHTTP2_STREAM_RESERVED); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 2, NULL, - reqnv, ARRLEN(reqnv), NULL)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 2, NULL, + reqnv, ARRLEN(reqnv), NULL)); ud.frame_send_cb_called = 0; ud.sent_frame_type = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, ud.frame_send_cb_called); nghttp2_session_del(session); } @@ -5855,43 +6063,45 @@ void test_nghttp2_submit_headers(void) { acc.length = 0; ud.acc = &acc; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; + callbacks.send_callback2 = accumulator_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); nghttp2_hd_inflate_init(&inflater, mem); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, reqnv, ARRLEN(reqnv), NULL)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + reqnv, ARRLEN(reqnv), NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(reqnv), ==, item->frame.headers.nvlen); assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) == - item->frame.hd.flags); + assert_uint8((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS), ==, + item->frame.hd.flags); ud.frame_send_cb_called = 0; ud.sent_frame_type = 0; /* The transimission will be canceled because the stream 1 is not open. */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, ud.frame_send_cb_called); stream = open_sent_stream(session, 1); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, reqnv, ARRLEN(reqnv), NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type); - CU_ASSERT(stream->shut_flags & NGHTTP2_SHUT_WR); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + reqnv, ARRLEN(reqnv), NULL)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.sent_frame_type); + assert_true(stream->shut_flags & NGHTTP2_SHUT_WR); - CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length)); + assert_int(0, ==, unpack_frame(&frame, acc.buf, acc.length)); nghttp2_bufs_add(&bufs, acc.buf, acc.length); inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem); - CU_ASSERT(ARRLEN(reqnv) == out.nvlen); + assert_size(ARRLEN(reqnv), ==, out.nvlen); assert_nv_equal(reqnv, out.nva, out.nvlen, mem); nva_out_reset(&out, mem); @@ -5903,16 +6113,16 @@ void test_nghttp2_submit_headers(void) { /* Try to depend on itself */ nghttp2_priority_spec_init(&pri_spec, 3, 16, 0); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 3, &pri_spec, - reqnv, ARRLEN(reqnv), NULL)); + assert_int32(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 3, &pri_spec, + reqnv, ARRLEN(reqnv), NULL)); session->next_stream_id = 5; nghttp2_priority_spec_init(&pri_spec, 5, 16, 0); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, &pri_spec, - reqnv, ARRLEN(reqnv), NULL)); + assert_int32(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, &pri_spec, + reqnv, ARRLEN(reqnv), NULL)); nghttp2_session_del(session); @@ -5921,14 +6131,14 @@ void test_nghttp2_submit_headers(void) { /* Sending nghttp2_submit_headers() with stream_id == 1 and server session is error */ - CU_ASSERT(NGHTTP2_ERR_PROTO == - nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, NULL, reqnv, - ARRLEN(reqnv), NULL)); + assert_int32(NGHTTP2_ERR_PROTO, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, NULL, + reqnv, ARRLEN(reqnv), NULL)); /* Sending stream ID <= 0 is error */ - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 0, NULL, resnv, - ARRLEN(resnv), NULL)); + assert_int32(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, 0, NULL, + resnv, ARRLEN(resnv), NULL)); nghttp2_session_del(session); } @@ -5953,21 +6163,22 @@ void test_nghttp2_submit_headers_continuation(void) { } memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &ud)); - CU_ASSERT(1 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, - NULL, nv, ARRLEN(nv), NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, &ud)); + assert_int32(1, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, + NULL, nv, ARRLEN(nv), NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) == - item->frame.hd.flags); - CU_ASSERT(0 == (item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY)); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_uint8((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS), ==, + item->frame.hd.flags); + assert_false(item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_session_del(session); } @@ -5992,7 +6203,7 @@ void test_nghttp2_submit_headers_continuation_extra_large(void) { } memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; /* The default size of max send header block length is too small to @@ -6000,18 +6211,20 @@ void test_nghttp2_submit_headers_continuation_extra_large(void) { nghttp2_option_new(&opt); nghttp2_option_set_max_send_header_block_length(opt, 102400); - CU_ASSERT(0 == nghttp2_session_client_new2(&session, &callbacks, &ud, opt)); - CU_ASSERT(1 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, - NULL, nv, ARRLEN(nv), NULL)); + assert_int(0, ==, + nghttp2_session_client_new2(&session, &callbacks, &ud, opt)); + assert_int32(1, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, + NULL, nv, ARRLEN(nv), NULL)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) == - item->frame.hd.flags); - CU_ASSERT(0 == (item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY)); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_uint8((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS), ==, + item->frame.hd.flags); + assert_false(item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_session_del(session); nghttp2_option_del(opt); @@ -6025,7 +6238,7 @@ void test_nghttp2_submit_priority(void) { nghttp2_priority_spec pri_spec; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; nghttp2_session_client_new(&session, &callbacks, &ud); @@ -6034,18 +6247,18 @@ void test_nghttp2_submit_priority(void) { nghttp2_priority_spec_init(&pri_spec, 0, 3, 0); /* depends on stream 0 */ - CU_ASSERT(0 == - nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(3 == stream->weight); + assert_int(0, ==, + nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(3, ==, stream->weight); /* submit against idle stream */ - CU_ASSERT(0 == - nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 3, &pri_spec)); + assert_int(0, ==, + nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 3, &pri_spec)); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_session_del(session); } @@ -6085,70 +6298,73 @@ void test_nghttp2_submit_settings(void) { iv[6].value = (uint32_t)NGHTTP2_MAX_WINDOW_SIZE + 1; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 7)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 7)); /* Make sure that local settings are not changed */ - CU_ASSERT(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS == - session->local_settings.max_concurrent_streams); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - session->local_settings.initial_window_size); + assert_uint32(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS, ==, + session->local_settings.max_concurrent_streams); + assert_uint32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + session->local_settings.initial_window_size); /* Now sends without 6th one */ - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 6)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 6)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_SETTINGS == item->frame.hd.type); + assert_uint8(NGHTTP2_SETTINGS, ==, item->frame.hd.type); frame = &item->frame; - CU_ASSERT(6 == frame->settings.niv); - CU_ASSERT(5 == frame->settings.iv[0].value); - CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == - frame->settings.iv[0].settings_id); + assert_size(6, ==, frame->settings.niv); + assert_uint32(5, ==, frame->settings.iv[0].value); + assert_int32(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ==, + frame->settings.iv[0].settings_id); - CU_ASSERT(16 * 1024 == frame->settings.iv[1].value); - CU_ASSERT(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE == - frame->settings.iv[1].settings_id); + assert_uint32(16 * 1024, ==, frame->settings.iv[1].value); + assert_int32(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, ==, + frame->settings.iv[1].settings_id); - CU_ASSERT(UNKNOWN_ID == frame->settings.iv[4].settings_id); - CU_ASSERT(999 == frame->settings.iv[4].value); + assert_int32(UNKNOWN_ID, ==, frame->settings.iv[4].settings_id); + assert_uint32(999, ==, frame->settings.iv[4].value); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); - CU_ASSERT(50 == session->pending_local_max_concurrent_stream); + assert_uint32(50, ==, session->pending_local_max_concurrent_stream); /* before receiving SETTINGS ACK, local settings have still default values */ - CU_ASSERT(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS == - nghttp2_session_get_local_settings( - session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - nghttp2_session_get_local_settings( - session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE)); + assert_uint32(NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS, ==, + nghttp2_session_get_local_settings( + session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)); + assert_uint32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + nghttp2_session_get_local_settings( + session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE)); nghttp2_frame_settings_init(&ack_frame.settings, NGHTTP2_FLAG_ACK, NULL, 0); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0)); + assert_int(0, ==, + nghttp2_session_on_settings_received(session, &ack_frame, 0)); nghttp2_frame_settings_free(&ack_frame.settings, mem); - CU_ASSERT(16 * 1024 == session->local_settings.initial_window_size); - CU_ASSERT(111 == session->hd_inflater.ctx.hd_table_bufsize_max); - CU_ASSERT(111 == session->hd_inflater.min_hd_table_bufsize_max); - CU_ASSERT(50 == session->local_settings.max_concurrent_streams); + assert_uint32(16 * 1024, ==, session->local_settings.initial_window_size); + assert_size(111, ==, session->hd_inflater.ctx.hd_table_bufsize_max); + assert_size(111, ==, session->hd_inflater.min_hd_table_bufsize_max); + assert_uint32(50, ==, session->local_settings.max_concurrent_streams); - CU_ASSERT(50 == nghttp2_session_get_local_settings( - session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)); - CU_ASSERT(16 * 1024 == nghttp2_session_get_local_settings( - session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE)); + assert_uint32(50, ==, + nghttp2_session_get_local_settings( + session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)); + assert_uint32(16 * 1024, ==, + nghttp2_session_get_local_settings( + session, NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE)); /* We just keep the last seen value */ - CU_ASSERT(50 == session->pending_local_max_concurrent_stream); + assert_uint32(50, ==, session->pending_local_max_concurrent_stream); nghttp2_session_del(session); @@ -6161,8 +6377,8 @@ void test_nghttp2_submit_settings(void) { iv[1].settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv[1].value = 0; - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 2)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 2)); nghttp2_session_del(session); @@ -6173,13 +6389,13 @@ void test_nghttp2_submit_settings(void) { iv[0].settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv[0].value = 1; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); iv[0].settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv[0].value = 0; - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); nghttp2_session_del(session); } @@ -6201,7 +6417,7 @@ void test_nghttp2_submit_settings_update_local_window_size(void) { iv[0].value = 16 * 1024; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -6211,20 +6427,21 @@ void test_nghttp2_submit_settings_update_local_window_size(void) { open_recv_stream(session, 3); - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, + nghttp2_session_on_settings_received(session, &ack_frame, 0)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(16 * 1024 + 100 == stream->local_window_size); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(16 * 1024 + 100, ==, stream->local_window_size); stream = nghttp2_session_get_stream(session, 3); - CU_ASSERT(16 * 1024 == stream->local_window_size); + assert_int32(16 * 1024, ==, stream->local_window_size); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(32768 == item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(32768, ==, item->frame.window_update.window_size_increment); nghttp2_session_del(session); @@ -6240,17 +6457,18 @@ void test_nghttp2_submit_settings_update_local_window_size(void) { stream->local_window_size = NGHTTP2_INITIAL_WINDOW_SIZE + 100; stream->recv_window_size = 32768; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, + nghttp2_session_on_settings_received(session, &ack_frame, 0)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(32768 == stream->recv_window_size); - CU_ASSERT(16 * 1024 + 100 == stream->local_window_size); + assert_int32(32768, ==, stream->recv_window_size); + assert_int32(16 * 1024 + 100, ==, stream->local_window_size); /* Check that we can handle the case where local_window_size < recv_window_size */ - CU_ASSERT(0 == nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int32(0, ==, nghttp2_session_get_stream_local_window_size(session, 1)); nghttp2_session_del(session); @@ -6260,13 +6478,15 @@ void test_nghttp2_submit_settings_update_local_window_size(void) { stream = open_recv_stream(session, 1); stream->local_window_size = NGHTTP2_MAX_WINDOW_SIZE; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, + nghttp2_session_on_settings_received(session, &ack_frame, 0)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_FLOW_CONTROL_ERROR == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_FLOW_CONTROL_ERROR, ==, + item->frame.rst_stream.error_code); nghttp2_session_del(session); nghttp2_frame_settings_free(&ack_frame.settings, mem); @@ -6280,7 +6500,7 @@ void test_nghttp2_submit_settings_multiple_times(void) { nghttp2_inflight_settings *inflight_settings; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -6291,60 +6511,60 @@ void test_nghttp2_submit_settings_multiple_times(void) { iv[1].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; iv[1].value = 0; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 2)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 2)); inflight_settings = session->inflight_settings_head; - CU_ASSERT(NULL != inflight_settings); - CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == - inflight_settings->iv[0].settings_id); - CU_ASSERT(100 == inflight_settings->iv[0].value); - CU_ASSERT(2 == inflight_settings->niv); - CU_ASSERT(NULL == inflight_settings->next); + assert_not_null(inflight_settings); + assert_int32(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ==, + inflight_settings->iv[0].settings_id); + assert_uint32(100, ==, inflight_settings->iv[0].value); + assert_size(2, ==, inflight_settings->niv); + assert_null(inflight_settings->next); - CU_ASSERT(100 == session->pending_local_max_concurrent_stream); - CU_ASSERT(0 == session->pending_enable_push); + assert_uint32(100, ==, session->pending_local_max_concurrent_stream); + assert_uint8(0, ==, session->pending_enable_push); /* second SETTINGS */ iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; iv[0].value = 99; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); + assert_int(0, ==, nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 1)); inflight_settings = session->inflight_settings_head->next; - CU_ASSERT(NULL != inflight_settings); - CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == - inflight_settings->iv[0].settings_id); - CU_ASSERT(99 == inflight_settings->iv[0].value); - CU_ASSERT(1 == inflight_settings->niv); - CU_ASSERT(NULL == inflight_settings->next); + assert_not_null(inflight_settings); + assert_int32(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ==, + inflight_settings->iv[0].settings_id); + assert_uint32(99, ==, inflight_settings->iv[0].value); + assert_size(1, ==, inflight_settings->niv); + assert_null(inflight_settings->next); - CU_ASSERT(99 == session->pending_local_max_concurrent_stream); - CU_ASSERT(0 == session->pending_enable_push); + assert_uint32(99, ==, session->pending_local_max_concurrent_stream); + assert_uint8(0, ==, session->pending_enable_push); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_ACK, NULL, 0); /* receive SETTINGS ACK */ - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); inflight_settings = session->inflight_settings_head; /* first inflight SETTINGS was removed */ - CU_ASSERT(NULL != inflight_settings); - CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == - inflight_settings->iv[0].settings_id); - CU_ASSERT(99 == inflight_settings->iv[0].value); - CU_ASSERT(1 == inflight_settings->niv); - CU_ASSERT(NULL == inflight_settings->next); + assert_not_null(inflight_settings); + assert_int32(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, ==, + inflight_settings->iv[0].settings_id); + assert_uint32(99, ==, inflight_settings->iv[0].value); + assert_size(1, ==, inflight_settings->niv); + assert_null(inflight_settings->next); - CU_ASSERT(100 == session->local_settings.max_concurrent_streams); + assert_uint32(100, ==, session->local_settings.max_concurrent_streams); /* receive SETTINGS ACK again */ - CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0)); + assert_int(0, ==, nghttp2_session_on_settings_received(session, &frame, 0)); - CU_ASSERT(NULL == session->inflight_settings_head); - CU_ASSERT(99 == session->local_settings.max_concurrent_streams); + assert_null(session->inflight_settings_head); + assert_uint32(99, ==, session->local_settings.max_concurrent_streams); nghttp2_session_del(session); } @@ -6356,42 +6576,43 @@ void test_nghttp2_submit_push_promise(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); open_recv_stream(session, 1); - CU_ASSERT(2 == nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1, - reqnv, ARRLEN(reqnv), &ud)); + assert_int32(2, ==, + nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1, reqnv, + ARRLEN(reqnv), &ud)); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NULL != stream); - CU_ASSERT(NGHTTP2_STREAM_RESERVED == stream->state); - CU_ASSERT(&ud == nghttp2_session_get_stream_user_data(session, 2)); + assert_not_null(stream); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_RESERVED, ==, stream->state); + assert_ptr_equal(&ud, nghttp2_session_get_stream_user_data(session, 2)); ud.frame_send_cb_called = 0; ud.sent_frame_type = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_PUSH_PROMISE == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_PUSH_PROMISE, ==, ud.sent_frame_type); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_RESERVED == stream->state); - CU_ASSERT(&ud == nghttp2_session_get_stream_user_data(session, 2)); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_RESERVED, ==, stream->state); + assert_ptr_equal(&ud, nghttp2_session_get_stream_user_data(session, 2)); /* submit PUSH_PROMISE while associated stream is not opened */ - CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == - nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 3, reqnv, - ARRLEN(reqnv), NULL)); + assert_int32(NGHTTP2_ERR_STREAM_CLOSED, ==, + nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 3, reqnv, + ARRLEN(reqnv), NULL)); /* Stream ID <= 0 is error */ - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 0, reqnv, - ARRLEN(reqnv), NULL)); + assert_int32(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 0, reqnv, + ARRLEN(reqnv), NULL)); nghttp2_session_del(session); } @@ -6404,42 +6625,42 @@ void test_nghttp2_submit_window_update(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, &ud); stream = open_recv_stream(session, 2); stream->recv_window_size = 4096; - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 1024)); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 1024)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(1024 == item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(3072 == stream->recv_window_size); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(1024, ==, item->frame.window_update.window_size_increment); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(3072, ==, stream->recv_window_size); - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 4096)); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 4096)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(4096 == item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == stream->recv_window_size); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(4096, ==, item->frame.window_update.window_size_increment); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(0, ==, stream->recv_window_size); - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 4096)); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 4096)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(4096 == item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == stream->recv_window_size); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(4096, ==, item->frame.window_update.window_size_increment); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int32(0, ==, stream->recv_window_size); - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 0)); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 0)); /* It is ok if stream is closed or does not exist at the call time */ - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 4, 4096)); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 4, 4096)); nghttp2_session_del(session); } @@ -6451,81 +6672,87 @@ void test_nghttp2_submit_window_update_local_window_size(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); stream = open_recv_stream(session, 2); stream->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, - stream->recv_window_size + 1)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1 == stream->local_window_size); - CU_ASSERT(0 == stream->recv_window_size); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, + stream->recv_window_size + 1)); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 1, ==, stream->local_window_size); + assert_int32(0, ==, stream->recv_window_size); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(4097 == item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(4097, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Let's decrement local window size */ stream->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, - -stream->local_window_size / 2)); - CU_ASSERT(32768 == stream->local_window_size); - CU_ASSERT(-28672 == stream->recv_window_size); - CU_ASSERT(32768 == stream->recv_reduction); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, + -stream->local_window_size / 2)); + assert_int32(32768, ==, stream->local_window_size); + assert_int32(-28672, ==, stream->recv_window_size); + assert_int32(32768, ==, stream->recv_reduction); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item == NULL); + assert_null(item); /* Increase local window size */ - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 16384)); - CU_ASSERT(49152 == stream->local_window_size); - CU_ASSERT(-12288 == stream->recv_window_size); - CU_ASSERT(16384 == stream->recv_reduction); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int( + 0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, 16384)); + assert_int32(49152, ==, stream->local_window_size); + assert_int32(-12288, ==, stream->recv_window_size); + assert_int32(16384, ==, stream->recv_reduction); + assert_null(nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(NGHTTP2_ERR_FLOW_CONTROL == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, - NGHTTP2_MAX_WINDOW_SIZE)); + assert_int(NGHTTP2_ERR_FLOW_CONTROL, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, + NGHTTP2_MAX_WINDOW_SIZE)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Check connection-level flow control */ session->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, - session->recv_window_size + 1)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1 == - session->local_window_size); - CU_ASSERT(0 == session->recv_window_size); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, + session->recv_window_size + 1)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1, ==, + session->local_window_size); + assert_int32(0, ==, session->recv_window_size); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(4097 == item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(4097, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Go decrement part */ session->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, - -session->local_window_size / 2)); - CU_ASSERT(32768 == session->local_window_size); - CU_ASSERT(-28672 == session->recv_window_size); - CU_ASSERT(32768 == session->recv_reduction); + assert_int(0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, + -session->local_window_size / 2)); + assert_int32(32768, ==, session->local_window_size); + assert_int32(-28672, ==, session->recv_window_size); + assert_int32(32768, ==, session->recv_reduction); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item == NULL); + assert_null(item); /* Increase local window size */ - CU_ASSERT(0 == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, 16384)); - CU_ASSERT(49152 == session->local_window_size); - CU_ASSERT(-12288 == session->recv_window_size); - CU_ASSERT(16384 == session->recv_reduction); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int( + 0, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, 16384)); + assert_int32(49152, ==, session->local_window_size); + assert_int32(-12288, ==, session->recv_window_size); + assert_int32(16384, ==, session->recv_reduction); + assert_null(nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(NGHTTP2_ERR_FLOW_CONTROL == - nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, - NGHTTP2_MAX_WINDOW_SIZE)); + assert_int(NGHTTP2_ERR_FLOW_CONTROL, ==, + nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, + NGHTTP2_MAX_WINDOW_SIZE)); nghttp2_session_del(session); } @@ -6536,43 +6763,44 @@ void test_nghttp2_submit_shutdown_notice(void) { my_user_data ud; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); - CU_ASSERT(0 == nghttp2_submit_shutdown_notice(session)); + assert_int(0, ==, nghttp2_submit_shutdown_notice(session)); ud.frame_send_cb_called = 0; nghttp2_session_send(session); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_GOAWAY == ud.sent_frame_type); - CU_ASSERT((1u << 31) - 1 == session->local_last_stream_id); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_GOAWAY, ==, ud.sent_frame_type); + assert_int32((1u << 31) - 1, ==, session->local_last_stream_id); /* After another GOAWAY, nghttp2_submit_shutdown_notice() is noop. */ - CU_ASSERT(0 == nghttp2_session_terminate_session(session, NGHTTP2_NO_ERROR)); + assert_int(0, ==, + nghttp2_session_terminate_session(session, NGHTTP2_NO_ERROR)); ud.frame_send_cb_called = 0; nghttp2_session_send(session); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_GOAWAY == ud.sent_frame_type); - CU_ASSERT(0 == session->local_last_stream_id); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_GOAWAY, ==, ud.sent_frame_type); + assert_int32(0, ==, session->local_last_stream_id); - CU_ASSERT(0 == nghttp2_submit_shutdown_notice(session)); + assert_int(0, ==, nghttp2_submit_shutdown_notice(session)); ud.frame_send_cb_called = 0; ud.frame_not_send_cb_called = 0; nghttp2_session_send(session); - CU_ASSERT(0 == ud.frame_send_cb_called); - CU_ASSERT(0 == ud.frame_not_send_cb_called); + assert_int(0, ==, ud.frame_send_cb_called); + assert_int(0, ==, ud.frame_not_send_cb_called); nghttp2_session_del(session); @@ -6580,8 +6808,8 @@ void test_nghttp2_submit_shutdown_notice(void) { is error */ nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_INVALID_STATE == - nghttp2_submit_shutdown_notice(session)); + assert_int(NGHTTP2_ERR_INVALID_STATE, ==, + nghttp2_submit_shutdown_notice(session)); nghttp2_session_del(session); } @@ -6597,31 +6825,35 @@ void test_nghttp2_submit_invalid_nv(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, NULL)); /* nghttp2_submit_response */ - CU_ASSERT(0 == nghttp2_submit_response(session, 2, empty_name_nv, - ARRLEN(empty_name_nv), NULL)); + assert_int(0, ==, + nghttp2_submit_response2(session, 2, empty_name_nv, + ARRLEN(empty_name_nv), NULL)); /* nghttp2_submit_push_promise */ open_recv_stream(session, 1); - CU_ASSERT(0 < nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1, - empty_name_nv, - ARRLEN(empty_name_nv), NULL)); + assert_int32(0, <, + nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1, + empty_name_nv, ARRLEN(empty_name_nv), + NULL)); nghttp2_session_del(session); - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); /* nghttp2_submit_request */ - CU_ASSERT(0 < nghttp2_submit_request(session, NULL, empty_name_nv, + assert_int32(0, <, + nghttp2_submit_request2(session, NULL, empty_name_nv, ARRLEN(empty_name_nv), NULL, NULL)); /* nghttp2_submit_headers */ - CU_ASSERT(0 < nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, NULL, - empty_name_nv, ARRLEN(empty_name_nv), - NULL)); + assert_int32(0, <, + nghttp2_submit_headers(session, NGHTTP2_FLAG_NONE, -1, NULL, + empty_name_nv, ARRLEN(empty_name_nv), + NULL)); nghttp2_session_del(session); } @@ -6641,8 +6873,8 @@ void test_nghttp2_submit_extension(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.pack_extension_callback = pack_extension_callback; - callbacks.send_callback = accumulator_send_callback; + callbacks.pack_extension_callback2 = pack_extension_callback; + callbacks.send_callback2 = accumulator_send_callback; nghttp2_buf_init2(&ud.scratchbuf, 4096, mem); @@ -6653,25 +6885,25 @@ void test_nghttp2_submit_extension(void) { rv = nghttp2_submit_extension(session, 211, 0x01, 3, &ud.scratchbuf); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); acc.length = 0; rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_FRAME_HDLEN + sizeof(data) == acc.length); + assert_int(0, ==, rv); + assert_size(NGHTTP2_FRAME_HDLEN + sizeof(data), ==, acc.length); len = nghttp2_get_uint32(acc.buf) >> 8; - CU_ASSERT(sizeof(data) == len); - CU_ASSERT(211 == acc.buf[3]); - CU_ASSERT(0x01 == acc.buf[4]); + assert_size(sizeof(data), ==, len); + assert_uint8(211, ==, acc.buf[3]); + assert_uint8(0x01, ==, acc.buf[4]); stream_id = (int32_t)nghttp2_get_uint32(acc.buf + 5); - CU_ASSERT(3 == stream_id); - CU_ASSERT(0 == memcmp(data, &acc.buf[NGHTTP2_FRAME_HDLEN], sizeof(data))); + assert_int32(3, ==, stream_id); + assert_memory_equal(sizeof(data), data, &acc.buf[NGHTTP2_FRAME_HDLEN]); nghttp2_session_del(session); @@ -6681,7 +6913,7 @@ void test_nghttp2_submit_extension(void) { rv = nghttp2_submit_extension(session, NGHTTP2_GOAWAY, NGHTTP2_FLAG_NONE, 0, NULL); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); nghttp2_session_del(session); nghttp2_buf_free(&ud.scratchbuf, mem); @@ -6692,7 +6924,7 @@ void test_nghttp2_submit_altsvc(void) { nghttp2_session_callbacks callbacks; my_user_data ud; int rv; - ssize_t len; + nghttp2_ssize len; const uint8_t *data; nghttp2_frame_hd hd; size_t origin_len; @@ -6707,42 +6939,42 @@ void test_nghttp2_submit_altsvc(void) { sizeof(origin) - 1, field_value, sizeof(field_value) - 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); ud.frame_send_cb_called = 0; - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len == NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1 + - sizeof(field_value) - 1); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1 + + sizeof(field_value) - 1, + ==, len); nghttp2_frame_unpack_frame_hd(&hd, data); - CU_ASSERT(2 + sizeof(origin) - 1 + sizeof(field_value) - 1 == hd.length); - CU_ASSERT(NGHTTP2_ALTSVC == hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); + assert_size(2 + sizeof(origin) - 1 + sizeof(field_value) - 1, ==, hd.length); + assert_uint8(NGHTTP2_ALTSVC, ==, hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); origin_len = nghttp2_get_uint16(data + NGHTTP2_FRAME_HDLEN); - CU_ASSERT(sizeof(origin) - 1 == origin_len); - CU_ASSERT(0 == - memcmp(origin, data + NGHTTP2_FRAME_HDLEN + 2, sizeof(origin) - 1)); - CU_ASSERT(0 == memcmp(field_value, - data + NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1, - hd.length - (sizeof(origin) - 1) - 2)); + assert_size(sizeof(origin) - 1, ==, origin_len); + assert_memory_equal(sizeof(origin) - 1, origin, + data + NGHTTP2_FRAME_HDLEN + 2); + assert_memory_equal(hd.length - (sizeof(origin) - 1) - 2, field_value, + data + NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1); /* submitting empty origin with stream_id == 0 is error */ rv = nghttp2_submit_altsvc(session, NGHTTP2_FLAG_NONE, 0, NULL, 0, field_value, sizeof(field_value) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* submitting non-empty origin with stream_id != 0 is error */ rv = nghttp2_submit_altsvc(session, NGHTTP2_FLAG_NONE, 1, origin, sizeof(origin) - 1, field_value, sizeof(field_value) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); nghttp2_session_del(session); @@ -6753,7 +6985,7 @@ void test_nghttp2_submit_altsvc(void) { sizeof(origin) - 1, field_value, sizeof(field_value) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_STATE == rv); + assert_int(NGHTTP2_ERR_INVALID_STATE, ==, rv); nghttp2_session_del(session); } @@ -6763,7 +6995,7 @@ void test_nghttp2_submit_origin(void) { nghttp2_session_callbacks callbacks; my_user_data ud; int rv; - ssize_t len; + nghttp2_ssize len; const uint8_t *data; static const uint8_t nghttp2[] = "https://nghttp2.org"; static const uint8_t examples[] = "https://examples.com"; @@ -6792,27 +7024,27 @@ void test_nghttp2_submit_origin(void) { rv = nghttp2_submit_origin(session, NGHTTP2_FLAG_NONE, ov, 2); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); ud.frame_send_cb_called = 0; - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len > 0); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_ptrdiff(0, <, len); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_frame_unpack_frame_hd(&frame.hd, data); rv = nghttp2_frame_unpack_origin_payload( &frame.ext, data + NGHTTP2_FRAME_HDLEN, (size_t)len - NGHTTP2_FRAME_HDLEN, mem); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == frame.hd.stream_id); - CU_ASSERT(NGHTTP2_ORIGIN == frame.hd.type); - CU_ASSERT(2 == origin.nov); - CU_ASSERT(0 == memcmp(nghttp2, origin.ov[0].origin, sizeof(nghttp2) - 1)); - CU_ASSERT(sizeof(nghttp2) - 1 == origin.ov[0].origin_len); - CU_ASSERT(0 == memcmp(examples, origin.ov[1].origin, sizeof(examples) - 1)); - CU_ASSERT(sizeof(examples) - 1 == origin.ov[1].origin_len); + assert_int(0, ==, rv); + assert_int32(0, ==, frame.hd.stream_id); + assert_uint8(NGHTTP2_ORIGIN, ==, frame.hd.type); + assert_size(2, ==, origin.nov); + assert_memory_equal(sizeof(nghttp2) - 1, nghttp2, origin.ov[0].origin); + assert_size(sizeof(nghttp2) - 1, ==, origin.ov[0].origin_len); + assert_memory_equal(sizeof(examples) - 1, examples, origin.ov[1].origin); + assert_size(sizeof(examples) - 1, ==, origin.ov[1].origin_len); nghttp2_frame_origin_free(&frame.ext, mem); @@ -6823,7 +7055,7 @@ void test_nghttp2_submit_origin(void) { rv = nghttp2_submit_origin(session, NGHTTP2_FLAG_NONE, ov, 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_STATE == rv); + assert_int(NGHTTP2_ERR_INVALID_STATE, ==, rv); nghttp2_session_del(session); @@ -6832,17 +7064,17 @@ void test_nghttp2_submit_origin(void) { rv = nghttp2_submit_origin(session, NGHTTP2_FLAG_NONE, NULL, 0); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); ud.frame_send_cb_called = 0; - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len == NGHTTP2_FRAME_HDLEN); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN, ==, len); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_frame_unpack_frame_hd(&frame.hd, data); - CU_ASSERT(NGHTTP2_ORIGIN == frame.hd.type); + assert_uint8(NGHTTP2_ORIGIN, ==, frame.hd.type); nghttp2_session_del(session); } @@ -6856,7 +7088,7 @@ void test_nghttp2_submit_priority_update(void) { int rv; nghttp2_frame frame; nghttp2_ext_priority_update priority_update; - ssize_t len; + nghttp2_ssize len; int32_t stream_id; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); @@ -6867,38 +7099,38 @@ void test_nghttp2_submit_priority_update(void) { session->pending_no_rfc7540_priorities = 1; stream_id = - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(1 == stream_id); + assert_int32(1, ==, stream_id); - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len > 0); + assert_ptrdiff(0, <, len); rv = nghttp2_submit_priority_update(session, NGHTTP2_FLAG_NONE, stream_id, field_value, sizeof(field_value) - 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); frame.ext.payload = &priority_update; ud.frame_send_cb_called = 0; - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len > 0); - CU_ASSERT(1 == ud.frame_send_cb_called); + assert_ptrdiff(0, <, len); + assert_int(1, ==, ud.frame_send_cb_called); nghttp2_frame_unpack_frame_hd(&frame.hd, data); nghttp2_frame_unpack_priority_update_payload( &frame.ext, (uint8_t *)(data + NGHTTP2_FRAME_HDLEN), (size_t)len - NGHTTP2_FRAME_HDLEN); - CU_ASSERT(0 == frame.hd.stream_id); - CU_ASSERT(NGHTTP2_PRIORITY_UPDATE == frame.hd.type); - CU_ASSERT(stream_id == priority_update.stream_id); - CU_ASSERT(sizeof(field_value) - 1 == priority_update.field_value_len); - CU_ASSERT(0 == memcmp(field_value, priority_update.field_value, - sizeof(field_value) - 1)); + assert_int32(0, ==, frame.hd.stream_id); + assert_uint8(NGHTTP2_PRIORITY_UPDATE, ==, frame.hd.type); + assert_int32(stream_id, ==, priority_update.stream_id); + assert_size(sizeof(field_value) - 1, ==, priority_update.field_value_len); + assert_memory_equal(sizeof(field_value) - 1, field_value, + priority_update.field_value); nghttp2_session_del(session); @@ -6910,7 +7142,7 @@ void test_nghttp2_submit_priority_update(void) { rv = nghttp2_submit_priority_update(session, NGHTTP2_FLAG_NONE, 1, field_value, sizeof(field_value) - 1); - CU_ASSERT(NGHTTP2_ERR_INVALID_STATE == rv); + assert_int(NGHTTP2_ERR_INVALID_STATE, ==, rv); nghttp2_session_del(session); @@ -6918,35 +7150,35 @@ void test_nghttp2_submit_priority_update(void) { nghttp2_session_client_new(&session, &callbacks, &ud); stream_id = - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(1 == stream_id); + assert_int32(1, ==, stream_id); - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len > 0); + assert_ptrdiff(0, <, len); rv = nghttp2_submit_priority_update(session, NGHTTP2_FLAG_NONE, stream_id, NULL, 0); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); frame.ext.payload = &priority_update; - len = nghttp2_session_mem_send(session, &data); + len = nghttp2_session_mem_send2(session, &data); - CU_ASSERT(len > 0); + assert_ptrdiff(0, <, len); nghttp2_frame_unpack_frame_hd(&frame.hd, data); nghttp2_frame_unpack_priority_update_payload( &frame.ext, (uint8_t *)(data + NGHTTP2_FRAME_HDLEN), (size_t)len - NGHTTP2_FRAME_HDLEN); - CU_ASSERT(0 == frame.hd.stream_id); - CU_ASSERT(NGHTTP2_PRIORITY_UPDATE == frame.hd.type); - CU_ASSERT(stream_id == priority_update.stream_id); - CU_ASSERT(0 == priority_update.field_value_len); - CU_ASSERT(NULL == priority_update.field_value); + assert_int32(0, ==, frame.hd.stream_id); + assert_uint8(NGHTTP2_PRIORITY_UPDATE, ==, frame.hd.type); + assert_int32(stream_id, ==, priority_update.stream_id); + assert_size(0, ==, priority_update.field_value_len); + assert_null(priority_update.field_value); nghttp2_session_del(session); } @@ -6966,11 +7198,11 @@ void test_nghttp2_submit_rst_stream(void) { rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_session_del(session); @@ -6980,11 +7212,11 @@ void test_nghttp2_submit_rst_stream(void) { rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 2, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_session_del(session); @@ -6996,13 +7228,13 @@ void test_nghttp2_submit_rst_stream(void) { rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(1 == item->frame.hd.stream_id); + assert_not_null(item); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.hd.stream_id); nghttp2_session_del(session); @@ -7014,13 +7246,13 @@ void test_nghttp2_submit_rst_stream(void) { rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 2, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(2 == item->frame.hd.stream_id); + assert_not_null(item); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(2, ==, item->frame.hd.stream_id); nghttp2_session_del(session); @@ -7028,26 +7260,26 @@ void test_nghttp2_submit_rst_stream(void) { nghttp2_session_client_new(&session, &callbacks, NULL); stream_id = - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(stream_id > 0); + assert_int32(0, <, stream_id); item = nghttp2_outbound_queue_top(&session->ob_syn); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT(0 == item->aux_data.headers.canceled); + assert_not_null(item); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_false(item->aux_data.headers.canceled); rv = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, stream_id, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); item = nghttp2_outbound_queue_top(&session->ob_syn); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT(1 == item->aux_data.headers.canceled); + assert_not_null(item); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_true(item->aux_data.headers.canceled); nghttp2_session_del(session); } @@ -7065,50 +7297,50 @@ void test_nghttp2_session_open_stream(void) { stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(0 == session->num_outgoing_streams); - CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); - CU_ASSERT(245 == stream->weight); - CU_ASSERT(&session->root == stream->dep_prev); - CU_ASSERT(NGHTTP2_SHUT_NONE == stream->shut_flags); + assert_size(1, ==, session->num_incoming_streams); + assert_size(0, ==, session->num_outgoing_streams); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENED, ==, stream->state); + assert_int32(245, ==, stream->weight); + assert_ptr_equal(&session->root, stream->dep_prev); + assert_uint8(NGHTTP2_SHUT_NONE, ==, stream->shut_flags); stream = nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE, &pri_spec_default, NGHTTP2_STREAM_OPENING, NULL); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(1 == session->num_outgoing_streams); - CU_ASSERT(&session->root == stream->dep_prev); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); - CU_ASSERT(NGHTTP2_SHUT_NONE == stream->shut_flags); + assert_size(1, ==, session->num_incoming_streams); + assert_size(1, ==, session->num_outgoing_streams); + assert_ptr_equal(&session->root, stream->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); + assert_uint8(NGHTTP2_SHUT_NONE, ==, stream->shut_flags); stream = nghttp2_session_open_stream(session, 4, NGHTTP2_STREAM_FLAG_NONE, &pri_spec_default, NGHTTP2_STREAM_RESERVED, NULL); - CU_ASSERT(1 == session->num_incoming_streams); - CU_ASSERT(1 == session->num_outgoing_streams); - CU_ASSERT(&session->root == stream->dep_prev); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); - CU_ASSERT(NGHTTP2_SHUT_RD == stream->shut_flags); + assert_size(1, ==, session->num_incoming_streams); + assert_size(1, ==, session->num_outgoing_streams); + assert_ptr_equal(&session->root, stream->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); + assert_uint8(NGHTTP2_SHUT_RD, ==, stream->shut_flags); nghttp2_priority_spec_init(&pri_spec, 1, 17, 1); stream = nghttp2_session_open_stream(session, 3, NGHTTP2_STREAM_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(17 == stream->weight); - CU_ASSERT(1 == stream->dep_prev->stream_id); + assert_int32(17, ==, stream->weight); + assert_int32(1, ==, stream->dep_prev->stream_id); /* Dependency to idle stream */ nghttp2_priority_spec_init(&pri_spec, 1000000007, 240, 1); stream = nghttp2_session_open_stream(session, 5, NGHTTP2_STREAM_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(240 == stream->weight); - CU_ASSERT(1000000007 == stream->dep_prev->stream_id); + assert_int32(240, ==, stream->weight); + assert_int32(1000000007, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream_raw(session, 1000000007); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); - CU_ASSERT(&session->root == stream->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); + assert_ptr_equal(&session->root, stream->dep_prev); /* Dependency to closed stream which is not in dependency tree */ session->last_recv_stream_id = 7; @@ -7118,8 +7350,8 @@ void test_nghttp2_session_open_stream(void) { stream = nghttp2_session_open_stream(session, 9, NGHTTP2_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); - CU_ASSERT(&session->root == stream->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); + assert_ptr_equal(&session->root, stream->dep_prev); nghttp2_session_del(session); @@ -7127,11 +7359,11 @@ void test_nghttp2_session_open_stream(void) { stream = nghttp2_session_open_stream(session, 4, NGHTTP2_STREAM_FLAG_NONE, &pri_spec_default, NGHTTP2_STREAM_RESERVED, NULL); - CU_ASSERT(0 == session->num_incoming_streams); - CU_ASSERT(0 == session->num_outgoing_streams); - CU_ASSERT(&session->root == stream->dep_prev); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); - CU_ASSERT(NGHTTP2_SHUT_WR == stream->shut_flags); + assert_size(0, ==, session->num_incoming_streams); + assert_size(0, ==, session->num_outgoing_streams); + assert_ptr_equal(&session->root, stream->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); + assert_uint8(NGHTTP2_SHUT_WR, ==, stream->shut_flags); nghttp2_session_del(session); } @@ -7151,13 +7383,13 @@ void test_nghttp2_session_open_stream_with_idle_stream_dep(void) { stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(245 == stream->weight); - CU_ASSERT(101 == stream->dep_prev->stream_id); + assert_int32(245, ==, stream->weight); + assert_int32(101, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream_raw(session, 101); - CU_ASSERT(NGHTTP2_STREAM_IDLE == stream->state); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, stream->state); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); nghttp2_priority_spec_init(&pri_spec, 211, 1, 0); @@ -7165,13 +7397,13 @@ void test_nghttp2_session_open_stream_with_idle_stream_dep(void) { stream = nghttp2_session_open_stream(session, 101, NGHTTP2_STREAM_FLAG_NONE, &pri_spec, NGHTTP2_STREAM_OPENED, NULL); - CU_ASSERT(1 == stream->weight); - CU_ASSERT(211 == stream->dep_prev->stream_id); + assert_int32(1, ==, stream->weight); + assert_int32(211, ==, stream->dep_prev->stream_id); stream = nghttp2_session_get_stream_raw(session, 211); - CU_ASSERT(NGHTTP2_STREAM_IDLE == stream->state); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, stream->state); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream->weight); nghttp2_session_del(session); } @@ -7182,22 +7414,23 @@ void test_nghttp2_session_get_next_ob_item(void) { nghttp2_priority_spec pri_spec; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); session->remote_settings.max_concurrent_streams = 2; - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL); - CU_ASSERT(NGHTTP2_PING == - nghttp2_session_get_next_ob_item(session)->frame.hd.type); + assert_uint8(NGHTTP2_PING, ==, + nghttp2_session_get_next_ob_item(session)->frame.hd.type); - CU_ASSERT(1 == nghttp2_submit_request(session, NULL, NULL, 0, NULL, NULL)); - CU_ASSERT(NGHTTP2_PING == - nghttp2_session_get_next_ob_item(session)->frame.hd.type); + assert_int32(1, ==, + nghttp2_submit_request2(session, NULL, NULL, 0, NULL, NULL)); + assert_uint8(NGHTTP2_PING, ==, + nghttp2_session_get_next_ob_item(session)->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); /* Incoming stream does not affect the number of outgoing max concurrent streams. */ @@ -7205,20 +7438,20 @@ void test_nghttp2_session_get_next_ob_item(void) { nghttp2_priority_spec_init(&pri_spec, 0, NGHTTP2_MAX_WEIGHT, 0); - CU_ASSERT(3 == - nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL)); - CU_ASSERT(NGHTTP2_HEADERS == - nghttp2_session_get_next_ob_item(session)->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(3, ==, + nghttp2_submit_request2(session, &pri_spec, NULL, 0, NULL, NULL)); + assert_uint8(NGHTTP2_HEADERS, ==, + nghttp2_session_get_next_ob_item(session)->frame.hd.type); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(5 == - nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(5, ==, + nghttp2_submit_request2(session, &pri_spec, NULL, 0, NULL, NULL)); + assert_null(nghttp2_session_get_next_ob_item(session)); session->remote_settings.max_concurrent_streams = 3; - CU_ASSERT(NGHTTP2_HEADERS == - nghttp2_session_get_next_ob_item(session)->frame.hd.type); + assert_uint8(NGHTTP2_HEADERS, ==, + nghttp2_session_get_next_ob_item(session)->frame.hd.type); nghttp2_session_del(session); @@ -7226,10 +7459,11 @@ void test_nghttp2_session_get_next_ob_item(void) { nghttp2_session_server_new(&session, &callbacks, NULL); session->remote_settings.max_concurrent_streams = 0; open_sent_stream2(session, 2, NGHTTP2_STREAM_RESERVED); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 2, - NULL, NULL, 0, NULL)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(1 == nghttp2_outbound_queue_size(&session->ob_syn)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 2, NULL, + NULL, 0, NULL)); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_size(1, ==, nghttp2_outbound_queue_size(&session->ob_syn)); nghttp2_session_del(session); } @@ -7242,30 +7476,30 @@ void test_nghttp2_session_pop_next_ob_item(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); session->remote_settings.max_concurrent_streams = 1; - CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session)); + assert_null(nghttp2_session_pop_next_ob_item(session)); nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL); nghttp2_priority_spec_init(&pri_spec, 0, 254, 0); - nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL); + nghttp2_submit_request2(session, &pri_spec, NULL, 0, NULL, NULL); item = nghttp2_session_pop_next_ob_item(session); - CU_ASSERT(NGHTTP2_PING == item->frame.hd.type); + assert_uint8(NGHTTP2_PING, ==, item->frame.hd.type); nghttp2_outbound_item_free(item, mem); mem->free(item, NULL); item = nghttp2_session_pop_next_ob_item(session); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); nghttp2_outbound_item_free(item, mem); mem->free(item, NULL); - CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session)); + assert_null(nghttp2_session_pop_next_ob_item(session)); /* Incoming stream does not affect the number of outgoing max concurrent streams. */ @@ -7275,14 +7509,14 @@ void test_nghttp2_session_pop_next_ob_item(void) { nghttp2_priority_spec_init(&pri_spec, 0, NGHTTP2_MAX_WEIGHT, 0); - nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL); + nghttp2_submit_request2(session, &pri_spec, NULL, 0, NULL, NULL); - CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session)); + assert_null(nghttp2_session_pop_next_ob_item(session)); session->remote_settings.max_concurrent_streams = 2; item = nghttp2_session_pop_next_ob_item(session); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); nghttp2_outbound_item_free(item, mem); mem->free(item, NULL); @@ -7292,28 +7526,29 @@ void test_nghttp2_session_pop_next_ob_item(void) { nghttp2_session_server_new(&session, &callbacks, NULL); session->remote_settings.max_concurrent_streams = 0; open_sent_stream2(session, 2, NGHTTP2_STREAM_RESERVED); - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 2, - NULL, NULL, 0, NULL)); - CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session)); - CU_ASSERT(1 == nghttp2_outbound_queue_size(&session->ob_syn)); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 2, NULL, + NULL, 0, NULL)); + assert_null(nghttp2_session_pop_next_ob_item(session)); + assert_size(1, ==, nghttp2_outbound_queue_size(&session->ob_syn)); nghttp2_session_del(session); } void test_nghttp2_session_reply_fail(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = fail_send_callback; + callbacks.send_callback2 = fail_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 4 * 1024; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_response(session, 1, NULL, 0, &data_prd)); - CU_ASSERT(NGHTTP2_ERR_CALLBACK_FAILURE == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_submit_response2(session, 1, NULL, 0, &data_prd)); + assert_int(NGHTTP2_ERR_CALLBACK_FAILURE, ==, nghttp2_session_send(session)); nghttp2_session_del(session); } @@ -7326,7 +7561,7 @@ void test_nghttp2_session_max_concurrent_streams(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); open_recv_stream(session, 1); @@ -7336,25 +7571,25 @@ void test_nghttp2_session_max_concurrent_streams(void) { NGHTTP2_HCAT_HEADERS, NULL, NULL, 0); session->pending_local_max_concurrent_stream = 1; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(NGHTTP2_REFUSED_STREAM == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_REFUSED_STREAM, ==, item->frame.rst_stream.error_code); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Check ACKed SETTINGS_MAX_CONCURRENT_STREAMS */ session->local_settings.max_concurrent_streams = 1; frame.hd.stream_id = 5; - CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK == - nghttp2_session_on_request_headers_received(session, &frame)); + assert_int(NGHTTP2_ERR_IGN_HEADER_BLOCK, ==, + nghttp2_session_on_request_headers_received(session, &frame)); item = nghttp2_outbound_queue_top(&session->ob_reg); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == item->frame.goaway.error_code); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_uint32(NGHTTP2_PROTOCOL_ERROR, ==, item->frame.goaway.error_code); nghttp2_frame_headers_free(&frame.headers, mem); nghttp2_session_del(session); @@ -7364,12 +7599,12 @@ void test_nghttp2_session_stop_data_with_rst_stream(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_frame frame; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_send_callback = on_frame_send_callback; - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; ud.frame_send_cb_called = 0; @@ -7377,28 +7612,28 @@ void test_nghttp2_session_stop_data_with_rst_stream(void) { nghttp2_session_server_new(&session, &callbacks, &ud); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - nghttp2_submit_response(session, 1, NULL, 0, &data_prd); + nghttp2_submit_response2(session, 1, NULL, 0, &data_prd); ud.block_count = 2; /* Sends response HEADERS + DATA[0] */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_DATA == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_DATA, ==, ud.sent_frame_type); /* data for DATA[1] is read from data_prd but it is not sent */ - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 2); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 2); nghttp2_frame_rst_stream_init(&frame.rst_stream, 1, NGHTTP2_CANCEL); - CU_ASSERT(0 == nghttp2_session_on_rst_stream_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_rst_stream_received(session, &frame)); nghttp2_frame_rst_stream_free(&frame.rst_stream); /* Big enough number to send all DATA frames potentially. */ ud.block_count = 100; /* Nothing will be sent in the following call. */ - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* With RST_STREAM, stream is canceled and further DATA on that stream are not sent. */ - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 2); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 2); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 1)); + assert_null(nghttp2_session_get_stream(session, 1)); nghttp2_session_del(session); } @@ -7407,13 +7642,13 @@ void test_nghttp2_session_defer_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_outbound_item *item; nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_send_callback = on_frame_send_callback; - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; data_prd.read_callback = defer_data_source_read_callback; ud.frame_send_cb_called = 0; @@ -7425,47 +7660,48 @@ void test_nghttp2_session_defer_data(void) { session->remote_window_size = 1 << 20; stream->remote_window_size = 1 << 20; - nghttp2_submit_response(session, 1, NULL, 0, &data_prd); + nghttp2_submit_response2(session, 1, NULL, 0, &data_prd); ud.block_count = 1; /* Sends HEADERS reply */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_HEADERS, ==, ud.sent_frame_type); /* No data is read */ - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 4); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 4); ud.block_count = 1; nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL); /* Sends PING */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_PING == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_PING, ==, ud.sent_frame_type); /* Resume deferred DATA */ - CU_ASSERT(0 == nghttp2_session_resume_data(session, 1)); + assert_int(0, ==, nghttp2_session_resume_data(session, 1)); item = stream->item; - item->aux_data.data.data_prd.read_callback = + item->aux_data.data.dpw.data_prd.v1.read_callback = fixed_length_data_source_read_callback; ud.block_count = 1; /* Reads 2 DATA chunks */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 2); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 2); /* Deferred again */ - item->aux_data.data.data_prd.read_callback = defer_data_source_read_callback; + item->aux_data.data.dpw.data_prd.v1.read_callback = + defer_data_source_read_callback; /* This is needed since 16KiB block is already read and waiting to be sent. No read_callback invocation. */ ud.block_count = 1; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 2); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 2); /* Resume deferred DATA */ - CU_ASSERT(0 == nghttp2_session_resume_data(session, 1)); - item->aux_data.data.data_prd.read_callback = + assert_int(0, ==, nghttp2_session_resume_data(session, 1)); + item->aux_data.data.dpw.data_prd.v1.read_callback = fixed_length_data_source_read_callback; ud.block_count = 1; /* Reads 2 16KiB blocks */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(ud.data_source_length == 0); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(ud.data_source_length, ==, 0); nghttp2_session_del(session); } @@ -7474,7 +7710,7 @@ void test_nghttp2_session_flow_control(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_frame frame; nghttp2_stream *stream; int32_t new_initial_window_size; @@ -7484,7 +7720,7 @@ void test_nghttp2_session_flow_control(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = fixed_bytes_send_callback; + callbacks.send_callback2 = fixed_bytes_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; @@ -7500,11 +7736,11 @@ void test_nghttp2_session_flow_control(void) { session->remote_window_size = 64 * 1024; session->remote_settings.initial_window_size = 64 * 1024; - nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL); + nghttp2_submit_request2(session, NULL, NULL, 0, &data_prd, NULL); /* Sends 64KiB - 1 data */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(64 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(64 * 1024, ==, ud.data_source_length); /* Back 32KiB in stream window */ nghttp2_frame_window_update_init(&frame.window_update, NGHTTP2_FLAG_NONE, 1, @@ -7512,16 +7748,16 @@ void test_nghttp2_session_flow_control(void) { nghttp2_session_on_window_update_received(session, &frame); /* Send nothing because of connection-level window */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(64 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(64 * 1024, ==, ud.data_source_length); /* Back 32KiB in connection-level window */ frame.hd.stream_id = 0; nghttp2_session_on_window_update_received(session, &frame); /* Sends another 32KiB data */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(32 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(32 * 1024, ==, ud.data_source_length); stream = nghttp2_session_get_stream(session, 1); /* Change initial window size to 16KiB. The window_size becomes @@ -7533,7 +7769,7 @@ void test_nghttp2_session_flow_control(void) { stream->remote_window_size); session->remote_settings.initial_window_size = (uint32_t)new_initial_window_size; - CU_ASSERT(-48 * 1024 == stream->remote_window_size); + assert_int32(-48 * 1024, ==, stream->remote_window_size); /* Back 48KiB to stream window */ frame.hd.stream_id = 1; @@ -7541,8 +7777,8 @@ void test_nghttp2_session_flow_control(void) { nghttp2_session_on_window_update_received(session, &frame); /* Nothing is sent because window_size is 0 */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(32 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(32 * 1024, ==, ud.data_source_length); /* Back 16KiB in stream window */ frame.hd.stream_id = 1; @@ -7555,8 +7791,8 @@ void test_nghttp2_session_flow_control(void) { nghttp2_session_on_window_update_received(session, &frame); /* Sends another 16KiB data */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(16 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(16 * 1024, ==, ud.data_source_length); /* Increase initial window size to 32KiB */ iv[0].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; @@ -7568,8 +7804,8 @@ void test_nghttp2_session_flow_control(void) { nghttp2_frame_settings_free(&settings_frame.settings, mem); /* Sends another 8KiB data */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(8 * 1024 == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(8 * 1024, ==, ud.data_source_length); /* Back 8KiB in connection-level window */ frame.hd.stream_id = 0; @@ -7577,10 +7813,10 @@ void test_nghttp2_session_flow_control(void) { nghttp2_session_on_window_update_received(session, &frame); /* Sends last 8KiB data */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.data_source_length); - CU_ASSERT(nghttp2_session_get_stream(session, 1)->shut_flags & - NGHTTP2_SHUT_WR); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(0, ==, ud.data_source_length); + assert_true(nghttp2_session_get_stream(session, 1)->shut_flags & + NGHTTP2_SHUT_WR); nghttp2_frame_window_update_free(&frame.window_update); nghttp2_session_del(session); @@ -7595,7 +7831,7 @@ void test_nghttp2_session_flow_control_data_recv(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* Initial window size to 64KiB - 1*/ nghttp2_session_client_new(&session, &callbacks, NULL); @@ -7613,34 +7849,36 @@ void test_nghttp2_session_flow_control_data_recv(void) { NGHTTP2_FLAG_END_STREAM, 1); nghttp2_frame_pack_frame_hd(data, &hd); - CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN == - nghttp2_session_mem_recv( - session, data, NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN)); + assert_ptrdiff( + NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN, ==, + nghttp2_session_mem_recv2(session, data, + NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN)); item = nghttp2_session_get_next_ob_item(session); /* Since this is the last frame, stream-level WINDOW_UPDATE is not issued, but connection-level is. */ - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(0 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN == - item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.hd.stream_id); + assert_int32(NGHTTP2_MAX_PAYLOADLEN, ==, + item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Receive DATA for closed stream. They are still subject to under connection-level flow control, since this situation arises when RST_STREAM is issued by the remote, but the local side keeps sending DATA frames. Without calculating connection-level window, the subsequent flow control gets confused. */ - CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN == - nghttp2_session_mem_recv( - session, data, NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN)); + assert_ptrdiff( + NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN, ==, + nghttp2_session_mem_recv2(session, data, + NGHTTP2_MAX_PAYLOADLEN + NGHTTP2_FRAME_HDLEN)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(0 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN == - item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.hd.stream_id); + assert_int32(NGHTTP2_MAX_PAYLOADLEN, ==, + item->frame.window_update.window_size_increment); nghttp2_session_del(session); } @@ -7654,7 +7892,7 @@ void test_nghttp2_session_flow_control_data_with_padding_recv(void) { nghttp2_option *option; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_option_new(&option); /* Disable auto window update so that we can check padding is @@ -7676,66 +7914,69 @@ void test_nghttp2_session_flow_control_data_with_padding_recv(void) { /* Set Pad Length field, which itself is padding */ data[NGHTTP2_FRAME_HDLEN] = 255; - CU_ASSERT( - (ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length) == - nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + hd.length)); + assert_ptrdiff((nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + hd.length), ==, + nghttp2_session_mem_recv2(session, data, + NGHTTP2_FRAME_HDLEN + hd.length)); - CU_ASSERT((int32_t)hd.length == session->recv_window_size); - CU_ASSERT((int32_t)hd.length == stream->recv_window_size); - CU_ASSERT(256 == session->consumed_size); - CU_ASSERT(256 == stream->consumed_size); - CU_ASSERT(357 == session->recv_window_size); - CU_ASSERT(357 == stream->recv_window_size); + assert_int32((int32_t)hd.length, ==, session->recv_window_size); + assert_int32((int32_t)hd.length, ==, stream->recv_window_size); + assert_int32(256, ==, session->consumed_size); + assert_int32(256, ==, stream->consumed_size); + assert_int32(357, ==, session->recv_window_size); + assert_int32(357, ==, stream->recv_window_size); /* Receive the same DATA frame, but in 2 parts: first 9 + 1 + 102 bytes which includes 1st padding byte, and remainder */ - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + 103) == - nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 103)); - CU_ASSERT(258 == session->consumed_size); - CU_ASSERT(258 == stream->consumed_size); - CU_ASSERT(460 == session->recv_window_size); - CU_ASSERT(460 == stream->recv_window_size); + assert_ptrdiff( + (nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + 103), ==, + nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 103)); + assert_int32(258, ==, session->consumed_size); + assert_int32(258, ==, stream->consumed_size); + assert_int32(460, ==, session->recv_window_size); + assert_int32(460, ==, stream->recv_window_size); /* 357 - 103 = 254 bytes left */ - CU_ASSERT(254 == nghttp2_session_mem_recv(session, data, 254)); - CU_ASSERT(512 == session->consumed_size); - CU_ASSERT(512 == stream->consumed_size); - CU_ASSERT(714 == session->recv_window_size); - CU_ASSERT(714 == stream->recv_window_size); + assert_ptrdiff(254, ==, nghttp2_session_mem_recv2(session, data, 254)); + assert_int32(512, ==, session->consumed_size); + assert_int32(512, ==, stream->consumed_size); + assert_int32(714, ==, session->recv_window_size); + assert_int32(714, ==, stream->recv_window_size); /* Receive the same DATA frame, but in 2 parts: first 9 = 1 + 101 bytes which only includes data without padding, 2nd part is padding only */ - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + 102) == - nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 102)); - CU_ASSERT(513 == session->consumed_size); - CU_ASSERT(513 == stream->consumed_size); - CU_ASSERT(816 == session->recv_window_size); - CU_ASSERT(816 == stream->recv_window_size); + assert_ptrdiff( + (nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + 102), ==, + nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 102)); + assert_int32(513, ==, session->consumed_size); + assert_int32(513, ==, stream->consumed_size); + assert_int32(816, ==, session->recv_window_size); + assert_int32(816, ==, stream->recv_window_size); /* 357 - 102 = 255 bytes left */ - CU_ASSERT(255 == nghttp2_session_mem_recv(session, data, 255)); - CU_ASSERT(768 == session->consumed_size); - CU_ASSERT(768 == stream->consumed_size); - CU_ASSERT(1071 == session->recv_window_size); - CU_ASSERT(1071 == stream->recv_window_size); + assert_ptrdiff(255, ==, nghttp2_session_mem_recv2(session, data, 255)); + assert_int32(768, ==, session->consumed_size); + assert_int32(768, ==, stream->consumed_size); + assert_int32(1071, ==, session->recv_window_size); + assert_int32(1071, ==, stream->recv_window_size); /* Receive the same DATA frame, but in 2 parts: first 9 = 1 + 50 bytes which includes byte up to middle of data, 2nd part is the remainder */ - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + 51) == - nghttp2_session_mem_recv(session, data, NGHTTP2_FRAME_HDLEN + 51)); - CU_ASSERT(769 == session->consumed_size); - CU_ASSERT(769 == stream->consumed_size); - CU_ASSERT(1122 == session->recv_window_size); - CU_ASSERT(1122 == stream->recv_window_size); + assert_ptrdiff( + (nghttp2_ssize)(NGHTTP2_FRAME_HDLEN + 51), ==, + nghttp2_session_mem_recv2(session, data, NGHTTP2_FRAME_HDLEN + 51)); + assert_int32(769, ==, session->consumed_size); + assert_int32(769, ==, stream->consumed_size); + assert_int32(1122, ==, session->recv_window_size); + assert_int32(1122, ==, stream->recv_window_size); /* 357 - 51 = 306 bytes left */ - CU_ASSERT(306 == nghttp2_session_mem_recv(session, data, 306)); - CU_ASSERT(1024 == session->consumed_size); - CU_ASSERT(1024 == stream->consumed_size); - CU_ASSERT(1428 == session->recv_window_size); - CU_ASSERT(1428 == stream->recv_window_size); + assert_ptrdiff(306, ==, nghttp2_session_mem_recv2(session, data, 306)); + assert_int32(1024, ==, session->consumed_size); + assert_int32(1024, ==, stream->consumed_size); + assert_int32(1428, ==, session->recv_window_size); + assert_int32(1428, ==, stream->recv_window_size); nghttp2_session_del(session); } @@ -7744,13 +7985,13 @@ void test_nghttp2_session_data_read_temporal_failure(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_frame frame; nghttp2_stream *stream; size_t data_size = 128 * 1024; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; @@ -7758,17 +7999,18 @@ void test_nghttp2_session_data_read_temporal_failure(void) { /* Initial window size is 64KiB - 1 */ nghttp2_session_client_new(&session, &callbacks, &ud); - nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL); + nghttp2_submit_request2(session, NULL, NULL, 0, &data_prd, NULL); /* Sends NGHTTP2_INITIAL_WINDOW_SIZE data, assuming, it is equal to or smaller than NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(data_size - NGHTTP2_INITIAL_WINDOW_SIZE == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(data_size - NGHTTP2_INITIAL_WINDOW_SIZE, ==, + ud.data_source_length); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_DATA == stream->item->frame.hd.type); + assert_uint8(NGHTTP2_DATA, ==, stream->item->frame.hd.type); - stream->item->aux_data.data.data_prd.read_callback = + stream->item->aux_data.data.dpw.data_prd.v1.read_callback = temporal_failure_data_source_read_callback; /* Back NGHTTP2_INITIAL_WINDOW_SIZE to both connection-level and @@ -7782,16 +8024,17 @@ void test_nghttp2_session_data_read_temporal_failure(void) { /* Sending data will fail (soft fail) and treated as stream error */ ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(data_size - NGHTTP2_INITIAL_WINDOW_SIZE == ud.data_source_length); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(data_size - NGHTTP2_INITIAL_WINDOW_SIZE, ==, + ud.data_source_length); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_RST_STREAM == ud.sent_frame_type); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_RST_STREAM, ==, ud.sent_frame_type); data_prd.read_callback = fail_data_source_read_callback; - nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL); + nghttp2_submit_request2(session, NULL, NULL, 0, &data_prd, NULL); /* Sending data will fail (hard fail) and session tear down */ - CU_ASSERT(NGHTTP2_ERR_CALLBACK_FAILURE == nghttp2_session_send(session)); + assert_int(NGHTTP2_ERR_CALLBACK_FAILURE, ==, nghttp2_session_send(session)); nghttp2_session_del(session); } @@ -7810,9 +8053,9 @@ void test_nghttp2_session_on_stream_close(void) { stream = open_sent_stream3(session, 1, NGHTTP2_STREAM_FLAG_NONE, &pri_spec_default, NGHTTP2_STREAM_OPENED, &user_data); - CU_ASSERT(stream != NULL); - CU_ASSERT(nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR) == 0); - CU_ASSERT(user_data.stream_close_cb_called == 1); + assert_not_null(stream); + assert_int(0, ==, nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR)); + assert_int(1, ==, user_data.stream_close_cb_called); nghttp2_session_del(session); } @@ -7824,7 +8067,7 @@ void test_nghttp2_session_on_ctrl_not_send(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_not_send_callback = on_frame_not_send_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; user_data.frame_not_send_cb_called = 0; user_data.not_sent_frame_type = 0; user_data.not_sent_error = 0; @@ -7836,57 +8079,64 @@ void test_nghttp2_session_on_ctrl_not_send(void) { /* Check response HEADERS */ /* Send bogus stream ID */ - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 3, - NULL, NULL, 0, NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == user_data.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == user_data.not_sent_error); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 3, NULL, + NULL, 0, NULL)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, user_data.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, user_data.not_sent_frame_type); + assert_int(NGHTTP2_ERR_STREAM_CLOSED, ==, user_data.not_sent_error); user_data.frame_not_send_cb_called = 0; /* Shutdown transmission */ stream->shut_flags |= NGHTTP2_SHUT_WR; - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, NULL, 0, NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == user_data.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_STREAM_SHUT_WR == user_data.not_sent_error); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + NULL, 0, NULL)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, user_data.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, user_data.not_sent_frame_type); + assert_int(NGHTTP2_ERR_STREAM_SHUT_WR, ==, user_data.not_sent_error); stream->shut_flags = NGHTTP2_SHUT_NONE; user_data.frame_not_send_cb_called = 0; /* Queue RST_STREAM */ - CU_ASSERT(0 == nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, - NULL, NULL, 0, NULL)); - CU_ASSERT(0 == nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, - NGHTTP2_INTERNAL_ERROR)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == user_data.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSING == user_data.not_sent_error); + assert_int32(0, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 1, NULL, + NULL, 0, NULL)); + assert_int(0, ==, + nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 1, + NGHTTP2_INTERNAL_ERROR)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, user_data.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, user_data.not_sent_frame_type); + assert_int(NGHTTP2_ERR_STREAM_CLOSING, ==, user_data.not_sent_error); nghttp2_session_del(session); /* Check request HEADERS */ user_data.frame_not_send_cb_called = 0; - CU_ASSERT(nghttp2_session_client_new(&session, &callbacks, &user_data) == 0); + assert_int(0, ==, + nghttp2_session_client_new(&session, &callbacks, &user_data)); /* Maximum Stream ID is reached */ session->next_stream_id = (1u << 31) + 1; - CU_ASSERT(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE == - nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, NULL, - NULL, 0, NULL)); + assert_int32(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE, ==, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, + NULL, NULL, 0, NULL)); user_data.frame_not_send_cb_called = 0; /* GOAWAY received */ session->goaway_flags |= NGHTTP2_GOAWAY_RECV; session->next_stream_id = 9; - CU_ASSERT(0 < nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, - NULL, NULL, 0, NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == user_data.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type); - CU_ASSERT(NGHTTP2_ERR_START_STREAM_NOT_ALLOWED == user_data.not_sent_error); + assert_int32(0, <, + nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, -1, + NULL, NULL, 0, NULL)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, user_data.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, user_data.not_sent_frame_type); + assert_int(NGHTTP2_ERR_START_STREAM_NOT_ALLOWED, ==, + user_data.not_sent_error); nghttp2_session_del(session); } @@ -7896,15 +8146,16 @@ void test_nghttp2_session_get_outbound_queue_size(void) { nghttp2_session_callbacks callbacks; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); - CU_ASSERT(0 == nghttp2_session_get_outbound_queue_size(session)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_size(0, ==, nghttp2_session_get_outbound_queue_size(session)); - CU_ASSERT(0 == nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL)); - CU_ASSERT(1 == nghttp2_session_get_outbound_queue_size(session)); + assert_int(0, ==, nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL)); + assert_size(1, ==, nghttp2_session_get_outbound_queue_size(session)); - CU_ASSERT(0 == nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE, 2, - NGHTTP2_NO_ERROR, NULL, 0)); - CU_ASSERT(2 == nghttp2_session_get_outbound_queue_size(session)); + assert_int(0, ==, + nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE, 2, + NGHTTP2_NO_ERROR, NULL, 0)); + assert_size(2, ==, nghttp2_session_get_outbound_queue_size(session)); nghttp2_session_del(session); } @@ -7915,84 +8166,89 @@ void test_nghttp2_session_get_effective_local_window_size(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); stream = open_sent_stream(session, 1); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE == - nghttp2_session_get_effective_local_window_size(session)); - CU_ASSERT(0 == nghttp2_session_get_effective_recv_data_length(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE, ==, + nghttp2_session_get_effective_local_window_size(session)); + assert_int32(0, ==, nghttp2_session_get_effective_recv_data_length(session)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - nghttp2_session_get_stream_effective_local_window_size(session, 1)); - CU_ASSERT(0 == - nghttp2_session_get_stream_effective_recv_data_length(session, 1)); + assert_int32( + NGHTTP2_INITIAL_WINDOW_SIZE, ==, + nghttp2_session_get_stream_effective_local_window_size(session, 1)); + assert_int32( + 0, ==, nghttp2_session_get_stream_effective_recv_data_length(session, 1)); /* Check connection flow control */ session->recv_window_size = 100; nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, 1100); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 == - nghttp2_session_get_effective_local_window_size(session)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 == - nghttp2_session_get_local_window_size(session)); - CU_ASSERT(0 == nghttp2_session_get_effective_recv_data_length(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_effective_local_window_size(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_local_window_size(session)); + assert_int32(0, ==, nghttp2_session_get_effective_recv_data_length(session)); nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, -50); /* Now session->recv_window_size = -50 */ - CU_ASSERT(-50 == session->recv_window_size); - CU_ASSERT(50 == session->recv_reduction); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950 == - nghttp2_session_get_effective_local_window_size(session)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 == - nghttp2_session_get_local_window_size(session)); - CU_ASSERT(0 == nghttp2_session_get_effective_recv_data_length(session)); + assert_int32(-50, ==, session->recv_window_size); + assert_int32(50, ==, session->recv_reduction); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950, ==, + nghttp2_session_get_effective_local_window_size(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_local_window_size(session)); + assert_int32(0, ==, nghttp2_session_get_effective_recv_data_length(session)); session->recv_window_size += 50; /* Now session->recv_window_size = 0 */ - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950 == - nghttp2_session_get_local_window_size(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 950, ==, + nghttp2_session_get_local_window_size(session)); nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, 100); - CU_ASSERT(50 == session->recv_window_size); - CU_ASSERT(0 == session->recv_reduction); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1050 == - nghttp2_session_get_effective_local_window_size(session)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000 == - nghttp2_session_get_local_window_size(session)); - CU_ASSERT(50 == nghttp2_session_get_effective_recv_data_length(session)); + assert_int32(50, ==, session->recv_window_size); + assert_int32(0, ==, session->recv_reduction); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1050, ==, + nghttp2_session_get_effective_local_window_size(session)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_local_window_size(session)); + assert_int32(50, ==, nghttp2_session_get_effective_recv_data_length(session)); /* Check stream flow control */ stream->recv_window_size = 100; nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 1, 1100); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 == - nghttp2_session_get_stream_effective_local_window_size(session, 1)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 == - nghttp2_session_get_stream_local_window_size(session, 1)); - CU_ASSERT(0 == - nghttp2_session_get_stream_effective_recv_data_length(session, 1)); + assert_int32( + NGHTTP2_INITIAL_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_stream_effective_local_window_size(session, 1)); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int32( + 0, ==, nghttp2_session_get_stream_effective_recv_data_length(session, 1)); nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 1, -50); /* Now stream->recv_window_size = -50 */ - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 950 == - nghttp2_session_get_stream_effective_local_window_size(session, 1)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 == - nghttp2_session_get_stream_local_window_size(session, 1)); - CU_ASSERT(0 == - nghttp2_session_get_stream_effective_recv_data_length(session, 1)); + assert_int32( + NGHTTP2_INITIAL_WINDOW_SIZE + 950, ==, + nghttp2_session_get_stream_effective_local_window_size(session, 1)); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int32( + 0, ==, nghttp2_session_get_stream_effective_recv_data_length(session, 1)); stream->recv_window_size += 50; /* Now stream->recv_window_size = 0 */ nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 1, 100); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1050 == - nghttp2_session_get_stream_effective_local_window_size(session, 1)); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE + 1000 == - nghttp2_session_get_stream_local_window_size(session, 1)); - CU_ASSERT(50 == - nghttp2_session_get_stream_effective_recv_data_length(session, 1)); + assert_int32( + NGHTTP2_INITIAL_WINDOW_SIZE + 1050, ==, + nghttp2_session_get_stream_effective_local_window_size(session, 1)); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE + 1000, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int32( + 50, ==, + nghttp2_session_get_stream_effective_recv_data_length(session, 1)); nghttp2_session_del(session); } @@ -8005,7 +8261,7 @@ void test_nghttp2_session_set_option(void) { int rv; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* Test for nghttp2_option_set_no_auto_window_update */ nghttp2_option_new(&option); @@ -8013,7 +8269,7 @@ void test_nghttp2_session_set_option(void) { nghttp2_session_client_new2(&session, &callbacks, NULL, option); - CU_ASSERT(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE); + assert_true(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE); nghttp2_session_del(session); nghttp2_option_del(option); @@ -8024,7 +8280,7 @@ void test_nghttp2_session_set_option(void) { nghttp2_session_client_new2(&session, &callbacks, NULL, option); - CU_ASSERT(100 == session->remote_settings.max_concurrent_streams); + assert_uint32(100, ==, session->remote_settings.max_concurrent_streams); nghttp2_session_del(session); nghttp2_option_del(option); @@ -8034,7 +8290,7 @@ void test_nghttp2_session_set_option(void) { nghttp2_session_client_new2(&session, &callbacks, NULL, option); - CU_ASSERT(99 == session->max_incoming_reserved_streams); + assert_size(99, ==, session->max_incoming_reserved_streams); nghttp2_session_del(session); nghttp2_option_del(option); @@ -8044,7 +8300,7 @@ void test_nghttp2_session_set_option(void) { nghttp2_session_client_new2(&session, &callbacks, NULL, option); - CU_ASSERT(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_PING_ACK); + assert_true(session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_PING_ACK); nghttp2_session_del(session); nghttp2_option_del(option); @@ -8057,15 +8313,15 @@ void test_nghttp2_session_set_option(void) { deflater = &session->hd_deflater; - rv = nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + rv = nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(1 == rv); + assert_int(1, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == deflater->deflate_hd_table_bufsize_max); - CU_ASSERT(0 == deflater->ctx.hd_table_bufsize); + assert_int(0, ==, rv); + assert_size(0, ==, deflater->deflate_hd_table_bufsize_max); + assert_size(0, ==, deflater->ctx.hd_table_bufsize); nghttp2_session_del(session); nghttp2_option_del(option); @@ -8075,11 +8331,11 @@ void test_nghttp2_session_data_backoff_by_high_pri_frame(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; my_user_data ud; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; data_prd.read_callback = fixed_length_data_source_read_callback; @@ -8087,34 +8343,34 @@ void test_nghttp2_session_data_backoff_by_high_pri_frame(void) { ud.data_source_length = NGHTTP2_DATA_PAYLOADLEN * 4; nghttp2_session_client_new(&session, &callbacks, &ud); - nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL); + nghttp2_submit_request2(session, NULL, NULL, 0, &data_prd, NULL); session->remote_window_size = 1 << 20; ud.block_count = 2; /* Sends request HEADERS + DATA[0] */ - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); stream = nghttp2_session_get_stream(session, 1); stream->remote_window_size = 1 << 20; - CU_ASSERT(NGHTTP2_DATA == ud.sent_frame_type); + assert_uint8(NGHTTP2_DATA, ==, ud.sent_frame_type); /* data for DATA[1] is read from data_prd but it is not sent */ - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN * 2); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN * 2); nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL); ud.block_count = 2; /* Sends DATA[1] + PING, PING is interleaved in DATA sequence */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_PING == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_PING, ==, ud.sent_frame_type); /* data for DATA[2] is read from data_prd but it is not sent */ - CU_ASSERT(ud.data_source_length == NGHTTP2_DATA_PAYLOADLEN); + assert_size(ud.data_source_length, ==, NGHTTP2_DATA_PAYLOADLEN); ud.block_count = 2; /* Sends DATA[2..3] */ - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(stream->shut_flags & NGHTTP2_SHUT_WR); + assert_true(stream->shut_flags & NGHTTP2_SHUT_WR); nghttp2_session_del(session); } @@ -8140,10 +8396,11 @@ static void check_session_recv_data_with_padding(nghttp2_bufs *bufs, ud.frame_recv_cb_called = 0; ud.data_chunk_len = 0; - CU_ASSERT((ssize_t)inlen == nghttp2_session_mem_recv(session, in, inlen)); + assert_ptrdiff((nghttp2_ssize)inlen, ==, + nghttp2_session_mem_recv2(session, in, inlen)); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(datalen == ud.data_chunk_len); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_size(datalen, ==, ud.data_chunk_len); mem->free(in, NULL); nghttp2_session_del(session); @@ -8153,7 +8410,7 @@ void test_nghttp2_session_pack_data_with_padding(void) { nghttp2_session *session; my_user_data ud; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; nghttp2_frame *frame; size_t datalen = 55; nghttp2_mem *mem; @@ -8161,9 +8418,9 @@ void test_nghttp2_session_pack_data_with_padding(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = block_count_send_callback; + callbacks.send_callback2 = block_count_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - callbacks.select_padding_callback = select_padding_callback; + callbacks.select_padding_callback2 = select_padding_callback; data_prd.read_callback = fixed_length_data_source_read_callback; @@ -8171,17 +8428,17 @@ void test_nghttp2_session_pack_data_with_padding(void) { ud.padlen = 63; - nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL); + nghttp2_submit_request2(session, NULL, NULL, 0, &data_prd, NULL); ud.block_count = 1; ud.data_source_length = datalen; /* Sends HEADERS */ - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type); + assert_int(0, ==, nghttp2_session_send(session)); + assert_uint8(NGHTTP2_HEADERS, ==, ud.sent_frame_type); frame = &session->aob.item->frame; - CU_ASSERT(ud.padlen == frame->data.padlen); - CU_ASSERT(frame->hd.flags & NGHTTP2_FLAG_PADDED); + assert_size(ud.padlen, ==, frame->data.padlen); + assert_true(frame->hd.flags & NGHTTP2_FLAG_PADDED); /* Check reception of this DATA frame */ check_session_recv_data_with_padding(&session->aob.framebufs, datalen, mem); @@ -8196,9 +8453,9 @@ void test_nghttp2_session_pack_headers_with_padding(void) { nghttp2_session_callbacks callbacks; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = accumulator_send_callback; + callbacks.send_callback2 = accumulator_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; - callbacks.select_padding_callback = select_padding_callback; + callbacks.select_padding_callback2 = select_padding_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; acc.length = 0; @@ -8209,16 +8466,17 @@ void test_nghttp2_session_pack_headers_with_padding(void) { ud.padlen = 163; - CU_ASSERT(1 == nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), - NULL, NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int32( + 1, ==, + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(acc.length < NGHTTP2_MAX_PAYLOADLEN); + assert_size(NGHTTP2_MAX_PAYLOADLEN, >, acc.length); ud.frame_recv_cb_called = 0; - CU_ASSERT((ssize_t)acc.length == - nghttp2_session_mem_recv(sv_session, acc.buf, acc.length)); - CU_ASSERT(1 == ud.frame_recv_cb_called); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(sv_session)); + assert_ptrdiff((nghttp2_ssize)acc.length, ==, + nghttp2_session_mem_recv2(sv_session, acc.buf, acc.length)); + assert_int(1, ==, ud.frame_recv_cb_called); + assert_null(nghttp2_session_get_next_ob_item(sv_session)); nghttp2_session_del(sv_session); nghttp2_session_del(session); @@ -8227,7 +8485,7 @@ void test_nghttp2_session_pack_headers_with_padding(void) { void test_nghttp2_pack_settings_payload(void) { nghttp2_settings_entry iv[2]; uint8_t buf[64]; - ssize_t len; + nghttp2_ssize len; nghttp2_settings_entry *resiv; size_t resniv; nghttp2_mem *mem; @@ -8239,28 +8497,29 @@ void test_nghttp2_pack_settings_payload(void) { iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; iv[1].value = 4095; - len = nghttp2_pack_settings_payload(buf, sizeof(buf), iv, 2); - CU_ASSERT(2 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH == len); - CU_ASSERT(0 == nghttp2_frame_unpack_settings_payload2(&resiv, &resniv, buf, - (size_t)len, mem)); - CU_ASSERT(2 == resniv); - CU_ASSERT(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE == resiv[0].settings_id); - CU_ASSERT(1023 == resiv[0].value); - CU_ASSERT(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE == resiv[1].settings_id); - CU_ASSERT(4095 == resiv[1].value); + len = nghttp2_pack_settings_payload2(buf, sizeof(buf), iv, 2); + assert_ptrdiff(2 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH, ==, len); + assert_int(0, ==, + nghttp2_frame_unpack_settings_payload2(&resiv, &resniv, buf, + (size_t)len, mem)); + assert_size(2, ==, resniv); + assert_int32(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE, ==, resiv[0].settings_id); + assert_uint32(1023, ==, resiv[0].value); + assert_int32(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, ==, resiv[1].settings_id); + assert_uint32(4095, ==, resiv[1].value); mem->free(resiv, NULL); - len = nghttp2_pack_settings_payload(buf, 9 /* too small */, iv, 2); - CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == len); + len = nghttp2_pack_settings_payload2(buf, 9 /* too small */, iv, 2); + assert_ptrdiff(NGHTTP2_ERR_INSUFF_BUFSIZE, ==, len); } #define check_stream_dep_sib(STREAM, DEP_PREV, DEP_NEXT, SIB_PREV, SIB_NEXT) \ do { \ - CU_ASSERT(DEP_PREV == STREAM->dep_prev); \ - CU_ASSERT(DEP_NEXT == STREAM->dep_next); \ - CU_ASSERT(SIB_PREV == STREAM->sib_prev); \ - CU_ASSERT(SIB_NEXT == STREAM->sib_next); \ + assert_ptr_equal(DEP_PREV, STREAM->dep_prev); \ + assert_ptr_equal(DEP_NEXT, STREAM->dep_next); \ + assert_ptr_equal(SIB_PREV, STREAM->sib_prev); \ + assert_ptr_equal(SIB_NEXT, STREAM->sib_next); \ } while (0) /* nghttp2_stream_dep_add() and its families functions should be @@ -8290,17 +8549,17 @@ void test_nghttp2_session_stream_dep_add(void) { * d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); check_stream_dep_sib(a, root, b, NULL, NULL); check_stream_dep_sib(b, a, NULL, NULL, c); check_stream_dep_sib(c, a, d, b, NULL); check_stream_dep_sib(d, c, NULL, NULL, NULL); - CU_ASSERT(a == session->root.dep_next); + assert_ptr_equal(a, session->root.dep_next); e = open_stream_with_dep_excl(session, 9, a); @@ -8313,11 +8572,11 @@ void test_nghttp2_session_stream_dep_add(void) { * d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == e->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, e->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); check_stream_dep_sib(a, root, e, NULL, NULL); check_stream_dep_sib(e, a, b, NULL, NULL); @@ -8325,7 +8584,7 @@ void test_nghttp2_session_stream_dep_add(void) { check_stream_dep_sib(c, e, d, b, NULL); check_stream_dep_sib(d, c, NULL, NULL, NULL); - CU_ASSERT(a == session->root.dep_next); + assert_ptr_equal(a, session->root.dep_next); nghttp2_session_del(session); } @@ -8362,17 +8621,17 @@ void test_nghttp2_session_stream_dep_remove(void) { * d */ - CU_ASSERT(0 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); + assert_int32(0, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); check_stream_dep_sib(a, NULL, NULL, NULL, NULL); check_stream_dep_sib(b, root, NULL, c, NULL); check_stream_dep_sib(c, root, d, NULL, b); check_stream_dep_sib(d, c, NULL, NULL, NULL); - CU_ASSERT(c == session->root.dep_next); + assert_ptr_equal(c, session->root.dep_next); nghttp2_session_del(session); @@ -8403,17 +8662,17 @@ void test_nghttp2_session_stream_dep_remove(void) { * d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); check_stream_dep_sib(a, root, c, NULL, NULL); check_stream_dep_sib(b, NULL, NULL, NULL, NULL); check_stream_dep_sib(c, a, d, NULL, NULL); check_stream_dep_sib(d, c, NULL, NULL, NULL); - CU_ASSERT(a == session->root.dep_next); + assert_ptr_equal(a, session->root.dep_next); nghttp2_session_del(session); @@ -8443,11 +8702,11 @@ void test_nghttp2_session_stream_dep_remove(void) { * e--d--b */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(0 == c->sum_dep_weight); - CU_ASSERT(0 == e->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(0, ==, c->sum_dep_weight); + assert_int32(0, ==, e->sum_dep_weight); check_stream_dep_sib(a, root, e, NULL, NULL); check_stream_dep_sib(b, a, NULL, d, NULL); @@ -8476,12 +8735,12 @@ void test_nghttp2_session_stream_dep_remove(void) { * f--e */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 3 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(0 == e->sum_dep_weight); - CU_ASSERT(0 == f->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 3, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(0, ==, e->sum_dep_weight); + assert_int32(0, ==, f->sum_dep_weight); nghttp2_stream_dep_remove(c); @@ -8493,12 +8752,12 @@ void test_nghttp2_session_stream_dep_remove(void) { /* c's weight 16 is distributed evenly to e and f. Each weight of e and f becomes 8. */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 + 8 * 2 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(0 == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(0 == e->sum_dep_weight); - CU_ASSERT(0 == f->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2 + 8 * 2, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(0, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(0, ==, e->sum_dep_weight); + assert_int32(0, ==, f->sum_dep_weight); check_stream_dep_sib(a, root, d, NULL, NULL); check_stream_dep_sib(b, a, NULL, e, NULL); @@ -8548,12 +8807,12 @@ void test_nghttp2_session_stream_dep_add_subtree(void) { * f d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 3 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == e->sum_dep_weight); - CU_ASSERT(0 == f->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 3, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, e->sum_dep_weight); + assert_int32(0, ==, f->sum_dep_weight); check_stream_dep_sib(a, root, e, NULL, NULL); check_stream_dep_sib(b, a, NULL, c, NULL); @@ -8597,12 +8856,12 @@ void test_nghttp2_session_stream_dep_add_subtree(void) { * d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 3 == e->sum_dep_weight); - CU_ASSERT(0 == f->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 3, ==, e->sum_dep_weight); + assert_int32(0, ==, f->sum_dep_weight); check_stream_dep_sib(a, root, e, NULL, NULL); check_stream_dep_sib(e, a, f, NULL, NULL); @@ -8646,10 +8905,10 @@ void test_nghttp2_session_stream_dep_remove_subtree(void) { * b d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); check_stream_dep_sib(a, root, b, NULL, NULL); check_stream_dep_sib(b, a, NULL, NULL, NULL); @@ -8685,10 +8944,10 @@ void test_nghttp2_session_stream_dep_remove_subtree(void) { * d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); check_stream_dep_sib(a, root, c, NULL, NULL); check_stream_dep_sib(c, a, d, NULL, NULL); @@ -8723,11 +8982,11 @@ void test_nghttp2_session_stream_dep_remove_subtree(void) { * b--e d */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(0 == e->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(0, ==, e->sum_dep_weight); check_stream_dep_sib(a, root, b, NULL, NULL); check_stream_dep_sib(b, a, NULL, NULL, e); @@ -8764,7 +9023,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { */ nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_insert_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_insert_subtree(&session->root, c)); /* * c @@ -8774,13 +9033,13 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { * b */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == c->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, c->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); check_stream_dep_sib(c, root, a, NULL, NULL); check_stream_dep_sib(a, c, b, NULL, NULL); @@ -8801,7 +9060,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { */ nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_insert_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_insert_subtree(&session->root, c)); /* * c @@ -8809,13 +9068,13 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { * b--a */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == c->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); - CU_ASSERT(0 == a->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, c->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); + assert_int32(0, ==, a->sum_dep_weight); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); check_stream_dep_sib(c, root, b, NULL, NULL); check_stream_dep_sib(b, c, NULL, NULL, a); @@ -8839,7 +9098,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { */ nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_insert_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_insert_subtree(&session->root, c)); /* * c @@ -8849,15 +9108,15 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { * b */ - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT * 2 == c->sum_dep_weight); - CU_ASSERT(0 == d->sum_dep_weight); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == a->sum_dep_weight); - CU_ASSERT(0 == b->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT * 2, ==, c->sum_dep_weight); + assert_int32(0, ==, d->sum_dep_weight); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, a->sum_dep_weight); + assert_int32(0, ==, b->sum_dep_weight); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); check_stream_dep_sib(c, root, d, NULL, NULL); check_stream_dep_sib(d, c, NULL, NULL, a); @@ -8886,7 +9145,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { nghttp2_stream_attach_item(b, db); nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_insert_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_insert_subtree(&session->root, c)); /* * c @@ -8896,14 +9155,14 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { * b */ - CU_ASSERT(c->queued); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!d->queued); + assert_true(c->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!d->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); check_stream_dep_sib(c, root, d, NULL, NULL); check_stream_dep_sib(d, c, NULL, NULL, a); @@ -8934,7 +9193,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { nghttp2_stream_attach_item(c, dc); nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_insert_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_insert_subtree(&session->root, c)); /* * c @@ -8944,10 +9203,10 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void) { * b */ - CU_ASSERT(c->queued); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!d->queued); + assert_true(c->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!d->queued); check_stream_dep_sib(c, root, d, NULL, NULL); check_stream_dep_sib(d, c, NULL, NULL, a); @@ -8986,80 +9245,80 @@ void test_nghttp2_session_stream_attach_item(void) { nghttp2_stream_attach_item(b, db); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); /* Attach item to c */ dc = create_data_ob_item(mem); nghttp2_stream_attach_item(c, dc); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(!d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); /* Attach item to a */ da = create_data_ob_item(mem); nghttp2_stream_attach_item(a, da); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(!d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); /* Detach item from a */ nghttp2_stream_detach_item(a); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(!d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); /* Attach item to d */ dd = create_data_ob_item(mem); nghttp2_stream_attach_item(d, dd); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); /* Detach item from c */ nghttp2_stream_detach_item(c); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); /* Detach item from b */ nghttp2_stream_detach_item(b); - CU_ASSERT(a->queued); - CU_ASSERT(!b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); + assert_true(a->queued); + assert_true(!b->queued); + assert_true(c->queued); + assert_true(d->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); /* exercises insertion */ e = open_stream_with_dep_excl(session, 9, a); @@ -9073,17 +9332,17 @@ void test_nghttp2_session_stream_attach_item(void) { * d */ - CU_ASSERT(a->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); + assert_true(a->queued); + assert_true(e->queued); + assert_true(!b->queued); + assert_true(c->queued); + assert_true(d->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_size(1, ==, nghttp2_pq_size(&e->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); /* exercises deletion */ nghttp2_stream_dep_remove(e); @@ -9095,20 +9354,20 @@ void test_nghttp2_session_stream_attach_item(void) { * d */ - CU_ASSERT(a->queued); - CU_ASSERT(!b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); + assert_true(a->queued); + assert_true(!b->queued); + assert_true(c->queued); + assert_true(d->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); /* e's weight 16 is distributed equally among c and b, both now have weight 8 each. */ - CU_ASSERT(8 == b->weight); - CU_ASSERT(8 == c->weight); + assert_int32(8, ==, b->weight); + assert_int32(8, ==, c->weight); /* da, db, dc have been detached */ nghttp2_outbound_item_free(da, mem); @@ -9142,28 +9401,28 @@ void test_nghttp2_session_stream_attach_item(void) { nghttp2_stream_attach_item(b, db); nghttp2_stream_attach_item(c, dc); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(!d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); /* Detach item from a */ nghttp2_stream_detach_item(a); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(!d->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(!d->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); /* da has been detached */ nghttp2_outbound_item_free(da, mem); @@ -9209,19 +9468,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { nghttp2_stream_attach_item(b, db); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Insert subtree e under a */ @@ -9238,25 +9497,25 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * d */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_size(1, ==, nghttp2_pq_size(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree b */ nghttp2_stream_dep_remove_subtree(b); - CU_ASSERT(0 == nghttp2_stream_dep_add_subtree(&session->root, b)); + assert_int(0, ==, nghttp2_stream_dep_add_subtree(&session->root, b)); /* * a b @@ -9268,45 +9527,45 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * d */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree a, and add it to root again */ nghttp2_stream_dep_remove_subtree(a); - CU_ASSERT(0 == nghttp2_stream_dep_add_subtree(&session->root, a)); + assert_int(0, ==, nghttp2_stream_dep_add_subtree(&session->root, a)); - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree c */ nghttp2_stream_dep_remove_subtree(c); - CU_ASSERT(0 == nghttp2_stream_dep_add_subtree(&session->root, c)); + assert_int(0, ==, nghttp2_stream_dep_add_subtree(&session->root, c)); /* * a b c @@ -9316,19 +9575,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * f */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(!c->queued); - CU_ASSERT(!d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(!c->queued); + assert_true(!d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(nghttp2_pq_empty(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_true(nghttp2_pq_empty(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); dd = create_data_ob_item(mem); @@ -9347,19 +9606,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * d f */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(2 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(nghttp2_pq_empty(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(2, ==, nghttp2_pq_size(&a->obq)); + assert_true(nghttp2_pq_empty(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Insert b under a */ @@ -9376,24 +9635,24 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * d f */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(1 == nghttp2_pq_size(&a->obq)); - CU_ASSERT(2 == nghttp2_pq_size(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_size(1, ==, nghttp2_pq_size(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree b */ nghttp2_stream_dep_remove_subtree(b); - CU_ASSERT(0 == nghttp2_stream_dep_add_subtree(&session->root, b)); + assert_int(0, ==, nghttp2_stream_dep_add_subtree(&session->root, b)); /* * b a @@ -9403,19 +9662,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * f d */ - CU_ASSERT(!a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(!a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(2 == nghttp2_pq_size(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree c, and detach item from b, and then re-add subtree c under b */ @@ -9432,19 +9691,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * f d */ - CU_ASSERT(!a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(!a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(2 == nghttp2_pq_size(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Attach data to a, and add subtree a under b */ @@ -9461,19 +9720,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * f d */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(!f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(!f->queued); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(3 == nghttp2_pq_size(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(nghttp2_pq_empty(&e->obq)); - CU_ASSERT(nghttp2_pq_empty(&f->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_size(3, ==, nghttp2_pq_size(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_true(nghttp2_pq_empty(&e->obq)); + assert_true(nghttp2_pq_empty(&f->obq)); /* Remove subtree c, and add under f */ nghttp2_stream_dep_remove_subtree(c); @@ -9491,19 +9750,19 @@ void test_nghttp2_session_stream_attach_item_subtree(void) { * d */ - CU_ASSERT(a->queued); - CU_ASSERT(b->queued); - CU_ASSERT(c->queued); - CU_ASSERT(d->queued); - CU_ASSERT(e->queued); - CU_ASSERT(f->queued); + assert_true(a->queued); + assert_true(b->queued); + assert_true(c->queued); + assert_true(d->queued); + assert_true(e->queued); + assert_true(f->queued); - CU_ASSERT(nghttp2_pq_empty(&a->obq)); - CU_ASSERT(2 == nghttp2_pq_size(&b->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&c->obq)); - CU_ASSERT(nghttp2_pq_empty(&d->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&e->obq)); - CU_ASSERT(1 == nghttp2_pq_size(&f->obq)); + assert_true(nghttp2_pq_empty(&a->obq)); + assert_size(2, ==, nghttp2_pq_size(&b->obq)); + assert_size(1, ==, nghttp2_pq_size(&c->obq)); + assert_true(nghttp2_pq_empty(&d->obq)); + assert_size(1, ==, nghttp2_pq_size(&e->obq)); + assert_size(1, ==, nghttp2_pq_size(&f->obq)); /* db has been detached */ nghttp2_outbound_item_free(db, mem); @@ -9520,8 +9779,8 @@ void test_nghttp2_session_stream_get_state(void) { nghttp2_bufs bufs; nghttp2_buf *buf; nghttp2_stream *stream; - ssize_t rv; - nghttp2_data_provider data_prd; + nghttp2_ssize rv; + nghttp2_data_provider2 data_prd; nghttp2_frame frame; mem = nghttp2_mem_default(); @@ -9529,28 +9788,30 @@ void test_nghttp2_session_stream_get_state(void) { memset(&data_prd, 0, sizeof(data_prd)); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); nghttp2_hd_deflate_init(&deflater, mem); - CU_ASSERT(NGHTTP2_STREAM_STATE_IDLE == - nghttp2_stream_get_state(nghttp2_session_get_root_stream(session))); + assert_enum( + nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_IDLE, ==, + nghttp2_stream_get_state(nghttp2_session_get_root_stream(session))); /* stream 1 HEADERS; without END_STREAM flag set */ pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); stream = nghttp2_session_find_stream(session, 1); - CU_ASSERT(NULL != stream); - CU_ASSERT(1 == stream->stream_id); - CU_ASSERT(NGHTTP2_STREAM_STATE_OPEN == nghttp2_stream_get_state(stream)); + assert_not_null(stream); + assert_int32(1, ==, stream->stream_id); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_OPEN, ==, + nghttp2_stream_get_state(stream)); nghttp2_bufs_reset(&bufs); @@ -9560,41 +9821,44 @@ void test_nghttp2_session_stream_get_state(void) { ARRLEN(reqnv), mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); stream = nghttp2_session_find_stream(session, 3); - CU_ASSERT(NULL != stream); - CU_ASSERT(3 == stream->stream_id); - CU_ASSERT(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE == - nghttp2_stream_get_state(stream)); + assert_not_null(stream); + assert_int32(3, ==, stream->stream_id); + assert_enum(nghttp2_stream_proto_state, + NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE, ==, + nghttp2_stream_get_state(stream)); nghttp2_bufs_reset(&bufs); /* Respond to stream 1 */ - nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), NULL); + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), NULL); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, + NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL, ==, + nghttp2_stream_get_state(stream)); /* Respond to stream 3 */ - nghttp2_submit_response(session, 3, resnv, ARRLEN(resnv), NULL); + nghttp2_submit_response2(session, 3, resnv, ARRLEN(resnv), NULL); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 3); - CU_ASSERT(NGHTTP2_STREAM_STATE_CLOSED == nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_CLOSED, ==, + nghttp2_stream_get_state(stream)); /* stream 5 HEADERS; with END_STREAM flag set */ pack_headers(&bufs, &deflater, 5, @@ -9602,9 +9866,9 @@ void test_nghttp2_session_stream_get_state(void) { ARRLEN(reqnv), mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); nghttp2_bufs_reset(&bufs); @@ -9612,57 +9876,58 @@ void test_nghttp2_session_stream_get_state(void) { rv = nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 5, reqnv, ARRLEN(reqnv), NULL); - CU_ASSERT(2 == rv); + assert_ptrdiff(2, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_STATE_RESERVED_LOCAL == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_RESERVED_LOCAL, + ==, nghttp2_stream_get_state(stream)); /* Send response to push stream 2 with END_STREAM set */ - nghttp2_submit_response(session, 2, resnv, ARRLEN(resnv), NULL); + nghttp2_submit_response2(session, 2, resnv, ARRLEN(resnv), NULL); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 2); /* At server, pushed stream object is not retained after closed */ - CU_ASSERT(NULL == stream); + assert_null(stream); /* Push stream 4 associated to stream 5 */ rv = nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 5, reqnv, ARRLEN(reqnv), NULL); - CU_ASSERT(4 == rv); + assert_ptrdiff(4, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 4); - CU_ASSERT(NGHTTP2_STREAM_STATE_RESERVED_LOCAL == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_RESERVED_LOCAL, + ==, nghttp2_stream_get_state(stream)); /* Send response to push stream 4 without closing */ data_prd.read_callback = defer_data_source_read_callback; - nghttp2_submit_response(session, 4, resnv, ARRLEN(resnv), &data_prd); + nghttp2_submit_response2(session, 4, resnv, ARRLEN(resnv), &data_prd); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_find_stream(session, 4); - CU_ASSERT(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, + NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE, ==, + nghttp2_stream_get_state(stream)); /* Create idle stream by PRIORITY frame */ nghttp2_frame_priority_init(&frame.priority, 7, &pri_spec_default); @@ -9672,13 +9937,14 @@ void test_nghttp2_session_stream_get_state(void) { nghttp2_frame_priority_free(&frame.priority); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); stream = nghttp2_session_find_stream(session, 7); - CU_ASSERT(NGHTTP2_STREAM_STATE_IDLE == nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_IDLE, ==, + nghttp2_stream_get_state(stream)); nghttp2_bufs_reset(&bufs); @@ -9690,25 +9956,25 @@ void test_nghttp2_session_stream_get_state(void) { nghttp2_session_client_new(&session, &callbacks, NULL); nghttp2_hd_deflate_init(&deflater, mem); - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); /* Receive PUSH_PROMISE 2 associated to stream 1 */ pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 2, reqnv, ARRLEN(reqnv), mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); stream = nghttp2_session_find_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_STATE_RESERVED_REMOTE == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, NGHTTP2_STREAM_STATE_RESERVED_REMOTE, + ==, nghttp2_stream_get_state(stream)); nghttp2_bufs_reset(&bufs); @@ -9717,14 +9983,15 @@ void test_nghttp2_session_stream_get_state(void) { ARRLEN(resnv), mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); stream = nghttp2_session_find_stream(session, 2); - CU_ASSERT(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL == - nghttp2_stream_get_state(stream)); + assert_enum(nghttp2_stream_proto_state, + NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL, ==, + nghttp2_stream_get_state(stream)); nghttp2_bufs_reset(&bufs); @@ -9745,28 +10012,28 @@ void test_nghttp2_session_stream_get_something(void) { a = open_stream(session, 1); - CU_ASSERT(nghttp2_session_get_root_stream(session) == - nghttp2_stream_get_parent(a)); - CU_ASSERT(NULL == nghttp2_stream_get_previous_sibling(a)); - CU_ASSERT(NULL == nghttp2_stream_get_next_sibling(a)); - CU_ASSERT(NULL == nghttp2_stream_get_first_child(a)); + assert_ptr_equal(nghttp2_session_get_root_stream(session), + nghttp2_stream_get_parent(a)); + assert_null(nghttp2_stream_get_previous_sibling(a)); + assert_null(nghttp2_stream_get_next_sibling(a)); + assert_null(nghttp2_stream_get_first_child(a)); b = open_stream_with_dep(session, 3, a); c = open_stream_with_dep_weight(session, 5, 11, a); - CU_ASSERT(a == nghttp2_stream_get_parent(c)); - CU_ASSERT(a == nghttp2_stream_get_parent(b)); + assert_ptr_equal(a, nghttp2_stream_get_parent(c)); + assert_ptr_equal(a, nghttp2_stream_get_parent(b)); - CU_ASSERT(c == nghttp2_stream_get_first_child(a)); + assert_ptr_equal(c, nghttp2_stream_get_first_child(a)); - CU_ASSERT(b == nghttp2_stream_get_next_sibling(c)); - CU_ASSERT(c == nghttp2_stream_get_previous_sibling(b)); + assert_ptr_equal(b, nghttp2_stream_get_next_sibling(c)); + assert_ptr_equal(c, nghttp2_stream_get_previous_sibling(b)); - CU_ASSERT(27 == nghttp2_stream_get_sum_dependency_weight(a)); + assert_int32(27, ==, nghttp2_stream_get_sum_dependency_weight(a)); - CU_ASSERT(11 == nghttp2_stream_get_weight(c)); - CU_ASSERT(5 == nghttp2_stream_get_stream_id(c)); - CU_ASSERT(0 == nghttp2_stream_get_stream_id(&session->root)); + assert_int32(11, ==, nghttp2_stream_get_weight(c)); + assert_int32(5, ==, nghttp2_stream_get_stream_id(c)); + assert_int32(0, ==, nghttp2_stream_get_stream_id(&session->root)); nghttp2_session_del(session); } @@ -9784,17 +10051,17 @@ void test_nghttp2_session_find_stream(void) { stream = nghttp2_session_find_stream(session, 1); - CU_ASSERT(NULL != stream); - CU_ASSERT(1 == stream->stream_id); + assert_not_null(stream); + assert_int32(1, ==, stream->stream_id); stream = nghttp2_session_find_stream(session, 0); - CU_ASSERT(&session->root == stream); - CU_ASSERT(0 == stream->stream_id); + assert_ptr_equal(&session->root, stream); + assert_int32(0, ==, stream->stream_id); stream = nghttp2_session_find_stream(session, 2); - CU_ASSERT(NULL == stream); + assert_null(stream); nghttp2_session_del(session); } @@ -9808,7 +10075,7 @@ void test_nghttp2_session_keep_closed_stream(void) { size_t i; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -9818,58 +10085,58 @@ void test_nghttp2_session_keep_closed_stream(void) { open_recv_stream(session, (int32_t)i * 2 + 1); } - CU_ASSERT(0 == session->num_closed_streams); + assert_size(0, ==, session->num_closed_streams); nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR); - CU_ASSERT(1 == session->num_closed_streams); - CU_ASSERT(1 == session->closed_stream_tail->stream_id); - CU_ASSERT(session->closed_stream_tail == session->closed_stream_head); + assert_size(1, ==, session->num_closed_streams); + assert_int32(1, ==, session->closed_stream_tail->stream_id); + assert_ptr_equal(session->closed_stream_tail, session->closed_stream_head); nghttp2_session_close_stream(session, 5, NGHTTP2_NO_ERROR); - CU_ASSERT(2 == session->num_closed_streams); - CU_ASSERT(5 == session->closed_stream_tail->stream_id); - CU_ASSERT(1 == session->closed_stream_head->stream_id); - CU_ASSERT(session->closed_stream_head == - session->closed_stream_tail->closed_prev); - CU_ASSERT(NULL == session->closed_stream_tail->closed_next); - CU_ASSERT(session->closed_stream_tail == - session->closed_stream_head->closed_next); - CU_ASSERT(NULL == session->closed_stream_head->closed_prev); + assert_size(2, ==, session->num_closed_streams); + assert_int32(5, ==, session->closed_stream_tail->stream_id); + assert_int32(1, ==, session->closed_stream_head->stream_id); + assert_ptr_equal(session->closed_stream_head, + session->closed_stream_tail->closed_prev); + assert_null(session->closed_stream_tail->closed_next); + assert_ptr_equal(session->closed_stream_tail, + session->closed_stream_head->closed_next); + assert_null(session->closed_stream_head->closed_prev); open_recv_stream(session, 11); nghttp2_session_adjust_closed_stream(session); - CU_ASSERT(1 == session->num_closed_streams); - CU_ASSERT(5 == session->closed_stream_tail->stream_id); - CU_ASSERT(session->closed_stream_tail == session->closed_stream_head); - CU_ASSERT(NULL == session->closed_stream_head->closed_prev); - CU_ASSERT(NULL == session->closed_stream_head->closed_next); + assert_size(1, ==, session->num_closed_streams); + assert_int32(5, ==, session->closed_stream_tail->stream_id); + assert_ptr_equal(session->closed_stream_tail, session->closed_stream_head); + assert_null(session->closed_stream_head->closed_prev); + assert_null(session->closed_stream_head->closed_next); open_recv_stream(session, 13); nghttp2_session_adjust_closed_stream(session); - CU_ASSERT(0 == session->num_closed_streams); - CU_ASSERT(NULL == session->closed_stream_tail); - CU_ASSERT(NULL == session->closed_stream_head); + assert_size(0, ==, session->num_closed_streams); + assert_null(session->closed_stream_tail); + assert_null(session->closed_stream_head); nghttp2_session_close_stream(session, 3, NGHTTP2_NO_ERROR); - CU_ASSERT(1 == session->num_closed_streams); - CU_ASSERT(3 == session->closed_stream_head->stream_id); + assert_size(1, ==, session->num_closed_streams); + assert_int32(3, ==, session->closed_stream_head->stream_id); /* server initiated stream is not counted to max concurrent limit */ open_sent_stream(session, 2); nghttp2_session_adjust_closed_stream(session); - CU_ASSERT(1 == session->num_closed_streams); - CU_ASSERT(3 == session->closed_stream_head->stream_id); + assert_size(1, ==, session->num_closed_streams); + assert_int32(3, ==, session->closed_stream_head->stream_id); nghttp2_session_close_stream(session, 2, NGHTTP2_NO_ERROR); - CU_ASSERT(1 == session->num_closed_streams); - CU_ASSERT(3 == session->closed_stream_head->stream_id); + assert_size(1, ==, session->num_closed_streams); + assert_int32(3, ==, session->closed_stream_head->stream_id); nghttp2_session_del(session); } @@ -9884,7 +10151,7 @@ void test_nghttp2_session_keep_idle_stream(void) { int32_t stream_id; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -9897,20 +10164,20 @@ void test_nghttp2_session_keep_idle_stream(void) { nghttp2_session_adjust_idle_stream(session); } - CU_ASSERT(NGHTTP2_MIN_IDLE_STREAMS == session->num_idle_streams); + assert_size(NGHTTP2_MIN_IDLE_STREAMS, ==, session->num_idle_streams); stream_id = (NGHTTP2_MIN_IDLE_STREAMS - 1) * 2 + 1; - CU_ASSERT(1 == session->idle_stream_head->stream_id); - CU_ASSERT(stream_id == session->idle_stream_tail->stream_id); + assert_int32(1, ==, session->idle_stream_head->stream_id); + assert_int32(stream_id, ==, session->idle_stream_tail->stream_id); stream_id += 2; open_recv_stream2(session, stream_id, NGHTTP2_STREAM_IDLE); nghttp2_session_adjust_idle_stream(session); - CU_ASSERT(NGHTTP2_MIN_IDLE_STREAMS == session->num_idle_streams); - CU_ASSERT(3 == session->idle_stream_head->stream_id); - CU_ASSERT(stream_id == session->idle_stream_tail->stream_id); + assert_size(NGHTTP2_MIN_IDLE_STREAMS, ==, session->num_idle_streams); + assert_int32(3, ==, session->idle_stream_head->stream_id); + assert_int32(stream_id, ==, session->idle_stream_tail->stream_id); nghttp2_session_del(session); } @@ -9922,7 +10189,7 @@ void test_nghttp2_session_detach_idle_stream(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -9931,38 +10198,38 @@ void test_nghttp2_session_detach_idle_stream(void) { &pri_spec_default, NGHTTP2_STREAM_IDLE, NULL); } - CU_ASSERT(3 == session->num_idle_streams); + assert_size(3, ==, session->num_idle_streams); /* Detach middle stream */ stream = nghttp2_session_get_stream_raw(session, 2); - CU_ASSERT(session->idle_stream_head == stream->closed_prev); - CU_ASSERT(session->idle_stream_tail == stream->closed_next); - CU_ASSERT(stream == session->idle_stream_head->closed_next); - CU_ASSERT(stream == session->idle_stream_tail->closed_prev); + assert_ptr_equal(session->idle_stream_head, stream->closed_prev); + assert_ptr_equal(session->idle_stream_tail, stream->closed_next); + assert_ptr_equal(stream, session->idle_stream_head->closed_next); + assert_ptr_equal(stream, session->idle_stream_tail->closed_prev); nghttp2_session_detach_idle_stream(session, stream); - CU_ASSERT(2 == session->num_idle_streams); + assert_size(2, ==, session->num_idle_streams); - CU_ASSERT(NULL == stream->closed_prev); - CU_ASSERT(NULL == stream->closed_next); + assert_null(stream->closed_prev); + assert_null(stream->closed_next); - CU_ASSERT(session->idle_stream_head == - session->idle_stream_tail->closed_prev); - CU_ASSERT(session->idle_stream_tail == - session->idle_stream_head->closed_next); + assert_ptr_equal(session->idle_stream_head, + session->idle_stream_tail->closed_prev); + assert_ptr_equal(session->idle_stream_tail, + session->idle_stream_head->closed_next); /* Detach head stream */ stream = session->idle_stream_head; nghttp2_session_detach_idle_stream(session, stream); - CU_ASSERT(1 == session->num_idle_streams); + assert_size(1, ==, session->num_idle_streams); - CU_ASSERT(session->idle_stream_head == session->idle_stream_tail); - CU_ASSERT(NULL == session->idle_stream_head->closed_prev); - CU_ASSERT(NULL == session->idle_stream_head->closed_next); + assert_ptr_equal(session->idle_stream_head, session->idle_stream_tail); + assert_null(session->idle_stream_head->closed_prev); + assert_null(session->idle_stream_head->closed_next); /* Detach last stream */ @@ -9970,17 +10237,17 @@ void test_nghttp2_session_detach_idle_stream(void) { nghttp2_session_detach_idle_stream(session, stream); - CU_ASSERT(0 == session->num_idle_streams); + assert_size(0, ==, session->num_idle_streams); - CU_ASSERT(NULL == session->idle_stream_head); - CU_ASSERT(NULL == session->idle_stream_tail); + assert_null(session->idle_stream_head); + assert_null(session->idle_stream_tail); for (i = 4; i <= 5; ++i) { nghttp2_session_open_stream(session, i, NGHTTP2_STREAM_FLAG_NONE, &pri_spec_default, NGHTTP2_STREAM_IDLE, NULL); } - CU_ASSERT(2 == session->num_idle_streams); + assert_size(2, ==, session->num_idle_streams); /* Detach tail stream */ @@ -9988,11 +10255,11 @@ void test_nghttp2_session_detach_idle_stream(void) { nghttp2_session_detach_idle_stream(session, stream); - CU_ASSERT(1 == session->num_idle_streams); + assert_size(1, ==, session->num_idle_streams); - CU_ASSERT(session->idle_stream_head == session->idle_stream_tail); - CU_ASSERT(NULL == session->idle_stream_head->closed_prev); - CU_ASSERT(NULL == session->idle_stream_head->closed_next); + assert_ptr_equal(session->idle_stream_head, session->idle_stream_tail); + assert_null(session->idle_stream_head->closed_prev); + assert_null(session->idle_stream_head->closed_next); nghttp2_session_del(session); } @@ -10006,7 +10273,7 @@ void test_nghttp2_session_large_dep_tree(void) { int32_t stream_id; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -10018,8 +10285,8 @@ void test_nghttp2_session_large_dep_tree(void) { stream_id = 1; for (i = 0; i < 250; ++i, stream_id += 2) { stream = nghttp2_session_get_stream(session, stream_id); - CU_ASSERT(nghttp2_stream_dep_find_ancestor(stream, &session->root)); - CU_ASSERT(nghttp2_stream_in_dep_tree(stream)); + assert_true(nghttp2_stream_dep_find_ancestor(stream, &session->root)); + assert_true(nghttp2_stream_in_dep_tree(stream)); } nghttp2_session_del(session); @@ -10031,7 +10298,7 @@ void test_nghttp2_session_graceful_shutdown(void) { my_user_data ud; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; callbacks.on_stream_close_callback = on_stream_close_callback; @@ -10043,44 +10310,46 @@ void test_nghttp2_session_graceful_shutdown(void) { open_recv_stream(session, 311); open_recv_stream(session, 319); - CU_ASSERT(0 == nghttp2_submit_shutdown_notice(session)); + assert_int(0, ==, nghttp2_submit_shutdown_notice(session)); ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT((1u << 31) - 1 == session->local_last_stream_id); + assert_int(1, ==, ud.frame_send_cb_called); + assert_int32((1u << 31) - 1, ==, session->local_last_stream_id); - CU_ASSERT(0 == nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE, 311, - NGHTTP2_NO_ERROR, NULL, 0)); + assert_int(0, ==, + nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE, 311, + NGHTTP2_NO_ERROR, NULL, 0)); ud.frame_send_cb_called = 0; ud.stream_close_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(311 == session->local_last_stream_id); - CU_ASSERT(1 == ud.stream_close_cb_called); + assert_int(1, ==, ud.frame_send_cb_called); + assert_int32(311, ==, session->local_last_stream_id); + assert_int(1, ==, ud.stream_close_cb_called); - CU_ASSERT(0 == - nghttp2_session_terminate_session2(session, 301, NGHTTP2_NO_ERROR)); + assert_int( + 0, ==, + nghttp2_session_terminate_session2(session, 301, NGHTTP2_NO_ERROR)); ud.frame_send_cb_called = 0; ud.stream_close_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(301 == session->local_last_stream_id); - CU_ASSERT(2 == ud.stream_close_cb_called); + assert_int(1, ==, ud.frame_send_cb_called); + assert_int32(301, ==, session->local_last_stream_id); + assert_int(2, ==, ud.stream_close_cb_called); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 301)); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 302)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 309)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 311)); - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 319)); + assert_not_null(nghttp2_session_get_stream(session, 301)); + assert_not_null(nghttp2_session_get_stream(session, 302)); + assert_null(nghttp2_session_get_stream(session, 309)); + assert_null(nghttp2_session_get_stream(session, 311)); + assert_null(nghttp2_session_get_stream(session, 319)); nghttp2_session_del(session); } @@ -10095,7 +10364,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) { nghttp2_nv nv[] = {MAKE_NV("alpha", "bravo"), MAKE_NV("charlie", "delta")}; nghttp2_nv *nva; size_t hdpos; - ssize_t rv; + nghttp2_ssize rv; nghttp2_frame frame; nghttp2_frame_hd hd; nghttp2_outbound_item *item; @@ -10134,18 +10403,18 @@ void test_nghttp2_session_on_header_temporal_failure(void) { nghttp2_frame_pack_frame_hd(&buf->pos[hdpos], &hd); ud.header_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_bufs_len(&bufs)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.header_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.header_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(1 == item->frame.hd.stream_id); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.hd.stream_id); /* Make sure no header decompression error occurred */ - CU_ASSERT(NGHTTP2_GOAWAY_NONE == session->goaway_flags); + assert_uint8(NGHTTP2_GOAWAY_NONE, ==, session->goaway_flags); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -10160,18 +10429,18 @@ void test_nghttp2_session_on_header_temporal_failure(void) { rv = pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 2, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.header_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(1 == ud.header_cb_called); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(1, ==, ud.header_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(2 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_INTERNAL_ERROR == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(2, ==, item->frame.hd.stream_id); + assert_uint32(NGHTTP2_INTERNAL_ERROR, ==, item->frame.rst_stream.error_code); nghttp2_session_del(session); nghttp2_hd_deflate_free(&deflater); @@ -10181,7 +10450,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) { void test_nghttp2_session_recv_client_magic(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - ssize_t rv; + nghttp2_ssize rv; nghttp2_frame ping_frame; uint8_t buf[16]; @@ -10193,21 +10462,23 @@ void test_nghttp2_session_recv_client_magic(void) { /* Check success case */ nghttp2_session_server_new(&session, &callbacks, NULL); - rv = nghttp2_session_mem_recv(session, (const uint8_t *)NGHTTP2_CLIENT_MAGIC, - NGHTTP2_CLIENT_MAGIC_LEN); + rv = nghttp2_session_mem_recv2(session, (const uint8_t *)NGHTTP2_CLIENT_MAGIC, + NGHTTP2_CLIENT_MAGIC_LEN); - CU_ASSERT(rv == NGHTTP2_CLIENT_MAGIC_LEN); - CU_ASSERT(NGHTTP2_IB_READ_FIRST_SETTINGS == session->iframe.state); + assert_ptrdiff(NGHTTP2_CLIENT_MAGIC_LEN, ==, rv); + assert_enum(nghttp2_inbound_state, NGHTTP2_IB_READ_FIRST_SETTINGS, ==, + session->iframe.state); /* Receiving PING is error because we want SETTINGS. */ nghttp2_frame_ping_init(&ping_frame.ping, NGHTTP2_FLAG_NONE, NULL); nghttp2_frame_pack_frame_hd(buf, &ping_frame.ping.hd); - rv = nghttp2_session_mem_recv(session, buf, NGHTTP2_FRAME_HDLEN); - CU_ASSERT(NGHTTP2_FRAME_HDLEN == rv); - CU_ASSERT(NGHTTP2_IB_IGN_ALL == session->iframe.state); - CU_ASSERT(0 == session->iframe.payloadleft); + rv = nghttp2_session_mem_recv2(session, buf, NGHTTP2_FRAME_HDLEN); + assert_ptrdiff(NGHTTP2_FRAME_HDLEN, ==, rv); + assert_enum(nghttp2_inbound_state, NGHTTP2_IB_IGN_ALL, ==, + session->iframe.state); + assert_size(0, ==, session->iframe.payloadleft); nghttp2_frame_ping_free(&ping_frame.ping); @@ -10217,16 +10488,17 @@ void test_nghttp2_session_recv_client_magic(void) { nghttp2_session_server_new(&session, &callbacks, NULL); /* Feed magic with one byte less */ - rv = nghttp2_session_mem_recv(session, (const uint8_t *)NGHTTP2_CLIENT_MAGIC, - NGHTTP2_CLIENT_MAGIC_LEN - 1); + rv = nghttp2_session_mem_recv2(session, (const uint8_t *)NGHTTP2_CLIENT_MAGIC, + NGHTTP2_CLIENT_MAGIC_LEN - 1); - CU_ASSERT(rv == NGHTTP2_CLIENT_MAGIC_LEN - 1); - CU_ASSERT(NGHTTP2_IB_READ_CLIENT_MAGIC == session->iframe.state); - CU_ASSERT(1 == session->iframe.payloadleft); + assert_ptrdiff(NGHTTP2_CLIENT_MAGIC_LEN - 1, ==, rv); + assert_enum(nghttp2_inbound_state, NGHTTP2_IB_READ_CLIENT_MAGIC, ==, + session->iframe.state); + assert_size(1, ==, session->iframe.payloadleft); - rv = nghttp2_session_mem_recv(session, (const uint8_t *)"\0", 1); + rv = nghttp2_session_mem_recv2(session, (const uint8_t *)"\0", 1); - CU_ASSERT(NGHTTP2_ERR_BAD_CLIENT_MAGIC == rv); + assert_ptrdiff(NGHTTP2_ERR_BAD_CLIENT_MAGIC, ==, rv); nghttp2_session_del(session); @@ -10238,7 +10510,7 @@ void test_nghttp2_session_delete_data_item(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; nghttp2_stream *a; - nghttp2_data_provider prd; + nghttp2_data_provider2 prd; memset(&callbacks, 0, sizeof(callbacks)); @@ -10251,8 +10523,8 @@ void test_nghttp2_session_delete_data_item(void) { prd.source.ptr = NULL; prd.read_callback = fail_data_source_read_callback; - CU_ASSERT(0 == nghttp2_submit_data(session, NGHTTP2_FLAG_NONE, 1, &prd)); - CU_ASSERT(0 == nghttp2_submit_data(session, NGHTTP2_FLAG_NONE, 3, &prd)); + assert_int(0, ==, nghttp2_submit_data2(session, NGHTTP2_FLAG_NONE, 1, &prd)); + assert_int(0, ==, nghttp2_submit_data2(session, NGHTTP2_FLAG_NONE, 3, &prd)); nghttp2_session_del(session); } @@ -10273,24 +10545,24 @@ void test_nghttp2_session_open_idle_stream(void) { nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); stream = nghttp2_session_get_stream_raw(session, 1); - CU_ASSERT(NGHTTP2_STREAM_IDLE == stream->state); - CU_ASSERT(NULL == stream->closed_prev); - CU_ASSERT(NULL == stream->closed_next); - CU_ASSERT(1 == session->num_idle_streams); - CU_ASSERT(session->idle_stream_head == stream); - CU_ASSERT(session->idle_stream_tail == stream); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, stream->state); + assert_null(stream->closed_prev); + assert_null(stream->closed_next); + assert_size(1, ==, session->num_idle_streams); + assert_ptr_equal(session->idle_stream_head, stream); + assert_ptr_equal(session->idle_stream_tail, stream); opened_stream = open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(stream == opened_stream); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); - CU_ASSERT(0 == session->num_idle_streams); - CU_ASSERT(NULL == session->idle_stream_head); - CU_ASSERT(NULL == session->idle_stream_tail); + assert_ptr_equal(stream, opened_stream); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); + assert_size(0, ==, session->num_idle_streams); + assert_null(session->idle_stream_head); + assert_null(session->idle_stream_tail); nghttp2_frame_priority_free(&frame.priority); @@ -10307,13 +10579,13 @@ void test_nghttp2_session_cancel_reserved_remote(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; mem = nghttp2_mem_default(); frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -10323,9 +10595,9 @@ void test_nghttp2_session_cancel_reserved_remote(void) { nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 2, NGHTTP2_CANCEL); - CU_ASSERT(NGHTTP2_STREAM_CLOSING == stream->state); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_CLOSING, ==, stream->state); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nvlen = ARRLEN(resnv); nghttp2_nv_array_copy(&nva, resnv, nvlen, mem); @@ -10334,19 +10606,19 @@ void test_nghttp2_session_cancel_reserved_remote(void) { NGHTTP2_HCAT_PUSH_RESPONSE, NULL, nva, nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); /* stream is not dangling, so assign NULL */ stream = NULL; /* No RST_STREAM or GOAWAY is generated since stream should be in NGHTTP2_STREAM_CLOSING and push response should be ignored. */ - CU_ASSERT(0 == nghttp2_outbound_queue_size(&session->ob_reg)); + assert_size(0, ==, nghttp2_outbound_queue_size(&session->ob_reg)); /* Check that we can receive push response HEADERS while RST_STREAM is just queued. */ @@ -10359,14 +10631,14 @@ void test_nghttp2_session_cancel_reserved_remote(void) { frame.hd.stream_id = 4; rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(1 == nghttp2_outbound_queue_size(&session->ob_reg)); + assert_size(1, ==, nghttp2_outbound_queue_size(&session->ob_reg)); nghttp2_frame_headers_free(&frame.headers, mem); @@ -10385,15 +10657,15 @@ void test_nghttp2_session_reset_pending_headers(void) { my_user_data ud; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; callbacks.on_stream_close_callback = on_stream_close_callback; nghttp2_session_client_new(&session, &callbacks, &ud); - stream_id = nghttp2_submit_request(session, NULL, NULL, 0, NULL, NULL); - CU_ASSERT(stream_id >= 1); + stream_id = nghttp2_submit_request2(session, NULL, NULL, 0, NULL, NULL); + assert_int32(1, <=, stream_id); nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, stream_id, NGHTTP2_CANCEL); @@ -10402,13 +10674,13 @@ void test_nghttp2_session_reset_pending_headers(void) { /* RST_STREAM cancels pending HEADERS and is not actually sent. */ ud.frame_send_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(0 == ud.frame_send_cb_called); + assert_int(0, ==, ud.frame_send_cb_called); stream = nghttp2_session_get_stream(session, stream_id); - CU_ASSERT(NULL == stream); + assert_null(stream); /* See HEADERS is not sent. on_stream_close is called just like transmission failure. */ @@ -10416,15 +10688,15 @@ void test_nghttp2_session_reset_pending_headers(void) { ud.frame_not_send_cb_called = 0; ud.stream_close_error_code = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_not_send_cb_called); - CU_ASSERT(NGHTTP2_HEADERS == ud.not_sent_frame_type); - CU_ASSERT(NGHTTP2_CANCEL == ud.stream_close_error_code); + assert_int(1, ==, ud.frame_not_send_cb_called); + assert_uint8(NGHTTP2_HEADERS, ==, ud.not_sent_frame_type); + assert_uint32(NGHTTP2_CANCEL, ==, ud.stream_close_error_code); stream = nghttp2_session_get_stream(session, stream_id); - CU_ASSERT(NULL == stream); + assert_null(stream); nghttp2_session_del(session); } @@ -10432,13 +10704,13 @@ void test_nghttp2_session_reset_pending_headers(void) { void test_nghttp2_session_send_data_callback(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; accumulator acc; nghttp2_frame_hd hd; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = accumulator_send_callback; + callbacks.send_callback2 = accumulator_send_callback; callbacks.send_data_callback = send_data_callback; data_prd.read_callback = no_copy_data_source_read_callback; @@ -10452,23 +10724,24 @@ void test_nghttp2_session_send_data_callback(void) { open_sent_stream(session, 1); - nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd); + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); - CU_ASSERT((NGHTTP2_FRAME_HDLEN + NGHTTP2_DATA_PAYLOADLEN) * 2 == acc.length); + assert_size((NGHTTP2_FRAME_HDLEN + NGHTTP2_DATA_PAYLOADLEN) * 2, ==, + acc.length); nghttp2_frame_unpack_frame_hd(&hd, acc.buf); - CU_ASSERT(16384 == hd.length); - CU_ASSERT(NGHTTP2_DATA == hd.type); - CU_ASSERT(NGHTTP2_FLAG_NONE == hd.flags); + assert_size(16384, ==, hd.length); + assert_uint8(NGHTTP2_DATA, ==, hd.type); + assert_uint8(NGHTTP2_FLAG_NONE, ==, hd.flags); nghttp2_frame_unpack_frame_hd(&hd, acc.buf + NGHTTP2_FRAME_HDLEN + hd.length); - CU_ASSERT(16384 == hd.length); - CU_ASSERT(NGHTTP2_DATA == hd.type); - CU_ASSERT(NGHTTP2_FLAG_END_STREAM == hd.flags); + assert_size(16384, ==, hd.length); + assert_uint8(NGHTTP2_DATA, ==, hd.type); + assert_uint8(NGHTTP2_FLAG_END_STREAM, ==, hd.flags); nghttp2_session_del(session); } @@ -10479,7 +10752,7 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) { my_user_data ud; nghttp2_bufs bufs; nghttp2_mem *mem; - ssize_t rv; + nghttp2_ssize rv; nghttp2_hd_deflater deflater; nghttp2_outbound_item *item; @@ -10492,25 +10765,25 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) { temporal_failure_on_begin_headers_callback; callbacks.on_header_callback = on_header_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, &ud); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.header_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.header_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.header_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(1 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_INTERNAL_ERROR == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.hd.stream_id); + assert_uint32(NGHTTP2_INTERNAL_ERROR, ==, item->frame.rst_stream.error_code); nghttp2_session_del(session); nghttp2_hd_deflate_free(&deflater); @@ -10524,20 +10797,20 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) { rv = pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 2, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud.header_cb_called = 0; ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv); - CU_ASSERT(0 == ud.header_cb_called); - CU_ASSERT(0 == ud.frame_recv_cb_called); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, rv); + assert_int(0, ==, ud.header_cb_called); + assert_int(0, ==, ud.frame_recv_cb_called); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(2 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_INTERNAL_ERROR == item->frame.rst_stream.error_code); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(2, ==, item->frame.hd.stream_id); + assert_uint32(NGHTTP2_INTERNAL_ERROR, ==, item->frame.rst_stream.error_code); nghttp2_session_del(session); nghttp2_hd_deflate_free(&deflater); @@ -10547,38 +10820,38 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) { void test_nghttp2_session_defer_then_close(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider prd; + nghttp2_data_provider2 prd; int rv; const uint8_t *datap; - ssize_t datalen; + nghttp2_ssize datalen; nghttp2_frame frame; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); prd.read_callback = defer_data_source_read_callback; - rv = nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), &prd, NULL); - CU_ASSERT(rv > 0); + rv = nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), &prd, NULL); + assert_ptrdiff(0, <, rv); /* This sends HEADERS */ - datalen = nghttp2_session_mem_send(session, &datap); + datalen = nghttp2_session_mem_send2(session, &datap); - CU_ASSERT(datalen > 0); + assert_ptrdiff(0, <, datalen); /* This makes DATA item deferred */ - datalen = nghttp2_session_mem_send(session, &datap); + datalen = nghttp2_session_mem_send2(session, &datap); - CU_ASSERT(datalen == 0); + assert_ptrdiff(0, ==, datalen); nghttp2_frame_rst_stream_init(&frame.rst_stream, 1, NGHTTP2_CANCEL); /* Assertion failure; GH-264 */ rv = nghttp2_session_on_rst_stream_received(session, &frame); - CU_ASSERT(rv == 0); + assert_int(0, ==, rv); nghttp2_session_del(session); } @@ -10587,7 +10860,7 @@ static int submit_response_on_stream_close(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *user_data) { - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; (void)error_code; (void)user_data; @@ -10596,12 +10869,14 @@ static int submit_response_on_stream_close(nghttp2_session *session, // Attempt to submit response or data to the stream being closed switch (stream_id) { case 1: - CU_ASSERT(0 == nghttp2_submit_response(session, stream_id, resnv, - ARRLEN(resnv), &data_prd)); + assert_int(0, ==, + nghttp2_submit_response2(session, stream_id, resnv, + ARRLEN(resnv), &data_prd)); break; case 3: - CU_ASSERT(0 == nghttp2_submit_data(session, NGHTTP2_FLAG_NONE, stream_id, - &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_NONE, stream_id, &data_prd)); break; } @@ -10614,7 +10889,7 @@ void test_nghttp2_session_detach_item_from_closed_stream(void) { memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_stream_close_callback = submit_response_on_stream_close; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -10625,7 +10900,7 @@ void test_nghttp2_session_detach_item_from_closed_stream(void) { nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR); nghttp2_session_close_stream(session, 3, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_session_del(session); } @@ -10655,13 +10930,14 @@ void test_nghttp2_session_flooding(void) { buf = &bufs.head->buf; for (i = 0; i < NGHTTP2_DEFAULT_MAX_OBQ_FLOOD_ITEM; ++i) { - CU_ASSERT( - (ssize_t)nghttp2_buf_len(buf) == - nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf))); + assert_ptrdiff( + (nghttp2_ssize)nghttp2_buf_len(buf), ==, + nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf))); } - CU_ASSERT(NGHTTP2_ERR_FLOODED == - nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf))); + assert_ptrdiff( + NGHTTP2_ERR_FLOODED, ==, + nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf))); nghttp2_session_del(session); @@ -10677,13 +10953,14 @@ void test_nghttp2_session_flooding(void) { buf = &bufs.head->buf; for (i = 0; i < NGHTTP2_DEFAULT_MAX_OBQ_FLOOD_ITEM; ++i) { - CU_ASSERT( - (ssize_t)nghttp2_buf_len(buf) == - nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf))); + assert_ptrdiff( + (nghttp2_ssize)nghttp2_buf_len(buf), ==, + nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf))); } - CU_ASSERT(NGHTTP2_ERR_FLOODED == - nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf))); + assert_ptrdiff( + NGHTTP2_ERR_FLOODED, ==, + nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf))); nghttp2_session_del(session); nghttp2_bufs_free(&bufs); @@ -10708,22 +10985,22 @@ void test_nghttp2_session_change_stream_priority(void) { rv = nghttp2_session_change_stream_priority(session, 2, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - CU_ASSERT(stream1 == stream2->dep_prev); - CU_ASSERT(256 == stream2->weight); + assert_ptr_equal(stream1, stream2->dep_prev); + assert_int32(256, ==, stream2->weight); /* Cannot change stream which does not exist */ rv = nghttp2_session_change_stream_priority(session, 5, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* It is an error to depend on itself */ rv = nghttp2_session_change_stream_priority(session, 1, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* It is an error to change priority of root stream (0) */ rv = nghttp2_session_change_stream_priority(session, 0, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* Depends on the non-existing idle stream. This creates that idle stream. */ @@ -10731,14 +11008,14 @@ void test_nghttp2_session_change_stream_priority(void) { rv = nghttp2_session_change_stream_priority(session, 2, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream5 = nghttp2_session_get_stream_raw(session, 5); - CU_ASSERT(NULL != stream5); - CU_ASSERT(&session->root == stream5->dep_prev); - CU_ASSERT(stream5 == stream2->dep_prev); - CU_ASSERT(9 == stream2->weight); + assert_not_null(stream5); + assert_ptr_equal(&session->root, stream5->dep_prev); + assert_ptr_equal(stream5, stream2->dep_prev); + assert_int32(9, ==, stream2->weight); nghttp2_session_del(session); @@ -10751,14 +11028,14 @@ void test_nghttp2_session_change_stream_priority(void) { rv = nghttp2_session_change_stream_priority(session, 1, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream5 = nghttp2_session_get_stream_raw(session, 5); - CU_ASSERT(NULL != stream5); - CU_ASSERT(&session->root == stream5->dep_prev); - CU_ASSERT(stream5 == stream1->dep_prev); - CU_ASSERT(9 == stream1->weight); + assert_not_null(stream5); + assert_ptr_equal(&session->root, stream5->dep_prev); + assert_ptr_equal(stream5, stream1->dep_prev); + assert_int32(9, ==, stream1->weight); nghttp2_session_del(session); } @@ -10768,7 +11045,7 @@ void test_nghttp2_session_change_extpri_stream_priority(void) { nghttp2_session_callbacks callbacks; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; nghttp2_option *option; nghttp2_extension frame; nghttp2_ext_priority_update priority_update; @@ -10796,19 +11073,19 @@ void test_nghttp2_session_change_extpri_stream_priority(void) { rv = nghttp2_session_change_extpri_stream_priority( session, 1, &extpri, /* ignore_client_signal = */ 0); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_EXTPRI_URGENCY_LOW == - nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_uint32(NGHTTP2_EXTPRI_URGENCY_LOW, ==, + nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); rv = nghttp2_session_get_extpri_stream_priority(session, &nextpri, 1); - CU_ASSERT(0 == rv); - CU_ASSERT(NGHTTP2_EXTPRI_URGENCY_LOW == nextpri.urgency); - CU_ASSERT(1 == nextpri.inc); + assert_ptrdiff(0, ==, rv); + assert_uint32(NGHTTP2_EXTPRI_URGENCY_LOW, ==, nextpri.urgency); + assert_true(nextpri.inc); /* Client can still update stream priority. */ frame.payload = &priority_update; @@ -10817,30 +11094,30 @@ void test_nghttp2_session_change_extpri_stream_priority(void) { nghttp2_frame_pack_priority_update(&bufs, &frame); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(2 == stream->extpri); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_uint8(2, ==, stream->extpri); /* Start to ignore client priority signal for this stream. */ rv = nghttp2_session_change_extpri_stream_priority( session, 1, &extpri, /* ignore_client_signal = */ 1); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_EXTPRI_URGENCY_LOW == - nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_uint32(NGHTTP2_EXTPRI_URGENCY_LOW, ==, + nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(NGHTTP2_EXTPRI_URGENCY_LOW == - nghttp2_extpri_uint8_urgency(stream->extpri)); - CU_ASSERT(1 == nghttp2_extpri_uint8_inc(stream->extpri)); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_uint32(NGHTTP2_EXTPRI_URGENCY_LOW, ==, + nghttp2_extpri_uint8_urgency(stream->extpri)); + assert_true(nghttp2_extpri_uint8_inc(stream->extpri)); nghttp2_session_del(session); nghttp2_option_del(option); @@ -10856,7 +11133,7 @@ void test_nghttp2_session_create_idle_stream(void) { int i; memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -10866,14 +11143,14 @@ void test_nghttp2_session_create_idle_stream(void) { rv = nghttp2_session_create_idle_stream(session, 4, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream4 = nghttp2_session_get_stream_raw(session, 4); - CU_ASSERT(4 == stream4->stream_id); - CU_ASSERT(111 == stream4->weight); - CU_ASSERT(stream2 == stream4->dep_prev); - CU_ASSERT(stream4 == stream2->dep_next); + assert_int32(4, ==, stream4->stream_id); + assert_int32(111, ==, stream4->weight); + assert_ptr_equal(stream2, stream4->dep_prev); + assert_ptr_equal(stream4, stream2->dep_next); /* If pri_spec->stream_id does not exist, and it is idle stream, it is created too */ @@ -10881,33 +11158,33 @@ void test_nghttp2_session_create_idle_stream(void) { rv = nghttp2_session_create_idle_stream(session, 8, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream8 = nghttp2_session_get_stream_raw(session, 8); stream10 = nghttp2_session_get_stream_raw(session, 10); - CU_ASSERT(8 == stream8->stream_id); - CU_ASSERT(109 == stream8->weight); - CU_ASSERT(10 == stream10->stream_id); - CU_ASSERT(16 == stream10->weight); - CU_ASSERT(stream10 == stream8->dep_prev); - CU_ASSERT(&session->root == stream10->dep_prev); + assert_int32(8, ==, stream8->stream_id); + assert_int32(109, ==, stream8->weight); + assert_int32(10, ==, stream10->stream_id); + assert_int32(16, ==, stream10->weight); + assert_ptr_equal(stream10, stream8->dep_prev); + assert_ptr_equal(&session->root, stream10->dep_prev); /* It is an error to attempt to create already existing idle stream */ rv = nghttp2_session_create_idle_stream(session, 4, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* It is an error to depend on itself */ pri_spec.stream_id = 6; rv = nghttp2_session_create_idle_stream(session, 6, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* It is an error to create root stream (0) as idle stream */ rv = nghttp2_session_create_idle_stream(session, 0, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); /* It is an error to create non-idle stream */ session->last_sent_stream_id = 20; @@ -10915,7 +11192,7 @@ void test_nghttp2_session_create_idle_stream(void) { rv = nghttp2_session_create_idle_stream(session, 18, &pri_spec); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, rv); nghttp2_session_del(session); @@ -10926,17 +11203,17 @@ void test_nghttp2_session_create_idle_stream(void) { rv = nghttp2_session_create_idle_stream(session, 2, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); stream4 = nghttp2_session_get_stream_raw(session, 4); stream2 = nghttp2_session_get_stream_raw(session, 2); - CU_ASSERT(NULL != stream4); - CU_ASSERT(NULL != stream2); - CU_ASSERT(&session->root == stream4->dep_prev); - CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream4->weight); - CU_ASSERT(stream4 == stream2->dep_prev); - CU_ASSERT(99 == stream2->weight); + assert_not_null(stream4); + assert_not_null(stream2); + assert_ptr_equal(&session->root, stream4->dep_prev); + assert_int32(NGHTTP2_DEFAULT_WEIGHT, ==, stream4->weight); + assert_ptr_equal(stream4, stream2->dep_prev); + assert_int32(99, ==, stream2->weight); nghttp2_session_del(session); @@ -10950,19 +11227,19 @@ void test_nghttp2_session_create_idle_stream(void) { for (i = 0; i < 100; ++i) { rv = nghttp2_session_create_idle_stream(session, i * 2 + 1, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_priority_spec_init(&pri_spec, i * 2 + 1, 16, 0); } - CU_ASSERT(100 == session->num_idle_streams); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(30 == session->num_idle_streams); - CU_ASSERT(141 == session->idle_stream_head->stream_id); + assert_size(100, ==, session->num_idle_streams); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(30, ==, session->num_idle_streams); + assert_int32(141, ==, session->idle_stream_head->stream_id); nghttp2_session_del(session); - /* Check that idle stream is reduced when nghttp2_session_mem_recv() is + /* Check that idle stream is reduced when nghttp2_session_mem_recv2() is called. */ nghttp2_session_client_new(&session, &callbacks, NULL); @@ -10972,15 +11249,15 @@ void test_nghttp2_session_create_idle_stream(void) { for (i = 0; i < 100; ++i) { rv = nghttp2_session_create_idle_stream(session, i * 2 + 1, &pri_spec); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); nghttp2_priority_spec_init(&pri_spec, i * 2 + 1, 16, 0); } - CU_ASSERT(100 == session->num_idle_streams); - CU_ASSERT(0 == nghttp2_session_mem_recv(session, NULL, 0)); - CU_ASSERT(30 == session->num_idle_streams); - CU_ASSERT(141 == session->idle_stream_head->stream_id); + assert_size(100, ==, session->num_idle_streams); + assert_ptrdiff(0, ==, nghttp2_session_mem_recv2(session, NULL, 0)); + assert_size(30, ==, session->num_idle_streams); + assert_int32(141, ==, session->idle_stream_head->stream_id); nghttp2_session_del(session); } @@ -11003,7 +11280,7 @@ void test_nghttp2_session_repeated_priority_change(void) { nghttp2_priority_spec_init(&pri_spec, 0, 16, 0); nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); nghttp2_frame_priority_free(&frame.priority); @@ -11014,24 +11291,24 @@ void test_nghttp2_session_repeated_priority_change(void) { nghttp2_priority_spec_init(&pri_spec, stream_id, 16, 0); nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); nghttp2_frame_priority_free(&frame.priority); } - CU_ASSERT(20 == session->num_idle_streams); - CU_ASSERT(1 == session->idle_stream_head->stream_id); + assert_size(20, ==, session->num_idle_streams); + assert_int32(1, ==, session->idle_stream_head->stream_id); /* 1 -> last_stream_id */ nghttp2_priority_spec_init(&pri_spec, last_stream_id, 16, 0); nghttp2_frame_priority_init(&frame.priority, 1, &pri_spec); - CU_ASSERT(0 == nghttp2_session_on_priority_received(session, &frame)); + assert_int(0, ==, nghttp2_session_on_priority_received(session, &frame)); nghttp2_frame_priority_free(&frame.priority); - CU_ASSERT(20 == session->num_idle_streams); - CU_ASSERT(3 == session->idle_stream_head->stream_id); + assert_size(20, ==, session->num_idle_streams); + assert_int32(3, ==, session->idle_stream_head->stream_id); nghttp2_session_del(session); } @@ -11045,7 +11322,7 @@ void test_nghttp2_session_repeated_priority_submission(void) { memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -11054,8 +11331,8 @@ void test_nghttp2_session_repeated_priority_submission(void) { /* 1 -> 0 */ nghttp2_priority_spec_init(&pri_spec, 0, 16, 0); - CU_ASSERT(0 == - nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); + assert_int(0, ==, + nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); last_stream_id = (int32_t)(max_streams * 2 + 1); @@ -11063,23 +11340,24 @@ void test_nghttp2_session_repeated_priority_submission(void) { /* 1 -> stream_id */ nghttp2_priority_spec_init(&pri_spec, stream_id, 16, 0); - CU_ASSERT( - 0 == nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); + assert_int( + 0, ==, + nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); } - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(max_streams == session->num_idle_streams); - CU_ASSERT(1 == session->idle_stream_head->stream_id); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(max_streams, ==, session->num_idle_streams); + assert_int32(1, ==, session->idle_stream_head->stream_id); /* 1 -> last_stream_id */ nghttp2_priority_spec_init(&pri_spec, last_stream_id, 16, 0); - CU_ASSERT(0 == - nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); + assert_int(0, ==, + nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, &pri_spec)); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(max_streams == session->num_idle_streams); - CU_ASSERT(3 == session->idle_stream_head->stream_id); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size(max_streams, ==, session->num_idle_streams); + assert_int32(3, ==, session->idle_stream_head->stream_id); nghttp2_session_del(session); } @@ -11091,117 +11369,129 @@ void test_nghttp2_session_set_local_window_size(void) { nghttp2_stream *stream; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); stream = open_sent_stream(session, 1); stream->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 1, 65536)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1 == - stream->local_window_size); - CU_ASSERT(4096 == stream->recv_window_size); - CU_ASSERT(65536 - 4096 == - nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 1, 65536)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1, ==, + stream->local_window_size); + assert_int32(4096, ==, stream->recv_window_size); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(1 == item->frame.window_update.hd.stream_id); - CU_ASSERT(1 == item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.window_update.hd.stream_id); + assert_int32(1, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Go decrement part */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 1, 32768)); - CU_ASSERT(32768 == stream->local_window_size); - CU_ASSERT(-28672 == stream->recv_window_size); - CU_ASSERT(32768 == stream->recv_reduction); - CU_ASSERT(65536 - 4096 == - nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 1, 32768)); + assert_int32(32768, ==, stream->local_window_size); + assert_int32(-28672, ==, stream->recv_window_size); + assert_int32(32768, ==, stream->recv_reduction); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item == NULL); + assert_null(item); /* Increase local window size */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 1, 49152)); - CU_ASSERT(49152 == stream->local_window_size); - CU_ASSERT(-12288 == stream->recv_window_size); - CU_ASSERT(16384 == stream->recv_reduction); - CU_ASSERT(65536 - 4096 == - nghttp2_session_get_stream_local_window_size(session, 1)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 1, 49152)); + assert_int32(49152, ==, stream->local_window_size); + assert_int32(-12288, ==, stream->recv_window_size); + assert_int32(16384, ==, stream->recv_reduction); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); + assert_null(nghttp2_session_get_next_ob_item(session)); /* Increase local window again */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 1, 65537)); - CU_ASSERT(65537 == stream->local_window_size); - CU_ASSERT(4096 == stream->recv_window_size); - CU_ASSERT(0 == stream->recv_reduction); - CU_ASSERT(65537 - 4096 == - nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 1, 65537)); + assert_int32(65537, ==, stream->local_window_size); + assert_int32(4096, ==, stream->recv_window_size); + assert_int32(0, ==, stream->recv_reduction); + assert_int32(65537 - 4096, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(1 == item->frame.window_update.window_size_increment); + assert_int32(1, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Check connection-level flow control */ session->recv_window_size = 4096; - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 0, 65536)); - CU_ASSERT(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1 == - session->local_window_size); - CU_ASSERT(4096 == session->recv_window_size); - CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 0, 65536)); + assert_int32(NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE + 1, ==, + session->local_window_size); + assert_int32(4096, ==, session->recv_window_size); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_local_window_size(session)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(0 == item->frame.window_update.hd.stream_id); - CU_ASSERT(1 == item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.window_update.hd.stream_id); + assert_int32(1, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); /* Go decrement part */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 0, 32768)); - CU_ASSERT(32768 == session->local_window_size); - CU_ASSERT(-28672 == session->recv_window_size); - CU_ASSERT(32768 == session->recv_reduction); - CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 0, 32768)); + assert_int32(32768, ==, session->local_window_size); + assert_int32(-28672, ==, session->recv_window_size); + assert_int32(32768, ==, session->recv_reduction); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_local_window_size(session)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(item == NULL); + assert_null(item); /* Increase local window size */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 0, 49152)); - CU_ASSERT(49152 == session->local_window_size); - CU_ASSERT(-12288 == session->recv_window_size); - CU_ASSERT(16384 == session->recv_reduction); - CU_ASSERT(65536 - 4096 == nghttp2_session_get_local_window_size(session)); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 0, 49152)); + assert_int32(49152, ==, session->local_window_size); + assert_int32(-12288, ==, session->recv_window_size); + assert_int32(16384, ==, session->recv_reduction); + assert_int32(65536 - 4096, ==, + nghttp2_session_get_local_window_size(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); /* Increase local window again */ - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 0, 65537)); - CU_ASSERT(65537 == session->local_window_size); - CU_ASSERT(4096 == session->recv_window_size); - CU_ASSERT(0 == session->recv_reduction); - CU_ASSERT(65537 - 4096 == nghttp2_session_get_local_window_size(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, + 0, 65537)); + assert_int32(65537, ==, session->local_window_size); + assert_int32(4096, ==, session->recv_window_size); + assert_int32(0, ==, session->recv_reduction); + assert_int32(65537 - 4096, ==, + nghttp2_session_get_local_window_size(session)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(1 == item->frame.window_update.window_size_increment); + assert_int32(1, ==, item->frame.window_update.window_size_increment); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_session_del(session); @@ -11211,25 +11501,26 @@ void test_nghttp2_session_set_local_window_size(void) { stream = open_sent_stream(session, 1); stream->recv_window_size = NGHTTP2_INITIAL_WINDOW_SIZE; - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 1, 0)); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(0 == nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int( + 0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, 1, 0)); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(0, ==, nghttp2_session_get_stream_local_window_size(session, 1)); /* This should submit WINDOW_UPDATE frame because stream-level receiving window is now full. */ - CU_ASSERT(0 == - nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, 1, - NGHTTP2_INITIAL_WINDOW_SIZE)); - CU_ASSERT(0 == stream->recv_window_size); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - nghttp2_session_get_stream_local_window_size(session, 1)); + assert_int(0, ==, + nghttp2_session_set_local_window_size( + session, NGHTTP2_FLAG_NONE, 1, NGHTTP2_INITIAL_WINDOW_SIZE)); + assert_int32(0, ==, stream->recv_window_size); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + nghttp2_session_get_stream_local_window_size(session, 1)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(1 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.hd.stream_id); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + item->frame.window_update.window_size_increment); nghttp2_session_del(session); @@ -11239,25 +11530,26 @@ void test_nghttp2_session_set_local_window_size(void) { nghttp2_session_client_new(&session, &callbacks, NULL); session->recv_window_size = NGHTTP2_INITIAL_WINDOW_SIZE; - CU_ASSERT(0 == nghttp2_session_set_local_window_size( - session, NGHTTP2_FLAG_NONE, 0, 0)); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(0 == nghttp2_session_get_local_window_size(session)); + assert_int( + 0, ==, + nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, 0, 0)); + assert_int32(0, ==, session->recv_window_size); + assert_int32(0, ==, nghttp2_session_get_local_window_size(session)); /* This should submit WINDOW_UPDATE frame because connection-level receiving window is now full. */ - CU_ASSERT(0 == - nghttp2_session_set_local_window_size(session, NGHTTP2_FLAG_NONE, 0, - NGHTTP2_INITIAL_WINDOW_SIZE)); - CU_ASSERT(0 == session->recv_window_size); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - nghttp2_session_get_local_window_size(session)); + assert_int(0, ==, + nghttp2_session_set_local_window_size( + session, NGHTTP2_FLAG_NONE, 0, NGHTTP2_INITIAL_WINDOW_SIZE)); + assert_int32(0, ==, session->recv_window_size); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + nghttp2_session_get_local_window_size(session)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_WINDOW_UPDATE == item->frame.hd.type); - CU_ASSERT(0 == item->frame.hd.stream_id); - CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == - item->frame.window_update.window_size_increment); + assert_uint8(NGHTTP2_WINDOW_UPDATE, ==, item->frame.hd.type); + assert_int32(0, ==, item->frame.hd.stream_id); + assert_int32(NGHTTP2_INITIAL_WINDOW_SIZE, ==, + item->frame.window_update.window_size_increment); nghttp2_session_del(session); } @@ -11268,7 +11560,7 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { nghttp2_session_callbacks callbacks; my_user_data ud; nghttp2_settings_entry iv; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; int32_t stream_id; nghttp2_stream *stream; @@ -11276,7 +11568,7 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { callbacks.before_frame_send_callback = cancel_before_frame_send_callback; callbacks.on_frame_not_send_callback = on_frame_not_send_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, &ud); @@ -11285,7 +11577,7 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { rv = nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); ud.frame_send_cb_called = 0; ud.before_frame_send_cb_called = 0; @@ -11293,18 +11585,18 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_send_cb_called); - CU_ASSERT(1 == ud.before_frame_send_cb_called); - CU_ASSERT(1 == ud.frame_not_send_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_send_cb_called); + assert_int(1, ==, ud.before_frame_send_cb_called); + assert_int(1, ==, ud.frame_not_send_cb_called); data_prd.source.ptr = NULL; data_prd.read_callback = temporal_failure_data_source_read_callback; - stream_id = nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), - &data_prd, NULL); + stream_id = nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), + &data_prd, NULL); - CU_ASSERT(stream_id > 0); + assert_int32(0, <, stream_id); ud.frame_send_cb_called = 0; ud.before_frame_send_cb_called = 0; @@ -11312,14 +11604,14 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_send_cb_called); - CU_ASSERT(1 == ud.before_frame_send_cb_called); - CU_ASSERT(1 == ud.frame_not_send_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_send_cb_called); + assert_int(1, ==, ud.before_frame_send_cb_called); + assert_int(1, ==, ud.frame_not_send_cb_called); stream = nghttp2_session_get_stream_raw(session, stream_id); - CU_ASSERT(NULL == stream); + assert_null(stream); nghttp2_session_del(session); @@ -11330,7 +11622,7 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { stream_id = nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1, reqnv, ARRLEN(reqnv), NULL); - CU_ASSERT(stream_id > 0); + assert_int32(0, <, stream_id); ud.frame_send_cb_called = 0; ud.before_frame_send_cb_called = 0; @@ -11338,14 +11630,14 @@ void test_nghttp2_session_cancel_from_before_frame_send(void) { rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); - CU_ASSERT(0 == ud.frame_send_cb_called); - CU_ASSERT(1 == ud.before_frame_send_cb_called); - CU_ASSERT(1 == ud.frame_not_send_cb_called); + assert_int(0, ==, rv); + assert_int(0, ==, ud.frame_send_cb_called); + assert_int(1, ==, ud.before_frame_send_cb_called); + assert_int(1, ==, ud.frame_not_send_cb_called); stream = nghttp2_session_get_stream_raw(session, stream_id); - CU_ASSERT(NULL == stream); + assert_null(stream); nghttp2_session_del(session); } @@ -11357,7 +11649,7 @@ void test_nghttp2_session_too_many_settings(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; nghttp2_settings_entry iv[3]; nghttp2_mem *mem; @@ -11368,14 +11660,14 @@ void test_nghttp2_session_too_many_settings(void) { memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.on_frame_recv_callback = on_frame_recv_callback; - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_option_new(&option); nghttp2_option_set_max_settings(option, 1); nghttp2_session_client_new2(&session, &callbacks, &ud, option); - CU_ASSERT(1 == session->max_settings); + assert_size(1, ==, session->max_settings); nghttp2_option_del(option); @@ -11390,8 +11682,8 @@ void test_nghttp2_session_too_many_settings(void) { rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); - CU_ASSERT(nghttp2_bufs_len(&bufs) > 0); + assert_ptrdiff(0, ==, rv); + assert_size(0, <, nghttp2_bufs_len(&bufs)); nghttp2_frame_settings_free(&frame.settings, mem); @@ -11400,11 +11692,11 @@ void test_nghttp2_session_too_many_settings(void) { ud.frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); nghttp2_bufs_reset(&bufs); nghttp2_bufs_free(&bufs); @@ -11418,7 +11710,7 @@ prepare_session_removed_closed_stream(nghttp2_session *session, nghttp2_settings_entry iv; nghttp2_bufs bufs; nghttp2_mem *mem; - ssize_t nread; + nghttp2_ssize nread; int i; nghttp2_stream *stream; nghttp2_frame_hd hd; @@ -11432,23 +11724,23 @@ prepare_session_removed_closed_stream(nghttp2_session *session, rv = nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); for (i = 1; i <= 3; i += 2) { rv = pack_headers(&bufs, deflater, i, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); nghttp2_bufs_reset(&bufs); } @@ -11459,17 +11751,17 @@ prepare_session_removed_closed_stream(nghttp2_session *session, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); /* Receiving stream 5 will erase stream 3 from closed stream list */ - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); stream = nghttp2_session_get_stream_raw(session, 3); - CU_ASSERT(NULL == stream); + assert_null(stream); /* Since the current max concurrent streams is NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS, receiving frame on stream @@ -11479,24 +11771,24 @@ prepare_session_removed_closed_stream(nghttp2_session *session, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, trailernv, ARRLEN(trailernv), mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_frame_hd_init(&hd, 0, NGHTTP2_DATA, NGHTTP2_FLAG_NONE, 3); nghttp2_bufs_reset(&bufs); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); + assert_null(nghttp2_session_get_next_ob_item(session)); /* Now server receives SETTINGS ACK */ nghttp2_frame_hd_init(&hd, 0, NGHTTP2_SETTINGS, NGHTTP2_FLAG_ACK, 0); @@ -11504,10 +11796,10 @@ prepare_session_removed_closed_stream(nghttp2_session *session, nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); nghttp2_bufs_free(&bufs); } @@ -11519,7 +11811,7 @@ void test_nghttp2_session_removed_closed_stream(void) { nghttp2_hd_deflater deflater; nghttp2_bufs bufs; nghttp2_mem *mem; - ssize_t nread; + nghttp2_ssize nread; nghttp2_frame_hd hd; nghttp2_outbound_item *item; @@ -11529,7 +11821,7 @@ void test_nghttp2_session_removed_closed_stream(void) { memset(&callbacks, 0, sizeof(callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -11548,16 +11840,16 @@ void test_nghttp2_session_removed_closed_stream(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, trailernv, ARRLEN(trailernv), mem); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -11573,14 +11865,14 @@ void test_nghttp2_session_removed_closed_stream(void) { nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - nread = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_bufs_len(&bufs)); + nread = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_bufs_len(&bufs)); - CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == nread); + assert_ptrdiff((nghttp2_ssize)nghttp2_bufs_len(&bufs), ==, nread); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -11588,7 +11880,7 @@ void test_nghttp2_session_removed_closed_stream(void) { nghttp2_bufs_free(&bufs); } -static ssize_t pause_once_data_source_read_callback( +static nghttp2_ssize pause_once_data_source_read_callback( nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t len, uint32_t *data_flags, nghttp2_data_source *source, void *user_data) { my_user_data *ud = user_data; @@ -11604,11 +11896,11 @@ static ssize_t pause_once_data_source_read_callback( void test_nghttp2_session_pause_data(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_send_callback = on_frame_send_callback; data_prd.read_callback = pause_once_data_source_read_callback; @@ -11618,19 +11910,20 @@ void test_nghttp2_session_pause_data(void) { open_recv_stream(session, 1); - CU_ASSERT( - 0 == nghttp2_submit_data(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_data2(session, NGHTTP2_FLAG_END_STREAM, 1, &data_prd)); ud.frame_send_cb_called = 0; ud.data_source_read_cb_paused = 0; - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(0 == ud.frame_send_cb_called); - CU_ASSERT(NULL == session->aob.item); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == ud.frame_send_cb_called); - CU_ASSERT(NGHTTP2_DATA == ud.sent_frame_type); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(0, ==, ud.frame_send_cb_called); + assert_null(session->aob.item); + assert_int(0, ==, nghttp2_session_send(session)); + assert_int(1, ==, ud.frame_send_cb_called); + assert_uint8(NGHTTP2_DATA, ==, ud.sent_frame_type); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_session_del(session); } @@ -11651,7 +11944,7 @@ void test_nghttp2_session_no_closed_streams(void) { nghttp2_session_close_stream(session, 1, NGHTTP2_NO_ERROR); - CU_ASSERT(0 == session->num_closed_streams); + assert_size(0, ==, session->num_closed_streams); nghttp2_session_del(session); nghttp2_option_del(option); @@ -11664,28 +11957,28 @@ void test_nghttp2_session_set_stream_user_data(void) { int user_data1, user_data2; int rv; const uint8_t *datap; - ssize_t datalen; + nghttp2_ssize datalen; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); nghttp2_session_client_new(&session, &callbacks, NULL); - stream_id = nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, - &user_data1); + stream_id = nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, + &user_data1); rv = nghttp2_session_set_stream_user_data(session, stream_id, &user_data2); - CU_ASSERT(0 == rv); + assert_int(0, ==, rv); - datalen = nghttp2_session_mem_send(session, &datap); + datalen = nghttp2_session_mem_send2(session, &datap); - CU_ASSERT(datalen > 0); + assert_ptrdiff(0, <, datalen); - CU_ASSERT(&user_data2 == - nghttp2_session_get_stream_user_data(session, stream_id)); + assert_ptr_equal(&user_data2, + nghttp2_session_get_stream_user_data(session, stream_id)); - CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_session_set_stream_user_data(session, 2, NULL)); + assert_int(NGHTTP2_ERR_INVALID_ARGUMENT, ==, + nghttp2_session_set_stream_user_data(session, 2, NULL)); nghttp2_session_del(session); } @@ -11693,7 +11986,7 @@ void test_nghttp2_session_set_stream_user_data(void) { void test_nghttp2_session_no_rfc7540_priorities(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; - nghttp2_data_provider data_prd; + nghttp2_data_provider2 data_prd; my_user_data ud; nghttp2_outbound_item *item; nghttp2_mem *mem; @@ -11703,70 +11996,76 @@ void test_nghttp2_session_no_rfc7540_priorities(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* Do not use a dependency tree if SETTINGS_NO_RFC7540_PRIORITIES = 1. */ data_prd.read_callback = fixed_length_data_source_read_callback; ud.data_source_length = 128 * 1024; - CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, &ud)); + assert_int(0, ==, nghttp2_session_server_new(&session, &callbacks, &ud)); iv.settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv.value = 1; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); + assert_int(0, ==, nghttp2_session_send(session)); open_recv_stream2(session, 1, NGHTTP2_STREAM_OPENING); - CU_ASSERT(0 == nghttp2_submit_response(session, 1, resnv, ARRLEN(resnv), - &data_prd)); + assert_int( + 0, ==, + nghttp2_submit_response2(session, 1, resnv, ARRLEN(resnv), &data_prd)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen); + assert_size(ARRLEN(resnv), ==, item->frame.headers.nvlen); assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen, mem); - CU_ASSERT(0 == nghttp2_session_send(session)); - CU_ASSERT(1 == nghttp2_pq_size( - &session->sched[NGHTTP2_EXTPRI_DEFAULT_URGENCY].ob_data)); - CU_ASSERT(nghttp2_pq_empty(&session->root.obq)); + assert_int(0, ==, nghttp2_session_send(session)); + assert_size( + 1, ==, + nghttp2_pq_size(&session->sched[NGHTTP2_EXTPRI_DEFAULT_URGENCY].ob_data)); + assert_true(nghttp2_pq_empty(&session->root.obq)); nghttp2_session_del(session); /* Priorities are sent as is before client receives SETTINGS_NO_RFC7540_PRIORITIES = 1 from server. */ - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); iv.settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv.value = 1; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); + assert_int(0, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); pri_spec.stream_id = 5; pri_spec.weight = 111; pri_spec.exclusive = 1; - CU_ASSERT(1 == nghttp2_submit_request(session, &pri_spec, reqnv, - ARRLEN(reqnv), NULL, NULL)); + assert_int32(1, ==, + nghttp2_submit_request2(session, &pri_spec, reqnv, ARRLEN(reqnv), + NULL, NULL)); item = nghttp2_outbound_queue_top(&session->ob_syn); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT(pri_spec.stream_id == item->frame.headers.pri_spec.stream_id); - CU_ASSERT(pri_spec.weight == item->frame.headers.pri_spec.weight); - CU_ASSERT(pri_spec.exclusive == item->frame.headers.pri_spec.exclusive); + assert_not_null(item); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_int32(pri_spec.stream_id, ==, item->frame.headers.pri_spec.stream_id); + assert_int32(pri_spec.weight, ==, item->frame.headers.pri_spec.weight); + assert_uint8(pri_spec.exclusive, ==, item->frame.headers.pri_spec.exclusive); nghttp2_session_del(session); /* Priorities are defaulted if client received SETTINGS_NO_RFC7540_PRIORITIES = 1 from server. */ - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); + assert_int(0, ==, nghttp2_session_client_new(&session, &callbacks, NULL)); iv.settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv.value = 1; - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); + assert_int(0, ==, + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1)); session->remote_settings.no_rfc7540_priorities = 1; @@ -11774,14 +12073,16 @@ void test_nghttp2_session_no_rfc7540_priorities(void) { pri_spec.weight = 111; pri_spec.exclusive = 1; - CU_ASSERT(1 == nghttp2_submit_request(session, &pri_spec, reqnv, - ARRLEN(reqnv), NULL, NULL)); + assert_int32(1, ==, + nghttp2_submit_request2(session, &pri_spec, reqnv, ARRLEN(reqnv), + NULL, NULL)); item = nghttp2_outbound_queue_top(&session->ob_syn); - CU_ASSERT(NULL != item); - CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type); - CU_ASSERT(nghttp2_priority_spec_check_default(&item->frame.headers.pri_spec)); + assert_not_null(item); + assert_uint8(NGHTTP2_HEADERS, ==, item->frame.hd.type); + assert_true( + nghttp2_priority_spec_check_default(&item->frame.headers.pri_spec)); nghttp2_session_del(session); } @@ -11793,7 +12094,7 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { nghttp2_frame frame; nghttp2_bufs bufs; nghttp2_buf *buf; - ssize_t rv; + nghttp2_ssize rv; nghttp2_settings_entry iv; nghttp2_mem *mem; nghttp2_hd_deflater deflater; @@ -11809,7 +12110,7 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; nghttp2_option_new(&option); @@ -11823,24 +12124,24 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { rv = nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, NULL, 0); rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_settings_free(&frame.settings, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(1 == session->fallback_rfc7540_priorities); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_true(session->fallback_rfc7540_priorities); nghttp2_hd_deflate_init(&deflater, mem); @@ -11853,27 +12154,28 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_headers_free(&frame.headers, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); anchor_stream = nghttp2_session_get_stream_raw(session, 3); - CU_ASSERT(NGHTTP2_STREAM_IDLE == anchor_stream->state); - CU_ASSERT( - !(anchor_stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)); - CU_ASSERT(&session->root == anchor_stream->dep_prev); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, + anchor_stream->state); + assert_false(anchor_stream->flags & + NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); + assert_ptr_equal(&session->root, anchor_stream->dep_prev); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); - CU_ASSERT(!(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES)); - CU_ASSERT(anchor_stream == stream->dep_prev); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); + assert_false(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); + assert_ptr_equal(anchor_stream, stream->dep_prev); /* Make sure that PRIORITY frame updates stream priority. */ nghttp2_priority_spec_init(&pri_spec, 5, 1, 0); @@ -11884,15 +12186,16 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { nghttp2_frame_priority_free(&frame.priority); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); anchor_stream = nghttp2_session_get_stream_raw(session, 5); - CU_ASSERT(NGHTTP2_STREAM_IDLE == anchor_stream->state); - CU_ASSERT(&session->root == anchor_stream->dep_prev); - CU_ASSERT(anchor_stream == stream->dep_prev); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_IDLE, ==, + anchor_stream->state); + assert_ptr_equal(&session->root, anchor_stream->dep_prev); + assert_ptr_equal(anchor_stream, stream->dep_prev); /* Make sure that PRIORITY_UPDATE frame is ignored. */ frame.ext.payload = &priority_update; @@ -11903,11 +12206,11 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { ud.frame_recv_cb_called = 0; buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == ud.frame_recv_cb_called); - CU_ASSERT(NGHTTP2_EXTPRI_DEFAULT_URGENCY == stream->extpri); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_int(0, ==, ud.frame_recv_cb_called); + assert_uint32(NGHTTP2_EXTPRI_DEFAULT_URGENCY, ==, stream->extpri); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -11917,11 +12220,11 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { rv = nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); iv.settings_id = NGHTTP2_SETTINGS_NO_RFC7540_PRIORITIES; iv.value = 0; @@ -11931,15 +12234,15 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_settings_free(&frame.settings, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(0 == session->fallback_rfc7540_priorities); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_false(session->fallback_rfc7540_priorities); nghttp2_hd_deflate_init(&deflater, mem); @@ -11952,20 +12255,20 @@ void test_nghttp2_session_server_fallback_rfc7540_priorities(void) { nghttp2_bufs_reset(&bufs); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_headers_free(&frame.headers, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); - CU_ASSERT(NULL == nghttp2_session_get_stream_raw(session, 3)); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); + assert_null(nghttp2_session_get_stream_raw(session, 3)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); - CU_ASSERT(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); + assert_enum(nghttp2_stream_state, NGHTTP2_STREAM_OPENING, ==, stream->state); + assert_true(stream->flags & NGHTTP2_STREAM_FLAG_NO_RFC7540_PRIORITIES); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -11978,7 +12281,7 @@ void test_nghttp2_session_stream_reset_ratelim(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; nghttp2_frame frame; - ssize_t rv; + nghttp2_ssize rv; nghttp2_bufs bufs; nghttp2_buf *buf; nghttp2_mem *mem; @@ -11994,7 +12297,7 @@ void test_nghttp2_session_stream_reset_ratelim(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_option_new(&option); nghttp2_option_set_stream_reset_rate_limit( @@ -12005,19 +12308,19 @@ void test_nghttp2_session_stream_reset_ratelim(void) { nghttp2_frame_settings_init(&frame.settings, NGHTTP2_FLAG_NONE, NULL, 0); rv = nghttp2_frame_pack_settings(&bufs, &frame.settings); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_settings_free(&frame.settings, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); /* Send SETTINGS ACK */ rv = nghttp2_session_send(session); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_hd_deflate_init(&deflater, mem); @@ -12034,14 +12337,14 @@ void test_nghttp2_session_stream_reset_ratelim(void) { nvlen); rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_headers_free(&frame.headers, mem); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); nghttp2_bufs_reset(&bufs); @@ -12052,23 +12355,23 @@ void test_nghttp2_session_stream_reset_ratelim(void) { nghttp2_frame_rst_stream_free(&frame.rst_stream); buf = &bufs.head->buf; - rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf)); + rv = nghttp2_session_mem_recv2(session, buf->pos, nghttp2_buf_len(buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(buf), ==, rv); if (i < NGHTTP2_DEFAULT_STREAM_RESET_BURST) { - CU_ASSERT(0 == nghttp2_outbound_queue_size(&session->ob_reg)); + assert_size(0, ==, nghttp2_outbound_queue_size(&session->ob_reg)); continue; } - CU_ASSERT(1 == nghttp2_outbound_queue_size(&session->ob_reg)); + assert_size(1, ==, nghttp2_outbound_queue_size(&session->ob_reg)); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_GOAWAY == item->frame.hd.type); - CU_ASSERT(NGHTTP2_DEFAULT_STREAM_RESET_BURST * 2 + 1 == - item->frame.goaway.last_stream_id); + assert_uint8(NGHTTP2_GOAWAY, ==, item->frame.hd.type); + assert_int32(NGHTTP2_DEFAULT_STREAM_RESET_BURST * 2 + 1, ==, + item->frame.goaway.last_stream_id); } nghttp2_hd_deflate_free(&deflater); @@ -12081,7 +12384,7 @@ static void check_nghttp2_http_recv_headers_fail( nghttp2_session *session, nghttp2_hd_deflater *deflater, int32_t stream_id, int stream_state, const nghttp2_nv *nva, size_t nvlen) { nghttp2_mem *mem; - ssize_t rv; + nghttp2_ssize rv; nghttp2_outbound_item *item; nghttp2_bufs bufs; my_user_data *ud; @@ -12101,21 +12404,21 @@ static void check_nghttp2_http_recv_headers_fail( rv = pack_headers(&bufs, deflater, stream_id, NGHTTP2_FLAG_END_HEADERS, nva, nvlen, mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud->invalid_frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(1 == ud->invalid_frame_recv_cb_called); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_ptrdiff(1, ==, ud->invalid_frame_recv_cb_called); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_free(&bufs); } @@ -12124,7 +12427,7 @@ static void check_nghttp2_http_recv_headers_ok( nghttp2_session *session, nghttp2_hd_deflater *deflater, int32_t stream_id, int stream_state, const nghttp2_nv *nva, size_t nvlen) { nghttp2_mem *mem; - ssize_t rv; + nghttp2_ssize rv; nghttp2_bufs bufs; my_user_data *ud; @@ -12143,16 +12446,16 @@ static void check_nghttp2_http_recv_headers_ok( rv = pack_headers(&bufs, deflater, stream_id, NGHTTP2_FLAG_END_HEADERS, nva, nvlen, mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); ud->frame_recv_cb_called = 0; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(1 == ud->frame_recv_cb_called); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_int(1, ==, ud->frame_recv_cb_called); nghttp2_bufs_free(&bufs); } @@ -12255,7 +12558,7 @@ void test_nghttp2_http_mandatory_headers(void) { mem = nghttp2_mem_default(); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_frame_recv_callback = on_frame_recv_callback; callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback; @@ -12459,7 +12762,7 @@ void test_nghttp2_http_content_length(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; nghttp2_stream *stream; const nghttp2_nv cl_resnv[] = {MAKE_NV(":status", "200"), MAKE_NV("te", "trailers"), @@ -12473,7 +12776,7 @@ void test_nghttp2_http_content_length(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -12483,15 +12786,15 @@ void test_nghttp2_http_content_length(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(9000000000LL == stream->content_length); - CU_ASSERT(200 == stream->status_code); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_int64(9000000000LL, ==, stream->content_length); + assert_int16(200, ==, stream->status_code); nghttp2_hd_deflate_free(&deflater); @@ -12506,17 +12809,17 @@ void test_nghttp2_http_content_length(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, cl_reqnv, ARRLEN(cl_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(9000000000LL == stream->content_length); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_int64(9000000000LL, ==, stream->content_length); nghttp2_hd_deflate_free(&deflater); @@ -12531,7 +12834,7 @@ void test_nghttp2_http_content_length_mismatch(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; const nghttp2_nv cl_reqnv[] = { MAKE_NV(":path", "/"), MAKE_NV(":method", "PUT"), MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"), @@ -12545,7 +12848,7 @@ void test_nghttp2_http_content_length_mismatch(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -12555,59 +12858,59 @@ void test_nghttp2_http_content_length_mismatch(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, cl_reqnv, ARRLEN(cl_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); /* header says content-length: 20, but DATA has 0 byte */ rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, cl_reqnv, ARRLEN(cl_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 0, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 3); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); /* header says content-length: 20, but DATA has 21 bytes */ rv = pack_headers(&bufs, &deflater, 5, NGHTTP2_FLAG_END_HEADERS, cl_reqnv, ARRLEN(cl_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 21, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 5); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN + 21; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); @@ -12621,83 +12924,83 @@ void test_nghttp2_http_content_length_mismatch(void) { nghttp2_hd_deflate_init(&deflater, mem); /* header says content-length: 20, but HEADERS has END_STREAM flag set */ - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 1)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_not_null(nghttp2_session_get_stream(session, 1)); + assert_int(0, ==, nghttp2_session_send(session)); /* After sending RST_STREAM, stream must be closed */ - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 1)); + assert_null(nghttp2_session_get_stream(session, 1)); nghttp2_bufs_reset(&bufs); /* header says content-length: 20, but DATA has 0 byte */ - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 0, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 3); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 3)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_not_null(nghttp2_session_get_stream(session, 3)); + assert_int(0, ==, nghttp2_session_send(session)); /* After sending RST_STREAM, stream must be closed */ - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 3)); + assert_null(nghttp2_session_get_stream(session, 3)); nghttp2_bufs_reset(&bufs); /* header says content-length: 20, but DATA has 21 bytes */ - nghttp2_submit_request(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); + nghttp2_submit_request2(session, NULL, reqnv, ARRLEN(reqnv), NULL, NULL); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); rv = pack_headers(&bufs, &deflater, 5, NGHTTP2_FLAG_END_HEADERS, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 21, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 5); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN + 21; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(NULL != nghttp2_session_get_stream(session, 5)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_not_null(nghttp2_session_get_stream(session, 5)); + assert_int(0, ==, nghttp2_session_send(session)); /* After sending RST_STREAM, stream must be closed */ - CU_ASSERT(NULL == nghttp2_session_get_stream(session, 5)); + assert_null(nghttp2_session_get_stream(session, 5)); nghttp2_bufs_reset(&bufs); @@ -12714,7 +13017,7 @@ void test_nghttp2_http_non_final_response(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; const nghttp2_nv nonfinal_resnv[] = { MAKE_NV(":status", "100"), }; @@ -12725,7 +13028,7 @@ void test_nghttp2_http_non_final_response(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -12737,17 +13040,17 @@ void test_nghttp2_http_non_final_response(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, nonfinal_resnv, ARRLEN(nonfinal_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); @@ -12756,21 +13059,21 @@ void test_nghttp2_http_non_final_response(void) { rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, nonfinal_resnv, ARRLEN(nonfinal_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 10, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 3); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN + 10; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); @@ -12780,18 +13083,18 @@ void test_nghttp2_http_non_final_response(void) { rv = pack_headers(&bufs, &deflater, 5, NGHTTP2_FLAG_END_HEADERS, nonfinal_resnv, ARRLEN(nonfinal_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 0, NGHTTP2_DATA, NGHTTP2_FLAG_NONE, 5); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_bufs_reset(&bufs); @@ -12801,22 +13104,22 @@ void test_nghttp2_http_non_final_response(void) { rv = pack_headers(&bufs, &deflater, 7, NGHTTP2_FLAG_END_HEADERS, nonfinal_resnv, ARRLEN(nonfinal_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_frame_hd_init(&hd, 0, NGHTTP2_DATA, NGHTTP2_FLAG_END_STREAM, 7); nghttp2_frame_pack_frame_hd(bufs.head->buf.last, &hd); bufs.head->buf.last += NGHTTP2_FRAME_HDLEN; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); @@ -12825,25 +13128,25 @@ void test_nghttp2_http_non_final_response(void) { rv = pack_headers(&bufs, &deflater, 9, NGHTTP2_FLAG_END_HEADERS, nonfinal_resnv, ARRLEN(nonfinal_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 9, NGHTTP2_FLAG_END_HEADERS, resnv, ARRLEN(resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_bufs_reset(&bufs); @@ -12860,7 +13163,7 @@ void test_nghttp2_http_trailer_headers(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; const nghttp2_nv trailer_reqnv[] = { MAKE_NV("foo", "bar"), }; @@ -12870,7 +13173,7 @@ void test_nghttp2_http_trailer_headers(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_server_new(&session, &callbacks, NULL); @@ -12879,84 +13182,84 @@ void test_nghttp2_http_trailer_headers(void) { /* good trailer header */ rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, trailer_reqnv, ARRLEN(trailer_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_bufs_reset(&bufs); /* trailer header without END_STREAM is illegal */ rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, trailer_reqnv, ARRLEN(trailer_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); /* trailer header including pseudo header field is illegal */ rv = pack_headers(&bufs, &deflater, 5, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 5, NGHTTP2_FLAG_END_HEADERS, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); @@ -12973,7 +13276,7 @@ void test_nghttp2_http_ignore_regular_header(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; my_user_data ud; const nghttp2_nv bad_reqnv[] = { MAKE_NV(":authority", "localhost"), @@ -12994,7 +13297,7 @@ void test_nghttp2_http_ignore_regular_header(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; callbacks.on_header_callback = pause_on_header_callback; nghttp2_session_server_new(&session, &callbacks, &ud); @@ -13004,32 +13307,32 @@ void test_nghttp2_http_ignore_regular_header(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, bad_reqnv, ARRLEN(bad_reqnv), mem); - CU_ASSERT_FATAL(0 == rv); + assert_ptrdiff(0, ==, rv); nghttp2_hd_deflate_free(&deflater); proclen = 0; for (i = 0; i < 4; ++i) { - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen, - nghttp2_buf_len(&bufs.head->buf) - proclen); - CU_ASSERT_FATAL(rv > 0); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos + proclen, + nghttp2_buf_len(&bufs.head->buf) - proclen); + assert_ptrdiff(0, <, rv); proclen += (size_t)rv; - CU_ASSERT(nghttp2_nv_equal(&bad_ansnv[i], &ud.nv)); + assert_true(nghttp2_nv_equal(&bad_ansnv[i], &ud.nv)); } - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen, - nghttp2_buf_len(&bufs.head->buf) - proclen); - CU_ASSERT_FATAL(rv > 0); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos + proclen, + nghttp2_buf_len(&bufs.head->buf) - proclen); + assert_ptrdiff(0, <, rv); /* Without on_invalid_frame_recv_callback, bad header causes stream reset */ item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); proclen += (size_t)rv; - CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == proclen); + assert_size(nghttp2_buf_len(&bufs.head->buf), ==, proclen); nghttp2_session_del(session); @@ -13043,29 +13346,29 @@ void test_nghttp2_http_ignore_regular_header(void) { ud.invalid_header_cb_called = 0; for (i = 0; i < 4; ++i) { - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen, - nghttp2_buf_len(&bufs.head->buf) - proclen); - CU_ASSERT_FATAL(rv > 0); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos + proclen, + nghttp2_buf_len(&bufs.head->buf) - proclen); + assert_ptrdiff(0, <, rv); proclen += (size_t)rv; - CU_ASSERT(nghttp2_nv_equal(&bad_ansnv[i], &ud.nv)); + assert_true(nghttp2_nv_equal(&bad_ansnv[i], &ud.nv)); } - CU_ASSERT(0 == ud.invalid_header_cb_called); + assert_int(0, ==, ud.invalid_header_cb_called); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen, - nghttp2_buf_len(&bufs.head->buf) - proclen); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos + proclen, + nghttp2_buf_len(&bufs.head->buf) - proclen); - CU_ASSERT_FATAL(rv > 0); - CU_ASSERT(1 == ud.invalid_header_cb_called); - CU_ASSERT(nghttp2_nv_equal(&bad_reqnv[4], &ud.nv)); + assert_ptrdiff(0, <, rv); + assert_int(1, ==, ud.invalid_header_cb_called); + assert_true(nghttp2_nv_equal(&bad_reqnv[4], &ud.nv)); proclen += (size_t)rv; - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen, - nghttp2_buf_len(&bufs.head->buf) - proclen); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos + proclen, + nghttp2_buf_len(&bufs.head->buf) - proclen); - CU_ASSERT(rv > 0); - CU_ASSERT(nghttp2_nv_equal(&bad_ansnv[4], &ud.nv)); + assert_ptrdiff(0, <, rv); + assert_true(nghttp2_nv_equal(&bad_ansnv[4], &ud.nv)); nghttp2_session_del(session); @@ -13076,15 +13379,15 @@ void test_nghttp2_http_ignore_regular_header(void) { nghttp2_session_server_new(&session, &callbacks, &ud); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT(rv == (ssize_t)nghttp2_buf_len(&bufs.head->buf)); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(1 == item->frame.hd.stream_id); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(1, ==, item->frame.hd.stream_id); nghttp2_session_del(session); nghttp2_bufs_free(&bufs); @@ -13096,7 +13399,7 @@ void test_nghttp2_http_ignore_content_length(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; const nghttp2_nv cl_resnv[] = {MAKE_NV(":status", "304"), MAKE_NV("content-length", "20")}; const nghttp2_nv conn_reqnv[] = {MAKE_NV(":authority", "localhost"), @@ -13110,7 +13413,7 @@ void test_nghttp2_http_ignore_content_length(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -13122,14 +13425,14 @@ void test_nghttp2_http_ignore_content_length(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); nghttp2_bufs_reset(&bufs); @@ -13139,15 +13442,15 @@ void test_nghttp2_http_ignore_content_length(void) { rv = pack_headers(&bufs, &deflater, 3, NGHTTP2_FLAG_END_HEADERS, conn_cl_resnv, ARRLEN(conn_cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(-1 == stream->content_length); + assert_null(nghttp2_session_get_next_ob_item(session)); + assert_int64(-1, ==, stream->content_length); nghttp2_bufs_reset(&bufs); @@ -13162,19 +13465,19 @@ void test_nghttp2_http_ignore_content_length(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, conn_reqnv, ARRLEN(conn_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(-1 == stream->content_length); - CU_ASSERT((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) > 0); + assert_int64(-1, ==, stream->content_length); + assert_true(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -13189,7 +13492,7 @@ void test_nghttp2_http_record_request_method(void) { const nghttp2_nv conn_resnv[] = {MAKE_NV(":status", "200"), MAKE_NV("content-length", "9999")}; nghttp2_stream *stream; - ssize_t rv; + nghttp2_ssize rv; nghttp2_bufs bufs; nghttp2_hd_deflater deflater; nghttp2_mem *mem; @@ -13199,37 +13502,38 @@ void test_nghttp2_http_record_request_method(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); nghttp2_hd_deflate_init(&deflater, mem); - CU_ASSERT(1 == nghttp2_submit_request(session, NULL, conn_reqnv, - ARRLEN(conn_reqnv), NULL, NULL)); + assert_int32(1, ==, + nghttp2_submit_request2(session, NULL, conn_reqnv, + ARRLEN(conn_reqnv), NULL, NULL)); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_int(0, ==, nghttp2_session_send(session)); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(NGHTTP2_HTTP_FLAG_METH_CONNECT == stream->http_flags); + assert_uint32(NGHTTP2_HTTP_FLAG_METH_CONNECT, ==, stream->http_flags); rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, conn_resnv, ARRLEN(conn_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT((NGHTTP2_HTTP_FLAG_METH_CONNECT & stream->http_flags) > 0); - CU_ASSERT(-1 == stream->content_length); + assert_true(NGHTTP2_HTTP_FLAG_METH_CONNECT & stream->http_flags); + assert_int64(-1, ==, stream->content_length); /* content-length is ignored in 200 response to a CONNECT request */ item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -13242,7 +13546,7 @@ void test_nghttp2_http_push_promise(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; nghttp2_stream *stream; const nghttp2_nv bad_reqnv[] = {MAKE_NV(":method", "GET")}; nghttp2_outbound_item *item; @@ -13251,7 +13555,7 @@ void test_nghttp2_http_push_promise(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* good PUSH_PROMISE case */ nghttp2_session_client_new(&session, &callbacks, NULL); @@ -13262,33 +13566,33 @@ void test_nghttp2_http_push_promise(void) { rv = pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 2, reqnv, ARRLEN(reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); stream = nghttp2_session_get_stream(session, 2); - CU_ASSERT(NULL != stream); + assert_not_null(stream); nghttp2_bufs_reset(&bufs); rv = pack_headers(&bufs, &deflater, 2, NGHTTP2_FLAG_END_HEADERS, resnv, ARRLEN(resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); - CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session)); + assert_null(nghttp2_session_get_next_ob_item(session)); - CU_ASSERT(200 == stream->status_code); + assert_int16(200, ==, stream->status_code); nghttp2_bufs_reset(&bufs); @@ -13296,17 +13600,17 @@ void test_nghttp2_http_push_promise(void) { rv = pack_push_promise(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, 4, bad_reqnv, ARRLEN(bad_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(4 == item->frame.hd.stream_id); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int32(4, ==, item->frame.hd.stream_id); nghttp2_bufs_reset(&bufs); @@ -13323,14 +13627,14 @@ void test_nghttp2_http_head_method_upgrade_workaround(void) { nghttp2_bufs bufs; nghttp2_hd_deflater deflater; nghttp2_mem *mem; - ssize_t rv; + nghttp2_ssize rv; nghttp2_stream *stream; mem = nghttp2_mem_default(); frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; nghttp2_session_client_new(&session, &callbacks, NULL); @@ -13341,16 +13645,16 @@ void test_nghttp2_http_head_method_upgrade_workaround(void) { rv = pack_headers(&bufs, &deflater, 1, NGHTTP2_FLAG_END_HEADERS, cl_resnv, ARRLEN(cl_resnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); stream = nghttp2_session_get_stream(session, 1); - CU_ASSERT(-1 == stream->content_length); + assert_int64(-1, ==, stream->content_length); nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session); @@ -13363,7 +13667,7 @@ void test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation(void) { nghttp2_hd_deflater deflater; nghttp2_mem *mem; nghttp2_bufs bufs; - ssize_t rv; + nghttp2_ssize rv; const nghttp2_nv ws_reqnv[] = { MAKE_NV(":path", "/"), MAKE_NV(":method", "GET"), @@ -13378,7 +13682,7 @@ void test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation(void) { frame_pack_bufs_init(&bufs); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - callbacks.send_callback = null_send_callback; + callbacks.send_callback2 = null_send_callback; /* By default, the leading and trailing white spaces validation is enabled as per RFC 9113. */ @@ -13390,17 +13694,17 @@ void test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, ws_reqnv, ARRLEN(ws_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type); - CU_ASSERT(0 == nghttp2_session_send(session)); + assert_uint8(NGHTTP2_RST_STREAM, ==, item->frame.hd.type); + assert_int(0, ==, nghttp2_session_send(session)); nghttp2_bufs_reset(&bufs); nghttp2_hd_deflate_free(&deflater); @@ -13418,16 +13722,16 @@ void test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation(void) { NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM, ws_reqnv, ARRLEN(ws_reqnv), mem); - CU_ASSERT(0 == rv); + assert_ptrdiff(0, ==, rv); - rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos, - nghttp2_buf_len(&bufs.head->buf)); + rv = nghttp2_session_mem_recv2(session, bufs.head->buf.pos, + nghttp2_buf_len(&bufs.head->buf)); - CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv); + assert_ptrdiff((nghttp2_ssize)nghttp2_buf_len(&bufs.head->buf), ==, rv); item = nghttp2_session_get_next_ob_item(session); - CU_ASSERT(NULL == item); + assert_null(item); nghttp2_bufs_reset(&bufs); nghttp2_hd_deflate_free(&deflater); diff --git a/tests/nghttp2_session_test.h b/tests/nghttp2_session_test.h index be4fdf8..43befbe 100644 --- a/tests/nghttp2_session_test.h +++ b/tests/nghttp2_session_test.h @@ -29,156 +29,165 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ -void test_nghttp2_session_recv(void); -void test_nghttp2_session_recv_invalid_stream_id(void); -void test_nghttp2_session_recv_invalid_frame(void); -void test_nghttp2_session_recv_eof(void); -void test_nghttp2_session_recv_data(void); -void test_nghttp2_session_recv_data_no_auto_flow_control(void); -void test_nghttp2_session_recv_continuation(void); -void test_nghttp2_session_recv_headers_with_priority(void); -void test_nghttp2_session_recv_headers_with_padding(void); -void test_nghttp2_session_recv_headers_early_response(void); -void test_nghttp2_session_recv_headers_for_closed_stream(void); -void test_nghttp2_session_recv_headers_with_extpri(void); -void test_nghttp2_session_server_recv_push_response(void); -void test_nghttp2_session_recv_premature_headers(void); -void test_nghttp2_session_recv_unknown_frame(void); -void test_nghttp2_session_recv_unexpected_continuation(void); -void test_nghttp2_session_recv_settings_header_table_size(void); -void test_nghttp2_session_recv_too_large_frame_length(void); -void test_nghttp2_session_recv_extension(void); -void test_nghttp2_session_recv_altsvc(void); -void test_nghttp2_session_recv_origin(void); -void test_nghttp2_session_recv_priority_update(void); -void test_nghttp2_session_continue(void); -void test_nghttp2_session_add_frame(void); -void test_nghttp2_session_on_request_headers_received(void); -void test_nghttp2_session_on_response_headers_received(void); -void test_nghttp2_session_on_headers_received(void); -void test_nghttp2_session_on_push_response_headers_received(void); -void test_nghttp2_session_on_priority_received(void); -void test_nghttp2_session_on_rst_stream_received(void); -void test_nghttp2_session_on_settings_received(void); -void test_nghttp2_session_on_push_promise_received(void); -void test_nghttp2_session_on_ping_received(void); -void test_nghttp2_session_on_goaway_received(void); -void test_nghttp2_session_on_window_update_received(void); -void test_nghttp2_session_on_data_received(void); -void test_nghttp2_session_on_data_received_fail_fast(void); -void test_nghttp2_session_on_altsvc_received(void); -void test_nghttp2_session_send_headers_start_stream(void); -void test_nghttp2_session_send_headers_reply(void); -void test_nghttp2_session_send_headers_frame_size_error(void); -void test_nghttp2_session_send_headers_push_reply(void); -void test_nghttp2_session_send_rst_stream(void); -void test_nghttp2_session_send_push_promise(void); -void test_nghttp2_session_is_my_stream_id(void); -void test_nghttp2_session_upgrade2(void); -void test_nghttp2_session_reprioritize_stream(void); -void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void); -void test_nghttp2_submit_data(void); -void test_nghttp2_submit_data_read_length_too_large(void); -void test_nghttp2_submit_data_read_length_smallest(void); -void test_nghttp2_submit_data_twice(void); -void test_nghttp2_submit_request_with_data(void); -void test_nghttp2_submit_request_without_data(void); -void test_nghttp2_submit_response_with_data(void); -void test_nghttp2_submit_response_without_data(void); -void test_nghttp2_submit_response_push_response(void); -void test_nghttp2_submit_trailer(void); -void test_nghttp2_submit_headers_start_stream(void); -void test_nghttp2_submit_headers_reply(void); -void test_nghttp2_submit_headers_push_reply(void); -void test_nghttp2_submit_headers(void); -void test_nghttp2_submit_headers_continuation(void); -void test_nghttp2_submit_headers_continuation_extra_large(void); -void test_nghttp2_submit_priority(void); -void test_nghttp2_submit_settings(void); -void test_nghttp2_submit_settings_update_local_window_size(void); -void test_nghttp2_submit_settings_multiple_times(void); -void test_nghttp2_submit_push_promise(void); -void test_nghttp2_submit_window_update(void); -void test_nghttp2_submit_window_update_local_window_size(void); -void test_nghttp2_submit_shutdown_notice(void); -void test_nghttp2_submit_invalid_nv(void); -void test_nghttp2_submit_extension(void); -void test_nghttp2_submit_altsvc(void); -void test_nghttp2_submit_origin(void); -void test_nghttp2_submit_priority_update(void); -void test_nghttp2_submit_rst_stream(void); -void test_nghttp2_session_open_stream(void); -void test_nghttp2_session_open_stream_with_idle_stream_dep(void); -void test_nghttp2_session_get_next_ob_item(void); -void test_nghttp2_session_pop_next_ob_item(void); -void test_nghttp2_session_reply_fail(void); -void test_nghttp2_session_max_concurrent_streams(void); -void test_nghttp2_session_stop_data_with_rst_stream(void); -void test_nghttp2_session_defer_data(void); -void test_nghttp2_session_flow_control(void); -void test_nghttp2_session_flow_control_data_recv(void); -void test_nghttp2_session_flow_control_data_with_padding_recv(void); -void test_nghttp2_session_data_read_temporal_failure(void); -void test_nghttp2_session_on_stream_close(void); -void test_nghttp2_session_on_ctrl_not_send(void); -void test_nghttp2_session_get_outbound_queue_size(void); -void test_nghttp2_session_get_effective_local_window_size(void); -void test_nghttp2_session_set_option(void); -void test_nghttp2_session_data_backoff_by_high_pri_frame(void); -void test_nghttp2_session_pack_data_with_padding(void); -void test_nghttp2_session_pack_headers_with_padding(void); -void test_nghttp2_pack_settings_payload(void); -void test_nghttp2_session_stream_dep_add(void); -void test_nghttp2_session_stream_dep_remove(void); -void test_nghttp2_session_stream_dep_add_subtree(void); -void test_nghttp2_session_stream_dep_remove_subtree(void); -void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void); -void test_nghttp2_session_stream_attach_item(void); -void test_nghttp2_session_stream_attach_item_subtree(void); -void test_nghttp2_session_stream_get_state(void); -void test_nghttp2_session_stream_get_something(void); -void test_nghttp2_session_find_stream(void); -void test_nghttp2_session_keep_closed_stream(void); -void test_nghttp2_session_keep_idle_stream(void); -void test_nghttp2_session_detach_idle_stream(void); -void test_nghttp2_session_large_dep_tree(void); -void test_nghttp2_session_graceful_shutdown(void); -void test_nghttp2_session_on_header_temporal_failure(void); -void test_nghttp2_session_recv_client_magic(void); -void test_nghttp2_session_delete_data_item(void); -void test_nghttp2_session_open_idle_stream(void); -void test_nghttp2_session_cancel_reserved_remote(void); -void test_nghttp2_session_reset_pending_headers(void); -void test_nghttp2_session_send_data_callback(void); -void test_nghttp2_session_on_begin_headers_temporal_failure(void); -void test_nghttp2_session_defer_then_close(void); -void test_nghttp2_session_detach_item_from_closed_stream(void); -void test_nghttp2_session_flooding(void); -void test_nghttp2_session_change_stream_priority(void); -void test_nghttp2_session_change_extpri_stream_priority(void); -void test_nghttp2_session_create_idle_stream(void); -void test_nghttp2_session_repeated_priority_change(void); -void test_nghttp2_session_repeated_priority_submission(void); -void test_nghttp2_session_set_local_window_size(void); -void test_nghttp2_session_cancel_from_before_frame_send(void); -void test_nghttp2_session_too_many_settings(void); -void test_nghttp2_session_removed_closed_stream(void); -void test_nghttp2_session_pause_data(void); -void test_nghttp2_session_no_closed_streams(void); -void test_nghttp2_session_set_stream_user_data(void); -void test_nghttp2_session_no_rfc7540_priorities(void); -void test_nghttp2_session_server_fallback_rfc7540_priorities(void); -void test_nghttp2_session_stream_reset_ratelim(void); -void test_nghttp2_http_mandatory_headers(void); -void test_nghttp2_http_content_length(void); -void test_nghttp2_http_content_length_mismatch(void); -void test_nghttp2_http_non_final_response(void); -void test_nghttp2_http_trailer_headers(void); -void test_nghttp2_http_ignore_regular_header(void); -void test_nghttp2_http_ignore_content_length(void); -void test_nghttp2_http_record_request_method(void); -void test_nghttp2_http_push_promise(void); -void test_nghttp2_http_head_method_upgrade_workaround(void); -void test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation(void); +#define MUNIT_ENABLE_ASSERT_ALIASES + +#include "munit.h" + +extern const MunitSuite session_suite; + +munit_void_test_decl(test_nghttp2_session_recv); +munit_void_test_decl(test_nghttp2_session_recv_invalid_stream_id); +munit_void_test_decl(test_nghttp2_session_recv_invalid_frame); +munit_void_test_decl(test_nghttp2_session_recv_eof); +munit_void_test_decl(test_nghttp2_session_recv_data); +munit_void_test_decl(test_nghttp2_session_recv_data_no_auto_flow_control); +munit_void_test_decl(test_nghttp2_session_recv_continuation); +munit_void_test_decl(test_nghttp2_session_recv_headers_with_priority); +munit_void_test_decl(test_nghttp2_session_recv_headers_with_padding); +munit_void_test_decl(test_nghttp2_session_recv_headers_early_response); +munit_void_test_decl(test_nghttp2_session_recv_headers_for_closed_stream); +munit_void_test_decl(test_nghttp2_session_recv_headers_with_extpri); +munit_void_test_decl(test_nghttp2_session_server_recv_push_response); +munit_void_test_decl(test_nghttp2_session_recv_premature_headers); +munit_void_test_decl(test_nghttp2_session_recv_unknown_frame); +munit_void_test_decl(test_nghttp2_session_recv_unexpected_continuation); +munit_void_test_decl(test_nghttp2_session_recv_settings_header_table_size); +munit_void_test_decl(test_nghttp2_session_recv_too_large_frame_length); +munit_void_test_decl(test_nghttp2_session_recv_extension); +munit_void_test_decl(test_nghttp2_session_recv_altsvc); +munit_void_test_decl(test_nghttp2_session_recv_origin); +munit_void_test_decl(test_nghttp2_session_recv_priority_update); +munit_void_test_decl(test_nghttp2_session_continue); +munit_void_test_decl(test_nghttp2_session_add_frame); +munit_void_test_decl(test_nghttp2_session_on_request_headers_received); +munit_void_test_decl(test_nghttp2_session_on_response_headers_received); +munit_void_test_decl(test_nghttp2_session_on_headers_received); +munit_void_test_decl(test_nghttp2_session_on_push_response_headers_received); +munit_void_test_decl(test_nghttp2_session_on_priority_received); +munit_void_test_decl(test_nghttp2_session_on_rst_stream_received); +munit_void_test_decl(test_nghttp2_session_on_settings_received); +munit_void_test_decl(test_nghttp2_session_on_push_promise_received); +munit_void_test_decl(test_nghttp2_session_on_ping_received); +munit_void_test_decl(test_nghttp2_session_on_goaway_received); +munit_void_test_decl(test_nghttp2_session_on_window_update_received); +munit_void_test_decl(test_nghttp2_session_on_data_received); +munit_void_test_decl(test_nghttp2_session_on_data_received_fail_fast); +munit_void_test_decl(test_nghttp2_session_on_altsvc_received); +munit_void_test_decl(test_nghttp2_session_send_headers_start_stream); +munit_void_test_decl(test_nghttp2_session_send_headers_reply); +munit_void_test_decl(test_nghttp2_session_send_headers_frame_size_error); +munit_void_test_decl(test_nghttp2_session_send_headers_push_reply); +munit_void_test_decl(test_nghttp2_session_send_rst_stream); +munit_void_test_decl(test_nghttp2_session_send_push_promise); +munit_void_test_decl(test_nghttp2_session_is_my_stream_id); +munit_void_test_decl(test_nghttp2_session_upgrade2); +munit_void_test_decl(test_nghttp2_session_reprioritize_stream); +munit_void_test_decl( + test_nghttp2_session_reprioritize_stream_with_idle_stream_dep); +munit_void_test_decl(test_nghttp2_submit_data); +munit_void_test_decl(test_nghttp2_submit_data_read_length_too_large); +munit_void_test_decl(test_nghttp2_submit_data_read_length_smallest); +munit_void_test_decl(test_nghttp2_submit_data_twice); +munit_void_test_decl(test_nghttp2_submit_request_with_data); +munit_void_test_decl(test_nghttp2_submit_request_without_data); +munit_void_test_decl(test_nghttp2_submit_response_with_data); +munit_void_test_decl(test_nghttp2_submit_response_without_data); +munit_void_test_decl(test_nghttp2_submit_response_push_response); +munit_void_test_decl(test_nghttp2_submit_trailer); +munit_void_test_decl(test_nghttp2_submit_headers_start_stream); +munit_void_test_decl(test_nghttp2_submit_headers_reply); +munit_void_test_decl(test_nghttp2_submit_headers_push_reply); +munit_void_test_decl(test_nghttp2_submit_headers); +munit_void_test_decl(test_nghttp2_submit_headers_continuation); +munit_void_test_decl(test_nghttp2_submit_headers_continuation_extra_large); +munit_void_test_decl(test_nghttp2_submit_priority); +munit_void_test_decl(test_nghttp2_submit_settings); +munit_void_test_decl(test_nghttp2_submit_settings_update_local_window_size); +munit_void_test_decl(test_nghttp2_submit_settings_multiple_times); +munit_void_test_decl(test_nghttp2_submit_push_promise); +munit_void_test_decl(test_nghttp2_submit_window_update); +munit_void_test_decl(test_nghttp2_submit_window_update_local_window_size); +munit_void_test_decl(test_nghttp2_submit_shutdown_notice); +munit_void_test_decl(test_nghttp2_submit_invalid_nv); +munit_void_test_decl(test_nghttp2_submit_extension); +munit_void_test_decl(test_nghttp2_submit_altsvc); +munit_void_test_decl(test_nghttp2_submit_origin); +munit_void_test_decl(test_nghttp2_submit_priority_update); +munit_void_test_decl(test_nghttp2_submit_rst_stream); +munit_void_test_decl(test_nghttp2_session_open_stream); +munit_void_test_decl(test_nghttp2_session_open_stream_with_idle_stream_dep); +munit_void_test_decl(test_nghttp2_session_get_next_ob_item); +munit_void_test_decl(test_nghttp2_session_pop_next_ob_item); +munit_void_test_decl(test_nghttp2_session_reply_fail); +munit_void_test_decl(test_nghttp2_session_max_concurrent_streams); +munit_void_test_decl(test_nghttp2_session_stop_data_with_rst_stream); +munit_void_test_decl(test_nghttp2_session_defer_data); +munit_void_test_decl(test_nghttp2_session_flow_control); +munit_void_test_decl(test_nghttp2_session_flow_control_data_recv); +munit_void_test_decl(test_nghttp2_session_flow_control_data_with_padding_recv); +munit_void_test_decl(test_nghttp2_session_data_read_temporal_failure); +munit_void_test_decl(test_nghttp2_session_on_stream_close); +munit_void_test_decl(test_nghttp2_session_on_ctrl_not_send); +munit_void_test_decl(test_nghttp2_session_get_outbound_queue_size); +munit_void_test_decl(test_nghttp2_session_get_effective_local_window_size); +munit_void_test_decl(test_nghttp2_session_set_option); +munit_void_test_decl(test_nghttp2_session_data_backoff_by_high_pri_frame); +munit_void_test_decl(test_nghttp2_session_pack_data_with_padding); +munit_void_test_decl(test_nghttp2_session_pack_headers_with_padding); +munit_void_test_decl(test_nghttp2_pack_settings_payload); +munit_void_test_decl(test_nghttp2_session_stream_dep_add); +munit_void_test_decl(test_nghttp2_session_stream_dep_remove); +munit_void_test_decl(test_nghttp2_session_stream_dep_add_subtree); +munit_void_test_decl(test_nghttp2_session_stream_dep_remove_subtree); +munit_void_test_decl( + test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us); +munit_void_test_decl(test_nghttp2_session_stream_attach_item); +munit_void_test_decl(test_nghttp2_session_stream_attach_item_subtree); +munit_void_test_decl(test_nghttp2_session_stream_get_state); +munit_void_test_decl(test_nghttp2_session_stream_get_something); +munit_void_test_decl(test_nghttp2_session_find_stream); +munit_void_test_decl(test_nghttp2_session_keep_closed_stream); +munit_void_test_decl(test_nghttp2_session_keep_idle_stream); +munit_void_test_decl(test_nghttp2_session_detach_idle_stream); +munit_void_test_decl(test_nghttp2_session_large_dep_tree); +munit_void_test_decl(test_nghttp2_session_graceful_shutdown); +munit_void_test_decl(test_nghttp2_session_on_header_temporal_failure); +munit_void_test_decl(test_nghttp2_session_recv_client_magic); +munit_void_test_decl(test_nghttp2_session_delete_data_item); +munit_void_test_decl(test_nghttp2_session_open_idle_stream); +munit_void_test_decl(test_nghttp2_session_cancel_reserved_remote); +munit_void_test_decl(test_nghttp2_session_reset_pending_headers); +munit_void_test_decl(test_nghttp2_session_send_data_callback); +munit_void_test_decl(test_nghttp2_session_on_begin_headers_temporal_failure); +munit_void_test_decl(test_nghttp2_session_defer_then_close); +munit_void_test_decl(test_nghttp2_session_detach_item_from_closed_stream); +munit_void_test_decl(test_nghttp2_session_flooding); +munit_void_test_decl(test_nghttp2_session_change_stream_priority); +munit_void_test_decl(test_nghttp2_session_change_extpri_stream_priority); +munit_void_test_decl(test_nghttp2_session_create_idle_stream); +munit_void_test_decl(test_nghttp2_session_repeated_priority_change); +munit_void_test_decl(test_nghttp2_session_repeated_priority_submission); +munit_void_test_decl(test_nghttp2_session_set_local_window_size); +munit_void_test_decl(test_nghttp2_session_cancel_from_before_frame_send); +munit_void_test_decl(test_nghttp2_session_too_many_settings); +munit_void_test_decl(test_nghttp2_session_removed_closed_stream); +munit_void_test_decl(test_nghttp2_session_pause_data); +munit_void_test_decl(test_nghttp2_session_no_closed_streams); +munit_void_test_decl(test_nghttp2_session_set_stream_user_data); +munit_void_test_decl(test_nghttp2_session_no_rfc7540_priorities); +munit_void_test_decl(test_nghttp2_session_server_fallback_rfc7540_priorities); +munit_void_test_decl(test_nghttp2_session_stream_reset_ratelim); +munit_void_test_decl(test_nghttp2_http_mandatory_headers); +munit_void_test_decl(test_nghttp2_http_content_length); +munit_void_test_decl(test_nghttp2_http_content_length_mismatch); +munit_void_test_decl(test_nghttp2_http_non_final_response); +munit_void_test_decl(test_nghttp2_http_trailer_headers); +munit_void_test_decl(test_nghttp2_http_ignore_regular_header); +munit_void_test_decl(test_nghttp2_http_ignore_content_length); +munit_void_test_decl(test_nghttp2_http_record_request_method); +munit_void_test_decl(test_nghttp2_http_push_promise); +munit_void_test_decl(test_nghttp2_http_head_method_upgrade_workaround); +munit_void_test_decl( + test_nghttp2_http_no_rfc9113_leading_and_trailing_ws_validation); #endif /* NGHTTP2_SESSION_TEST_H */ diff --git a/tests/nghttp2_stream_test.c b/tests/nghttp2_stream_test.c index 75b4d68..91be376 100644 --- a/tests/nghttp2_stream_test.c +++ b/tests/nghttp2_stream_test.c @@ -26,6 +26,4 @@ #include <stdio.h> -#include <CUnit/CUnit.h> - #include "nghttp2_stream.h" diff --git a/tests/nghttp2_test_helper.c b/tests/nghttp2_test_helper.c index 1bd4a63..c1b912b 100644 --- a/tests/nghttp2_test_helper.c +++ b/tests/nghttp2_test_helper.c @@ -27,8 +27,6 @@ #include <stdio.h> #include <assert.h> -#include <CUnit/CUnit.h> - #include "nghttp2_helper.h" #include "nghttp2_priority_spec.h" @@ -155,9 +153,9 @@ void add_out(nva_out *out, nghttp2_nv *nv, nghttp2_mem *mem) { ++out->nvlen; } -ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, - nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem) { - ssize_t rv; +nghttp2_ssize inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, + nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem) { + nghttp2_ssize rv; nghttp2_nv nv; int inflate_flags; nghttp2_buf_chain *ci; @@ -183,7 +181,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, for (;;) { inflate_flags = 0; - rv = nghttp2_hd_inflate_hd2(inflater, &nv, &inflate_flags, bp.pos, + rv = nghttp2_hd_inflate_hd3(inflater, &nv, &inflate_flags, bp.pos, nghttp2_buf_len(&bp), fin); if (rv < 0) { @@ -210,7 +208,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, nghttp2_hd_inflate_end_headers(inflater); - return (ssize_t)processed; + return (nghttp2_ssize)processed; } int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater, diff --git a/tests/nghttp2_test_helper.h b/tests/nghttp2_test_helper.h index c66298a..c0ed0b3 100644 --- a/tests/nghttp2_test_helper.h +++ b/tests/nghttp2_test_helper.h @@ -40,24 +40,6 @@ } #define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0])) -#define assert_nv_equal(A, B, len, mem) \ - do { \ - size_t alloclen = sizeof(nghttp2_nv) * len; \ - const nghttp2_nv *sa = A, *sb = B; \ - nghttp2_nv *a = mem->malloc(alloclen, NULL); \ - nghttp2_nv *b = mem->malloc(alloclen, NULL); \ - ssize_t i_; \ - memcpy(a, sa, alloclen); \ - memcpy(b, sb, alloclen); \ - nghttp2_nv_array_sort(a, len); \ - nghttp2_nv_array_sort(b, len); \ - for (i_ = 0; i_ < (ssize_t)len; ++i_) { \ - CU_ASSERT(nghttp2_nv_equal(&a[i_], &b[i_])); \ - } \ - mem->free(b, NULL); \ - mem->free(a, NULL); \ - } while (0); - int unpack_framebuf(nghttp2_frame *frame, nghttp2_bufs *bufs); int unpack_frame(nghttp2_frame *frame, const uint8_t *in, size_t len); @@ -78,8 +60,8 @@ void nva_out_reset(nva_out *out, nghttp2_mem *mem); void add_out(nva_out *out, nghttp2_nv *nv, nghttp2_mem *mem); -ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, - nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem); +nghttp2_ssize inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out, + nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem); int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater, int32_t stream_id, uint8_t flags, const nghttp2_nv *nva, |