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/truncate.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/truncate.cc')
-rw-r--r-- | test/syscalls/linux/truncate.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/syscalls/linux/truncate.cc b/test/syscalls/linux/truncate.cc index 5db0b8276..0f08d9996 100644 --- a/test/syscalls/linux/truncate.cc +++ b/test/syscalls/linux/truncate.cc @@ -181,7 +181,7 @@ TEST(TruncateTest, FtruncateDir) { TEST(TruncateTest, TruncateNonWriteable) { // Make sure we don't have CAP_DAC_OVERRIDE, since that allows the user to // always override write permissions. - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_OVERRIDE, false)); + AutoCapability cap(CAP_DAC_OVERRIDE, false); auto temp_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFileWith( GetAbsoluteTestTmpdir(), absl::string_view(), 0555 /* mode */)); EXPECT_THAT(truncate(temp_file.path().c_str(), 0), @@ -210,7 +210,7 @@ TEST(TruncateTest, FtruncateWithOpath) { // regardless of whether the file permissions allow writing. TEST(TruncateTest, FtruncateWithoutWritePermission) { // Drop capabilities that allow us to override file permissions. - ASSERT_NO_ERRNO(SetCapability(CAP_DAC_OVERRIDE, false)); + AutoCapability cap(CAP_DAC_OVERRIDE, false); // The only time we can open a file with flags forbidden by its permissions // is when we are creating the file. We cannot re-open with the same flags, |