[libc-commits] [libc] [libc] Relax read errno check (PR #215053)
via libc-commits
libc-commits at lists.llvm.org
Sat Aug 8 21:21:36 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Pavel Labath (labath)
<details>
<summary>Changes</summary>
read_write_test was failing on the libc-arm32-qemu-debian-dbg bot due to a different errno number. Even though the test has a qemu branch, it did not kick in because the bot does not set CMAKE_CROSSCOMPILING_EMULATOR (I assume the tests get run via binfmt_misc).
While we could fix this in the bot config, and the different error *might* be considered a qemu bug, I don't think this is particularly relevant for this test, as we're merely forwarding the error number from the kernel (as such, the errno expectation is more of a test for the kernel that for libc). I think this okay to relax the check to expect one of the two reasonable error messages.
---
Full diff: https://github.com/llvm/llvm-project/pull/215053.diff
2 Files Affected:
- (modified) libc/config/linux/arm/entrypoints.txt (+1)
- (modified) libc/test/src/unistd/read_write_test.cpp (+5-5)
``````````diff
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 219364b906857..9a56ab5ee80b6 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -248,6 +248,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.unistd.lseek
libc.src.unistd.pipe
libc.src.unistd.pipe2
+ libc.src.unistd.read
libc.src.unistd.readlink
libc.src.unistd.readlinkat
libc.src.unistd.rmdir
diff --git a/libc/test/src/unistd/read_write_test.cpp b/libc/test/src/unistd/read_write_test.cpp
index 7b700154d2f30..de46d3fbb23fd 100644
--- a/libc/test/src/unistd/read_write_test.cpp
+++ b/libc/test/src/unistd/read_write_test.cpp
@@ -43,15 +43,15 @@ TEST_F(LlvmLibcUniStd, WriteFails) {
}
TEST_F(LlvmLibcUniStd, ReadFails) {
+ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::any_of;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
-#ifdef LIBC_TEST_UNDER_EMULATOR
- // QEMU returns EFAULT instead of EBADF when reading into a nullptr.
char buf[1];
EXPECT_THAT(LIBC_NAMESPACE::read(-1, buf, 1), Fails<ssize_t>(EBADF));
-#else
- EXPECT_THAT(LIBC_NAMESPACE::read(-1, nullptr, 1), Fails<ssize_t>(EBADF));
-#endif
EXPECT_THAT(LIBC_NAMESPACE::read(0, reinterpret_cast<void *>(-1), 1),
Fails<ssize_t>(EFAULT));
+ EXPECT_THAT(LIBC_NAMESPACE::read(-1, nullptr, 1),
+ Fails<ssize_t>(any_of(
+ EBADF, EFAULT)) // Depending on what gets checked first.
+ );
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/215053
More information about the libc-commits
mailing list