Commit 800b9452 authored by Pekka Pessi's avatar Pekka Pessi

tstdef.h: added tst_abort

darcs-hash:20061128220234-65a35-5b05aa1d3b3ba661532e0ce2f341ee493e930611.gz
parent ba5f94f6
...@@ -121,6 +121,8 @@ int main(int argc, char *argv[]) ...@@ -121,6 +121,8 @@ int main(int argc, char *argv[])
for (i = 1; argv[i]; i++) { for (i = 1; argv[i]; i++) {
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
tstflags |= tst_verbatim; tstflags |= tst_verbatim;
else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--abort") == 0)
tstflags |= tst_abort;
else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0)
tstflags &= ~tst_verbatim, o_quiet = 1; tstflags &= ~tst_verbatim, o_quiet = 1;
else if (strcmp(argv[i], "-k") == 0) else if (strcmp(argv[i], "-k") == 0)
......
...@@ -136,7 +136,9 @@ SOFIA_BEGIN_DECLS ...@@ -136,7 +136,9 @@ SOFIA_BEGIN_DECLS
enum { enum {
/** If (TSTFLAGS & tst_verbatim) is non-zero, be verbatim. */ /** If (TSTFLAGS & tst_verbatim) is non-zero, be verbatim. */
tst_verbatim = 1 tst_verbatim = 1,
/** If (TSTFLAGS & tst_abort) is non-zero, abort() when failed. */
tst_abort = 2,
}; };
#ifndef TSTFLAGS #ifndef TSTFLAGS
...@@ -183,6 +185,9 @@ enum { ...@@ -183,6 +185,9 @@ enum {
#define END(flags) (void) tstdef_dummy; } END_(flags) #define END(flags) (void) tstdef_dummy; } END_(flags)
#endif #endif
#define TEST_FAILED(flags) \
((flags) & tst_abort) ? abort() : (void)0; return 1
/** @HIDE */ /** @HIDE */
#define TEST_1_(flags, suite) do { \ #define TEST_1_(flags, suite) do { \
if (flags & tst_verbatim) { \ if (flags & tst_verbatim) { \
...@@ -191,7 +196,8 @@ enum { ...@@ -191,7 +196,8 @@ enum {
if ((suite)) { if (flags & tst_verbatim) \ if ((suite)) { if (flags & tst_verbatim) \
printf("%s: %s%sok: (%s)\n", TSTNAME, #suite); break ; } \ printf("%s: %s%sok: (%s)\n", TSTNAME, #suite); break ; } \
fprintf(stderr, "%s:%u: %s %s%sFAILED: (%s)\n", \ fprintf(stderr, "%s:%u: %s %s%sFAILED: (%s)\n", \
__FILE__, __LINE__, TSTNAME, #suite); fflush(stderr); return 1; } \ __FILE__, __LINE__, TSTNAME, #suite); fflush(stderr); \
TEST_FAILED(flags); } \
while(0) while(0)
/** @HIDE */ /** @HIDE */
...@@ -220,7 +226,7 @@ enum { ...@@ -220,7 +226,7 @@ enum {
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, (size_t)_value, (size_t)_expect); \ #suite, #expect, (size_t)_value, (size_t)_expect); \
fflush(stderr); \ fflush(stderr); \
return 1; \ TEST_FAILED(flags); \
} while(0) } while(0)
/** @HIDE */ /** @HIDE */
...@@ -236,8 +242,9 @@ enum { ...@@ -236,8 +242,9 @@ enum {
} \ } \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %p != %p\n", \ fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %p != %p\n", \
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, _value, _expect); fflush(stderr); return 1; } \ #suite, #expect, _value, _expect); fflush(stderr); \
while(0) TEST_FAILED(flags); \
} while(0)
/** @HIDE */ /** @HIDE */
#define TEST_SIZE_(flags, suite, expect) do { \ #define TEST_SIZE_(flags, suite, expect) do { \
...@@ -251,8 +258,9 @@ enum { ...@@ -251,8 +258,9 @@ enum {
printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \ printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "MOD_ZU" != "MOD_ZU"\n", \ fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "MOD_ZU" != "MOD_ZU"\n", \
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, _value, _expect); fflush(stderr); return 1; } \ #suite, #expect, _value, _expect); fflush(stderr); \
while(0) TEST_FAILED(flags); \
} while(0)
/** @HIDE */ /** @HIDE */
...@@ -268,7 +276,7 @@ enum { ...@@ -268,7 +276,7 @@ enum {
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, (unsigned longlong)_value, \ #suite, #expect, (unsigned longlong)_value, \
(unsigned longlong)_expect); fflush(stderr); \ (unsigned longlong)_expect); fflush(stderr); \
return 1; \ TEST_FAILED(flags); \
} while(0) } while(0)
/** @HIDE */ /** @HIDE */
...@@ -283,7 +291,7 @@ enum { ...@@ -283,7 +291,7 @@ enum {
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %g != %g\n", \ fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %g != %g\n", \
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, _value, _expect); fflush(stderr); \ #suite, #expect, _value, _expect); fflush(stderr); \
return 1; \ TEST_FAILED(flags); \
} while(0) } while(0)
/** @HIDE */ /** @HIDE */
...@@ -302,8 +310,9 @@ enum { ...@@ -302,8 +310,9 @@ enum {
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, \ #suite, #expect, \
_value ? "\"" : "", _value ? _value : "NULL", _value ? "\"" : "", \ _value ? "\"" : "", _value ? _value : "NULL", _value ? "\"" : "", \
_expect); fflush(stderr); return 1; } \ _expect); fflush(stderr); \
while(0) TEST_FAILED(flags); \
} while(0)
/** @HIDE */ /** @HIDE */
#define TEST_M_(flags, suite, expect, len) do { \ #define TEST_M_(flags, suite, expect, len) do { \
...@@ -323,8 +332,9 @@ enum { ...@@ -323,8 +332,9 @@ enum {
"or \"%.*s\" != \"%.*s\"\n", \ "or \"%.*s\" != \"%.*s\"\n", \
__FILE__, __LINE__, TSTNAME, \ __FILE__, __LINE__, TSTNAME, \
#suite, #expect, _len, (char *)_value, _len, (char *)_expect); \ #suite, #expect, _len, (char *)_value, _len, (char *)_expect); \
fflush(stderr); return 1; } \ fflush(stderr); \
while(0) TEST_FAILED(flags); \
} while(0)
/** @HIDE */ /** @HIDE */
#define BEGIN_(flags) \ #define BEGIN_(flags) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment