mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 12:31:52 -04:00
selftests/nolibc: fix test_file_stream() on musl libc
fwrite() modifying errno is non-standard.
Only validate this behavior on those libc implementations which
implement it.
Fixes: a5f00be9b3 ("tools/nolibc: Add a simple test for writing to a FILE and reading it back")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
@@ -74,6 +74,14 @@ static const int is_nolibc =
|
||||
#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 */
|
||||
@@ -866,7 +874,7 @@ int test_file_stream(void)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user