LCOV - code coverage report
Current view: top level - test - check_base64.c (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 29 36 80.6 %
Date: 2024-11-11 21:44:55 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**   @file  check_base64.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-04 11:50
       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* base64_suite();                          /* base64_encode/decode */
      26             : 
      27           9 : 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             :     /*
      35             :      * CK_SILENT
      36             :      * CK_MINIMAL
      37             :      * CK_NORMAL
      38             :      * CK_VERBOSE
      39             :      * CK_ENV
      40             :      */
      41           9 :     ck_verbosity = CK_ENV;
      42           9 :     printf("Verbosity: ");
      43           9 :     if ((argc==2)&&(0==strcmp(argv[1],"-v"))) {
      44           0 :         printf("yes-CK_VERBOSE\n");
      45           0 :         ck_verbosity = CK_VERBOSE;
      46             :     } else
      47           9 :         printf("default-CK_ENV (look for CK_VERBOSITY env)\n");
      48             : 
      49             :     /* Limit available RAM to really available RAM for all
      50             :      * suites/testcase/process/fork to test OOM without exhausting the system's
      51             :      * resources, hitting the swap or consumming too much time to fill the RAM
      52             :      * */
      53             :     /* oomtest_config(RAMLIMIT_HARD); */ /* debug library not included in rsstats */
      54             : 
      55             :     /* Empty suite, to initialize the framework with the specific
      56             :      * function and to display a CRLF in the output */
      57           9 :     sr = srunner_create(suite_create(""));
      58             : 
      59             :     /*  CK_FORK
      60             :      *  CK_NOFORK
      61             :      *  CK_FORK_GETENV (default)
      62             :      */
      63           9 :     printf ("Fork mode (with signal catch): ");
      64           9 :     if ((getenv("CK_FORK")) && (strlen(getenv("CK_FORK"))>0)) {
      65           0 :         printf("%s if possible (CK_FORK defined)",getenv("CK_FORK"));
      66             :     } else {
      67           9 :         printf("yes if possible (default)");
      68             :     }
      69           9 :     printf("\n");
      70           9 :     srunner_set_fork_status (sr, CK_FORK_GETENV);
      71             : 
      72             :     /* Print what will be run, in case of environment variable override */
      73           9 :     printf("CK_RUN_SUITE=");
      74           9 :     if ((getenv("CK_RUN_SUITE")) && (strlen(getenv("CK_RUN_SUITE"))>0))
      75           0 :         printf("%s\n",getenv("CK_RUN_SUITE"));
      76             :     else
      77           9 :         printf("all\n");
      78           9 :     printf("CK_RUN_CASE=");
      79           9 :     if ((getenv("CK_RUN_CASE")) && (strlen(getenv("CK_RUN_CASE"))>0))
      80           0 :         printf("%s\n",getenv("CK_RUN_CASE"));
      81             :     else
      82           9 :         printf("all\n");
      83           9 :     printf("CK_INCLUDE_TAGS=");
      84           9 :     if ((getenv("CK_INCLUDE_TAGS")) && (strlen(getenv("CK_INCLUDE_TAGS"))>0))
      85           0 :         printf("%s\n",getenv("CK_INCLUDE_TAGS"));
      86             :     else
      87           9 :         printf("all\n");
      88           9 :     printf("CK_EXCLUDE_TAGS=");
      89           9 :     if ((getenv("CK_EXCLUDE_TAGS")) && (strlen(getenv("CK_EXCLUDE_TAGS"))>0))
      90           0 :         printf("%s\n",getenv("CK_EXCLUDE_TAGS"));
      91             :     else
      92           9 :         printf("all\n");
      93             : 
      94           9 :     srunner_add_suite (sr, base64_suite());
      95             : 
      96           9 :     srunner_run_all(sr, ck_verbosity);
      97             : 
      98           1 :     number_failed = srunner_ntests_failed(sr);
      99           1 :     srunner_free(sr);
     100             : 
     101           1 :     printf("\n");
     102             : 
     103             :     /*
     104             :      * Return error code 1 if the one of test failed.
     105             :      * Return 77 if test skipped
     106             :      */
     107           1 :     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
     108             : }
     109             : /* vim: set tw=80: */

Generated by: LCOV version 1.16