[compiler-rt] [rtsan] Fix ioctl args in interceptor test (PR #154959)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 22 07:26:38 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: None (davidtrevelyan)
<details>
<summary>Changes</summary>
This PR:
- Updates ioctl interceptor test to pass in a required third argument (for `FIONREAD`)
- Introduces a new test for ioctl call without a third argument (for `FIONCLEX`)
- Updates other ioctl test to check returned result
- Formats two outstanding lines to allow auto-formatting the entire test file without introducing diffs elsewhere
---
Full diff: https://github.com/llvm/llvm-project/pull/154959.diff
1 Files Affected:
- (modified) compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp (+14-5)
``````````diff
diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
index 9b684e36e3b35..45c419b30091c 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -462,7 +462,7 @@ TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
ASSERT_THAT(fd, Ne(-1));
auto Func = [fd]() {
- struct flock lock{};
+ struct flock lock {};
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
@@ -753,15 +753,24 @@ TEST_F(RtsanOpenedFileTest, RewindDieWhenRealtime) {
#endif
TEST_F(RtsanOpenedFileTest, IoctlDiesWhenRealtime) {
- auto Func = [this]() { ioctl(GetOpenFd(), FIONREAD); };
+ auto Func = [this]() {
+ int arg{};
+ ioctl(GetOpenFd(), FIONREAD, &arg);
+ EXPECT_THAT(arg, Ge(0));
+ };
ExpectRealtimeDeath(Func, "ioctl");
ExpectNonRealtimeSurvival(Func);
}
+TEST_F(RtsanOpenedFileTest, IoctlBehavesWithoutOutputArg) {
+ const int result = ioctl(GetOpenFd(), FIONCLEX);
+ EXPECT_THAT(result, Ne(-1));
+}
+
TEST_F(RtsanOpenedFileTest, IoctlBehavesWithOutputArg) {
int arg{};
- ioctl(GetOpenFd(), FIONREAD, &arg);
-
+ const int result = ioctl(GetOpenFd(), FIONREAD, &arg);
+ ASSERT_THAT(result, Ne(-1));
EXPECT_THAT(arg, Ge(0));
}
@@ -802,7 +811,7 @@ TEST(TestRtsanInterceptors, IoctlBehavesWithOutputPointer) {
GTEST_SKIP();
}
- struct ifreq ifr{};
+ struct ifreq ifr {};
strncpy(ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ - 1);
int retval = ioctl(sock, SIOCGIFADDR, &ifr);
``````````
</details>
https://github.com/llvm/llvm-project/pull/154959
More information about the llvm-commits
mailing list