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

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

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Fixed bots. Created 3 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return tmp_dir.value(); 153 return tmp_dir.value();
154 #endif 154 #endif
155 } 155 }
156 156
157 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { 157 MULTIPROCESS_TEST_MAIN(SimpleChildProcess) {
158 return kSuccess; 158 return kSuccess;
159 } 159 }
160 160
161 // TODO(viettrungluu): This should be in a "MultiProcessTestTest". 161 // TODO(viettrungluu): This should be in a "MultiProcessTestTest".
162 TEST_F(ProcessUtilTest, SpawnChild) { 162 TEST_F(ProcessUtilTest, SpawnChild) {
163 base::Process process = SpawnChild("SimpleChildProcess"); 163 base::SpawnChildResult spawn_result = SpawnChild("SimpleChildProcess");
164 base::Process process = std::move(spawn_result.process);
164 ASSERT_TRUE(process.IsValid()); 165 ASSERT_TRUE(process.IsValid());
165 int exit_code; 166 int exit_code;
166 EXPECT_TRUE(process.WaitForExitWithTimeout( 167 EXPECT_TRUE(process.WaitForExitWithTimeout(
167 TestTimeouts::action_max_timeout(), &exit_code)); 168 TestTimeouts::action_max_timeout(), &exit_code));
168 } 169 }
169 170
170 MULTIPROCESS_TEST_MAIN(SlowChildProcess) { 171 MULTIPROCESS_TEST_MAIN(SlowChildProcess) {
171 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileSlow).c_str()); 172 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileSlow).c_str());
172 return kSuccess; 173 return kSuccess;
173 } 174 }
174 175
175 TEST_F(ProcessUtilTest, KillSlowChild) { 176 TEST_F(ProcessUtilTest, KillSlowChild) {
176 const std::string signal_file = 177 const std::string signal_file =
177 ProcessUtilTest::GetSignalFilePath(kSignalFileSlow); 178 ProcessUtilTest::GetSignalFilePath(kSignalFileSlow);
178 remove(signal_file.c_str()); 179 remove(signal_file.c_str());
179 base::Process process = SpawnChild("SlowChildProcess"); 180 base::SpawnChildResult spawn_result = SpawnChild("SlowChildProcess");
181 base::Process process = std::move(spawn_result.process);
180 ASSERT_TRUE(process.IsValid()); 182 ASSERT_TRUE(process.IsValid());
181 SignalChildren(signal_file.c_str()); 183 SignalChildren(signal_file.c_str());
182 int exit_code; 184 int exit_code;
183 EXPECT_TRUE(process.WaitForExitWithTimeout( 185 EXPECT_TRUE(process.WaitForExitWithTimeout(
184 TestTimeouts::action_max_timeout(), &exit_code)); 186 TestTimeouts::action_max_timeout(), &exit_code));
185 remove(signal_file.c_str()); 187 remove(signal_file.c_str());
186 } 188 }
187 189
188 // Times out on Linux and Win, flakes on other platforms, http://crbug.com/95058 190 // Times out on Linux and Win, flakes on other platforms, http://crbug.com/95058
189 TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) { 191 TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) {
190 const std::string signal_file = 192 const std::string signal_file =
191 ProcessUtilTest::GetSignalFilePath(kSignalFileSlow); 193 ProcessUtilTest::GetSignalFilePath(kSignalFileSlow);
192 remove(signal_file.c_str()); 194 remove(signal_file.c_str());
193 base::Process process = SpawnChild("SlowChildProcess"); 195 base::SpawnChildResult spawn_result = SpawnChild("SlowChildProcess");
196 base::Process process = std::move(spawn_result.process);
194 ASSERT_TRUE(process.IsValid()); 197 ASSERT_TRUE(process.IsValid());
195 198
196 int exit_code = 42; 199 int exit_code = 42;
197 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, 200 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
198 base::GetTerminationStatus(process.Handle(), &exit_code)); 201 base::GetTerminationStatus(process.Handle(), &exit_code));
199 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); 202 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
200 203
201 SignalChildren(signal_file.c_str()); 204 SignalChildren(signal_file.c_str());
202 exit_code = 42; 205 exit_code = 42;
203 base::TerminationStatus status = 206 base::TerminationStatus status =
(...skipping 24 matching lines...) Expand all
228 231
229 TEST_F(ProcessUtilTest, CurrentDirectory) { 232 TEST_F(ProcessUtilTest, CurrentDirectory) {
230 // TODO(rickyz): Add support for passing arguments to multiprocess children, 233 // TODO(rickyz): Add support for passing arguments to multiprocess children,
231 // then create a special directory for this test. 234 // then create a special directory for this test.
232 base::FilePath tmp_dir; 235 base::FilePath tmp_dir;
233 ASSERT_TRUE(base::GetTempDir(&tmp_dir)); 236 ASSERT_TRUE(base::GetTempDir(&tmp_dir));
234 237
235 base::LaunchOptions options; 238 base::LaunchOptions options;
236 options.current_directory = tmp_dir; 239 options.current_directory = tmp_dir;
237 240
238 base::Process process(SpawnChildWithOptions("CheckCwdProcess", options)); 241 base::SpawnChildResult spawn_result =
242 SpawnChildWithOptions("CheckCwdProcess", options);
243 base::Process process = std::move(spawn_result.process);
239 ASSERT_TRUE(process.IsValid()); 244 ASSERT_TRUE(process.IsValid());
240 245
241 int exit_code = 42; 246 int exit_code = 42;
242 EXPECT_TRUE(process.WaitForExit(&exit_code)); 247 EXPECT_TRUE(process.WaitForExit(&exit_code));
243 EXPECT_EQ(kSuccess, exit_code); 248 EXPECT_EQ(kSuccess, exit_code);
244 } 249 }
245 #endif // !defined(OS_ANDROID) 250 #endif // !defined(OS_ANDROID)
246 251
247 #if defined(OS_WIN) 252 #if defined(OS_WIN)
248 // TODO(cpu): figure out how to test this in other platforms. 253 // TODO(cpu): figure out how to test this in other platforms.
249 TEST_F(ProcessUtilTest, GetProcId) { 254 TEST_F(ProcessUtilTest, GetProcId) {
250 base::ProcessId id1 = base::GetProcId(GetCurrentProcess()); 255 base::ProcessId id1 = base::GetProcId(GetCurrentProcess());
251 EXPECT_NE(0ul, id1); 256 EXPECT_NE(0ul, id1);
252 base::Process process = SpawnChild("SimpleChildProcess"); 257 base::SpawnChildResult spawn_result = SpawnChild("SimpleChildProcess");
258 base::Process process = std::move(spawn_result.process);
253 ASSERT_TRUE(process.IsValid()); 259 ASSERT_TRUE(process.IsValid());
254 base::ProcessId id2 = process.Pid(); 260 base::ProcessId id2 = process.Pid();
255 EXPECT_NE(0ul, id2); 261 EXPECT_NE(0ul, id2);
256 EXPECT_NE(id1, id2); 262 EXPECT_NE(id1, id2);
257 } 263 }
258 #endif // defined(OS_WIN) 264 #endif // defined(OS_WIN)
259 265
260 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 266 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
261 // This test is disabled on Mac, since it's flaky due to ReportCrash 267 // This test is disabled on Mac, since it's flaky due to ReportCrash
262 // taking a variable amount of time to parse and load the debug and 268 // taking a variable amount of time to parse and load the debug and
(...skipping 25 matching lines...) Expand all
288 // AddressSanitizer. 294 // AddressSanitizer.
289 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 295 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
290 #define MAYBE_GetTerminationStatusCrash DISABLED_GetTerminationStatusCrash 296 #define MAYBE_GetTerminationStatusCrash DISABLED_GetTerminationStatusCrash
291 #else 297 #else
292 #define MAYBE_GetTerminationStatusCrash GetTerminationStatusCrash 298 #define MAYBE_GetTerminationStatusCrash GetTerminationStatusCrash
293 #endif 299 #endif
294 TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) { 300 TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) {
295 const std::string signal_file = 301 const std::string signal_file =
296 ProcessUtilTest::GetSignalFilePath(kSignalFileCrash); 302 ProcessUtilTest::GetSignalFilePath(kSignalFileCrash);
297 remove(signal_file.c_str()); 303 remove(signal_file.c_str());
298 base::Process process = SpawnChild("CrashingChildProcess"); 304 base::SpawnChildResult spawn_result = SpawnChild("CrashingChildProcess");
305 base::Process process = std::move(spawn_result.process);
299 ASSERT_TRUE(process.IsValid()); 306 ASSERT_TRUE(process.IsValid());
300 307
301 int exit_code = 42; 308 int exit_code = 42;
302 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, 309 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
303 base::GetTerminationStatus(process.Handle(), &exit_code)); 310 base::GetTerminationStatus(process.Handle(), &exit_code));
304 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); 311 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
305 312
306 SignalChildren(signal_file.c_str()); 313 SignalChildren(signal_file.c_str());
307 exit_code = 42; 314 exit_code = 42;
308 base::TerminationStatus status = 315 base::TerminationStatus status =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // Send a SIGTERM to this process. 350 // Send a SIGTERM to this process.
344 ::kill(getpid(), SIGTERM); 351 ::kill(getpid(), SIGTERM);
345 return 1; 352 return 1;
346 } 353 }
347 #endif // defined(OS_POSIX) 354 #endif // defined(OS_POSIX)
348 355
349 TEST_F(ProcessUtilTest, GetTerminationStatusSigKill) { 356 TEST_F(ProcessUtilTest, GetTerminationStatusSigKill) {
350 const std::string signal_file = 357 const std::string signal_file =
351 ProcessUtilTest::GetSignalFilePath(kSignalFileKill); 358 ProcessUtilTest::GetSignalFilePath(kSignalFileKill);
352 remove(signal_file.c_str()); 359 remove(signal_file.c_str());
353 base::Process process = SpawnChild("KilledChildProcess"); 360 base::SpawnChildResult spawn_result = SpawnChild("KilledChildProcess");
361 base::Process process = std::move(spawn_result.process);
354 ASSERT_TRUE(process.IsValid()); 362 ASSERT_TRUE(process.IsValid());
355 363
356 int exit_code = 42; 364 int exit_code = 42;
357 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, 365 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
358 base::GetTerminationStatus(process.Handle(), &exit_code)); 366 base::GetTerminationStatus(process.Handle(), &exit_code));
359 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); 367 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
360 368
361 SignalChildren(signal_file.c_str()); 369 SignalChildren(signal_file.c_str());
362 exit_code = 42; 370 exit_code = 42;
363 base::TerminationStatus status = 371 base::TerminationStatus status =
(...skipping 13 matching lines...) Expand all
377 EXPECT_EQ(SIGKILL, signal); 385 EXPECT_EQ(SIGKILL, signal);
378 #endif 386 #endif
379 remove(signal_file.c_str()); 387 remove(signal_file.c_str());
380 } 388 }
381 389
382 #if defined(OS_POSIX) 390 #if defined(OS_POSIX)
383 TEST_F(ProcessUtilTest, GetTerminationStatusSigTerm) { 391 TEST_F(ProcessUtilTest, GetTerminationStatusSigTerm) {
384 const std::string signal_file = 392 const std::string signal_file =
385 ProcessUtilTest::GetSignalFilePath(kSignalFileTerm); 393 ProcessUtilTest::GetSignalFilePath(kSignalFileTerm);
386 remove(signal_file.c_str()); 394 remove(signal_file.c_str());
387 base::Process process = SpawnChild("TerminatedChildProcess"); 395 base::SpawnChildResult spawn_result = SpawnChild("TerminatedChildProcess");
396 base::Process process = std::move(spawn_result.process);
388 ASSERT_TRUE(process.IsValid()); 397 ASSERT_TRUE(process.IsValid());
389 398
390 int exit_code = 42; 399 int exit_code = 42;
391 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, 400 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
392 base::GetTerminationStatus(process.Handle(), &exit_code)); 401 base::GetTerminationStatus(process.Handle(), &exit_code));
393 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); 402 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
394 403
395 SignalChildren(signal_file.c_str()); 404 SignalChildren(signal_file.c_str());
396 exit_code = 42; 405 exit_code = 42;
397 base::TerminationStatus status = 406 base::TerminationStatus status =
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 629
621 int ProcessUtilTest::CountOpenFDsInChild() { 630 int ProcessUtilTest::CountOpenFDsInChild() {
622 int fds[2]; 631 int fds[2];
623 if (pipe(fds) < 0) 632 if (pipe(fds) < 0)
624 NOTREACHED(); 633 NOTREACHED();
625 634
626 base::FileHandleMappingVector fd_mapping_vec; 635 base::FileHandleMappingVector fd_mapping_vec;
627 fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe)); 636 fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe));
628 base::LaunchOptions options; 637 base::LaunchOptions options;
629 options.fds_to_remap = &fd_mapping_vec; 638 options.fds_to_remap = &fd_mapping_vec;
630 base::Process process = 639 base::SpawnChildResult spawn_result =
631 SpawnChildWithOptions("ProcessUtilsLeakFDChildProcess", options); 640 SpawnChildWithOptions("ProcessUtilsLeakFDChildProcess", options);
641 base::Process process = std::move(spawn_result.process);
632 CHECK(process.IsValid()); 642 CHECK(process.IsValid());
633 int ret = IGNORE_EINTR(close(fds[1])); 643 int ret = IGNORE_EINTR(close(fds[1]));
634 DPCHECK(ret == 0); 644 DPCHECK(ret == 0);
635 645
636 // Read number of open files in client process from pipe; 646 // Read number of open files in client process from pipe;
637 int num_open_files = -1; 647 int num_open_files = -1;
638 ssize_t bytes_read = 648 ssize_t bytes_read =
639 HANDLE_EINTR(read(fds[0], &num_open_files, sizeof(num_open_files))); 649 HANDLE_EINTR(read(fds[0], &num_open_files, sizeof(num_open_files)));
640 CHECK_EQ(bytes_read, static_cast<ssize_t>(sizeof(num_open_files))); 650 CHECK_EQ(bytes_read, static_cast<ssize_t>(sizeof(num_open_files)));
641 651
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // TODO(port): port those unit tests. 872 // TODO(port): port those unit tests.
863 bool IsProcessDead(base::ProcessHandle child) { 873 bool IsProcessDead(base::ProcessHandle child) {
864 // waitpid() will actually reap the process which is exactly NOT what we 874 // waitpid() will actually reap the process which is exactly NOT what we
865 // want to test for. The good thing is that if it can't find the process 875 // want to test for. The good thing is that if it can't find the process
866 // we'll get a nice value for errno which we can test for. 876 // we'll get a nice value for errno which we can test for.
867 const pid_t result = HANDLE_EINTR(waitpid(child, NULL, WNOHANG)); 877 const pid_t result = HANDLE_EINTR(waitpid(child, NULL, WNOHANG));
868 return result == -1 && errno == ECHILD; 878 return result == -1 && errno == ECHILD;
869 } 879 }
870 880
871 TEST_F(ProcessUtilTest, DelayedTermination) { 881 TEST_F(ProcessUtilTest, DelayedTermination) {
872 base::Process child_process = SpawnChild("process_util_test_never_die"); 882 base::SpawnChildResult spawn_result =
883 SpawnChild("process_util_test_never_die");
884 base::Process child_process = std::move(spawn_result.process);
873 ASSERT_TRUE(child_process.IsValid()); 885 ASSERT_TRUE(child_process.IsValid());
874 base::EnsureProcessTerminated(child_process.Duplicate()); 886 base::EnsureProcessTerminated(child_process.Duplicate());
875 int exit_code; 887 int exit_code;
876 child_process.WaitForExitWithTimeout(base::TimeDelta::FromSeconds(5), 888 child_process.WaitForExitWithTimeout(base::TimeDelta::FromSeconds(5),
877 &exit_code); 889 &exit_code);
878 890
879 // Check that process was really killed. 891 // Check that process was really killed.
880 EXPECT_TRUE(IsProcessDead(child_process.Handle())); 892 EXPECT_TRUE(IsProcessDead(child_process.Handle()));
881 } 893 }
882 894
883 MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { 895 MULTIPROCESS_TEST_MAIN(process_util_test_never_die) {
884 while (1) { 896 while (1) {
885 sleep(500); 897 sleep(500);
886 } 898 }
887 return kSuccess; 899 return kSuccess;
888 } 900 }
889 901
890 TEST_F(ProcessUtilTest, ImmediateTermination) { 902 TEST_F(ProcessUtilTest, ImmediateTermination) {
891 base::Process child_process = SpawnChild("process_util_test_die_immediately"); 903 base::SpawnChildResult spawn_result =
904 SpawnChild("process_util_test_die_immediately");
905 base::Process child_process = std::move(spawn_result.process);
892 ASSERT_TRUE(child_process.IsValid()); 906 ASSERT_TRUE(child_process.IsValid());
893 // Give it time to die. 907 // Give it time to die.
894 sleep(2); 908 sleep(2);
895 base::EnsureProcessTerminated(child_process.Duplicate()); 909 base::EnsureProcessTerminated(child_process.Duplicate());
896 910
897 // Check that process was really killed. 911 // Check that process was really killed.
898 EXPECT_TRUE(IsProcessDead(child_process.Handle())); 912 EXPECT_TRUE(IsProcessDead(child_process.Handle()));
899 } 913 }
900 914
901 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { 915 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) {
(...skipping 25 matching lines...) Expand all
927 941
928 base::ScopedFD read_fd(pipe_fds[0]); 942 base::ScopedFD read_fd(pipe_fds[0]);
929 base::ScopedFD write_fd(pipe_fds[1]); 943 base::ScopedFD write_fd(pipe_fds[1]);
930 base::FileHandleMappingVector fds_to_remap; 944 base::FileHandleMappingVector fds_to_remap;
931 fds_to_remap.push_back(std::make_pair(read_fd.get(), read_fd.get())); 945 fds_to_remap.push_back(std::make_pair(read_fd.get(), read_fd.get()));
932 946
933 ReadFromPipeDelegate read_from_pipe_delegate(read_fd.get()); 947 ReadFromPipeDelegate read_from_pipe_delegate(read_fd.get());
934 base::LaunchOptions options; 948 base::LaunchOptions options;
935 options.fds_to_remap = &fds_to_remap; 949 options.fds_to_remap = &fds_to_remap;
936 options.pre_exec_delegate = &read_from_pipe_delegate; 950 options.pre_exec_delegate = &read_from_pipe_delegate;
937 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); 951 base::SpawnChildResult spawn_result =
952 SpawnChildWithOptions("SimpleChildProcess", options);
953 base::Process process(std::move(spawn_result.process));
938 ASSERT_TRUE(process.IsValid()); 954 ASSERT_TRUE(process.IsValid());
939 955
940 read_fd.reset(); 956 read_fd.reset();
941 ASSERT_EQ(1, HANDLE_EINTR(write(write_fd.get(), &kPipeValue, 1))); 957 ASSERT_EQ(1, HANDLE_EINTR(write(write_fd.get(), &kPipeValue, 1)));
942 958
943 int exit_code = 42; 959 int exit_code = 42;
944 EXPECT_TRUE(process.WaitForExit(&exit_code)); 960 EXPECT_TRUE(process.WaitForExit(&exit_code));
945 EXPECT_EQ(0, exit_code); 961 EXPECT_EQ(0, exit_code);
946 } 962 }
947 #endif // !defined(OS_ANDROID) 963 #endif // !defined(OS_ANDROID)
(...skipping 14 matching lines...) Expand all
962 if (RunningOnValgrind() || 978 if (RunningOnValgrind() ||
963 !base::PathExists(FilePath("/proc/self/ns/user")) || 979 !base::PathExists(FilePath("/proc/self/ns/user")) ||
964 !base::PathExists(FilePath("/proc/self/ns/pid"))) { 980 !base::PathExists(FilePath("/proc/self/ns/pid"))) {
965 // User or PID namespaces are not supported. 981 // User or PID namespaces are not supported.
966 return; 982 return;
967 } 983 }
968 984
969 base::LaunchOptions options; 985 base::LaunchOptions options;
970 options.clone_flags = CLONE_NEWUSER | CLONE_NEWPID; 986 options.clone_flags = CLONE_NEWUSER | CLONE_NEWPID;
971 987
972 base::Process process(SpawnChildWithOptions("CheckPidProcess", options)); 988 base::SpawnChildResult spawn_result =
989 SpawnChildWithOptions("CheckPidProcess", options);
990 base::Process process = std::move(spawn_result.process);
973 ASSERT_TRUE(process.IsValid()); 991 ASSERT_TRUE(process.IsValid());
974 992
975 int exit_code = 42; 993 int exit_code = 42;
976 EXPECT_TRUE(process.WaitForExit(&exit_code)); 994 EXPECT_TRUE(process.WaitForExit(&exit_code));
977 EXPECT_EQ(kSuccess, exit_code); 995 EXPECT_EQ(kSuccess, exit_code);
978 } 996 }
979 #endif // defined(CLONE_NEWUSER) && defined(CLONE_NEWPID) 997 #endif // defined(CLONE_NEWUSER) && defined(CLONE_NEWPID)
980 998
981 TEST(ForkWithFlagsTest, UpdatesPidCache) { 999 TEST(ForkWithFlagsTest, UpdatesPidCache) {
982 // The libc clone function, which allows ForkWithFlags to keep the pid cache 1000 // The libc clone function, which allows ForkWithFlags to keep the pid cache
(...skipping 20 matching lines...) Expand all
1003 int status = 42; 1021 int status = 42;
1004 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); 1022 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0)));
1005 ASSERT_TRUE(WIFEXITED(status)); 1023 ASSERT_TRUE(WIFEXITED(status));
1006 EXPECT_EQ(kSuccess, WEXITSTATUS(status)); 1024 EXPECT_EQ(kSuccess, WEXITSTATUS(status));
1007 } 1025 }
1008 1026
1009 TEST_F(ProcessUtilTest, InvalidCurrentDirectory) { 1027 TEST_F(ProcessUtilTest, InvalidCurrentDirectory) {
1010 base::LaunchOptions options; 1028 base::LaunchOptions options;
1011 options.current_directory = base::FilePath("/dev/null"); 1029 options.current_directory = base::FilePath("/dev/null");
1012 1030
1013 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); 1031 base::SpawnChildResult spawn_result =
1032 SpawnChildWithOptions("SimpleChildProcess", options);
1033 base::Process process = std::move(spawn_result.process);
1014 ASSERT_TRUE(process.IsValid()); 1034 ASSERT_TRUE(process.IsValid());
1015 1035
1016 int exit_code = kSuccess; 1036 int exit_code = kSuccess;
1017 EXPECT_TRUE(process.WaitForExit(&exit_code)); 1037 EXPECT_TRUE(process.WaitForExit(&exit_code));
1018 EXPECT_NE(kSuccess, exit_code); 1038 EXPECT_NE(kSuccess, exit_code);
1019 } 1039 }
1020 #endif // defined(OS_LINUX) 1040 #endif // defined(OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698