diff options
| author | Thomas Weißschuh <linux@weissschuh.net> | 2026-03-18 18:00:33 +0100 |
|---|---|---|
| committer | Thomas Weißschuh <linux@weissschuh.net> | 2026-03-20 17:44:06 +0100 |
| commit | 8ba600aa577f73cc551747fdf121afc7d04afcea (patch) | |
| tree | a9c69d2d7a7bf69a3f8fcf3ce0644d7d8c0fb015 | |
| parent | 55f1d6a9d6780e779e882a4d2d1b3db311835798 (diff) | |
| download | linux-8ba600aa577f73cc551747fdf121afc7d04afcea.tar.gz linux-8ba600aa577f73cc551747fdf121afc7d04afcea.zip | |
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: 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>
| -rw-r--r-- | tools/testing/selftests/nolibc/nolibc-test.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1b9d3b2e2491..1aca8468eac4 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -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; } |
