diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-01 06:45:32 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-01 06:45:32 +0000 |
commit | 5072488a950e6775bf1d02db2d4dfc473007ab75 (patch) | |
tree | 5c8b8a3e53f50cdbb9f13dfa00e4983a0b65aac9 | |
parent | 3138941e682264dd3d22e28370c4ba0205c65231 (diff) | |
download | tor-5072488a950e6775bf1d02db2d4dfc473007ab75.tar tor-5072488a950e6775bf1d02db2d4dfc473007ab75.tar.gz |
make 'make test' exit(1) if a test fails.
svn:r1190
-rw-r--r-- | src/common/test.h | 10 | ||||
-rw-r--r-- | src/or/test.c | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/common/test.h b/src/common/test.h index 017ecf22d..d30a458e0 100644 --- a/src/common/test.h +++ b/src/common/test.h @@ -16,8 +16,11 @@ #define PRETTY_FUNCTION "" #endif +extern int have_failed; + #define test_fail() \ STMT_BEGIN \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): assertion failed.", \ __FILE__, \ __LINE__, \ @@ -28,6 +31,7 @@ #define test_assert(expr) \ STMT_BEGIN \ if(expr) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \ __FILE__, \ __LINE__, \ @@ -40,6 +44,7 @@ STMT_BEGIN \ long v1=(long)(expr1), v2=(long)(expr2); \ if(v1==v2) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\ " (%ld != %ld)\n", \ __FILE__, \ @@ -54,6 +59,7 @@ STMT_BEGIN \ long v1=(long)(expr1), v2=(long)(expr2); \ if(v1!=v2) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\ " (%ld == %ld)\n", \ __FILE__, \ @@ -68,6 +74,7 @@ STMT_BEGIN \ char *v1=(expr1), *v2=(expr2); \ if(!strcmp(v1,v2)) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\ " (\"%s\" != \"%s\")\n", \ __FILE__, \ @@ -82,6 +89,7 @@ STMT_BEGIN \ char *v1=(expr1), *v2=(expr2); \ if(strcmp(v1,v2)) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\ " (\"%s\" == \"%s\")\n", \ __FILE__, \ @@ -96,6 +104,7 @@ STMT_BEGIN \ void *v1=(expr1), *v2=(expr2); \ if(!memcmp(v1,v2,(len))) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \ __FILE__, \ __LINE__, \ @@ -108,6 +117,7 @@ STMT_BEGIN \ void *v1=(expr1), *v2=(expr2); \ if(memcmp(v1,v2,(len))) { printf("."); } else { \ + have_failed = 1; \ printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \ __FILE__, \ __LINE__, \ diff --git a/src/or/test.c b/src/or/test.c index 48978b649..a8b4d90b1 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -15,6 +15,8 @@ #include "or.h" #include "../common/test.h" +int have_failed = 0; + void dump_hex(char *s, int len) { @@ -715,7 +717,11 @@ main(int c, char**v){ puts("\n========================= Directory Formats ==============="); test_dir_format(); puts(""); - return 0; + + if (have_failed) + return 1; + else + return 0; } /* |