summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/poll.cc
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-04-17 12:56:23 -0700
committerShentubot <shentubot@google.com>2019-04-17 12:57:40 -0700
commitc8cee7108f1a1b37e89961c6dd69ccab97952c86 (patch)
tree57565d1df112795354487f636d42b9bca5a231e2 /test/syscalls/linux/poll.cc
parent08d99c5fbea76ecc92038280387d24ecdf7ed814 (diff)
Use FD limit and file size limit from host
FD limit and file size limit is read from the host, instead of using hard-coded defaults, given that they effect the sandbox process. Also limit the direct cache to use no more than half if the available FDs. PiperOrigin-RevId: 244050323 Change-Id: I787ad0fdf07c49d589e51aebfeae477324fe26e6
Diffstat (limited to 'test/syscalls/linux/poll.cc')
-rw-r--r--test/syscalls/linux/poll.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/syscalls/linux/poll.cc b/test/syscalls/linux/poll.cc
index 7a6a39444..67a86cc22 100644
--- a/test/syscalls/linux/poll.cc
+++ b/test/syscalls/linux/poll.cc
@@ -255,7 +255,16 @@ TEST_F(PollTest, Nfds) {
// Stash value of RLIMIT_NOFILES.
struct rlimit rlim;
TEST_PCHECK(getrlimit(RLIMIT_NOFILE, &rlim) == 0);
+
+ // gVisor caps the number of FDs that epoll can use beyond RLIMIT_NOFILE.
+ constexpr rlim_t gVisorMax = 1048576;
+ if (rlim.rlim_cur > gVisorMax) {
+ rlim.rlim_cur = gVisorMax;
+ TEST_PCHECK(setrlimit(RLIMIT_NOFILE, &rlim) == 0);
+ }
+
rlim_t max_fds = rlim.rlim_cur;
+ LOG(INFO) << "Using limit: " << max_fds;
// Create an eventfd. Since its value is initially zero, it is writable.
FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD());