From 943bc9bb02212649a83ec32152299d50d34226e6 Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 21 Feb 1999 18:07:25 +0000 Subject: 1999-02-23 Ross Johnson * Makefile: Now actually runs the tests. * tests.h: Define our own assert macro. The Mingw32 version pops up a dialog but we want to run non-interactively. * equal1.c: use assert a little more directly so that it prints the actual call statement. * exit1.c: Modify to return 0 on success, 1 on failure. --- tests/test.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'tests/test.h') diff --git a/tests/test.h b/tests/test.h index 0beeaab..23bcd48 100644 --- a/tests/test.h +++ b/tests/test.h @@ -4,11 +4,12 @@ * Useful definitions and declarations for tests. */ -#include - #ifndef _PTHREAD_TEST_H_ #define _PTHREAD_TEST_H_ +#include +#include + char * error_string[] = { "ZERO", "EPERM", @@ -55,4 +56,27 @@ char * error_string[] = { "EILSEQ", }; +/* + * The Mingw32 assert macro calls the CRTDLL _assert function + * which pops up a dialog. We want to run in batch mode so + * we define our own assert macro. + */ +#ifdef NDEBUG + +#define assert(e) ((void)0) + +#else /* NDEBUG */ + +#ifdef assert +# undef assert +#endif + +#define assert(e) \ + ((e) ? (void) 0 : \ + (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ + #e, __FILE__, (int) __LINE__), exit(1))) + +#endif /* NDEBUG */ + + #endif -- cgit v1.2.3