test: don't treat a signal exit as success
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 11 Apr 2019 02:10:32 +0000 (12:10 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 28 May 2019 00:32:08 +0000 (10:32 +1000)
WEXITSTATUS() "should be employed only if WIFEXITED returned true", see
wait(2). If a test failed with an abort, WIFEXITED is false and WEXITSTATUS
is... undefined? and apparently zero, so test case failures would cause a
false postive test result.

This doesn't affect a normal test run because check handles the aborts
correctly, but the valgrind invocation with CK_FORK ended up being handle by
litest. So with the result that any abort during valgrind was a silent success
and if there was a memleak in the same process that exited with a signal, the
memleak would be ignored too.

Fixes #267

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/litest.c

index 0fab117..6941ab9 100644 (file)
@@ -916,7 +916,7 @@ litest_fork_subtests(struct list *tests, int max_forks)
 
        /* parent process only */
        while (wait(&status) != -1 && errno != ECHILD) {
-               if (WEXITSTATUS(status) != 0)
+               if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
                        failed = 1;
        }