00001 #include <stdarg.h>
00002 #include <stdio.h>
00003
00009 static int total = 0;
00010 static int failed = 0;
00011 static int skipped = 0;
00012 static void ok(int predval, const char *fmt, ...)
00013 {
00014 static int testno=1;
00015 va_list ap;
00016 printf("%s %d - ", predval ? "ok" : "not ok", testno++);
00017 va_start(ap, fmt);
00018 vprintf(fmt, ap);
00019 va_end(ap);
00020 printf("\n");
00021 if (!predval)
00022 {
00023 failed++;
00024 }
00025 total++;
00026 }
00027
00028 #if __STDC_VERSION__ >= 199901L
00029 #define get_explanationok(predval, ...) __VA_ARGS__
00030
00031
00032 #define skip(skip_predicate, ...) \
00033 if (skip_predicate) \
00034 { \
00035 ok(1, " # SKIP (" #skip_predicate ") " get_explanation ## __VA_ARGS__); \
00036 skipped++; \
00037 } \
00038 else \
00039 { \
00040 __VA_ARGS__; \
00041 }
00042 #else
00043 #define skip(skip_predicate, okcall) \
00044 if (skip_predicate) \
00045 { \
00046 ok(1, " # SKIP (" #skip_predicate ") "); \
00047 skipped++; \
00048 } \
00049 else \
00050 { \
00051 okcall; \
00052 }
00053 #endif
00054
00055 #define TEST_EXIT_CODE (skipped == total) ? 77 : failed