]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/test/run-history.c
failtest: use ccan/time
[ccan] / ccan / failtest / test / run-history.c
index 3b5220a518a803cbd0d8eb538e0932c1d153d653..ef28a3f5a09329db0722bffbc55a0f549f3fed20 100644 (file)
@@ -2,52 +2,9 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <ccan/tap/tap.h>
-
-#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 <ccan/failtest/failtest.c>
 
-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();
 }