X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ffailtest%2Ffailtest.c;h=91420dc699b9c7fdf7f40171b1e39d5fbb7d7ef3;hb=7141adfed692b149bfbaccf19e2ab258774810fb;hp=2471510614a070c6c404e04d51789bbc28a8536e;hpb=4601063b15ad7a1896135bf91bbcb7cabfbc9000;p=ccan diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index 24715106..91420dc6 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -1,3 +1,4 @@ +/* Licensed under LGPL - see LICENSE file for details */ #include "config.h" #include #include @@ -361,7 +362,7 @@ static bool should_fail(struct failtest_call *call) 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) @@ -411,17 +412,22 @@ static bool should_fail(struct failtest_call *call) 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_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(); }