]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/failtest.c
failtest: call failtest_exit_check even in non-failing parent.
[ccan] / ccan / failtest / failtest.c
index ad7e0feac1ec00be4b161c545e3e5c497a8cd8f6..ccc89b22f344bbdde2b193f6c33cb91c26f75692 100644 (file)
@@ -455,9 +455,13 @@ static bool should_fail(struct failtest_call *call)
        close(output[0]);
        close(control[0]);
        waitpid(child, &status, 0);
-       if (!WIFEXITED(status))
-               child_fail(out, outlen, "Killed by signal %u: ",
-                          WTERMSIG(status));
+       if (!WIFEXITED(status)) {
+               if (WTERMSIG(status) == SIGUSR1)
+                       child_fail(out, outlen, "Timed out");
+               else
+                       child_fail(out, outlen, "Killed by signal %u: ",
+                                  WTERMSIG(status));
+       }
        /* Child printed failure already, just pass up exit code. */
        if (type == FAILURE) {
                fprintf(stderr, "%.*s", (int)outlen, out);
@@ -976,16 +980,16 @@ void failtest_exit(int status)
 {
        int i;
 
-       if (control_fd == -1) {
-               free_everything();
-               exit(status);
-       }
-
        if (failtest_exit_check) {
                if (!failtest_exit_check(history, history_num))
                        child_fail(NULL, 0, "failtest_exit_check failed\n");
        }
 
+       if (control_fd == -1) {
+               free_everything();
+               exit(status);
+       }
+
        /* Cleanup everything, in reverse order. */
        for (i = history_num - 1; i >= 0; i--)
                if (history[i].cleanup)