From b0e3d89942503548611989a9f84eaf2db204ede3 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 1 Nov 2023 00:23:58 -0700 Subject: [PATCH] Work around qemu-aarch64 bug Qemu appears to define O_LARGEFILE as having its x86-64 value, which is an easy mistake to make since this is one of the few magic numbers that Linux special-cases for AARCH64. --- test/libc/calls/specialfile_test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/libc/calls/specialfile_test.c b/test/libc/calls/specialfile_test.c index ebc750789..05a70b8cc 100644 --- a/test/libc/calls/specialfile_test.c +++ b/test/libc/calls/specialfile_test.c @@ -46,7 +46,8 @@ void RestoreStdout(void) { TEST(specialfile, devNull) { ASSERT_SYS(0, 3, creat("/dev/null", 0644)); - ASSERT_EQ(O_WRONLY, fcntl(3, F_GETFL) & ~O_LARGEFILE); + // qemu-aarch64 defines o_largefile wrong + ASSERT_EQ(O_WRONLY, fcntl(3, F_GETFL) & ~(O_LARGEFILE | 0x00008000)); ASSERT_SYS(0, 2, write(3, "hi", 2)); ASSERT_SYS(0, 2, pwrite(3, "hi", 2, 0)); ASSERT_SYS(0, 2, pwrite(3, "hi", 2, 2)); @@ -63,7 +64,8 @@ TEST(specialfile, devNull) { TEST(specialfile, devNullRead) { char buf[8] = {0}; ASSERT_SYS(0, 3, open("/dev/null", O_RDONLY)); - ASSERT_EQ(O_RDONLY, fcntl(3, F_GETFL) & ~O_LARGEFILE); + // qemu-aarch64 defines o_largefile wrong + ASSERT_EQ(O_RDONLY, fcntl(3, F_GETFL) & ~(O_LARGEFILE | 0x00008000)); ASSERT_SYS(0, 0, read(3, buf, 8)); ASSERT_SYS(0, 0, close(3)); }