[cairo-commit] 2 commits - test/cairo-test-runner.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 25 15:50:24 UTC 2021


 test/cairo-test-runner.c |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 5090dc3f4af6ff7a47f2da6162316e7c3e8962d6
Merge: f5a4ec8ad 446d3972e
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Mar 25 15:50:22 2021 +0000

    Merge branch 'flush-in-tests' into 'master'
    
    test suite: fflush() before fork()
    
    See merge request cairo/cairo!139

commit 446d3972e53dbbaf7dbd47768cbc189a98df1ba5
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Mar 8 13:28:41 2021 +0100

    test suite: fflush() before fork()
    
    Forking a process also duplicates the buffers of FILE*s. Thus, if there
    is pending data, both the parent and the child process will write
    things. This is seldom a good idea.
    
    This issue was not noticed so far since by default the test suite
    already calls fflush() a lot. However, when stdout and stderr are both
    not a tty (according to isatty(1) and isatty(2)), these flushes are
    skipped. The result is that the child process repeat the full output
    from the test suite starting with "Compiled against cairo 1.17.4,
    running on 1.17.4."
    
    To reproduce this problem run: ./cairo-test-suite 2>&1 | cat
    
    Fix this by flushing all the files that I managed to find before fork().
    
    Thanks to Pekka Paalanen for helping me figure this out.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 779addf5b..551a4e072 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -208,6 +208,9 @@ _cairo_test_runner_preamble (cairo_test_runner_t *runner,
     if (! runner->foreground) {
 	pid_t pid;
 
+	/* fork() duplicates output buffers, so clear them */
+	fflush (NULL);
+
 	switch ((pid = fork ())) {
 	case -1: /* error */
 	    return CAIRO_TEST_UNTESTED;
@@ -234,6 +237,9 @@ _cairo_test_runner_draw (cairo_test_runner_t *runner,
     if (! runner->foreground) {
 	pid_t pid;
 
+	/* fork() duplicates output buffers, so clear them */
+	fflush (NULL);
+
 	switch ((pid = fork ())) {
 	case -1: /* error */
 	    return CAIRO_TEST_UNTESTED;


More information about the cairo-commit mailing list