LCOV - code coverage report
Current view: top level - test - suite_sample.c (source / functions) Hit Total Coverage
Test: mkernel.info Lines: 24 24 100.0 %
Date: 2024-07-31 10:26:45 Functions: 6 6 100.0 %

          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-07-20 15:38
       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          20 : START_TEST(sample_test)
      35             : {
      36             :     /* This test is supposed to trigger a SIGABRT(6) and will crash the
      37             :      * whole testsuite if not caught or not in a child process */
      38          20 :     forktest_only;
      39             : 
      40          15 :     abort();
      41             : }
      42             : END_TEST
      43             : 
      44             : /************************************************************************/
      45             : /* Begining of test (potentially in child) */
      46          20 : void sample_checked_uninitialized_setup()
      47             : {
      48          20 :     signals_catch();
      49          20 :     forktest_gprofdir();
      50          20 : }
      51             : 
      52             : /* End of test (potentially in child) */
      53           5 : void sample_checked_uninitialized_teardown()
      54             : {
      55           5 :     signals_release();
      56           5 : }
      57             : /************************************************************************/
      58        6443 : void sample_unchecked_common_setup()
      59             : {
      60        6443 :     forktest_init();
      61        6443 : }
      62        6428 : void sample_unchecked_common_teardown()
      63             : {
      64        6428 : }
      65             : /************************************************************************/
      66        6443 : Suite* sample_suite()
      67             : {
      68             :     Suite *s;
      69             :     TCase *tc;
      70             : 
      71        6443 :     s = suite_create("SampleSuite");
      72             : 
      73        6443 :     tc = tcase_create("SampleCase");
      74        6443 :     tcase_set_tags(tc,"SampleTag tag2");
      75             :     /* tcase_set_timeout(tc,5); */ /* seconds */
      76        6443 :     tcase_add_checked_fixture(tc, sample_checked_uninitialized_setup, sample_checked_uninitialized_teardown);
      77        6443 :     tcase_add_unchecked_fixture(tc, sample_unchecked_common_setup, sample_unchecked_common_teardown);
      78        6443 :     suite_add_tcase(s, tc);
      79        6443 :     tcase_add_test_raise_signal(tc, sample_test,6);
      80             : 
      81        6443 :     return s;
      82             : }

Generated by: LCOV version 1.16