summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/rlimits.cc15
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