LCOV - code coverage report
Current view: top level - test - check_json.c (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 37 37 100.0 %
Date: 2024-12-05 21:00:54 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**   @file  check_json.c
       2             :  *   @brief  Check unit testing framework main function
       3             :  *  @author  François Cerbelle (Fanfan), francois@cerbelle.net
       4             :  *
       5             :  *  @internal
       6             :  *       Created:  19/03/2022
       7             :  *      Revision:  none
       8             :  * Last modified:  2024-11-24 18:26
       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>                             /* EXIT_SUCCESS */
      23             : #include <stdio.h>                              /* printf */
      24             : 
      25             : Suite* json_suite();                            /* json2text */
      26             : 
      27           8 : int main(int argc, char* argv[], char* env[]) {
      28             :     SRunner *sr;
      29             :     int number_failed;
      30             :     enum print_output ck_verbosity;
      31             : 
      32             :     (void) env; /* Avoids "unused" warning */
      33             : 
      34             : #ifndef NDEBUG
      35           8 :     printf("Debug build\n");
      36             : #else
      37             :     printf("Release build\n");
      38             : #endif
      39             : 
      40             :     /*
      41             :      * CK_SILENT
      42             :      * CK_MINIMAL
      43             :      * CK_NORMAL
      44             :      * CK_VERBOSE
      45             :      * CK_ENV
      46             :      */
      47           8 :     ck_verbosity = CK_ENV;
      48           8 :     printf("Verbosity: ");
      49           8 :     if ((argc==2)&&(0==strcmp(argv[1],"-v"))) {
      50           1 :         printf("yes-CK_VERBOSE\n");
      51           1 :         ck_verbosity = CK_VERBOSE;
      52             :     } else
      53           7 :         printf("default-CK_ENV (look for CK_VERBOSITY env)\n");
      54             : 
      55             :     /* Limit available RAM to really available RAM for all
      56             :      * suites/testcase/process/fork to test OOM without exhausting the system's
      57             :      * resources, hitting the swap or consumming too much time to fill the RAM
      58             :      * */
      59             :     /* oomtest_config(RAMLIMIT_HARD); */ /* debug library not included in rsstats */
      60             : 
      61             :     /* Empty suite, to initialize the framework with the specific
      62             :      * function and to display a CRLF in the output */
      63           8 :     sr = srunner_create(suite_create(""));
      64             : 
      65             :     /*  CK_FORK
      66             :      *  CK_NOFORK
      67             :      *  CK_FORK_GETENV (default)
      68             :      */
      69           8 :     printf ("Fork mode (with signal catch): ");
      70           8 :     if ((getenv("CK_FORK")) && (strlen(getenv("CK_FORK"))>0)) {
      71           2 :         printf("%s if possible (CK_FORK defined)",getenv("CK_FORK"));
      72             :     } else {
      73           6 :         printf("yes if possible (default)");
      74             :     }
      75           8 :     printf("\n");
      76           8 :     srunner_set_fork_status (sr, CK_FORK_GETENV);
      77             : 
      78             :     /* Print what will be run, in case of environment variable override */
      79           8 :     printf("CK_RUN_SUITE=");
      80           8 :     if ((getenv("CK_RUN_SUITE")) && (strlen(getenv("CK_RUN_SUITE"))>0))
      81           1 :         printf("%s\n",getenv("CK_RUN_SUITE"));
      82             :     else
      83           7 :         printf("all\n");
      84           8 :     printf("CK_RUN_CASE=");
      85           8 :     if ((getenv("CK_RUN_CASE")) && (strlen(getenv("CK_RUN_CASE"))>0))
      86           1 :         printf("%s\n",getenv("CK_RUN_CASE"));
      87             :     else
      88           7 :         printf("all\n");
      89           8 :     printf("CK_INCLUDE_TAGS=");
      90           8 :     if ((getenv("CK_INCLUDE_TAGS")) && (strlen(getenv("CK_INCLUDE_TAGS"))>0))
      91           1 :         printf("%s\n",getenv("CK_INCLUDE_TAGS"));
      92             :     else
      93           7 :         printf("all\n");
      94           8 :     printf("CK_EXCLUDE_TAGS=");
      95           8 :     if ((getenv("CK_EXCLUDE_TAGS")) && (strlen(getenv("CK_EXCLUDE_TAGS"))>0))
      96           1 :         printf("%s\n",getenv("CK_EXCLUDE_TAGS"));
      97             :     else
      98           7 :         printf("all\n");
      99             : 
     100           8 :     srunner_add_suite (sr, json_suite());
     101             : 
     102           8 :     srunner_run_all(sr, ck_verbosity);
     103             : 
     104           4 :     number_failed = srunner_ntests_failed(sr);
     105           4 :     srunner_free(sr);
     106             : 
     107           4 :     printf("\n");
     108             : 
     109             :     /*
     110             :      * Return error code 1 if the one of test failed.
     111             :      * Return 77 if test skipped
     112             :      */
     113           4 :     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
     114             : }
     115             : /* vim: set tw=80: */

Generated by: LCOV version 1.16