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

          Line data    Source code
       1             : /**   @file  suite_libhttp.c
       2             :  *   @brief  Check testsuite for libhttp functions
       3             :  *  @author  François Cerbelle (Fanfan), francois@cerbelle.net
       4             :  *
       5             :  *  @internal
       6             :  *       Created:  20/03/2022
       7             :  *      Revision:  none
       8             :  * Last modified:  2024-11-19 20:25
       9             :  *      Compiler:  gcc
      10             :  *  Organization:  Cerbelle.net
      11             :  *     Copyright:  Copyright (c) 2024, François Cerbelle
      12             :  *
      13             :  *  This source code is released for free distribution under the terms of the
      14             :  *  GNU General Public License as published by the Free Software Foundation.
      15             :  */
      16             : 
      17             : #ifdef HAVE_CONFIG_H
      18             : #include "config.h"
      19             : #endif
      20             : 
      21             : #include <check.h>
      22             : #include <stdlib.h>
      23             : #include "checktools.inc"
      24             : 
      25             : #include "libhttp.h"
      26             : #include <stdio.h>                              /* perror */
      27             : 
      28             : /** Dummy test to trigger fixtures
      29             :  *
      30             :  * This test is defined and added to all testcases in order to execute at
      31             :  * least one test test in each testcase of the testsuite, trigger the
      32             :  * fixtures and have a decent coverage report.
      33             :  */
      34           3 : START_TEST(libhttp_test) {
      35             :     /* This test is supposed to trigger a SIGABRT(6) and will crash the
      36             :      * whole testsuite if not caught or not in a child process */
      37           3 :     forktest_only;
      38             : 
      39           2 :     abort();
      40             : }
      41             : END_TEST
      42             : 
      43             : #if 0
      44             : int main(int argc, char** argv, char** env) {
      45             :     char* tmp;
      46             :     HTTP_t* uut;
      47             : 
      48             :     (void) argc;
      49             :     (void) argv;
      50             :     (void) env;
      51             : 
      52             :     uut = HTTP_new();
      53             :     HTTP_setbody(uut,"<HTML/>\n");
      54             :     HTTP_addheader(uut,"Host","localhost");
      55             : 
      56             :     tmp=HTTP_getrequest(HTTPMETHOD_GET,"/v1/api/bdbs",HTTPVERSION_HTTP11);
      57             :     printf("%s",tmp);
      58             :     free(tmp);
      59             : 
      60             :     tmp = HTTP_getheaders(uut);
      61             :     printf("%s\r\n",tmp);
      62             : 
      63             :     printf("%s",HTTP_getbody(uut));
      64             : 
      65             :     HTTP_del(uut);
      66             : 
      67             :     return (EXIT_SUCCESS);
      68             : }
      69             : #endif
      70             : 
      71             : /************************************************************************/
      72             : /* Begining of test (potentially in child) */
      73           3 : void libhttp_checked_uninitialized_setup() {
      74           3 :     signals_catch();
      75           3 :     forktest_gprofdir();
      76           3 : }
      77             : 
      78             : /* End of test (potentially in child) */
      79           1 : void libhttp_checked_uninitialized_teardown() {
      80           1 :     signals_release();
      81           1 : }
      82             : /************************************************************************/
      83           5 : void libhttp_unchecked_common_setup() {
      84           5 :     forktest_init();
      85           5 : }
      86           3 : void libhttp_unchecked_common_teardown() {
      87           3 : }
      88             : /************************************************************************/
      89           6 : Suite* libhttp_suite() {
      90             :     Suite *s;
      91             :     TCase *tc;
      92             : 
      93           6 :     s = suite_create("LibHTTP");
      94             : 
      95           6 :     tc = tcase_create("LibHTTPUninitialized");
      96           6 :     tcase_set_tags(tc,"LibHTTPTag LibHTTPTag2");
      97             :     /* tcase_set_timeout(tc,5); */ /* seconds */
      98           6 :     tcase_add_checked_fixture(tc, libhttp_checked_uninitialized_setup, libhttp_checked_uninitialized_teardown);
      99           6 :     tcase_add_unchecked_fixture(tc, libhttp_unchecked_common_setup, libhttp_unchecked_common_teardown);
     100           6 :     suite_add_tcase(s, tc);
     101           6 :     tcase_add_test_raise_signal(tc, libhttp_test,6);
     102             : 
     103           6 :     return s;
     104             : }
     105             : /* vim: set tw=80: */

Generated by: LCOV version 1.16