diff options
author | Zach Koopmans <zkoopmans@google.com> | 2019-01-10 09:43:43 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-10 09:44:45 -0800 |
commit | 7f8de3bf92decbd745a4bc4e8aebf1ba1159ed4b (patch) | |
tree | c667c9bd31a29cec2ddce86ef0b6128fee2defc2 /test/syscalls/linux/mlock.cc | |
parent | 9270d940eb1a6e31587c34f4644189f3b2c002e1 (diff) |
Fixing select call to not enforce RLIMIT_NOFILE.
Removing check to RLIMIT_NOFILE in select call.
Adding unit test to select suite to document behavior.
Moving setrlimit class from mlock to a util file for reuse.
Fixing flaky test based on comments from Jamie.
PiperOrigin-RevId: 228726131
Change-Id: Ie9dbe970bbf835ba2cca6e17eec7c2ee6fadf459
Diffstat (limited to 'test/syscalls/linux/mlock.cc')
-rw-r--r-- | test/syscalls/linux/mlock.cc | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/test/syscalls/linux/mlock.cc b/test/syscalls/linux/mlock.cc index 1d93bff58..a492b2404 100644 --- a/test/syscalls/linux/mlock.cc +++ b/test/syscalls/linux/mlock.cc @@ -12,18 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include <errno.h> -#include <string.h> #include <sys/mman.h> #include <sys/resource.h> #include <sys/syscall.h> #include <unistd.h> +#include <cerrno> +#include <cstring> #include "gmock/gmock.h" #include "test/util/capability_util.h" #include "test/util/cleanup.h" #include "test/util/memory_util.h" #include "test/util/multiprocess_util.h" +#include "test/util/rlimit_util.h" #include "test/util/test_util.h" using ::testing::_; @@ -58,20 +59,6 @@ bool IsPageMlocked(uintptr_t addr) { return true; } -PosixErrorOr<Cleanup> ScopedSetSoftRlimit(int resource, rlim_t newval) { - struct rlimit old_rlim; - if (getrlimit(resource, &old_rlim) != 0) { - return PosixError(errno, "getrlimit failed"); - } - struct rlimit new_rlim = old_rlim; - new_rlim.rlim_cur = newval; - if (setrlimit(resource, &new_rlim) != 0) { - return PosixError(errno, "setrlimit failed"); - } - return Cleanup([resource, old_rlim] { - TEST_PCHECK(setrlimit(resource, &old_rlim) == 0); - }); -} TEST(MlockTest, Basic) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(CanMlock())); |