X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ffailtest%2Ftest%2Frun-history.c;h=ef28a3f5a09329db0722bffbc55a0f549f3fed20;hp=3b5220a518a803cbd0d8eb538e0932c1d153d653;hb=e8f0484b7808efe03dbb573563b336d533487e29;hpb=f0002cb9e4f6f403a25ad50252c06694439900f0 diff --git a/ccan/failtest/test/run-history.c b/ccan/failtest/test/run-history.c index 3b5220a5..ef28a3f5 100644 --- a/ccan/failtest/test/run-history.c +++ b/ccan/failtest/test/run-history.c @@ -2,52 +2,9 @@ #include #include #include - -#define printf saved_printf -static int saved_printf(const char *fmt, ...); - -#define fprintf saved_fprintf -static int saved_fprintf(FILE *ignored, const char *fmt, ...); - /* Include the C files directly. */ #include -static char *output = NULL; - -static int saved_vprintf(const char *fmt, va_list ap) -{ - int ret = vsnprintf(NULL, 0, fmt, ap); - int len = 0; - - if (output) - len = strlen(output); - - output = realloc(output, len + ret + 1); - return vsprintf(output + len, fmt, ap); -} - -static int saved_printf(const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = saved_vprintf(fmt, ap); - va_end(ap); - return ret; -} - -static int saved_fprintf(FILE *ignored, const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = saved_vprintf(fmt, ap); - va_end(ap); - return ret; -} - int main(void) { struct failtest_call *call; @@ -60,6 +17,7 @@ int main(void) struct write_call write_call; char buf[20]; unsigned int i; + char *path; /* This is how many tests you plan to run */ plan_tests(47); @@ -87,8 +45,8 @@ int main(void) realloc_call.ret = realloc(malloc_call.ret, 3); realloc_call.ptr = malloc_call.ret; realloc_call.size = 3; - call = add_history(FAILTEST_REALLOC, "run-history.c", - 3, &realloc_call); + call = add_history(FAILTEST_REALLOC, "run-history.c", 3, + &realloc_call); ok1(call->type == FAILTEST_REALLOC); ok1(strcmp(call->file, "run-history.c") == 0); ok1(call->line == 3); @@ -149,18 +107,16 @@ int main(void) for (i = 0; i < history_num; i++) history[i].fail = false; - print_reproduce(); - ok1(strcmp(output, "To reproduce: --failpath=cmeoprw\n") == 0); - free(output); - output = NULL; + path = failpath_string(); + ok1(strcmp(path, "cmeoprw") == 0); + free(path); for (i = 0; i < history_num; i++) history[i].fail = true; - print_reproduce(); - ok1(strcmp(output, "To reproduce: --failpath=CMEOPRW\n") == 0); - free(output); - output = NULL; + path = failpath_string(); + ok1(strcmp(path, "CMEOPRW") == 0); + free(path); return exit_status(); }