diff options
author | Fabricio Voznika <fvoznika@google.com> | 2021-04-28 16:14:52 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-28 16:22:24 -0700 |
commit | e1149179f3d5d7cbacb160d5bee6b00fe64a08ae (patch) | |
tree | bf1537c80ce62848d5f483212ebbb0e3f49bb540 /test/syscalls/linux/unlink.cc | |
parent | 704728d38fdb3ceaf8dfbfdba84eee183775b90c (diff) |
Remove side effect from test cases
Restore capabilities for tests that need to change them.
PiperOrigin-RevId: 371007047
Diffstat (limited to 'test/syscalls/linux/unlink.cc')
-rw-r--r-- | test/syscalls/linux/unlink.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/syscalls/linux/unlink.cc b/test/syscalls/linux/unlink.cc index 7c301c305..75dcf4465 100644 --- a/test/syscalls/linux/unlink.cc +++ b/test/syscalls/linux/unlink.cc @@ -66,8 +66,8 @@ TEST(UnlinkTest, AtDir) { TEST(UnlinkTest, AtDirDegradedPermissions) { // Drop capabilities that allow us to override file and directory permissions. - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_OVERRIDE, false)); - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_READ_SEARCH, false)); + AutoCapability cap1(CAP_DAC_OVERRIDE, false); + AutoCapability cap2(CAP_DAC_READ_SEARCH, false); auto dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir()); @@ -86,8 +86,8 @@ TEST(UnlinkTest, AtDirDegradedPermissions) { // Files cannot be unlinked if the parent is not writable and executable. TEST(UnlinkTest, ParentDegradedPermissions) { // Drop capabilities that allow us to override file and directory permissions. - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_OVERRIDE, false)); - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_READ_SEARCH, false)); + AutoCapability cap1(CAP_DAC_OVERRIDE, false); + AutoCapability cap2(CAP_DAC_READ_SEARCH, false); auto dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir()); auto file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFileIn(dir.path())); |