aboutsummaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-29 00:35:12 +0200
committerMattias Andrée <maandree@kth.se>2018-08-29 00:35:12 +0200
commitac15d5da43275997dc871fc1128c6d01c3c5a4cc (patch)
tree0ff763e83f1541610329a825079eb78a8b3a9b87 /test.c
parentWarn about unran tests under valgrind (diff)
downloadlibsimple-ac15d5da43275997dc871fc1128c6d01c3c5a4cc.tar.gz
libsimple-ac15d5da43275997dc871fc1128c6d01c3c5a4cc.tar.bz2
libsimple-ac15d5da43275997dc871fc1128c6d01c3c5a4cc.tar.xz
Add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--test.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/test.c b/test.c
index edc3d15..4d16ebb 100644
--- a/test.c
+++ b/test.c
@@ -8,6 +8,8 @@
#undef memdup
+char *argv0 = (char []){"<test>"};
+
size_t alloc_fail_in = 0;
int exit_real = 0;
int exit_ok = 0;
@@ -16,6 +18,7 @@ jmp_buf exit_jmp;
char stderr_buf[8 << 10];
size_t stderr_n = 0;
int stderr_real = 0;
+int stderr_ok = 0;
static int custom_malloc = 0;
@@ -274,9 +277,10 @@ vfprintf(FILE *restrict stream, const char *restrict format, va_list ap)
n = (size_t)r;
buf = alloca(n + 1);
n = vsnprintf(buf, n + 1, format, ap);
- if (fileno(stream) != STDERR_FILENO) {
+ if (fileno(stream) != STDERR_FILENO || stderr_real) {
fwrite(buf, 1, n, stream);
} else {
+ assert(stderr_ok);
assert(stderr_n + n <= sizeof(stderr_buf));
memcpy(&stderr_buf[stderr_n], buf, n);
stderr_n += n;