When running the test suite in full fork mode, the error messages are in the quite verbose output and searching for them is annoying. Work around this by opening a pipe to each subprocess and writing the failed test cases to that pipe. When all tests have finished, print the messages to stdout. This way the failures are always the last thing printed by the test suite.
Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- test/litest.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/test/litest.c b/test/litest.c index 05726726..d4874d43 100644 --- a/test/litest.c +++ b/test/litest.c @@ -787,7 +787,7 @@ litest_free_test_list(struct list *tests) } static int -litest_run_suite(struct list *tests, int which, int max) +litest_run_suite(struct list *tests, int which, int max, int error_fd) { int failed = 0; SRunner *sr = NULL; @@ -865,6 +865,19 @@ litest_run_suite(struct list *tests, int which, int max) srunner_run_all(sr, CK_ENV); failed = srunner_ntests_failed(sr); + if (failed) { + TestResult **trs; + + trs = srunner_failures(sr); + for (int i = 0; i < failed; i++) { + dprintf(error_fd, + ":: Failure: %s:%d:%s\n", + tr_lfile(trs[i]), + tr_lno(trs[i]), + tr_tcname(trs[i])); + } + free(trs); + } srunner_free(sr); out: list_for_each_safe(n, tmp, &testnames, node) { @@ -882,14 +895,29 @@ litest_fork_subtests(struct list *tests, int max_forks) int status; pid_t pid; int f; + int pipes[max_forks]; for (f = 0; f < max_forks; f++) { + int rc; + int pipefd[2]; + + rc = pipe2(pipefd, O_NONBLOCK|O_NONBLOCK); + assert(rc != -1); + pid = fork(); if (pid == 0) { - failed = litest_run_suite(tests, f, max_forks); + close(pipefd[0]); + failed = litest_run_suite(tests, + f, + max_forks, + pipefd[1]); + litest_free_test_list(&all_tests); exit(failed); /* child always exits here */ + } else { + pipes[f] = pipefd[0]; + close(pipefd[1]); } } @@ -899,6 +927,18 @@ litest_fork_subtests(struct list *tests, int max_forks) failed = 1; } + for (f = 0; f < max_forks; f++) { + char buf[1024] = {0}; + int rc; + + while ((rc = read(pipes[f], buf, sizeof(buf) - 1)) > 0) { + buf[rc] = '\0'; + fprintf(stderr, "%s", buf); + } + + close(pipes[f]); + } + return failed; } @@ -923,7 +963,7 @@ litest_run(int argc, char **argv) litest_setup_sighandler(SIGINT); if (jobs == 1) - failed = litest_run_suite(&all_tests, 1, 1); + failed = litest_run_suite(&all_tests, 1, 1, STDERR_FILENO); else failed = litest_fork_subtests(&all_tests, jobs); -- 2.13.6 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel