Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: base/process/process_util_unittest.cc

Issue 1189683004: ifdef out ProcessUtilTest.CloneFlags on linux with old kernel headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 const int kSuccess = 0; 1018 const int kSuccess = 0;
1019 1019
1020 MULTIPROCESS_TEST_MAIN(CheckPidProcess) { 1020 MULTIPROCESS_TEST_MAIN(CheckPidProcess) {
1021 const pid_t kInitPid = 1; 1021 const pid_t kInitPid = 1;
1022 const pid_t pid = syscall(__NR_getpid); 1022 const pid_t pid = syscall(__NR_getpid);
1023 CHECK(pid == kInitPid); 1023 CHECK(pid == kInitPid);
1024 CHECK(getpid() == pid); 1024 CHECK(getpid() == pid);
1025 return kSuccess; 1025 return kSuccess;
1026 } 1026 }
1027 1027
1028 #if defined(CLONE_NEWUSER) && defined(CLONE_NEWPID)
1028 TEST_F(ProcessUtilTest, CloneFlags) { 1029 TEST_F(ProcessUtilTest, CloneFlags) {
1029 if (RunningOnValgrind() || 1030 if (RunningOnValgrind() ||
1030 !base::PathExists(FilePath("/proc/self/ns/user")) || 1031 !base::PathExists(FilePath("/proc/self/ns/user")) ||
1031 !base::PathExists(FilePath("/proc/self/ns/pid"))) { 1032 !base::PathExists(FilePath("/proc/self/ns/pid"))) {
1032 // User or PID namespaces are not supported. 1033 // User or PID namespaces are not supported.
1033 return; 1034 return;
1034 } 1035 }
1035 1036
1036 base::LaunchOptions options; 1037 base::LaunchOptions options;
1037 options.clone_flags = CLONE_NEWUSER | CLONE_NEWPID; 1038 options.clone_flags = CLONE_NEWUSER | CLONE_NEWPID;
1038 1039
1039 base::Process process(SpawnChildWithOptions("CheckPidProcess", options)); 1040 base::Process process(SpawnChildWithOptions("CheckPidProcess", options));
1040 ASSERT_TRUE(process.IsValid()); 1041 ASSERT_TRUE(process.IsValid());
1041 1042
1042 int exit_code = 42; 1043 int exit_code = 42;
1043 EXPECT_TRUE(process.WaitForExit(&exit_code)); 1044 EXPECT_TRUE(process.WaitForExit(&exit_code));
1044 EXPECT_EQ(kSuccess, exit_code); 1045 EXPECT_EQ(kSuccess, exit_code);
1045 } 1046 }
1047 #endif
1046 1048
1047 TEST(ForkWithFlagsTest, UpdatesPidCache) { 1049 TEST(ForkWithFlagsTest, UpdatesPidCache) {
1048 // The libc clone function, which allows ForkWithFlags to keep the pid cache 1050 // The libc clone function, which allows ForkWithFlags to keep the pid cache
1049 // up to date, does not work on Valgrind. 1051 // up to date, does not work on Valgrind.
1050 if (RunningOnValgrind()) { 1052 if (RunningOnValgrind()) {
1051 return; 1053 return;
1052 } 1054 }
1053 1055
1054 // Warm up the libc pid cache, if there is one. 1056 // Warm up the libc pid cache, if there is one.
1055 ASSERT_EQ(syscall(__NR_getpid), getpid()); 1057 ASSERT_EQ(syscall(__NR_getpid), getpid());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 options.current_directory = base::FilePath("/dev/null"); 1105 options.current_directory = base::FilePath("/dev/null");
1104 1106
1105 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); 1107 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options));
1106 ASSERT_TRUE(process.IsValid()); 1108 ASSERT_TRUE(process.IsValid());
1107 1109
1108 int exit_code = kSuccess; 1110 int exit_code = kSuccess;
1109 EXPECT_TRUE(process.WaitForExit(&exit_code)); 1111 EXPECT_TRUE(process.WaitForExit(&exit_code));
1110 EXPECT_NE(kSuccess, exit_code); 1112 EXPECT_NE(kSuccess, exit_code);
1111 } 1113 }
1112 #endif 1114 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698