diff options
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r-- | test/syscalls/linux/rename.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/syscalls/linux/rename.cc b/test/syscalls/linux/rename.cc index 22c8c19cf..b1a813de0 100644 --- a/test/syscalls/linux/rename.cc +++ b/test/syscalls/linux/rename.cc @@ -424,6 +424,20 @@ TEST(RenameTest, SysfsPathEndingWithDots) { SyscallFailsWithErrno(EBUSY)); } +TEST(RenameTest, SysfsFileToSelf) { + // If a non-root user tries to rename inside /sys then we get EPERM. + SKIP_IF(geteuid() != 0); + std::string const path = "/sys/devices/system/cpu/online"; + EXPECT_THAT(rename(path.c_str(), path.c_str()), SyscallSucceeds()); +} + +TEST(RenameTest, SysfsDirectoryToSelf) { + // If a non-root user tries to rename inside /sys then we get EPERM. + SKIP_IF(geteuid() != 0); + std::string const path = "/sys/devices"; + EXPECT_THAT(rename(path.c_str(), path.c_str()), SyscallSucceeds()); +} + } // namespace } // namespace testing |