dte test coverage


Directory: ./
File: src/util/xstdio.c
Date: 2025-12-11 10:43:49
Coverage Exec Excl Total
Lines: 100.0% 37 0 37
Functions: 100.0% 6 0 6
Branches: 27.3% 6 0 22

Line Branch Exec Source
1 #include "xstdio.h"
2
3 1 char *xfgets(char *restrict buf, int bufsize, FILE *restrict stream)
4 {
5 1 char *r;
6 3 do {
7 1 clearerr(stream);
8 1 r = fgets(buf, bufsize, stream);
9
2/6
✓ Branch 5 → 6 taken 1 time.
✗ Branch 5 → 9 not taken.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 1 time.
✗ Branch 8 → 3 not taken.
✗ Branch 8 → 9 not taken.
1 } while (unlikely(!r && ferror(stream) && errno == EINTR));
10 1 return r;
11 }
12
13 9 int xfputs(const char *restrict str, FILE *restrict stream)
14 {
15 9 int r;
16 18 do {
17 9 r = fputs(str, stream);
18
1/4
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 9 times.
✗ Branch 5 → 3 not taken.
✗ Branch 5 → 6 not taken.
9 } while (unlikely(r == EOF && errno == EINTR));
19 9 return r;
20 }
21
22 9 int xfputc(int c, FILE *stream)
23 {
24 9 int r;
25 18 do {
26 9 r = fputc(c, stream);
27
1/4
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 9 times.
✗ Branch 5 → 3 not taken.
✗ Branch 5 → 6 not taken.
9 } while (unlikely(r == EOF && errno == EINTR));
28 9 return r;
29 }
30
31 1 int xvfprintf(FILE *restrict stream, const char *restrict fmt, va_list ap)
32 {
33 1 int r;
34 2 do {
35 1 r = vfprintf(stream, fmt, ap);
36
1/4
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 1 time.
✗ Branch 5 → 3 not taken.
✗ Branch 5 → 6 not taken.
1 } while (unlikely(r < 0 && errno == EINTR));
37 1 return r;
38 }
39
40 1 int xfprintf(FILE *restrict stream, const char *restrict fmt, ...)
41 {
42 1 va_list ap;
43 1 va_start(ap, fmt);
44 1 int r = xvfprintf(stream, fmt, ap);
45 1 va_end(ap);
46 1 return r;
47 }
48
49 1 int xfflush(FILE *stream)
50 {
51 1 int r;
52 2 do {
53 1 r = fflush(stream);
54
1/4
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 1 time.
✗ Branch 5 → 3 not taken.
✗ Branch 5 → 6 not taken.
1 } while (unlikely(r != 0 && errno == EINTR));
55 1 return r;
56 }
57