Chromium Code Reviews| Index: base/process/process_unittest.cc |
| diff --git a/base/process/process_unittest.cc b/base/process/process_unittest.cc |
| index 5180f64c55a8111a5db6456570d1ac4d38f2776e..59b3bb0fb22485e33b3a33bfd19159b34b53b728 100644 |
| --- a/base/process/process_unittest.cc |
| +++ b/base/process/process_unittest.cc |
| @@ -7,10 +7,18 @@ |
| #include "base/process/kill.h" |
| #include "base/test/multiprocess_test.h" |
| #include "base/test/test_timeouts.h" |
| +#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| #include "base/threading/platform_thread.h" |
| +#include "build/build_config.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/multiprocess_func_list.h" |
| +#if defined(OS_LINUX) |
| +#include <errno.h> |
| +#include <sys/syscall.h> |
| +#include <sys/types.h> |
| +#include <unistd.h> |
| +#endif |
| namespace { |
| @@ -201,4 +209,42 @@ TEST_F(ProcessTest, SetProcessBackgroundedSelf) { |
| EXPECT_EQ(old_priority, new_priority); |
| } |
| +#if defined(OS_LINUX) |
| +const int kSuccess = 0; |
| +const int kFail = 1; |
| + |
| +MULTIPROCESS_TEST_MAIN(CheckPidProcess) { |
| + const pid_t kInitPid = 1; |
| + pid_t pid = syscall(__NR_getpid); |
|
jln (very slow on Chromium)
2015/01/06 00:22:31
const
rickyz (no longer on Chrome)
2015/01/06 02:45:37
Done.
|
| + if (pid != kInitPid) { |
| + return kFail; |
| + } |
| + |
| + if (!RunningOnValgrind() && getpid() != pid) { |
| + return kFail; |
| + } |
| + |
| + return kSuccess; |
| +} |
| + |
| +TEST_F(ProcessTest, CloneFlags) { |
| + LaunchOptions options; |
| + options.clone_flags = CLONE_NEWUSER | CLONE_NEWPID | CLONE_NEWNET; |
| + |
| + ProcessHandle proc = SpawnChildWithOptions("CheckPidProcess", options); |
| + if (proc == kNullProcessHandle && errno == EINVAL) { |
| + // Some of the namespace types are not supported. |
| + return; |
| + } |
| + |
| + Process process(proc); |
| + ASSERT_TRUE(process.IsValid()); |
| + |
| + const int kDummyExitCode = 42; |
| + int exit_code = kDummyExitCode; |
|
jln (very slow on Chromium)
2015/01/06 00:22:31
Why not kFail?
rickyz (no longer on Chrome)
2015/01/06 02:45:37
Done.
|
| + EXPECT_TRUE(process.WaitForExit(&exit_code)); |
| + EXPECT_EQ(kSuccess, exit_code); |
| +} |
| +#endif |
| + |
| } // namespace base |