LCOV - code coverage report
Current view: top level - test - suite_libhttp.c (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 655 655 100.0 %
Date: 2024-11-29 19:32:20 Functions: 69 69 100.0 %

          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-29 19:14
      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             : 
     989             : 
     990             : 
     991             : 
     992           3 : START_TEST(libhttp_basictest) {
     993             :     char* output_str;
     994             :     HTTP_t* http;
     995             : 
     996             :     /* Build HTTP */
     997           3 :     http = HTTP_new();
     998           3 :     ck_assert(HTTP_addheader(http,"Host","localhost"));
     999           3 :     ck_assert(HTTP_addheader(http,"Content-type","text/html"));
    1000           3 :     HTTP_setbody(http,"<HTML></HTML>\r\n");
    1001             : 
    1002             :     /* Generate request */
    1003           3 :     output_str=HTTP_buildrequest(http, HTTPMETHOD_GET,"/v1/api/bdbs",HTTPVERSION_HTTP11);
    1004           3 :     printf("%s",output_str);
    1005           3 :     free(output_str);
    1006             : 
    1007             :     /* Cleanup */
    1008           3 :     HTTP_del(http);
    1009           3 : }
    1010             : END_TEST
    1011             : 
    1012             : /************************************************************************/
    1013             : /* Begining of test (potentially in child) */
    1014         192 : void libhttp_checked_common_setup() {
    1015         192 :     signals_catch();
    1016         192 :     forktest_gprofdir();
    1017         192 : }
    1018             : 
    1019             : /* End of test (potentially in child) */
    1020         142 : void libhttp_checked_common_teardown() {
    1021         142 :     signals_release();
    1022         142 : }
    1023             : /************************************************************************/
    1024         131 : void libhttp_unchecked_common_setup() {
    1025         131 :     forktest_init();
    1026         131 : }
    1027           3 : void libhttp_unchecked_common_teardown() {
    1028           3 : }
    1029             : /************************************************************************/
    1030         132 : Suite* libhttp_suite() {
    1031             :     Suite *s;
    1032             :     TCase *tc;
    1033             : 
    1034         132 :     s = suite_create("LibHTTP");
    1035             : 
    1036         132 :     tc = tcase_create("LibHTTPUninitialized");
    1037         132 :     tcase_set_tags(tc,"LibHTTPTag LibHTTPTag2");
    1038             :     /* tcase_set_timeout(tc,5); */ /* seconds */
    1039         132 :     tcase_add_checked_fixture(tc, libhttp_checked_common_setup, libhttp_checked_common_teardown);
    1040         132 :     tcase_add_unchecked_fixture(tc, libhttp_unchecked_common_setup, libhttp_unchecked_common_teardown);
    1041         132 :     suite_add_tcase(s, tc);
    1042         132 :     tcase_add_test_raise_signal(tc, libhttp_test,6);
    1043         132 :     tcase_add_test(tc, libhttp_new);
    1044         132 :     tcase_add_test_raise_signal(tc, libhttp_del_null,SIG_ABRTSEGV);
    1045         132 :     tcase_add_test(tc, libhttp_del_empty);
    1046         132 :     tcase_add_test(tc, libhttp_del_populated);
    1047         132 :     tcase_add_test_raise_signal(tc, libhttp_setbody_nullhttp,SIG_ABRTSEGV);
    1048         132 :     tcase_add_test_raise_signal(tc, libhttp_setbody_nullbody,SIG_ABRTSEGV);
    1049         132 :     tcase_add_test(tc, libhttp_setbody_empty);
    1050         132 :     tcase_add_test(tc, libhttp_setbody_valid);
    1051         132 :     tcase_add_test_raise_signal(tc, libhttp_getbody_null,SIG_ABRTSEGV);
    1052         132 :     tcase_add_test(tc, libhttp_getbody_populated);
    1053         132 :     tcase_add_test_raise_signal(tc, libhttp_addheader_nullhttp,SIG_ABRTSEGV);
    1054         132 :     tcase_add_test_raise_signal(tc, libhttp_addheader_nullname,SIG_ABRTSEGV);
    1055         132 :     tcase_add_test_raise_signal(tc, libhttp_addheader_nullvalue,SIG_ABRTSEGV);
    1056         132 :     tcase_add_test(tc, libhttp_addheader_emptyname);
    1057         132 :     tcase_add_test(tc, libhttp_addheader_emptyvalue);
    1058         132 :     tcase_add_test(tc, libhttp_addheader_valid);
    1059         132 :     tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullhttp,SIG_ABRTSEGV);
    1060         132 :     tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nulllogin,SIG_ABRTSEGV);
    1061         132 :     tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullpass,SIG_ABRTSEGV);
    1062         132 :     tcase_add_test(tc, libhttp_addbasicauth_emptylogin);
    1063         132 :     tcase_add_test(tc, libhttp_addbasicauth_emptypass);
    1064         132 :     tcase_add_test(tc, libhttp_addbasicauth_valid);
    1065         132 :     tcase_add_test_raise_signal(tc, libhttp_setname_nullheader,SIG_ABRTSEGV);
    1066         132 :     tcase_add_test_raise_signal(tc, libhttp_setname_nullname,SIG_ABRTSEGV);
    1067         132 :     tcase_add_test(tc, libhttp_setname_emptyname);
    1068         132 :     tcase_add_test(tc, libhttp_setname_valid);
    1069         132 :     tcase_add_test_raise_signal(tc, libhttp_getname_nullheader,SIG_ABRTSEGV);
    1070         132 :     tcase_add_test(tc, libhttp_getname_valid);
    1071         132 :     tcase_add_test_raise_signal(tc, libhttp_setvalue_nullheader,SIG_ABRTSEGV);
    1072         132 :     tcase_add_test_raise_signal(tc, libhttp_setvalue_nullvalue,SIG_ABRTSEGV);
    1073         132 :     tcase_add_test(tc, libhttp_setvalue_emptyvalue);
    1074         132 :     tcase_add_test(tc, libhttp_setvalue_valid);
    1075         132 :     tcase_add_test_raise_signal(tc, libhttp_getvalue_nullheader,SIG_ABRTSEGV);
    1076         132 :     tcase_add_test(tc, libhttp_getvalue_valid);
    1077         132 :     tcase_add_test_raise_signal(tc, libhttp_firstheader_nullhttp,SIG_ABRTSEGV);
    1078         132 :     tcase_add_test(tc, libhttp_firstheader_empty);
    1079         132 :     tcase_add_test(tc, libhttp_firstheader_single);
    1080         132 :     tcase_add_test(tc, libhttp_firstheader_multi);
    1081         132 :     tcase_add_test_raise_signal(tc, libhttp_nextheader_nullheader,SIG_ABRTSEGV);
    1082         132 :     tcase_add_test_raise_signal(tc, libhttp_nextheader_empty,SIG_ABRTSEGV);
    1083         132 :     tcase_add_test(tc, libhttp_nextheader_single);
    1084         132 :     tcase_add_test(tc, libhttp_nextheader_multi);
    1085         132 :     tcase_add_test_raise_signal(tc, libhttp_findheader_nullheader,SIG_ABRTSEGV);
    1086         132 :     tcase_add_test_raise_signal(tc, libhttp_findheader_nullname,SIG_ABRTSEGV);
    1087         132 :     tcase_add_test(tc, libhttp_findheader_emptyname);
    1088         132 :     tcase_add_test(tc, libhttp_findheader_missingname);
    1089         132 :     tcase_add_test(tc, libhttp_findheader_firstname);
    1090         132 :     tcase_add_test(tc, libhttp_findheader_middlename);
    1091         132 :     tcase_add_test(tc, libhttp_findheader_lastname);
    1092         132 :     tcase_add_test(tc, libhttp_findheader_secondmiddle);
    1093         132 :     tcase_add_test(tc, libhttp_findheader_secondlast);
    1094         132 :     tcase_add_test_raise_signal(tc, libhttp_remheader_nullhttp,SIG_ABRTSEGV);
    1095         132 :     tcase_add_test_raise_signal(tc, libhttp_remheader_nullheader,SIG_ABRTSEGV);
    1096         132 :     tcase_add_test(tc, libhttp_remheader_missingheader);
    1097         132 :     tcase_add_test(tc, libhttp_remheader_firstheader);
    1098         132 :     tcase_add_test(tc, libhttp_remheader_middleheader);
    1099         132 :     tcase_add_test(tc, libhttp_remheader_lastheader);
    1100         132 :     tcase_add_test(tc, libhttp_remheader_onlyheader);
    1101         132 :     tcase_add_test_raise_signal(tc, libhttp_buildheaders_null,SIG_ABRTSEGV);
    1102         132 :     tcase_add_test(tc, libhttp_buildheaders_empty);
    1103         132 :     tcase_add_test(tc, libhttp_buildheaders_single);
    1104         132 :     tcase_add_test(tc, libhttp_buildheaders_multi);
    1105         132 :     tcase_add_test(tc, libhttp_basictest);
    1106             : 
    1107             : #if 0
    1108             :     /** @todo OOM unit tests */
    1109             :     tc = tcase_create("LibHTTPOOM");
    1110             :     tcase_set_tags(tc,"LibHTTPTag LibHTTPTag2");
    1111             :     /* tcase_set_timeout(tc,5); */ /* seconds */
    1112             :     tcase_add_checked_fixture(tc, libhttp_checked_common_setup, libhttp_checked_common_teardown);
    1113             :     tcase_add_unchecked_fixture(tc, libhttp_unchecked_common_setup, libhttp_unchecked_common_teardown);
    1114             :     suite_add_tcase(s, tc);
    1115             :     tcase_add_test_raise_signal(tc, libhttp_test,6);
    1116             : #endif
    1117             : 
    1118         132 :     return s;
    1119             : }
    1120             : /* vim: set tw=80: */

Generated by: LCOV version 1.16