Add test for graceful shutdown use case

This commit is contained in:
Tatsuhiro Tsujikawa 2014-06-18 12:08:12 +09:00
parent 9294622519
commit 8e0fcd3922
3 changed files with 41 additions and 0 deletions

View File

@ -227,6 +227,8 @@ int main(int argc, char* argv[])
test_nghttp2_session_stream_attach_data_subtree) ||
!CU_add_test(pSuite, "session_stream_keep_closed_stream",
test_nghttp2_session_keep_closed_stream) ||
!CU_add_test(pSuite, "session_graceful_shutdown",
test_nghttp2_session_graceful_shutdown) ||
!CU_add_test(pSuite, "frame_pack_headers",
test_nghttp2_frame_pack_headers) ||
!CU_add_test(pSuite, "frame_pack_headers_frame_too_large",

View File

@ -5791,3 +5791,41 @@ void test_nghttp2_session_keep_closed_stream(void)
nghttp2_session_del(session);
}
void test_nghttp2_session_graceful_shutdown(void)
{
nghttp2_session *session;
nghttp2_session_callbacks callbacks;
my_user_data ud;
memset(&callbacks, 0, sizeof(callbacks));
callbacks.send_callback = block_count_send_callback;
callbacks.on_frame_send_callback = on_frame_send_callback;
nghttp2_session_server_new(&session, &callbacks, &ud);
CU_ASSERT(0 == nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE,
(1u << 31) - 1, NGHTTP2_NO_ERROR,
NULL, 0));
ud.block_count = 1;
ud.frame_send_cb_called = 0;
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(1 == ud.frame_send_cb_called);
CU_ASSERT((1u << 31) - 1 == session->local_last_stream_id);
CU_ASSERT(0 == nghttp2_session_terminate_session2(session, 300,
NGHTTP2_NO_ERROR));
ud.block_count = 1;
ud.frame_send_cb_called = 0;
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(1 == ud.frame_send_cb_called);
CU_ASSERT(300 == session->local_last_stream_id);
nghttp2_session_del(session);
}

View File

@ -106,5 +106,6 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void);
void test_nghttp2_session_stream_attach_data(void);
void test_nghttp2_session_stream_attach_data_subtree(void);
void test_nghttp2_session_keep_closed_stream(void);
void test_nghttp2_session_graceful_shutdown(void);
#endif /* NGHTTP2_SESSION_TEST_H */