Fix crash on app list start page keyboard navigation with <4 apps.
[chromium-blink-merge.git] / sandbox / linux / services / resource_limits_unittests.cc
blob910c740f7bc0b75a3870c8473b8602a60c198a6e
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sandbox/linux/services/resource_limits.h"
7 #include <errno.h>
8 #include <sys/resource.h>
9 #include <sys/time.h>
10 #include <unistd.h>
12 #include "base/logging.h"
13 #include "sandbox/linux/tests/test_utils.h"
14 #include "sandbox/linux/tests/unit_tests.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 namespace sandbox {
19 namespace {
21 // Fails on Android: crbug.com/459158
22 #if !defined(OS_ANDROID)
23 #define MAYBE_NoFork DISABLE_ON_ASAN(NoFork)
24 #else
25 #define MAYBE_NoFork DISABLED_NoFork
26 #endif // OS_ANDROID
28 // Not being able to fork breaks LeakSanitizer, so disable on
29 // all ASAN builds.
30 SANDBOX_TEST(ResourceLimits, MAYBE_NoFork) {
31 // Make sure that fork will fail with EAGAIN.
32 SANDBOX_ASSERT(ResourceLimits::Lower(RLIMIT_NPROC, 0));
33 errno = 0;
34 pid_t pid = fork();
35 // Reap any child if fork succeeded.
36 TestUtils::HandlePostForkReturn(pid);
37 SANDBOX_ASSERT_EQ(-1, pid);
38 CHECK_EQ(EAGAIN, errno);
41 } // namespace
43 } // namespace sandbox