git » libfiu » commit 870a90e

tests/generated: fprintf() test should successfuly flush

author Alberto Bertogli
2019-09-29 11:00:12 UTC
committer Alberto Bertogli
2019-10-05 10:12:44 UTC
parent 20ea5e85ec63e3dedd6904e103fb2e56b46840cf

tests/generated: fprintf() test should successfuly flush

Gianfranco Costamagna (locutusofborg@debian.org) reported that the
automatic builds in Ubuntu have been failing on the fprintf() generated
tests, on all platforms.  The tests pass the successful case, but fail
to invoke the callback.

This is very suspicious. Gianfranco had a theory about /dev/null writes,
and while looking into it, I noticed that the libc buffering might be
making the success case pass even if the file can't be written to.

So this patch forces the success case to do a flush, to try to identify
these situations early.

tests/generated/tests/fprintf.conf +6 -1

diff --git a/tests/generated/tests/fprintf.conf b/tests/generated/tests/fprintf.conf
index f8ed16e..c5f082b 100644
--- a/tests/generated/tests/fprintf.conf
+++ b/tests/generated/tests/fprintf.conf
@@ -4,7 +4,12 @@ fp: posix/stdio/sp/fprintf
 include: stdio.h
 prep: int r; FILE *fp = fopen("/dev/null", "w");
 call: r = fprintf(fp, "%%d\n", 1234);
-success_cond: r == 5 && ferror(fp) == 0
+
+# The success condition is a bit more extensive, and in particular checks that
+# we're able to flush to the file. This reduces the possibility of the
+# buffering covering for I/O errors that would make the test flaky.
+success_cond: fp != NULL && r == 5 && ferror(fp) == 0 && fflush(fp) == 0
+
 failure_cond: r == -1 && ferror(fp) != 0
 errno_on_fail: EIO