WvTest::WvTest(const char *_descr, const char *_idstr, MainFunc *_main, int _slowness) : descr(_descr), idstr(pathstrip(_idstr)), main(_main), slowness(_slowness), next(NULL) { if (first) last->next = this; else first = this; last = this; }
// If we aren't running in parallel, we want to output the name of the test // before we run it, so we know what happened if it crashes. If we are // running in parallel, outputting this information in multiple printf()s // can confuse parsers, so we want to output everything in one printf(). // // This function gets called by both start() and check(). If we're not // running in parallel, just print the data. If we're running in parallel, // and we're starting a test, save a copy of the file/line/description until // the test is done and we can output it all at once. // // Yes, this is probably the worst API of all time. static void print_result_str(bool start, const char *_file, int _line, const char *_condstr, const char *result) { static char *file; static char *condstr; static int line; char *cptr; if (start) { if (file) free(file); if (condstr) free(condstr); file = strdup(pathstrip(_file)); condstr = strdup(_condstr); line = _line; for (cptr = condstr; *cptr; cptr++) { if (!isprint((unsigned char)*cptr)) *cptr = '!'; } } if (run_twice) { if (!start) printf(TEST_START_FORMAT "%s\n", file, line, condstr, result); } else { if (start) printf(TEST_START_FORMAT, file, line, condstr); else printf("%s\n", result); } fflush(stdout); if (!start) { if (file) free(file); if (condstr) free(condstr); file = condstr = NULL; } }