Line data Source code
1 : /**
2 : * @file suite_libhttp.c
3 : * @brief Check testsuite for libhttp functions
4 : * @author François Cerbelle (Fanfan), francois@cerbelle.net
5 : *
6 : * @internal
7 : * Created: 20/03/2022
8 : * Revision: none
9 : * Last modified: 2024-11-30 22:15
10 : * Compiler: gcc
11 : * Organization: Cerbelle.net
12 : * Copyright: Copyright (c) 2024, François Cerbelle
13 : *
14 : * This source code is released for free distribution under the terms of the
15 : * GNU General Public License as published by the Free Software Foundation.
16 : */
17 :
18 : #ifdef HAVE_CONFIG_H
19 : #include "config.h"
20 : #endif
21 :
22 : #include <check.h>
23 : #include <stdlib.h>
24 : #include "checktools.inc"
25 :
26 : #include "libhttp.h"
27 : #include <stdio.h> /* perror */
28 :
29 : /** Dummy test to trigger fixtures
30 : *
31 : * This test is defined and added to all testcases in order to execute at
32 : * least one test test in each testcase of the testsuite, trigger the
33 : * fixtures and have a decent coverage report.
34 : */
35 3 : START_TEST(libhttp_test) {
36 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
37 : * whole testsuite if not caught or not in a child process */
38 3 : forktest_only;
39 :
40 2 : abort();
41 : }
42 : END_TEST
43 :
44 3 : START_TEST(libhttp_new) {
45 : HTTP_t* http;
46 : char* body;
47 : HTTPHeader_t* header;
48 :
49 3 : http = HTTP_new();
50 3 : ck_assert(http);
51 :
52 3 : body = HTTP_getbody(http);
53 3 : ck_assert(body);
54 3 : ck_assert(strcmp(body,"")==0);
55 :
56 3 : header = HTTP_firstheader(http);
57 3 : ck_assert(header==NULL);
58 :
59 3 : HTTP_del(http);
60 3 : }
61 : END_TEST
62 :
63 3 : START_TEST(libhttp_del_null) {
64 : /* SIG6 in debug builds, SIG11 in release builds */
65 3 : forktest_only;
66 :
67 2 : HTTP_del(NULL);
68 : }
69 : END_TEST
70 :
71 3 : START_TEST(libhttp_del_empty) {
72 : HTTP_t* http;
73 :
74 3 : http = HTTP_new();
75 3 : ck_assert(http);
76 3 : HTTP_del(http);
77 3 : }
78 : END_TEST
79 :
80 3 : START_TEST(libhttp_del_populated) {
81 : HTTP_t* http;
82 : HTTPHeader_t* header;
83 :
84 3 : http = HTTP_new();
85 3 : ck_assert(http);
86 :
87 3 : header = HTTP_addheader(http,"name1","value1");
88 3 : ck_assert(header);
89 :
90 3 : header = HTTP_addheader(http,"name2","value2");
91 3 : ck_assert(header);
92 :
93 3 : http = HTTP_setbody(http,"<HTML></HTML>");
94 3 : ck_assert(http);
95 :
96 3 : HTTP_del(http);
97 3 : }
98 : END_TEST
99 :
100 3 : START_TEST(libhttp_setbody_nullhttp) {
101 : /* SIG6 in debug builds, SIG11 in release builds */
102 3 : forktest_only;
103 :
104 2 : HTTP_setbody(NULL,"");
105 : }
106 : END_TEST
107 :
108 3 : START_TEST(libhttp_setbody_nullbody) {
109 : HTTP_t* http;
110 :
111 : /* SIG6 in debug builds, SIG11 in release builds */
112 3 : forktest_only;
113 :
114 2 : http = HTTP_new();
115 2 : ck_assert(http);
116 :
117 2 : HTTP_setbody(http,NULL);
118 : }
119 : END_TEST
120 :
121 3 : START_TEST(libhttp_setbody_empty) {
122 : HTTP_t* http;
123 : char* body;
124 :
125 3 : http = HTTP_new();
126 3 : ck_assert(http);
127 :
128 3 : http = HTTP_setbody(http,"");
129 3 : ck_assert(http);
130 3 : body = HTTP_getbody(http);
131 3 : ck_assert(strcmp(body,"")==0);
132 :
133 3 : HTTP_del(http);
134 3 : }
135 : END_TEST
136 :
137 3 : START_TEST(libhttp_setbody_valid) {
138 : HTTP_t* http;
139 : char* body;
140 :
141 3 : http = HTTP_new();
142 3 : ck_assert(http);
143 :
144 3 : http = HTTP_setbody(http,"<HTML></HTML>");
145 3 : ck_assert(http);
146 3 : body = HTTP_getbody(http);
147 3 : ck_assert(strcmp(body,"<HTML></HTML>")==0);
148 :
149 3 : HTTP_del(http);
150 3 : }
151 : END_TEST
152 :
153 3 : START_TEST(libhttp_getbody_null) {
154 : /* SIG6 in debug builds, SIG11 in release builds */
155 3 : forktest_only;
156 :
157 2 : HTTP_getbody(NULL);
158 : }
159 : END_TEST
160 :
161 3 : START_TEST(libhttp_getbody_populated) {
162 : HTTP_t* http;
163 : char* body;
164 :
165 3 : http = HTTP_new();
166 3 : ck_assert(http);
167 :
168 3 : body = HTTP_getbody(http);
169 3 : ck_assert(body);
170 3 : ck_assert(strcmp(body,"")==0);
171 :
172 3 : http = HTTP_setbody(http,"<HTML></HTML>");
173 3 : ck_assert(http);
174 :
175 3 : body = HTTP_getbody(http);
176 3 : ck_assert(body);
177 3 : ck_assert(strcmp(body,"<HTML></HTML>")==0);
178 :
179 3 : HTTP_del(http);
180 3 : }
181 : END_TEST
182 :
183 3 : START_TEST(libhttp_addheader_nullhttp) {
184 : /* SIG6 in debug builds, SIG11 in release builds */
185 3 : forktest_only;
186 2 : HTTP_addheader(NULL,"name","value");
187 : }
188 : END_TEST
189 :
190 3 : START_TEST(libhttp_addheader_nullname) {
191 : HTTP_t* http;
192 :
193 : /* SIG6 in debug builds, SIG11 in release builds */
194 3 : forktest_only;
195 :
196 2 : http=HTTP_new();
197 2 : HTTP_addheader(http,NULL,"value");
198 : }
199 : END_TEST
200 :
201 3 : START_TEST(libhttp_addheader_nullvalue) {
202 : HTTP_t* http;
203 :
204 : /* SIG6 in debug builds, SIG11 in release builds */
205 3 : forktest_only;
206 :
207 2 : http=HTTP_new();
208 2 : HTTP_addheader(http,"name",NULL);
209 : }
210 : END_TEST
211 :
212 3 : START_TEST(libhttp_addheader_emptyname) {
213 : HTTP_t* http;
214 : HTTPHeader_t *header;
215 :
216 3 : http=HTTP_new();
217 3 : header = HTTP_addheader(http,"","value");
218 3 : ck_assert(NULL==header);
219 3 : HTTP_del(http);
220 3 : }
221 : END_TEST
222 :
223 3 : START_TEST(libhttp_addheader_emptyvalue) {
224 : HTTP_t* http;
225 : HTTPHeader_t *header;
226 :
227 3 : http=HTTP_new();
228 3 : header = HTTP_addheader(http,"name","");
229 3 : ck_assert(NULL!=header);
230 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
231 3 : ck_assert(0==strcmp("",HTTPHeader_getvalue(header)));
232 3 : HTTP_del(http);
233 3 : }
234 : END_TEST
235 :
236 3 : START_TEST(libhttp_addheader_valid) {
237 : HTTP_t* http;
238 : HTTPHeader_t *header;
239 :
240 3 : http=HTTP_new();
241 3 : header = HTTP_addheader(http,"name","value");
242 3 : ck_assert(NULL!=header);
243 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
244 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
245 3 : HTTP_del(http);
246 3 : }
247 : END_TEST
248 :
249 3 : START_TEST(libhttp_addbasicauth_nullhttp) {
250 : /* SIG6 in debug builds, SIG11 in release builds */
251 3 : forktest_only;
252 2 : HTTP_addbasicauth(NULL,"login","pass");
253 : }
254 : END_TEST
255 :
256 3 : START_TEST(libhttp_addbasicauth_nulllogin) {
257 : HTTP_t* http;
258 :
259 : /* SIG6 in debug builds, SIG11 in release builds */
260 3 : forktest_only;
261 :
262 2 : http=HTTP_new();
263 2 : HTTP_addbasicauth(http,NULL,"pass");
264 : }
265 : END_TEST
266 :
267 3 : START_TEST(libhttp_addbasicauth_nullpass) {
268 : HTTP_t* http;
269 :
270 : /* SIG6 in debug builds, SIG11 in release builds */
271 3 : forktest_only;
272 :
273 2 : http=HTTP_new();
274 2 : HTTP_addbasicauth(http,"login",NULL);
275 : }
276 : END_TEST
277 :
278 3 : START_TEST(libhttp_addbasicauth_emptylogin) {
279 : HTTP_t* http;
280 : HTTPHeader_t *header;
281 :
282 3 : http=HTTP_new();
283 3 : header = HTTP_addbasicauth(http,"","pass");
284 3 : ck_assert(NULL!=header);
285 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
286 3 : ck_assert(0==strcmp("Basic OnBhc3M=",HTTPHeader_getvalue(header)));
287 3 : HTTP_del(http);
288 3 : }
289 : END_TEST
290 :
291 3 : START_TEST(libhttp_addbasicauth_emptypass) {
292 : HTTP_t* http;
293 : HTTPHeader_t *header;
294 :
295 3 : http=HTTP_new();
296 3 : header = HTTP_addbasicauth(http,"login","");
297 3 : ck_assert(NULL!=header);
298 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
299 3 : ck_assert(0==strcmp("Basic bG9naW46",HTTPHeader_getvalue(header)));
300 3 : HTTP_del(http);
301 3 : }
302 : END_TEST
303 :
304 3 : START_TEST(libhttp_addbasicauth_valid) {
305 : HTTP_t* http;
306 : HTTPHeader_t *header;
307 :
308 3 : http=HTTP_new();
309 3 : header = HTTP_addbasicauth(http,"login","pass");
310 3 : ck_assert(NULL!=header);
311 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
312 3 : ck_assert(0==strcmp("Basic bG9naW46cGFzcw==",HTTPHeader_getvalue(header)));
313 3 : HTTP_del(http);
314 3 : }
315 : END_TEST
316 :
317 3 : START_TEST(libhttp_setname_nullheader) {
318 : /* SIG6 in debug builds, SIG11 in release builds */
319 3 : forktest_only;
320 2 : HTTPHeader_setname(NULL,"name");
321 : }
322 : END_TEST
323 :
324 3 : START_TEST(libhttp_setname_nullname) {
325 : HTTP_t* http;
326 : HTTPHeader_t *header;
327 :
328 : /* SIG6 in debug builds, SIG11 in release builds */
329 3 : forktest_only;
330 :
331 2 : http=HTTP_new();
332 2 : header = HTTP_addheader(http,"name","value");
333 2 : ck_assert(NULL!=header);
334 2 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
335 2 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
336 :
337 2 : header = HTTPHeader_setname(header,NULL);
338 : }
339 : END_TEST
340 :
341 3 : START_TEST(libhttp_setname_emptyname) {
342 : HTTP_t* http;
343 : HTTPHeader_t *header;
344 :
345 3 : http=HTTP_new();
346 3 : header = HTTP_addheader(http,"name","value");
347 3 : ck_assert(NULL!=header);
348 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
349 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
350 :
351 3 : header = HTTPHeader_setname(header,"");
352 3 : ck_assert(NULL==header);
353 3 : header = HTTP_firstheader(http);
354 3 : ck_assert(NULL!=header);
355 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
356 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
357 3 : HTTP_del(http);
358 3 : }
359 : END_TEST
360 :
361 3 : START_TEST(libhttp_setname_valid) {
362 : HTTP_t* http;
363 : HTTPHeader_t *header;
364 :
365 3 : http=HTTP_new();
366 3 : header = HTTP_addheader(http,"name","value");
367 3 : ck_assert(NULL!=header);
368 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
369 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
370 :
371 3 : header = HTTPHeader_setname(header,"newname");
372 3 : ck_assert(NULL!=header);
373 3 : ck_assert(0==strcmp("newname",HTTPHeader_getname(header)));
374 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
375 3 : HTTP_del(http);
376 3 : }
377 : END_TEST
378 :
379 3 : START_TEST(libhttp_getname_nullheader) {
380 : /* SIG6 in debug builds, SIG11 in release builds */
381 3 : forktest_only;
382 2 : HTTPHeader_getname(NULL);
383 : }
384 : END_TEST
385 :
386 3 : START_TEST(libhttp_getname_valid) {
387 : HTTP_t* http;
388 : HTTPHeader_t *header;
389 :
390 3 : http=HTTP_new();
391 3 : header = HTTP_addheader(http,"name","value");
392 3 : ck_assert(NULL!=header);
393 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
394 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
395 3 : HTTP_del(http);
396 3 : }
397 : END_TEST
398 :
399 3 : START_TEST(libhttp_setvalue_nullheader) {
400 : /* SIG6 in debug builds, SIG11 in release builds */
401 3 : forktest_only;
402 2 : HTTPHeader_setvalue(NULL,"value");
403 : }
404 : END_TEST
405 :
406 3 : START_TEST(libhttp_setvalue_nullvalue) {
407 : HTTP_t* http;
408 : HTTPHeader_t *header;
409 :
410 : /* SIG6 in debug builds, SIG11 in release builds */
411 3 : forktest_only;
412 :
413 2 : http=HTTP_new();
414 2 : header = HTTP_addheader(http,"name","value");
415 2 : ck_assert(NULL!=header);
416 2 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
417 2 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
418 :
419 2 : header = HTTPHeader_setvalue(header,NULL);
420 : }
421 : END_TEST
422 :
423 3 : START_TEST(libhttp_setvalue_emptyvalue) {
424 : HTTP_t* http;
425 : HTTPHeader_t *header;
426 :
427 3 : http=HTTP_new();
428 3 : header = HTTP_addheader(http,"name","value");
429 3 : ck_assert(NULL!=header);
430 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
431 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
432 :
433 3 : header = HTTPHeader_setvalue(header,"");
434 3 : ck_assert(NULL!=header);
435 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
436 3 : ck_assert(0==strcmp("",HTTPHeader_getvalue(header)));
437 3 : HTTP_del(http);
438 3 : }
439 : END_TEST
440 :
441 3 : START_TEST(libhttp_setvalue_valid) {
442 : HTTP_t* http;
443 : HTTPHeader_t *header;
444 :
445 3 : http=HTTP_new();
446 3 : header = HTTP_addheader(http,"name","value");
447 3 : ck_assert(NULL!=header);
448 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
449 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
450 :
451 3 : header = HTTPHeader_setvalue(header,"newvalue");
452 3 : ck_assert(NULL!=header);
453 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
454 3 : ck_assert(0==strcmp("newvalue",HTTPHeader_getvalue(header)));
455 3 : HTTP_del(http);
456 3 : }
457 : END_TEST
458 :
459 3 : START_TEST(libhttp_getvalue_nullheader) {
460 : /* SIG6 in debug builds, SIG11 in release builds */
461 3 : forktest_only;
462 2 : HTTPHeader_getvalue(NULL);
463 : }
464 : END_TEST
465 :
466 3 : START_TEST(libhttp_getvalue_valid) {
467 : HTTP_t* http;
468 : HTTPHeader_t *header;
469 :
470 3 : http=HTTP_new();
471 3 : header = HTTP_addheader(http,"name","value");
472 3 : ck_assert(NULL!=header);
473 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
474 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
475 3 : HTTP_del(http);
476 3 : }
477 : END_TEST
478 :
479 3 : START_TEST(libhttp_firstheader_nullhttp) {
480 : /* SIG6 in debug builds, SIG11 in release builds */
481 3 : forktest_only;
482 2 : HTTP_firstheader(NULL);
483 : }
484 : END_TEST
485 :
486 3 : START_TEST(libhttp_firstheader_empty) {
487 : HTTP_t* http;
488 : HTTPHeader_t *header;
489 :
490 3 : http=HTTP_new();
491 3 : header = HTTP_firstheader(http);
492 3 : ck_assert(NULL==header);
493 3 : HTTP_del(http);
494 3 : }
495 : END_TEST
496 :
497 3 : START_TEST(libhttp_firstheader_single) {
498 : HTTP_t* http;
499 : HTTPHeader_t *header;
500 :
501 3 : http=HTTP_new();
502 3 : header = HTTP_addheader(http,"name","value");
503 3 : ck_assert(NULL!=header);
504 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
505 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
506 :
507 3 : header = HTTP_firstheader(http);
508 3 : ck_assert(NULL!=header);
509 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
510 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
511 3 : HTTP_del(http);
512 3 : }
513 : END_TEST
514 :
515 3 : START_TEST(libhttp_firstheader_multi) {
516 : HTTP_t* http;
517 : HTTPHeader_t *header;
518 :
519 3 : http=HTTP_new();
520 3 : header = HTTP_addheader(http,"name1","value1");
521 3 : ck_assert(NULL!=header);
522 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
523 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
524 3 : header = HTTP_addheader(http,"name2","value2");
525 3 : ck_assert(NULL!=header);
526 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
527 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
528 :
529 3 : header = HTTP_firstheader(http);
530 3 : ck_assert(NULL!=header);
531 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
532 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
533 3 : HTTP_del(http);
534 3 : }
535 : END_TEST
536 :
537 3 : START_TEST(libhttp_nextheader_nullheader) {
538 : /* SIG6 in debug builds, SIG11 in release builds */
539 3 : forktest_only;
540 2 : HTTP_nextheader(NULL);
541 : }
542 : END_TEST
543 :
544 3 : START_TEST(libhttp_nextheader_empty) {
545 : HTTP_t* http;
546 : HTTPHeader_t *header;
547 :
548 : /* SIG6 in debug builds, SIG11 in release builds */
549 3 : forktest_only;
550 :
551 2 : http=HTTP_new();
552 2 : header = HTTP_firstheader(http);
553 2 : header = HTTP_nextheader(header);
554 : }
555 : END_TEST
556 :
557 3 : START_TEST(libhttp_nextheader_single) {
558 : HTTP_t* http;
559 : HTTPHeader_t *header;
560 :
561 3 : http=HTTP_new();
562 3 : header = HTTP_addheader(http,"name","value");
563 3 : ck_assert(NULL!=header);
564 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
565 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
566 :
567 3 : header = HTTP_firstheader(http);
568 3 : header = HTTP_nextheader(header);
569 3 : ck_assert(NULL==header);
570 :
571 3 : HTTP_del(http);
572 3 : }
573 : END_TEST
574 :
575 3 : START_TEST(libhttp_nextheader_multi) {
576 : HTTP_t* http;
577 : HTTPHeader_t *header;
578 :
579 3 : http=HTTP_new();
580 3 : header = HTTP_addheader(http,"name1","value1");
581 3 : ck_assert(NULL!=header);
582 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
583 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
584 3 : header = HTTP_addheader(http,"name2","value2");
585 3 : ck_assert(NULL!=header);
586 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
587 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
588 3 : header = HTTP_addheader(http,"name3","value3");
589 3 : ck_assert(NULL!=header);
590 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
591 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
592 :
593 3 : header = HTTP_firstheader(http);
594 3 : ck_assert(NULL!=header);
595 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
596 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
597 3 : header = HTTP_nextheader(header);
598 3 : ck_assert(NULL!=header);
599 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
600 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
601 3 : header = HTTP_nextheader(header);
602 3 : ck_assert(NULL!=header);
603 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
604 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
605 3 : header = HTTP_nextheader(header);
606 3 : ck_assert(NULL==header);
607 :
608 3 : HTTP_del(http);
609 3 : }
610 : END_TEST
611 :
612 3 : START_TEST(libhttp_findheader_nullheader) {
613 : /* SIG6 in debug builds, SIG11 in release builds */
614 3 : forktest_only;
615 2 : HTTP_findheader(NULL,"");
616 : }
617 : END_TEST
618 :
619 3 : START_TEST(libhttp_findheader_nullname) {
620 : HTTP_t* http;
621 : HTTPHeader_t *header;
622 :
623 : /* SIG6 in debug builds, SIG11 in release builds */
624 3 : forktest_only;
625 :
626 2 : http=HTTP_new();
627 2 : header = HTTP_addheader(http,"name1","value1");
628 2 : header = HTTP_addheader(http,"name2","value2");
629 2 : header = HTTP_addheader(http,"name3","value3");
630 2 : header = HTTP_firstheader(http);
631 2 : HTTP_findheader(header,NULL);
632 : }
633 : END_TEST
634 :
635 3 : START_TEST(libhttp_findheader_emptyname) {
636 : HTTP_t* http;
637 : HTTPHeader_t *header;
638 :
639 3 : http=HTTP_new();
640 3 : header = HTTP_addheader(http,"name1","value1");
641 3 : header = HTTP_addheader(http,"name2","value2");
642 3 : header = HTTP_addheader(http,"name3","value3");
643 3 : header = HTTP_firstheader(http);
644 3 : header = HTTP_findheader(header,"");
645 : /* Search accepted despite empty header name forbidden, will return NULL
646 : * because there will always be a miss */
647 3 : ck_assert(NULL==header);
648 :
649 3 : HTTP_del(http);
650 3 : }
651 : END_TEST
652 :
653 3 : START_TEST(libhttp_findheader_missingname) {
654 : HTTP_t* http;
655 : HTTPHeader_t *header;
656 :
657 3 : http=HTTP_new();
658 3 : header = HTTP_addheader(http,"name1","value1");
659 3 : header = HTTP_addheader(http,"name2","value2");
660 3 : header = HTTP_addheader(http,"name3","value3");
661 3 : header = HTTP_firstheader(http);
662 3 : header = HTTP_findheader(header,"name4");
663 3 : ck_assert(NULL==header);
664 :
665 3 : HTTP_del(http);
666 3 : }
667 : END_TEST
668 :
669 3 : START_TEST(libhttp_findheader_firstname) {
670 : HTTP_t* http;
671 : HTTPHeader_t *header;
672 :
673 3 : http=HTTP_new();
674 3 : header = HTTP_addheader(http,"name1","value1");
675 3 : header = HTTP_addheader(http,"name2","value2");
676 3 : header = HTTP_addheader(http,"name3","value3");
677 3 : header = HTTP_firstheader(http);
678 3 : header = HTTP_findheader(header,"name1");
679 3 : ck_assert(NULL!=header);
680 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
681 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
682 :
683 3 : HTTP_del(http);
684 3 : }
685 : END_TEST
686 :
687 3 : START_TEST(libhttp_findheader_middlename) {
688 : HTTP_t* http;
689 : HTTPHeader_t *header;
690 :
691 3 : http=HTTP_new();
692 3 : header = HTTP_addheader(http,"name1","value1");
693 3 : header = HTTP_addheader(http,"name2","value2");
694 3 : header = HTTP_addheader(http,"name3","value3");
695 3 : header = HTTP_firstheader(http);
696 3 : header = HTTP_findheader(header,"name2");
697 3 : ck_assert(NULL!=header);
698 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
699 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
700 :
701 3 : HTTP_del(http);
702 3 : }
703 : END_TEST
704 :
705 3 : START_TEST(libhttp_findheader_lastname) {
706 : HTTP_t* http;
707 : HTTPHeader_t *header;
708 :
709 3 : http=HTTP_new();
710 3 : header = HTTP_addheader(http,"name1","value1");
711 3 : header = HTTP_addheader(http,"name2","value2");
712 3 : header = HTTP_addheader(http,"name3","value3");
713 3 : header = HTTP_firstheader(http);
714 3 : header = HTTP_findheader(header,"name3");
715 3 : ck_assert(NULL!=header);
716 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
717 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
718 :
719 3 : HTTP_del(http);
720 3 : }
721 : END_TEST
722 :
723 3 : START_TEST(libhttp_findheader_secondmiddle) {
724 : HTTP_t* http;
725 : HTTPHeader_t *header;
726 :
727 3 : http=HTTP_new();
728 3 : header = HTTP_addheader(http,"name1","value1");
729 3 : header = HTTP_addheader(http,"name2","value2");
730 3 : header = HTTP_addheader(http,"name1","value4");
731 3 : header = HTTP_addheader(http,"name3","value3");
732 3 : header = HTTP_firstheader(http);
733 3 : header = HTTP_findheader(header,"name1");
734 3 : ck_assert(NULL!=header);
735 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
736 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
737 3 : header = HTTP_nextheader(header);
738 3 : header = HTTP_findheader(header,"name1");
739 3 : ck_assert(NULL!=header);
740 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
741 3 : ck_assert(0==strcmp("value4",HTTPHeader_getvalue(header)));
742 :
743 3 : HTTP_del(http);
744 3 : }
745 : END_TEST
746 :
747 3 : START_TEST(libhttp_findheader_secondlast) {
748 : HTTP_t* http;
749 : HTTPHeader_t *header;
750 :
751 3 : http=HTTP_new();
752 3 : header = HTTP_addheader(http,"name1","value1");
753 3 : header = HTTP_addheader(http,"name2","value2");
754 3 : header = HTTP_addheader(http,"name1","value3");
755 3 : header = HTTP_firstheader(http);
756 3 : header = HTTP_findheader(header,"name1");
757 3 : ck_assert(NULL!=header);
758 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
759 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
760 3 : header = HTTP_nextheader(header);
761 3 : header = HTTP_findheader(header,"name1");
762 3 : ck_assert(NULL!=header);
763 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
764 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
765 :
766 3 : HTTP_del(http);
767 3 : }
768 : END_TEST
769 :
770 3 : START_TEST(libhttp_remheader_nullhttp) {
771 : HTTP_t* http;
772 : HTTPHeader_t *header;
773 :
774 : /* SIG6 in debug builds, SIG11 in release builds */
775 3 : forktest_only;
776 :
777 2 : http=HTTP_new();
778 2 : header = HTTP_addheader(http,"name1","value1");
779 2 : HTTP_remheader(NULL,header);
780 : }
781 : END_TEST
782 :
783 3 : START_TEST(libhttp_remheader_nullheader) {
784 : HTTP_t* http;
785 :
786 : /* SIG6 in debug builds, SIG11 in release builds */
787 3 : forktest_only;
788 :
789 2 : http=HTTP_new();
790 2 : HTTP_remheader(http,NULL);
791 : }
792 : END_TEST
793 :
794 3 : START_TEST(libhttp_remheader_missingheader) {
795 : HTTP_t* http;
796 : HTTP_t* http2;
797 : HTTPHeader_t *header;
798 :
799 3 : http=HTTP_new();
800 3 : header = HTTP_addheader(http,"name1","value1");
801 3 : header = HTTP_addheader(http,"name2","value2");
802 3 : header = HTTP_addheader(http,"name3","value3");
803 :
804 3 : http2=HTTP_new();
805 3 : header = HTTP_addheader(http2,"name4","value4");
806 3 : header = HTTP_firstheader(http2);
807 :
808 3 : header = HTTP_firstheader(http2);
809 :
810 : /* Try to remove http2 header from http (not here) */
811 3 : ck_assert(NULL==HTTP_remheader(http,header));
812 :
813 3 : header = HTTP_firstheader(http);
814 3 : ck_assert(NULL!=header);
815 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
816 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
817 3 : header = HTTP_nextheader(header);
818 3 : ck_assert(NULL!=header);
819 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
820 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
821 3 : header = HTTP_nextheader(header);
822 3 : ck_assert(NULL!=header);
823 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
824 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
825 3 : header = HTTP_nextheader(header);
826 3 : ck_assert(NULL==header);
827 3 : header = HTTP_firstheader(http2);
828 3 : ck_assert(NULL!=header);
829 3 : ck_assert(0==strcmp("name4",HTTPHeader_getname(header)));
830 3 : ck_assert(0==strcmp("value4",HTTPHeader_getvalue(header)));
831 3 : header = HTTP_nextheader(header);
832 3 : ck_assert(NULL==header);
833 :
834 3 : HTTP_del(http);
835 3 : HTTP_del(http2);
836 3 : }
837 : END_TEST
838 :
839 3 : START_TEST(libhttp_remheader_firstheader) {
840 : HTTP_t* http;
841 : HTTPHeader_t *header;
842 :
843 3 : http=HTTP_new();
844 3 : header = HTTP_addheader(http,"name1","value1");
845 3 : header = HTTP_addheader(http,"name2","value2");
846 3 : header = HTTP_addheader(http,"name3","value3");
847 :
848 3 : header = HTTP_firstheader(http);
849 3 : ck_assert(http==HTTP_remheader(http,header));
850 :
851 3 : header = HTTP_firstheader(http);
852 3 : ck_assert(NULL!=header);
853 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
854 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
855 3 : header = HTTP_nextheader(header);
856 3 : ck_assert(NULL!=header);
857 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
858 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
859 3 : header = HTTP_nextheader(header);
860 3 : ck_assert(NULL==header);
861 :
862 3 : HTTP_del(http);
863 3 : }
864 : END_TEST
865 :
866 3 : START_TEST(libhttp_remheader_middleheader) {
867 : HTTP_t* http;
868 : HTTPHeader_t *header;
869 :
870 3 : http=HTTP_new();
871 3 : header = HTTP_addheader(http,"name1","value1");
872 3 : header = HTTP_addheader(http,"name2","value2");
873 3 : header = HTTP_addheader(http,"name3","value3");
874 :
875 3 : header = HTTP_findheader(HTTP_firstheader(http),"name2");
876 3 : ck_assert(http==HTTP_remheader(http,header));
877 :
878 3 : header = HTTP_firstheader(http);
879 3 : ck_assert(NULL!=header);
880 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
881 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
882 3 : header = HTTP_nextheader(header);
883 3 : ck_assert(NULL!=header);
884 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
885 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
886 3 : header = HTTP_nextheader(header);
887 3 : ck_assert(NULL==header);
888 :
889 3 : HTTP_del(http);
890 3 : }
891 : END_TEST
892 :
893 3 : START_TEST(libhttp_remheader_lastheader) {
894 : HTTP_t* http;
895 : HTTPHeader_t *header;
896 :
897 3 : http=HTTP_new();
898 3 : header = HTTP_addheader(http,"name1","value1");
899 3 : header = HTTP_addheader(http,"name2","value2");
900 3 : header = HTTP_addheader(http,"name3","value3");
901 :
902 3 : header = HTTP_findheader(HTTP_firstheader(http),"name3");
903 3 : ck_assert(http==HTTP_remheader(http,header));
904 :
905 3 : header = HTTP_firstheader(http);
906 3 : ck_assert(NULL!=header);
907 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
908 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
909 3 : header = HTTP_nextheader(header);
910 3 : ck_assert(NULL!=header);
911 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
912 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
913 3 : header = HTTP_nextheader(header);
914 3 : ck_assert(NULL==header);
915 :
916 3 : HTTP_del(http);
917 3 : }
918 : END_TEST
919 :
920 3 : START_TEST(libhttp_remheader_onlyheader) {
921 : HTTP_t* http;
922 : HTTPHeader_t *header;
923 :
924 3 : http=HTTP_new();
925 3 : header = HTTP_addheader(http,"name1","value1");
926 :
927 3 : header = HTTP_firstheader(http);
928 3 : ck_assert(http==HTTP_remheader(http,header));
929 :
930 3 : header = HTTP_firstheader(http);
931 3 : ck_assert(NULL==header);
932 :
933 3 : HTTP_del(http);
934 3 : }
935 : END_TEST
936 :
937 3 : START_TEST(libhttp_buildheaders_null) {
938 : /* SIG6 in debug builds, SIG11 in release builds */
939 3 : forktest_only;
940 :
941 2 : HTTP_buildheaders(NULL);
942 : }
943 : END_TEST
944 :
945 3 : START_TEST(libhttp_buildheaders_empty) {
946 : HTTP_t* http;
947 : char* headers;
948 :
949 3 : http=HTTP_new();
950 3 : headers = HTTP_buildheaders(http);
951 3 : ck_assert(0==strcmp(headers,""));
952 3 : free(headers);
953 3 : HTTP_del(http);
954 3 : }
955 : END_TEST
956 :
957 3 : START_TEST(libhttp_buildheaders_single) {
958 : HTTP_t* http;
959 : HTTPHeader_t* header;
960 : char* headers;
961 :
962 3 : http=HTTP_new();
963 3 : header = HTTP_addheader(http,"name1","value1");
964 3 : ck_assert(header);
965 3 : headers = HTTP_buildheaders(http);
966 3 : ck_assert(0==strcmp(headers,"name1: value1\r\n"));
967 3 : free(headers);
968 3 : HTTP_del(http);
969 3 : }
970 : END_TEST
971 :
972 3 : START_TEST(libhttp_buildheaders_multi) {
973 : HTTP_t* http;
974 : HTTPHeader_t* header;
975 : char* headers;
976 :
977 3 : http=HTTP_new();
978 3 : header = HTTP_addheader(http,"name1","value1");
979 3 : ck_assert(header);
980 3 : header = HTTP_addheader(http,"name2","value2");
981 3 : headers = HTTP_buildheaders(http);
982 3 : ck_assert(0==strcmp(headers,"name1: value1\r\nname2: value2\r\n"));
983 3 : free(headers);
984 3 : HTTP_del(http);
985 3 : }
986 : END_TEST
987 :
988 3 : START_TEST(libhttp_buildrequest_nullhttp) {
989 : /* SIG6 in debug builds, SIG11 in release builds */
990 3 : forktest_only;
991 :
992 2 : HTTP_buildrequest(NULL, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
993 :
994 : }
995 : END_TEST
996 :
997 3 : START_TEST(libhttp_buildrequest_nulluri) {
998 : HTTP_t* http;
999 :
1000 : /* SIG6 in debug builds, SIG11 in release builds */
1001 3 : forktest_only;
1002 :
1003 2 : http=HTTP_new();
1004 2 : HTTP_buildrequest(http, HTTPMETHOD_GET, NULL, HTTPVERSION_HTTP11);
1005 : }
1006 : END_TEST
1007 :
1008 3 : START_TEST(libhttp_buildrequest_badmethod) {
1009 : HTTP_t* http;
1010 : char* request;
1011 :
1012 3 : http=HTTP_new();
1013 3 : request=HTTP_buildrequest(http, HTTPMETHOD_INVALID+1, "/v1", HTTPVERSION_HTTP11);
1014 3 : ck_assert(NULL==request);
1015 3 : HTTP_del(http);
1016 3 : }
1017 : END_TEST
1018 :
1019 3 : START_TEST(libhttp_buildrequest_badversion) {
1020 : HTTP_t* http;
1021 : char* request;
1022 :
1023 3 : http=HTTP_new();
1024 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_INVALID+1);
1025 3 : ck_assert(NULL==request);
1026 3 : HTTP_del(http);
1027 3 : }
1028 : END_TEST
1029 :
1030 3 : START_TEST(libhttp_buildrequest_emptyuri) {
1031 : HTTP_t* http;
1032 : char* request;
1033 :
1034 3 : http=HTTP_new();
1035 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "", HTTPVERSION_HTTP11);
1036 3 : ck_assert(request);
1037 3 : ck_assert(0==strcmp(request,"GET HTTP/1.1\r\n\r\n"));
1038 3 : free(request);
1039 3 : HTTP_del(http);
1040 3 : }
1041 : END_TEST
1042 :
1043 3 : START_TEST(libhttp_buildrequest_noheader) {
1044 : HTTP_t* http;
1045 : char* request;
1046 :
1047 3 : http=HTTP_new();
1048 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1049 3 : ck_assert(request);
1050 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\n\r\n"));
1051 3 : free(request);
1052 3 : HTTP_del(http);
1053 3 : }
1054 : END_TEST
1055 :
1056 3 : START_TEST(libhttp_buildrequest_singleheader) {
1057 : HTTP_t* http;
1058 : char* request;
1059 :
1060 3 : http=HTTP_new();
1061 3 : HTTP_addheader(http,"name1","value1");
1062 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1063 3 : ck_assert(request);
1064 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\nname1: value1\r\n\r\n"));
1065 3 : free(request);
1066 3 : HTTP_del(http);
1067 3 : }
1068 : END_TEST
1069 :
1070 3 : START_TEST(libhttp_buildrequest_multiheader) {
1071 : HTTP_t* http;
1072 : char* request;
1073 :
1074 3 : http=HTTP_new();
1075 3 : HTTP_addheader(http,"name1","value1");
1076 3 : HTTP_addheader(http,"name2","value2");
1077 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1078 3 : ck_assert(request);
1079 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\nname1: value1\r\nname2: value2\r\n\r\n"));
1080 3 : free(request);
1081 3 : HTTP_del(http);
1082 3 : }
1083 : END_TEST
1084 :
1085 3 : START_TEST(libhttp_buildreply_basic) {
1086 : HTTP_t* http;
1087 : char* reply;
1088 :
1089 3 : http=HTTP_new();
1090 3 : HTTP_addheader(http,"name1","value1");
1091 3 : HTTP_addheader(http,"name2","value2");
1092 3 : HTTP_setbody(http,"<html></html>");
1093 3 : reply=HTTP_buildreply(http, HTTPVERSION_HTTP11, SUCCESS_OK);
1094 3 : ck_assert(reply);
1095 3 : printf("%s\n",reply);
1096 3 : free(reply);
1097 3 : HTTP_del(http);
1098 3 : }
1099 : END_TEST
1100 :
1101 : /************************************************************************/
1102 : /* Begining of test (potentially in child) */
1103 216 : void libhttp_checked_common_setup() {
1104 216 : signals_catch();
1105 216 : forktest_gprofdir();
1106 216 : }
1107 :
1108 : /* End of test (potentially in child) */
1109 162 : void libhttp_checked_common_teardown() {
1110 162 : signals_release();
1111 162 : }
1112 : /************************************************************************/
1113 147 : void libhttp_unchecked_common_setup() {
1114 147 : forktest_init();
1115 147 : }
1116 3 : void libhttp_unchecked_common_teardown() {
1117 3 : }
1118 : /************************************************************************/
1119 148 : Suite* libhttp_suite() {
1120 : Suite *s;
1121 : TCase *tc;
1122 :
1123 148 : s = suite_create("LibHTTP");
1124 :
1125 148 : tc = tcase_create("LibHTTPUninitialized");
1126 148 : tcase_set_tags(tc,"LibHTTPTag LibHTTPTag2");
1127 : /* tcase_set_timeout(tc,5); */ /* seconds */
1128 148 : tcase_add_checked_fixture(tc, libhttp_checked_common_setup, libhttp_checked_common_teardown);
1129 148 : tcase_add_unchecked_fixture(tc, libhttp_unchecked_common_setup, libhttp_unchecked_common_teardown);
1130 148 : suite_add_tcase(s, tc);
1131 148 : tcase_add_test_raise_signal(tc, libhttp_test,6);
1132 148 : tcase_add_test(tc, libhttp_new);
1133 148 : tcase_add_test_raise_signal(tc, libhttp_del_null,SIG_ABRTSEGV);
1134 148 : tcase_add_test(tc, libhttp_del_empty);
1135 148 : tcase_add_test(tc, libhttp_del_populated);
1136 148 : tcase_add_test_raise_signal(tc, libhttp_setbody_nullhttp,SIG_ABRTSEGV);
1137 148 : tcase_add_test_raise_signal(tc, libhttp_setbody_nullbody,SIG_ABRTSEGV);
1138 148 : tcase_add_test(tc, libhttp_setbody_empty);
1139 148 : tcase_add_test(tc, libhttp_setbody_valid);
1140 148 : tcase_add_test_raise_signal(tc, libhttp_getbody_null,SIG_ABRTSEGV);
1141 148 : tcase_add_test(tc, libhttp_getbody_populated);
1142 148 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullhttp,SIG_ABRTSEGV);
1143 148 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullname,SIG_ABRTSEGV);
1144 148 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullvalue,SIG_ABRTSEGV);
1145 148 : tcase_add_test(tc, libhttp_addheader_emptyname);
1146 148 : tcase_add_test(tc, libhttp_addheader_emptyvalue);
1147 148 : tcase_add_test(tc, libhttp_addheader_valid);
1148 148 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullhttp,SIG_ABRTSEGV);
1149 148 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nulllogin,SIG_ABRTSEGV);
1150 148 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullpass,SIG_ABRTSEGV);
1151 148 : tcase_add_test(tc, libhttp_addbasicauth_emptylogin);
1152 148 : tcase_add_test(tc, libhttp_addbasicauth_emptypass);
1153 148 : tcase_add_test(tc, libhttp_addbasicauth_valid);
1154 148 : tcase_add_test_raise_signal(tc, libhttp_setname_nullheader,SIG_ABRTSEGV);
1155 148 : tcase_add_test_raise_signal(tc, libhttp_setname_nullname,SIG_ABRTSEGV);
1156 148 : tcase_add_test(tc, libhttp_setname_emptyname);
1157 148 : tcase_add_test(tc, libhttp_setname_valid);
1158 148 : tcase_add_test_raise_signal(tc, libhttp_getname_nullheader,SIG_ABRTSEGV);
1159 148 : tcase_add_test(tc, libhttp_getname_valid);
1160 148 : tcase_add_test_raise_signal(tc, libhttp_setvalue_nullheader,SIG_ABRTSEGV);
1161 148 : tcase_add_test_raise_signal(tc, libhttp_setvalue_nullvalue,SIG_ABRTSEGV);
1162 148 : tcase_add_test(tc, libhttp_setvalue_emptyvalue);
1163 148 : tcase_add_test(tc, libhttp_setvalue_valid);
1164 148 : tcase_add_test_raise_signal(tc, libhttp_getvalue_nullheader,SIG_ABRTSEGV);
1165 148 : tcase_add_test(tc, libhttp_getvalue_valid);
1166 148 : tcase_add_test_raise_signal(tc, libhttp_firstheader_nullhttp,SIG_ABRTSEGV);
1167 148 : tcase_add_test(tc, libhttp_firstheader_empty);
1168 148 : tcase_add_test(tc, libhttp_firstheader_single);
1169 148 : tcase_add_test(tc, libhttp_firstheader_multi);
1170 148 : tcase_add_test_raise_signal(tc, libhttp_nextheader_nullheader,SIG_ABRTSEGV);
1171 148 : tcase_add_test_raise_signal(tc, libhttp_nextheader_empty,SIG_ABRTSEGV);
1172 148 : tcase_add_test(tc, libhttp_nextheader_single);
1173 148 : tcase_add_test(tc, libhttp_nextheader_multi);
1174 148 : tcase_add_test_raise_signal(tc, libhttp_findheader_nullheader,SIG_ABRTSEGV);
1175 148 : tcase_add_test_raise_signal(tc, libhttp_findheader_nullname,SIG_ABRTSEGV);
1176 148 : tcase_add_test(tc, libhttp_findheader_emptyname);
1177 148 : tcase_add_test(tc, libhttp_findheader_missingname);
1178 148 : tcase_add_test(tc, libhttp_findheader_firstname);
1179 148 : tcase_add_test(tc, libhttp_findheader_middlename);
1180 148 : tcase_add_test(tc, libhttp_findheader_lastname);
1181 148 : tcase_add_test(tc, libhttp_findheader_secondmiddle);
1182 148 : tcase_add_test(tc, libhttp_findheader_secondlast);
1183 148 : tcase_add_test_raise_signal(tc, libhttp_remheader_nullhttp,SIG_ABRTSEGV);
1184 148 : tcase_add_test_raise_signal(tc, libhttp_remheader_nullheader,SIG_ABRTSEGV);
1185 148 : tcase_add_test(tc, libhttp_remheader_missingheader);
1186 148 : tcase_add_test(tc, libhttp_remheader_firstheader);
1187 148 : tcase_add_test(tc, libhttp_remheader_middleheader);
1188 148 : tcase_add_test(tc, libhttp_remheader_lastheader);
1189 148 : tcase_add_test(tc, libhttp_remheader_onlyheader);
1190 148 : tcase_add_test_raise_signal(tc, libhttp_buildheaders_null,SIG_ABRTSEGV);
1191 148 : tcase_add_test(tc, libhttp_buildheaders_empty);
1192 148 : tcase_add_test(tc, libhttp_buildheaders_single);
1193 148 : tcase_add_test(tc, libhttp_buildheaders_multi);
1194 : #if 0
1195 : tcase_add_test_raise_signal(tc, libhttp_parseheaders_null,SIG_ABRTSEGV);
1196 : tcase_add_test(tc, libhttp_parseheaders_empty);
1197 : tcase_add_test(tc, libhttp_parseheaders_single);
1198 : tcase_add_test(tc, libhttp_parseheaders_multi);
1199 : tcase_add_test(tc, libhttp_parseheaders_split);
1200 : tcase_add_test(tc, libhttp_parseheaders_invalid_nocolon);
1201 : tcase_add_test(tc, libhttp_parseheaders_invalid_novalue);
1202 : tcase_add_test(tc, libhttp_parseheaders_invalid_noname);
1203 : #endif
1204 148 : tcase_add_test_raise_signal(tc, libhttp_buildrequest_nullhttp,SIG_ABRTSEGV);
1205 148 : tcase_add_test_raise_signal(tc, libhttp_buildrequest_nulluri,SIG_ABRTSEGV);
1206 148 : tcase_add_test(tc, libhttp_buildrequest_badmethod);
1207 148 : tcase_add_test(tc, libhttp_buildrequest_badversion);
1208 148 : tcase_add_test(tc, libhttp_buildrequest_emptyuri);
1209 148 : tcase_add_test(tc, libhttp_buildrequest_noheader);
1210 148 : tcase_add_test(tc, libhttp_buildrequest_singleheader);
1211 148 : tcase_add_test(tc, libhttp_buildrequest_multiheader);
1212 : #if 0
1213 : tcase_add_test_raise_signal(tc, libhttp_parserequest_nullrequest,SIG_ABRTSEGV);
1214 : #endif
1215 148 : tcase_add_test(tc, libhttp_buildreply_basic);
1216 :
1217 148 : return s;
1218 : }
1219 : /* vim: set tw=80: */
|