diff options
author | Kevin Krakauer <krakauer@google.com> | 2019-04-10 12:35:43 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-10 12:36:45 -0700 |
commit | f7aff0aaa4320505933df838cf5b551b69d5e513 (patch) | |
tree | f773a8942f4f025d370ee0d8c0e711944f168f4c /test/syscalls | |
parent | 0a0619216ec9ca96c181dd69d9bf31e7762090cb (diff) |
Allow threads with CAP_SYS_RESOURCE to raise hard rlimits.
PiperOrigin-RevId: 242919489
Change-Id: Ie3267b3bcd8a54b54bc16a6556369a19e843376f
Diffstat (limited to 'test/syscalls')
-rw-r--r-- | test/syscalls/linux/rlimits.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/syscalls/linux/rlimits.cc b/test/syscalls/linux/rlimits.cc index dc31bad9a..5a6174d99 100644 --- a/test/syscalls/linux/rlimits.cc +++ b/test/syscalls/linux/rlimits.cc @@ -25,15 +25,12 @@ namespace { TEST(RlimitTest, SetRlimitHigher) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_RESOURCE))); - SKIP_IF(!IsRunningOnGvisor()); struct rlimit rl = {}; EXPECT_THAT(getrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); - // TODO: Even with CAP_SYS_RESOURCE, gVisor does not allow - // setting a higher rlimit. rl.rlim_max++; - EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EPERM)); + EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); } TEST(RlimitTest, UnprivilegedSetRlimit) { @@ -56,6 +53,16 @@ TEST(RlimitTest, UnprivilegedSetRlimit) { EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EPERM)); } +TEST(RlimitTest, SetSoftRlimitAboveHard) { + SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_RESOURCE))); + + struct rlimit rl = {}; + EXPECT_THAT(getrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); + + rl.rlim_cur = rl.rlim_max + 1; + EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EINVAL)); +} + } // namespace } // namespace testing |