5 /* TODO: not thread-safe nor fork-safe */
6 static volatile int test_status
;
8 #define error(...) test_error(__FILE__, __LINE__, __VA_ARGS__)
10 static int test_error(const char *fn
, int l
, const char *s
, ...)
17 n
= snprintf(buf
, sizeof buf
, "ERROR %s:%d: ", fn
, l
);
20 else if (n
>= sizeof buf
)
23 k
= vsnprintf(buf
+ n
, sizeof buf
- n
, s
, ap
);
27 else if (k
>= sizeof buf
- n
) {
29 buf
[n
+ k
- 1] = '\n';
34 return write(1, buf
, n
+ k
);
37 static int test_printf(const char *s
, ...)
45 n
= vsnprintf(buf
, sizeof buf
, s
, ap
);
49 else if (n
>= sizeof buf
) {
56 return write(1, buf
, n
);