test-utils-glib: Try to emit TAP diagnostics before aborting
authorSimon McVittie <smcv@collabora.com>
Wed, 27 Sep 2017 12:14:36 +0000 (13:14 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 27 Sep 2017 13:45:34 +0000 (14:45 +0100)
commit5aca0fc1a5bc0b7918839bc692747b1f57c3285c
treecfd6face9823231e7ddcefb02caf556119a798bc
parent1330bd2cd3307615320c66f55a42c84242d54d46
test-utils-glib: Try to emit TAP diagnostics before aborting

We can't use normal I/O in a signal handler, so resort to write().

"Bail out!" is a special syntactic token in TAP. If I artifically force
the tests to time out by reducing timeouts and increasing the number of
operations, I get results like this:

ERROR: test-sd-activation - Bail out! Test timed out (GLib main loop timeout callback reached)
ERROR: test-refs - Bail out! Test timed out (SIGALRM received)

which is a lot easier to understand than "Not enough tests run" or
"nonzero exit status". The differing output is because test-sd-activation
iterates the main loop, whereas test-refs just blocks (it is joining a
series of worker threads, each of which is spamming refcount operations).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103009
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Use STDOUT_FILENO as per Philip's review]
Signed-off-by: Simon McVittie <smcv@collabora.com>
test/test-utils-glib.c