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