LCOV - code coverage report
Current view: top level - test - check_svcmgr.c (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 39 39 100.0 %
Date: 2024-07-31 00:13:03 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.16