]> git.ozlabs.org Git - ccan/commitdiff
failtest: fix silent exit when top-level return FAIL_PROBE
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 1 Aug 2011 08:29:09 +0000 (17:59 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 1 Aug 2011 08:29:09 +0000 (17:59 +0930)
We were missing failed tests: if the top-level returns FAIL_PROBE, we would
exit; this should only apply to children.

ccan/failtest/failtest.c

index d9a0849daf600d1518514df57b74c71be1b78709..91420dc699b9c7fdf7f40171b1e39d5fbb7d7ef3 100644 (file)
@@ -362,7 +362,7 @@ static bool should_fail(struct failtest_call *call)
        struct saved_file *files;
 
        /* Are we probing? */
        struct saved_file *files;
 
        /* Are we probing? */
-       if (probe_count && --probe_count == 0)
+       if (probe_count && --probe_count == 0 && control_fd != -1)
                failtest_cleanup(true, 0);
 
        if (call == &unrecorded_call)
                failtest_cleanup(true, 0);
 
        if (call == &unrecorded_call)
@@ -412,17 +412,22 @@ static bool should_fail(struct failtest_call *call)
                switch (failtest_hook(history, history_num)) {
                case FAIL_OK:
                        break;
                switch (failtest_hook(history, history_num)) {
                case FAIL_OK:
                        break;
+               case FAIL_PROBE:
+                       /* Already down probe path?  Stop now. */
+                       if (!probe_count) {
+                               /* FIXME: We should run *parent* and
+                                * run probe until calls match up again. */
+                               probe_count = 3;
+                               break;
+                       } else {
+                               /* Child should give up now. */
+                               if (control_fd != -1)
+                                       failtest_cleanup(true, 0);
+                               /* Parent, don't fail again. */
+                       }
                case FAIL_DONT_FAIL:
                        call->fail = false;
                        return false;
                case FAIL_DONT_FAIL:
                        call->fail = false;
                        return false;
-               case FAIL_PROBE:
-                       /* Already down probe path?  Stop now. */
-                       if (probe_count)
-                               failtest_cleanup(true, 0);
-                       /* FIXME: We should run *parent* and run probe until
-                        * calls match up again. */
-                       probe_count = 3;
-                       break;
                default:
                        abort();
                }
                default:
                        abort();
                }