dte test coverage


Directory: ./
File: src/util/progname.h
Date: 2025-12-11 10:43:49
Coverage Exec Excl Total
Lines: 100.0% 3 0 3
Functions: 100.0% 1 0 1
Branches: 100.0% 8 0 8

Line Branch Exec Source
1 #ifndef UTIL_PROGNAME_H
2 #define UTIL_PROGNAME_H
3
4 #include "macros.h"
5
6 // Get the program name from argv[0] (as passed to main()), or fall back to a
7 // pre-defined string if it's missing
8 RETURNS_NONNULL
9 8 static inline const char *progname(int argc, char *argv[], const char *fallback)
10 {
11 // Setting argv[0] properly is under the control of the parent process,
12 // so it's safest to make as few assumptions about it as possible
13
6/6
✓ Branch 2 → 3 taken 5 times.
✓ Branch 2 → 5 taken 3 times.
✓ Branch 3 → 4 taken 4 times.
✓ Branch 3 → 5 taken 1 time.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 7 taken 3 times.
8 if (likely(argc >= 1 && argv && argv[0] && argv[0][0])) {
14 return argv[0];
15 }
16
2/2
✓ Branch 5 → 6 taken 1 time.
✓ Branch 5 → 7 taken 4 times.
5 return fallback ? fallback : "_PROG_";
17 }
18
19 #endif
20