GCC Code Coverage Report


Directory: ./
File: tests/unit/test_process.h
Date: 2026-11-30 15:03:27
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 2 2 100.0%
Branches: 2 4 50.0%

Line Branch Exec Source
1 /*********************************************************************************/
2 /* Copyright 2009-2026 Barcelona Supercomputing Center */
3 /* */
4 /* This file is part of the DLB library. */
5 /* */
6 /* DLB is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU Lesser General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* DLB is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU Lesser General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU Lesser General Public License */
17 /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */
18 /*********************************************************************************/
19
20 #ifndef TEST_PROCESS_H
21 #define TEST_PROCESS_H
22
23 #include <assert.h>
24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <sys/wait.h>
27
28 #define FORK(F) do { \
29 int pid_a = fork(); \
30 if (pid_a == 0) { \
31 F; \
32 dlb_test__exit(0); \
33 } \
34 \
35 } while(0)
36
37 #define WAITALL do { \
38 int wstatus; \
39 while(waitpid(0, &wstatus, 0) > -1) { \
40 assert(WIFEXITED(wstatus)); \
41 assert(WEXITSTATUS(wstatus) == EXIT_SUCCESS); \
42 } \
43 } while(0)
44
45 void __gcov_flush(void) __attribute__((weak));
46 void __gcov_dump(void) __attribute__((weak));
47
48 79 static inline void dlb_test__gcov_dump(void) {
49
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if (__gcov_flush) __gcov_flush();
50
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if (__gcov_dump) __gcov_dump();
51 }
52
53 75 static inline void dlb_test__exit(int error) {
54 75 dlb_test__gcov_dump();
55 ✗ _exit(error);
56 }
57
58 #endif /* TEST_PROCESS_H */
59