aboutsummaryrefslogtreecommitdiffstats
path: root/test.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-28 14:18:41 +0200
committerMattias Andrée <maandree@kth.se>2018-08-28 14:18:41 +0200
commitbad369a06217cd1588c289a75b6a1c17d44119b3 (patch)
tree626b3847268037f2621157a25bfbabb874bb88dc /test.h
parentMake it possible to force all memory allocation functions to fail in tests (diff)
downloadlibsimple-bad369a06217cd1588c289a75b6a1c17d44119b3.tar.gz
libsimple-bad369a06217cd1588c289a75b6a1c17d44119b3.tar.bz2
libsimple-bad369a06217cd1588c289a75b6a1c17d44119b3.tar.xz
Replace exit and fprintf
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test.h')
-rw-r--r--test.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/test.h b/test.h
index 5281cbc..e68c9c1 100644
--- a/test.h
+++ b/test.h
@@ -5,10 +5,21 @@
do {\
if (EXPR)\
break;\
+ stderr_real = 1;\
fprintf(stderr, "Failed at %s:%i: %s\n", __FILE__, __LINE__, #EXPR);\
+ exit_real = 1;\
exit(1);\
} while (0)
+#define subassert(EXPR)\
+ do {\
+ if (EXPR)\
+ break;\
+ stderr_real = 1;\
+ fprintf(stderr, "Failed at %s:%i: %s\n", __FILE__, __LINE__, #EXPR);\
+ return 0;\
+ } while (0)
+
struct allocinfo {
void *real_beginning;
@@ -22,6 +33,13 @@ struct allocinfo {
extern size_t alloc_fail_in;
+extern int exit_real;
+extern int exit_ok;
+extern int exit_status;
+extern jmp_buf exit_jmp;
+extern char stderr_buf[8 << 10];
+extern size_t stderr_n;
+extern int stderr_real;
size_t get_pagesize(void);