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