Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 RAW_CHECK(getpid() == ctid); | 1016 RAW_CHECK(getpid() == ctid); |
| 1017 _exit(kSuccess); | 1017 _exit(kSuccess); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 ASSERT_NE(-1, pid); | 1020 ASSERT_NE(-1, pid); |
| 1021 int status = 42; | 1021 int status = 42; |
| 1022 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); | 1022 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); |
| 1023 ASSERT_TRUE(WIFEXITED(status)); | 1023 ASSERT_TRUE(WIFEXITED(status)); |
| 1024 EXPECT_EQ(kSuccess, WEXITSTATUS(status)); | 1024 EXPECT_EQ(kSuccess, WEXITSTATUS(status)); |
| 1025 } | 1025 } |
| 1026 | |
| 1027 MULTIPROCESS_TEST_MAIN(CheckCwdProcess) { | |
| 1028 base::FilePath expected; | |
| 1029 CHECK(base::GetTempDir(&expected)); | |
| 1030 base::FilePath actual; | |
| 1031 CHECK(base::GetCurrentDirectory(&actual)); | |
| 1032 CHECK(actual == expected); | |
| 1033 return kSuccess; | |
| 1034 } | |
| 1035 | |
| 1036 TEST_F(ProcessUtilTest, CurrentDirectory) { | |
| 1037 base::FilePath orig_cwd; | |
| 1038 ASSERT_TRUE(base::GetCurrentDirectory(&orig_cwd)); | |
| 1039 ASSERT_TRUE(base::SetCurrentDirectory(base::FilePath("/"))); | |
| 1040 | |
| 1041 base::FilePath tmp_dir; | |
| 1042 ASSERT_TRUE(base::GetTempDir(&tmp_dir)); | |
| 1043 | |
| 1044 base::LaunchOptions options; | |
| 1045 options.current_directory = tmp_dir; | |
| 1046 | |
| 1047 base::Process process(SpawnChildWithOptions("CheckCwdProcess", options)); | |
| 1048 ASSERT_TRUE(process.IsValid()); | |
| 1049 | |
| 1050 int exit_code = 42; | |
| 1051 EXPECT_TRUE(process.WaitForExit(&exit_code)); | |
| 1052 EXPECT_EQ(kSuccess, exit_code); | |
| 1053 | |
| 1054 ASSERT_TRUE(base::SetCurrentDirectory(orig_cwd)); | |
|
jln (very slow on Chromium)
2015/01/31 00:21:56
You could put this in a ClosureRunner instead, but
rickyz (no longer on Chrome)
2015/01/31 00:59:37
This ended up getting removed.
| |
| 1055 } | |
| 1056 | |
| 1057 TEST_F(ProcessUtilTest, InvalidCurrentDirectory) { | |
| 1058 base::LaunchOptions options; | |
| 1059 options.current_directory = base::FilePath("/etc/passwd"); | |
|
jln (very slow on Chromium)
2015/01/31 00:21:56
How about /dev/null? I'm not sure /etc/passwd is g
rickyz (no longer on Chrome)
2015/01/31 00:59:37
Done.
| |
| 1060 | |
| 1061 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); | |
| 1062 ASSERT_TRUE(process.IsValid()); | |
| 1063 | |
| 1064 int exit_code = 42; | |
| 1065 EXPECT_TRUE(process.WaitForExit(&exit_code)); | |
| 1066 EXPECT_EQ(-1, exit_code); | |
|
jln (very slow on Chromium)
2015/01/31 00:21:56
Let's do EXPECT_NE(kSuccess, ...) since we're rely
rickyz (no longer on Chrome)
2015/01/31 00:59:37
Done.
| |
| 1067 } | |
| 1026 #endif | 1068 #endif |
| OLD | NEW |