git » libfiu » master » tree

[master] / tests / generated / tests / fprintf.conf

[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);

# 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