dte test coverage


Directory: ./
File: src/util/xstdio.c
Date: 2025-02-14 16:55:22
Exec Total Coverage
Lines: 37 37 100.0%
Functions: 6 6 100.0%
Branches: 6 22 27.3%

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 0 (5→6) taken 1 times.
✗ Branch 1 (5→9) not taken.
✗ Branch 2 (7→8) not taken.
✓ Branch 3 (7→9) taken 1 times.
✗ Branch 4 (8→3) not taken.
✗ Branch 5 (8→9) not taken.
1 } while (unlikely(!r && ferror(stream) && errno == EINTR));
10 1 return r;
11 }
12
13 8 int xfputs(const char *restrict str, FILE *restrict stream)
14 {
15 8 int r;
16 16 do {
17 8 r = fputs(str, stream);
18
1/4
✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 8 times.
✗ Branch 2 (5→3) not taken.
✗ Branch 3 (5→6) not taken.
8 } while (unlikely(r == EOF && errno == EINTR));
19 8 return r;
20 }
21
22 8 int xfputc(int c, FILE *stream)
23 {
24 8 int r;
25 16 do {
26 8 r = fputc(c, stream);
27
1/4
✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 8 times.
✗ Branch 2 (5→3) not taken.
✗ Branch 3 (5→6) not taken.
8 } while (unlikely(r == EOF && errno == EINTR));
28 8 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 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
✗ Branch 2 (5→3) not taken.
✗ Branch 3 (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 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
✗ Branch 2 (5→3) not taken.
✗ Branch 3 (5→6) not taken.
1 } while (unlikely(r != 0 && errno == EINTR));
55 1 return r;
56 }
57