2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2012 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #endif /* HAVE_CONFIG_H */
31 #include <CUnit/Basic.h>
32 /* include test cases' include files here */
33 #include "nghttp2_pq_test.h"
34 #include "nghttp2_map_test.h"
35 #include "nghttp2_queue_test.h"
36 #include "nghttp2_session_test.h"
37 #include "nghttp2_frame_test.h"
38 #include "nghttp2_stream_test.h"
39 #include "nghttp2_hd_test.h"
40 #include "nghttp2_npn_test.h"
41 #include "nghttp2_helper_test.h"
42 #include "nghttp2_buf_test.h"
44 extern int nghttp2_enable_strict_preface;
46 static int init_suite1(void) { return 0; }
48 static int clean_suite1(void) { return 0; }
50 int main(int argc _U_, char *argv[] _U_) {
51 CU_pSuite pSuite = NULL;
52 unsigned int num_tests_failed;
54 nghttp2_enable_strict_preface = 0;
56 /* initialize the CUnit test registry */
57 if (CUE_SUCCESS != CU_initialize_registry())
58 return CU_get_error();
60 /* add a suite to the registry */
61 pSuite = CU_add_suite("libnghttp2_TestSuite", init_suite1, clean_suite1);
63 CU_cleanup_registry();
64 return CU_get_error();
67 /* add the tests to the suite */
68 if (!CU_add_test(pSuite, "pq", test_nghttp2_pq) ||
69 !CU_add_test(pSuite, "pq_update", test_nghttp2_pq_update) ||
70 !CU_add_test(pSuite, "map", test_nghttp2_map) ||
71 !CU_add_test(pSuite, "map_functional", test_nghttp2_map_functional) ||
72 !CU_add_test(pSuite, "map_each_free", test_nghttp2_map_each_free) ||
73 !CU_add_test(pSuite, "queue", test_nghttp2_queue) ||
74 !CU_add_test(pSuite, "npn", test_nghttp2_npn) ||
75 !CU_add_test(pSuite, "session_recv", test_nghttp2_session_recv) ||
76 !CU_add_test(pSuite, "session_recv_invalid_stream_id",
77 test_nghttp2_session_recv_invalid_stream_id) ||
78 !CU_add_test(pSuite, "session_recv_invalid_frame",
79 test_nghttp2_session_recv_invalid_frame) ||
80 !CU_add_test(pSuite, "session_recv_eof", test_nghttp2_session_recv_eof) ||
81 !CU_add_test(pSuite, "session_recv_data",
82 test_nghttp2_session_recv_data) ||
83 !CU_add_test(pSuite, "session_recv_continuation",
84 test_nghttp2_session_recv_continuation) ||
85 !CU_add_test(pSuite, "session_recv_headers_with_priority",
86 test_nghttp2_session_recv_headers_with_priority) ||
87 !CU_add_test(pSuite, "session_recv_premature_headers",
88 test_nghttp2_session_recv_premature_headers) ||
89 !CU_add_test(pSuite, "session_recv_unknown_frame",
90 test_nghttp2_session_recv_unknown_frame) ||
91 !CU_add_test(pSuite, "session_recv_unexpected_continuation",
92 test_nghttp2_session_recv_unexpected_continuation) ||
93 !CU_add_test(pSuite, "session_recv_settings_header_table_size",
94 test_nghttp2_session_recv_settings_header_table_size) ||
95 !CU_add_test(pSuite, "session_recv_too_large_frame_length",
96 test_nghttp2_session_recv_too_large_frame_length) ||
97 !CU_add_test(pSuite, "session_continue", test_nghttp2_session_continue) ||
98 !CU_add_test(pSuite, "session_add_frame",
99 test_nghttp2_session_add_frame) ||
100 !CU_add_test(pSuite, "session_on_request_headers_received",
101 test_nghttp2_session_on_request_headers_received) ||
102 !CU_add_test(pSuite, "session_on_response_headers_received",
103 test_nghttp2_session_on_response_headers_received) ||
104 !CU_add_test(pSuite, "session_on_headers_received",
105 test_nghttp2_session_on_headers_received) ||
106 !CU_add_test(pSuite, "session_on_push_response_headers_received",
107 test_nghttp2_session_on_push_response_headers_received) ||
108 !CU_add_test(pSuite, "session_on_priority_received",
109 test_nghttp2_session_on_priority_received) ||
110 !CU_add_test(pSuite, "session_on_rst_stream_received",
111 test_nghttp2_session_on_rst_stream_received) ||
112 !CU_add_test(pSuite, "session_on_settings_received",
113 test_nghttp2_session_on_settings_received) ||
114 !CU_add_test(pSuite, "session_on_push_promise_received",
115 test_nghttp2_session_on_push_promise_received) ||
116 !CU_add_test(pSuite, "session_on_ping_received",
117 test_nghttp2_session_on_ping_received) ||
118 !CU_add_test(pSuite, "session_on_goaway_received",
119 test_nghttp2_session_on_goaway_received) ||
120 !CU_add_test(pSuite, "session_on_window_update_received",
121 test_nghttp2_session_on_window_update_received) ||
122 !CU_add_test(pSuite, "session_on_data_received",
123 test_nghttp2_session_on_data_received) ||
124 !CU_add_test(pSuite, "session_send_headers_start_stream",
125 test_nghttp2_session_send_headers_start_stream) ||
126 !CU_add_test(pSuite, "session_send_headers_reply",
127 test_nghttp2_session_send_headers_reply) ||
128 !CU_add_test(pSuite, "session_send_headers_frame_size_error",
129 test_nghttp2_session_send_headers_frame_size_error) ||
130 !CU_add_test(pSuite, "session_send_headers_push_reply",
131 test_nghttp2_session_send_headers_push_reply) ||
132 !CU_add_test(pSuite, "session_send_rst_stream",
133 test_nghttp2_session_send_rst_stream) ||
134 !CU_add_test(pSuite, "session_send_push_promise",
135 test_nghttp2_session_send_push_promise) ||
136 !CU_add_test(pSuite, "session_is_my_stream_id",
137 test_nghttp2_session_is_my_stream_id) ||
138 !CU_add_test(pSuite, "session_upgrade", test_nghttp2_session_upgrade) ||
139 !CU_add_test(pSuite, "session_reprioritize_stream",
140 test_nghttp2_session_reprioritize_stream) ||
142 pSuite, "session_reprioritize_stream_with_idle_stream_dep",
143 test_nghttp2_session_reprioritize_stream_with_idle_stream_dep) ||
144 !CU_add_test(pSuite, "submit_data", test_nghttp2_submit_data) ||
145 !CU_add_test(pSuite, "submit_data_read_length_too_large",
146 test_nghttp2_submit_data_read_length_too_large) ||
147 !CU_add_test(pSuite, "submit_data_twice",
148 test_nghttp2_submit_data_twice) ||
149 !CU_add_test(pSuite, "submit_request_with_data",
150 test_nghttp2_submit_request_with_data) ||
151 !CU_add_test(pSuite, "submit_request_without_data",
152 test_nghttp2_submit_request_without_data) ||
153 !CU_add_test(pSuite, "submit_response_with_data",
154 test_nghttp2_submit_response_with_data) ||
155 !CU_add_test(pSuite, "submit_response_without_data",
156 test_nghttp2_submit_response_without_data) ||
157 !CU_add_test(pSuite, "submit_trailer", test_nghttp2_submit_trailer) ||
158 !CU_add_test(pSuite, "submit_headers_start_stream",
159 test_nghttp2_submit_headers_start_stream) ||
160 !CU_add_test(pSuite, "submit_headers_reply",
161 test_nghttp2_submit_headers_reply) ||
162 !CU_add_test(pSuite, "submit_headers_push_reply",
163 test_nghttp2_submit_headers_push_reply) ||
164 !CU_add_test(pSuite, "submit_headers", test_nghttp2_submit_headers) ||
165 !CU_add_test(pSuite, "submit_headers_continuation",
166 test_nghttp2_submit_headers_continuation) ||
167 !CU_add_test(pSuite, "submit_priority", test_nghttp2_submit_priority) ||
168 !CU_add_test(pSuite, "session_submit_settings",
169 test_nghttp2_submit_settings) ||
170 !CU_add_test(pSuite, "session_submit_settings_update_local_window_size",
171 test_nghttp2_submit_settings_update_local_window_size) ||
172 !CU_add_test(pSuite, "session_submit_push_promise",
173 test_nghttp2_submit_push_promise) ||
174 !CU_add_test(pSuite, "submit_window_update",
175 test_nghttp2_submit_window_update) ||
176 !CU_add_test(pSuite, "submit_window_update_local_window_size",
177 test_nghttp2_submit_window_update_local_window_size) ||
178 !CU_add_test(pSuite, "submit_shutdown_notice",
179 test_nghttp2_submit_shutdown_notice) ||
180 !CU_add_test(pSuite, "submit_invalid_nv",
181 test_nghttp2_submit_invalid_nv) ||
182 !CU_add_test(pSuite, "session_open_stream",
183 test_nghttp2_session_open_stream) ||
184 !CU_add_test(pSuite, "session_open_stream_with_idle_stream_dep",
185 test_nghttp2_session_open_stream_with_idle_stream_dep) ||
186 !CU_add_test(pSuite, "session_get_next_ob_item",
187 test_nghttp2_session_get_next_ob_item) ||
188 !CU_add_test(pSuite, "session_pop_next_ob_item",
189 test_nghttp2_session_pop_next_ob_item) ||
190 !CU_add_test(pSuite, "session_reply_fail",
191 test_nghttp2_session_reply_fail) ||
192 !CU_add_test(pSuite, "session_max_concurrent_streams",
193 test_nghttp2_session_max_concurrent_streams) ||
194 !CU_add_test(pSuite, "session_stream_close_on_headers_push",
195 test_nghttp2_session_stream_close_on_headers_push) ||
196 !CU_add_test(pSuite, "session_stop_data_with_rst_stream",
197 test_nghttp2_session_stop_data_with_rst_stream) ||
198 !CU_add_test(pSuite, "session_defer_data",
199 test_nghttp2_session_defer_data) ||
200 !CU_add_test(pSuite, "session_flow_control",
201 test_nghttp2_session_flow_control) ||
202 !CU_add_test(pSuite, "session_flow_control_data_recv",
203 test_nghttp2_session_flow_control_data_recv) ||
204 !CU_add_test(pSuite, "session_flow_control_data_with_padding_recv",
205 test_nghttp2_session_flow_control_data_with_padding_recv) ||
206 !CU_add_test(pSuite, "session_data_read_temporal_failure",
207 test_nghttp2_session_data_read_temporal_failure) ||
208 !CU_add_test(pSuite, "session_on_stream_close",
209 test_nghttp2_session_on_stream_close) ||
210 !CU_add_test(pSuite, "session_on_ctrl_not_send",
211 test_nghttp2_session_on_ctrl_not_send) ||
212 !CU_add_test(pSuite, "session_get_outbound_queue_size",
213 test_nghttp2_session_get_outbound_queue_size) ||
214 !CU_add_test(pSuite, "session_get_effective_local_window_size",
215 test_nghttp2_session_get_effective_local_window_size) ||
216 !CU_add_test(pSuite, "session_set_option",
217 test_nghttp2_session_set_option) ||
218 !CU_add_test(pSuite, "session_data_backoff_by_high_pri_frame",
219 test_nghttp2_session_data_backoff_by_high_pri_frame) ||
220 !CU_add_test(pSuite, "session_pack_data_with_padding",
221 test_nghttp2_session_pack_data_with_padding) ||
222 !CU_add_test(pSuite, "session_pack_headers_with_padding",
223 test_nghttp2_session_pack_headers_with_padding) ||
224 !CU_add_test(pSuite, "pack_settings_payload",
225 test_nghttp2_pack_settings_payload) ||
226 !CU_add_test(pSuite, "session_stream_dep_add",
227 test_nghttp2_session_stream_dep_add) ||
228 !CU_add_test(pSuite, "session_stream_dep_remove",
229 test_nghttp2_session_stream_dep_remove) ||
230 !CU_add_test(pSuite, "session_stream_dep_add_subtree",
231 test_nghttp2_session_stream_dep_add_subtree) ||
232 !CU_add_test(pSuite, "session_stream_dep_remove_subtree",
233 test_nghttp2_session_stream_dep_remove_subtree) ||
235 pSuite, "session_stream_dep_all_your_stream_are_belong_to_us",
236 test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us) ||
237 !CU_add_test(pSuite, "session_stream_attach_item",
238 test_nghttp2_session_stream_attach_item) ||
239 !CU_add_test(pSuite, "session_stream_attach_item_subtree",
240 test_nghttp2_session_stream_attach_item_subtree) ||
241 !CU_add_test(pSuite, "session_stream_keep_closed_stream",
242 test_nghttp2_session_keep_closed_stream) ||
243 !CU_add_test(pSuite, "session_stream_keep_idle_stream",
244 test_nghttp2_session_keep_idle_stream) ||
245 !CU_add_test(pSuite, "session_detach_idle_stream",
246 test_nghttp2_session_detach_idle_stream) ||
247 !CU_add_test(pSuite, "session_large_dep_tree",
248 test_nghttp2_session_large_dep_tree) ||
249 !CU_add_test(pSuite, "session_graceful_shutdown",
250 test_nghttp2_session_graceful_shutdown) ||
251 !CU_add_test(pSuite, "session_on_header_temporal_failure",
252 test_nghttp2_session_on_header_temporal_failure) ||
253 !CU_add_test(pSuite, "session_recv_client_magic",
254 test_nghttp2_session_recv_client_magic) ||
255 !CU_add_test(pSuite, "session_delete_data_item",
256 test_nghttp2_session_delete_data_item) ||
257 !CU_add_test(pSuite, "session_open_idle_stream",
258 test_nghttp2_session_open_idle_stream) ||
259 !CU_add_test(pSuite, "session_cancel_reserved_remote",
260 test_nghttp2_session_cancel_reserved_remote) ||
261 !CU_add_test(pSuite, "session_reset_pending_headers",
262 test_nghttp2_session_reset_pending_headers) ||
263 !CU_add_test(pSuite, "session_send_data_callback",
264 test_nghttp2_session_send_data_callback) ||
265 !CU_add_test(pSuite, "session_on_begin_headers_temporal_failure",
266 test_nghttp2_session_on_begin_headers_temporal_failure) ||
267 !CU_add_test(pSuite, "http_mandatory_headers",
268 test_nghttp2_http_mandatory_headers) ||
269 !CU_add_test(pSuite, "http_content_length",
270 test_nghttp2_http_content_length) ||
271 !CU_add_test(pSuite, "http_content_length_mismatch",
272 test_nghttp2_http_content_length_mismatch) ||
273 !CU_add_test(pSuite, "http_non_final_response",
274 test_nghttp2_http_non_final_response) ||
275 !CU_add_test(pSuite, "http_trailer_headers",
276 test_nghttp2_http_trailer_headers) ||
277 !CU_add_test(pSuite, "http_ignore_regular_header",
278 test_nghttp2_http_ignore_regular_header) ||
279 !CU_add_test(pSuite, "http_ignore_content_length",
280 test_nghttp2_http_ignore_content_length) ||
281 !CU_add_test(pSuite, "http_record_request_method",
282 test_nghttp2_http_record_request_method) ||
283 !CU_add_test(pSuite, "http_push_promise",
284 test_nghttp2_http_push_promise) ||
285 !CU_add_test(pSuite, "frame_pack_headers",
286 test_nghttp2_frame_pack_headers) ||
287 !CU_add_test(pSuite, "frame_pack_headers_frame_too_large",
288 test_nghttp2_frame_pack_headers_frame_too_large) ||
289 !CU_add_test(pSuite, "frame_pack_headers_frame_smallest",
290 test_nghttp2_submit_data_read_length_smallest) ||
291 !CU_add_test(pSuite, "frame_pack_priority",
292 test_nghttp2_frame_pack_priority) ||
293 !CU_add_test(pSuite, "frame_pack_rst_stream",
294 test_nghttp2_frame_pack_rst_stream) ||
295 !CU_add_test(pSuite, "frame_pack_settings",
296 test_nghttp2_frame_pack_settings) ||
297 !CU_add_test(pSuite, "frame_pack_push_promise",
298 test_nghttp2_frame_pack_push_promise) ||
299 !CU_add_test(pSuite, "frame_pack_ping", test_nghttp2_frame_pack_ping) ||
300 !CU_add_test(pSuite, "frame_pack_goaway",
301 test_nghttp2_frame_pack_goaway) ||
302 !CU_add_test(pSuite, "frame_pack_window_update",
303 test_nghttp2_frame_pack_window_update) ||
304 !CU_add_test(pSuite, "nv_array_copy", test_nghttp2_nv_array_copy) ||
305 !CU_add_test(pSuite, "iv_check", test_nghttp2_iv_check) ||
306 !CU_add_test(pSuite, "hd_deflate", test_nghttp2_hd_deflate) ||
307 !CU_add_test(pSuite, "hd_deflate_same_indexed_repr",
308 test_nghttp2_hd_deflate_same_indexed_repr) ||
309 !CU_add_test(pSuite, "hd_inflate_indexed",
310 test_nghttp2_hd_inflate_indexed) ||
311 !CU_add_test(pSuite, "hd_inflate_indname_noinc",
312 test_nghttp2_hd_inflate_indname_noinc) ||
313 !CU_add_test(pSuite, "hd_inflate_indname_inc",
314 test_nghttp2_hd_inflate_indname_inc) ||
315 !CU_add_test(pSuite, "hd_inflate_indname_inc_eviction",
316 test_nghttp2_hd_inflate_indname_inc_eviction) ||
317 !CU_add_test(pSuite, "hd_inflate_newname_noinc",
318 test_nghttp2_hd_inflate_newname_noinc) ||
319 !CU_add_test(pSuite, "hd_inflate_newname_inc",
320 test_nghttp2_hd_inflate_newname_inc) ||
321 !CU_add_test(pSuite, "hd_inflate_clearall_inc",
322 test_nghttp2_hd_inflate_clearall_inc) ||
323 !CU_add_test(pSuite, "hd_inflate_zero_length_huffman",
324 test_nghttp2_hd_inflate_zero_length_huffman) ||
325 !CU_add_test(pSuite, "hd_ringbuf_reserve",
326 test_nghttp2_hd_ringbuf_reserve) ||
327 !CU_add_test(pSuite, "hd_change_table_size",
328 test_nghttp2_hd_change_table_size) ||
329 !CU_add_test(pSuite, "hd_deflate_inflate",
330 test_nghttp2_hd_deflate_inflate) ||
331 !CU_add_test(pSuite, "hd_no_index", test_nghttp2_hd_no_index) ||
332 !CU_add_test(pSuite, "hd_deflate_bound", test_nghttp2_hd_deflate_bound) ||
333 !CU_add_test(pSuite, "hd_public_api", test_nghttp2_hd_public_api) ||
334 !CU_add_test(pSuite, "hd_decode_length", test_nghttp2_hd_decode_length) ||
335 !CU_add_test(pSuite, "hd_huff_encode", test_nghttp2_hd_huff_encode) ||
336 !CU_add_test(pSuite, "adjust_local_window_size",
337 test_nghttp2_adjust_local_window_size) ||
338 !CU_add_test(pSuite, "check_header_name",
339 test_nghttp2_check_header_name) ||
340 !CU_add_test(pSuite, "check_header_value",
341 test_nghttp2_check_header_value) ||
342 !CU_add_test(pSuite, "bufs_add", test_nghttp2_bufs_add) ||
343 !CU_add_test(pSuite, "bufs_add_stack_buffer_overflow_bug",
344 test_nghttp2_bufs_add_stack_buffer_overflow_bug) ||
345 !CU_add_test(pSuite, "bufs_addb", test_nghttp2_bufs_addb) ||
346 !CU_add_test(pSuite, "bufs_orb", test_nghttp2_bufs_orb) ||
347 !CU_add_test(pSuite, "bufs_remove", test_nghttp2_bufs_remove) ||
348 !CU_add_test(pSuite, "bufs_reset", test_nghttp2_bufs_reset) ||
349 !CU_add_test(pSuite, "bufs_advance", test_nghttp2_bufs_advance) ||
350 !CU_add_test(pSuite, "bufs_next_present",
351 test_nghttp2_bufs_next_present) ||
352 !CU_add_test(pSuite, "bufs_realloc", test_nghttp2_bufs_realloc)) {
353 CU_cleanup_registry();
354 return CU_get_error();
357 /* Run all tests using the CUnit Basic interface */
358 CU_basic_set_mode(CU_BRM_VERBOSE);
359 CU_basic_run_tests();
360 num_tests_failed = CU_get_number_of_tests_failed();
361 CU_cleanup_registry();
362 if (CU_get_error() == CUE_SUCCESS) {
363 return num_tests_failed;
365 printf("CUnit Error: %s\n", CU_get_error_msg());
366 return CU_get_error();