diff --git a/test/syscalls/linux/chmod.cc b/test/syscalls/linux/chmod.cc index f5ae8f926..3c6bc7234 100644 --- a/test/syscalls/linux/chmod.cc +++ b/test/syscalls/linux/chmod.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -102,7 +103,11 @@ TEST(ChmodTest, FchmodFileWithOpath) { auto file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_PATH)); - ASSERT_THAT(fchmod(fd.get(), 0444), SyscallFailsWithErrno(EBADF)); + // Bionic's implementation of fchmod() uses chmod() when O_PATH is set + // to circumvent the behavior this is testing for. + // Use syscall() here to avoid running through Bionic on Android. + ASSERT_THAT(syscall(SYS_fchmod, fd.get(), 0444), + SyscallFailsWithErrno(EBADF)); } TEST(ChmodTest, FchmodDirWithOpath) { @@ -110,7 +115,8 @@ TEST(ChmodTest, FchmodDirWithOpath) { const auto fd = ASSERT_NO_ERRNO_AND_VALUE(Open(dir.path(), O_DIRECTORY | O_PATH)); - ASSERT_THAT(fchmod(fd.get(), 0444), SyscallFailsWithErrno(EBADF)); + ASSERT_THAT(syscall(SYS_fchmod, fd.get(), 0444), + SyscallFailsWithErrno(EBADF)); } TEST(ChmodTest, FchmodatWithOpath) {