fwrite() modifying errno is non-standard.
Only validate this behavior on those libc implementations which
implement it.
Fixes: a5f00be9b3b0 ("tools/nolibc: Add a simple test for writing to a FILE and reading it back")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
#endif
;
+static const int is_glibc =
+#ifdef __GLIBC__
+ 1
+#else
+ 0
+#endif
+;
+
/* definition of a series of tests */
struct test {
const char *name; /* test name */
errno = 0;
r = fwrite("foo", 1, 3, f);
- if (r != 0 || errno != EBADF) {
+ if (r != 0 || ((is_nolibc || is_glibc) && errno != EBADF)) {
fclose(f);
return -1;
}