X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ffailtest%2Ftest%2Frun-history.c;h=dc5a3f96a4732f16c6232595f2578ea922a6799d;hp=3b5220a518a803cbd0d8eb538e0932c1d153d653;hb=f75f0ca743b7a41fe3b31dbde7d2595ba2e75bbe;hpb=0d66a226c98d0c5b5bced64be3663e52ea6cfb9d diff --git a/ccan/failtest/test/run-history.c b/ccan/failtest/test/run-history.c index 3b5220a5..dc5a3f96 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); @@ -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(); }