22 #include "my_global.h"
23 #include "my_stacktrace.h"
37 #if defined(_MSC_VER) && ( _MSC_VER == 1310 )
38 #define vsnprintf _vsnprintf
54 static TEST_DATA g_test = { NO_PLAN, 0, 0,
"" };
80 vemit_tap(
int pass,
char const *
fmt, va_list ap)
82 fprintf(
tapout,
"%sok %d%s",
85 (fmt && *fmt) ?
" - " :
"");
108 emit_dir(
const char *dir,
const char *why)
110 fprintf(
tapout,
" # %s %s", dir, why);
128 handle_core_signal(
int signo)
131 #ifdef HAVE_STACKTRACE
132 fprintf(stderr,
"Signal %d thrown, attempting backtrace.\n", signo);
133 my_print_stacktrace(NULL, 0);
135 signal(signo, SIG_DFL);
145 fprintf(
tapout,
"Bail out! ");
146 vfprintf(
tapout, fmt, ap);
159 vfprintf(
tapout, fmt, ap);
170 { SIGQUIT, handle_core_signal },
171 { SIGILL, handle_core_signal },
172 { SIGABRT, handle_core_signal },
173 { SIGFPE, handle_core_signal },
174 { SIGSEGV, handle_core_signal }
176 , { SIGBUS, handle_core_signal }
179 , { SIGXCPU, handle_core_signal }
182 , { SIGXFSZ, handle_core_signal }
185 , { SIGSYS, handle_core_signal }
188 , { SIGTRAP, handle_core_signal }
192 int skip_big_tests= 1;
197 char *
config= getenv(
"MYTAP_CONFIG");
201 skip_big_tests= strcmp(config,
"big");
207 for (i= 0; i <
sizeof(install_signal)/
sizeof(*install_signal); ++
i)
208 signal(install_signal[i].signo, install_signal[i].
handler);
218 fprintf(
tapout,
"1..%d\n", count);
230 va_start(ap, reason);
231 fprintf(
tapout,
"1..0 # skip ");
232 vfprintf(
tapout, reason, ap);
239 ok(
int const pass,
char const *
fmt, ...)
244 if (!pass && *g_test.
todo ==
'\0')
247 vemit_tap(pass, fmt, ap);
249 if (*g_test.
todo !=
'\0')
250 emit_dir(
"todo", g_test.
todo);
259 memset(&ap, 0,
sizeof(ap));
261 if (!pass && *g_test.
todo ==
'\0')
264 vemit_tap(pass, NULL, ap);
266 if (*g_test.
todo !=
'\0')
267 emit_dir(
"todo", g_test.
todo);
273 skip(
int how_many,
char const *fmt, ...)
280 vsnprintf(reason,
sizeof(reason), fmt, ap);
286 while (how_many-- > 0)
289 memset((
char*) &ap, 0,
sizeof(ap));
290 vemit_tap(1, NULL, ap);
291 emit_dir(
"skip", reason);
300 va_start(ap, message);
301 vsnprintf(g_test.
todo,
sizeof(g_test.
todo), message, ap);
315 if (g_test.
plan == NO_PLAN)
320 diag(
"%d tests planned but%s %d executed",