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/prctl.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/prctl.cc')
-rw-r--r-- | test/syscalls/linux/prctl.cc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/test/syscalls/linux/prctl.cc b/test/syscalls/linux/prctl.cc index f675dc430..19a57d353 100644 --- a/test/syscalls/linux/prctl.cc +++ b/test/syscalls/linux/prctl.cc @@ -184,10 +184,8 @@ TEST(PrctlTest, PDeathSig) { // This test is to validate that calling prctl with PR_SET_MM without the // CAP_SYS_RESOURCE returns EPERM. TEST(PrctlTest, InvalidPrSetMM) { - if (ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_RESOURCE))) { - ASSERT_NO_ERRNO(SetCapability(CAP_SYS_RESOURCE, - false)); // Drop capability to test below. - } + // Drop capability to test below. + AutoCapability cap(CAP_SYS_RESOURCE, false); ASSERT_THAT(prctl(PR_SET_MM, 0, 0, 0, 0), SyscallFailsWithErrno(EPERM)); } |