xvfb start seems racy
We have had this testsuite result:
TEST: cairo... (pid=4433)
Unable to init server: Could not connect: Connection refused
(/tmp/buildd/gtk+3.0-3.22.11/debian/build/shared/testsuite/gdk/.libs/cairo:4433): Gdk-WARNING **: cannot open display:
FAIL: cairo
TEST: display... (pid=4448)
/display/unset-display: OK
/display/bad-display: OK
PASS: display
etc.
This looks like a Xvfb start race condition, and indeed, looking at the XVFB_START script, which is basically
{ Xvfb :0 & } && DISPLAY=:0 run test
there is no guarantee that Xvfb has finished initializing itself before running the test.
It happens that Xorg supports signalling when it is ready to accept connexions, see SIGUSR1 in Xserver(1). Basically, Debian's xvfb-run script does this:
trap : USR1
( trap '' USR1 ; exec Xvfb ) &
wait || :
which does indeed properly wait for Xvfb's USR1.
Edited by Samuel Thibault