Skip to content

Commit 57ce8a8

Browse files
t-8chgregkh
authored andcommitted
selftests/nolibc: fix test_file_stream() on musl libc
[ Upstream commit 8ba600a ] fwrite() modifying errno is non-standard. Only validate this behavior on those libc implementations which implement it. Fixes: a5f00be ("tools/nolibc: Add a simple test for writing to a FILE and reading it back") Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e84acaf commit 57ce8a8

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tools/testing/selftests/nolibc/nolibc-test.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ static const int is_nolibc =
7474
#endif
7575
;
7676

77+
static const int is_glibc =
78+
#ifdef __GLIBC__
79+
1
80+
#else
81+
0
82+
#endif
83+
;
84+
7785
/* definition of a series of tests */
7886
struct test {
7987
const char *name; /* test name */
@@ -866,7 +874,7 @@ int test_file_stream(void)
866874

867875
errno = 0;
868876
r = fwrite("foo", 1, 3, f);
869-
if (r != 0 || errno != EBADF) {
877+
if (r != 0 || ((is_nolibc || is_glibc) && errno != EBADF)) {
870878
fclose(f);
871879
return -1;
872880
}

0 commit comments

Comments
 (0)