git » libfiu » commit 426569a

tests: Skip fprintf() test if it can't be wrapped

author Alberto Bertogli
2022-08-28 15:05:33 UTC
committer Alberto Bertogli
2022-08-28 15:12:55 UTC
parent 902b282375587352dccf6467fa740330d6900e54

tests: Skip fprintf() test if it can't be wrapped

Under some conditions, fprintf() is declared as a macro. And when
_FORTIFY_SOURCE is set, it can be declared in the headers and forced to
be inlined. In both cases, the preload can't work because the function
is never looked up outside the binary.

This has caused some test failures in the Ubuntu packaging automated
builds, which builds the libfiu packages using fortified flags.

Thanks to Gianfranco Costamagna <locutusofborg@debian.org> for
identifying and reporting this issue.

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

diff --git a/tests/generated/tests/fprintf.conf b/tests/generated/tests/fprintf.conf
index c5f082b..28b2d73 100644
--- a/tests/generated/tests/fprintf.conf
+++ b/tests/generated/tests/fprintf.conf
@@ -2,6 +2,12 @@
 [fprintf]
 fp: posix/stdio/sp/fprintf
 include: stdio.h
+
+# In some situations/environments, fprintf can be a macro instead of a
+# function. And when _FORTIFY_SOURCE is set, it is forced inline and defined
+# in the headers, which prevents it from being wrapped.
+if: (!defined fprintf) && (!defined _FORTIFY_SOURCE)
+
 prep: int r; FILE *fp = fopen("/dev/null", "w");
 call: r = fprintf(fp, "%%d\n", 1234);