LCOV - code coverage report
Current view: top level - test - suite_sample.c (source / functions) Hit Total Coverage
Test: liboom.info Lines: 24 24 100.0 %
Date: 2024-12-21 19:46:36 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-12-06 21:41
       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             : #define _XOPEN_SOURCE 500                       /* snprintf */
      22             : #include <check.h>
      23             : #include <unistd.h>                             /* pid_t getpid() */
      24             : #include <sys/stat.h>                           /* mkdir(), chdir(), mode_t */
      25             : #include <stdio.h>                              /* fprintf */
      26             : #include <stdlib.h>                             /* abort() */
      27             : #include "checktools.inc"
      28             : 
      29             : /** Dummy test to trigger fixtures
      30             :  *
      31             :  * This test is defined and added to all testcases in order to execute at
      32             :  * least one test test in each testcase of the testsuite, trigger the
      33             :  * fixtures and have a decent coverage report.
      34             :  */
      35           4 : START_TEST(sample_test) {
      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           4 :     forktest_only;
      39             : 
      40           3 :     abort();
      41             : }
      42             : END_TEST
      43             : 
      44             : /************************************************************************/
      45             : /* Begining of test (potentially in child) */
      46           4 : void sample_checked_uninitialized_setup() {
      47           4 :     signals_catch();
      48           4 :     forktest_gprofdir();
      49           4 : }
      50             : 
      51             : /* End of test (potentially in child) */
      52           1 : void sample_checked_uninitialized_teardown() {
      53           1 :     signals_release();
      54           1 : }
      55             : /************************************************************************/
      56         367 : void sample_unchecked_common_setup() {
      57         367 :     forktest_init();
      58         367 : }
      59         364 : void sample_unchecked_common_teardown() {
      60         364 : }
      61             : /************************************************************************/
      62         367 : Suite* sample_suite() {
      63             :     Suite *s;
      64             :     TCase *tc;
      65             : 
      66         367 :     s = suite_create("SampleSuite");
      67             : 
      68         367 :     tc = tcase_create("SampleCase");
      69         367 :     tcase_set_tags(tc,"SampleTag tag2");
      70             :     /* tcase_set_timeout(tc,5); */ /* seconds */
      71         367 :     tcase_add_checked_fixture(tc, sample_checked_uninitialized_setup, sample_checked_uninitialized_teardown);
      72         367 :     tcase_add_unchecked_fixture(tc, sample_unchecked_common_setup, sample_unchecked_common_teardown);
      73         367 :     suite_add_tcase(s, tc);
      74         367 :     tcase_add_test_raise_signal(tc, sample_test,6);
      75             : 
      76         367 :     return s;
      77             : }
      78             : /* vim: set tw=80: */

Generated by: LCOV version 1.16