Line data Source code
1 : /** @file suite_sample.c 2 : * @brief Check testsuite template 3 : * @author François Cerbelle (Fanfan), francois@cerbelle.net 4 : * 5 : * @internal 6 : * Created: 20/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 <check.h> 22 : #include <unistd.h> /* pid_t getpid() */ 23 : #include <sys/stat.h> /* mkdir(), chdir(), mode_t */ 24 : #include <stdio.h> /* fprintf */ 25 : #include <stdlib.h> /* abort() */ 26 : #include "checktools.inc" 27 : 28 : /** Dummy test to trigger fixtures 29 : * 30 : * This test is defined and added to all testcases in order to execute at 31 : * least one test test in each testcase of the testsuite, trigger the 32 : * fixtures and have a decent coverage report. 33 : */ 34 10 : START_TEST(sample_test) { 35 : /* This test is supposed to trigger a SIGABRT(6) and will crash the 36 : * whole testsuite if not caught or not in a child process */ 37 10 : forktest_only; 38 : 39 6 : abort(); 40 : } 41 : END_TEST 42 : 43 : /************************************************************************/ 44 : /* Begining of test (potentially in child) */ 45 10 : void sample_checked_uninitialized_setup() { 46 10 : signals_catch(); 47 10 : forktest_gprofdir(); 48 10 : } 49 : 50 : /* End of test (potentially in child) */ 51 4 : void sample_checked_uninitialized_teardown() { 52 4 : signals_release(); 53 4 : } 54 : /************************************************************************/ 55 16 : void sample_unchecked_common_setup() { 56 16 : forktest_init(); 57 16 : } 58 10 : void sample_unchecked_common_teardown() { 59 10 : } 60 : /************************************************************************/ 61 19 : Suite* sample_suite() { 62 : Suite *s; 63 : TCase *tc; 64 : 65 19 : s = suite_create("SampleSuite"); 66 : 67 19 : tc = tcase_create("SampleCase"); 68 19 : tcase_set_tags(tc,"SampleTag tag2"); 69 : /* tcase_set_timeout(tc,5); */ /* seconds */ 70 19 : tcase_add_checked_fixture(tc, sample_checked_uninitialized_setup, sample_checked_uninitialized_teardown); 71 19 : tcase_add_unchecked_fixture(tc, sample_unchecked_common_setup, sample_unchecked_common_teardown); 72 19 : suite_add_tcase(s, tc); 73 19 : tcase_add_test_raise_signal(tc, sample_test,6); 74 : 75 19 : return s; 76 : } 77 : /* vim: set tw=80: */