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-12-05 21:00:54 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-11-11 21:33
       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           3 : 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           3 :     forktest_only;
      38             : 
      39           2 :     abort();
      40             : }
      41             : END_TEST
      42             : 
      43             : /************************************************************************/
      44             : /* Begining of test (potentially in child) */
      45           3 : void sample_checked_uninitialized_setup() {
      46           3 :     signals_catch();
      47           3 :     forktest_gprofdir();
      48           3 : }
      49             : 
      50             : /* End of test (potentially in child) */
      51           1 : void sample_checked_uninitialized_teardown() {
      52           1 :     signals_release();
      53           1 : }
      54             : /************************************************************************/
      55           5 : void sample_unchecked_common_setup() {
      56           5 :     forktest_init();
      57           5 : }
      58           3 : void sample_unchecked_common_teardown() {
      59           3 : }
      60             : /************************************************************************/
      61           6 : Suite* sample_suite() {
      62             :     Suite *s;
      63             :     TCase *tc;
      64             : 
      65           6 :     s = suite_create("SampleSuite");
      66             : 
      67           6 :     tc = tcase_create("SampleCase");
      68           6 :     tcase_set_tags(tc,"SampleTag SampleTag2");
      69             :     /* tcase_set_timeout(tc,5); */ /* seconds */
      70           6 :     tcase_add_checked_fixture(tc, sample_checked_uninitialized_setup, sample_checked_uninitialized_teardown);
      71           6 :     tcase_add_unchecked_fixture(tc, sample_unchecked_common_setup, sample_unchecked_common_teardown);
      72           6 :     suite_add_tcase(s, tc);
      73           6 :     tcase_add_test_raise_signal(tc, sample_test,6);
      74             : 
      75           6 :     return s;
      76             : }
      77             : /* vim: set tw=80: */

Generated by: LCOV version 1.16