Chromium Code Reviews| Index: base/process/process_util_unittest.cc |
| diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc |
| index 33cf00f31dce49628807adb7fa11448ccb2fdd88..01600b604623022c2bf28b3999dde082e40d731c 100644 |
| --- a/base/process/process_util_unittest.cc |
| +++ b/base/process/process_util_unittest.cc |
| @@ -1023,4 +1023,46 @@ TEST(ForkWithFlagsTest, UpdatesPidCache) { |
| ASSERT_TRUE(WIFEXITED(status)); |
| EXPECT_EQ(kSuccess, WEXITSTATUS(status)); |
| } |
| + |
| +MULTIPROCESS_TEST_MAIN(CheckCwdProcess) { |
| + base::FilePath expected; |
| + CHECK(base::GetTempDir(&expected)); |
| + base::FilePath actual; |
| + CHECK(base::GetCurrentDirectory(&actual)); |
| + CHECK(actual == expected); |
| + return kSuccess; |
| +} |
| + |
| +TEST_F(ProcessUtilTest, CurrentDirectory) { |
| + base::FilePath orig_cwd; |
| + ASSERT_TRUE(base::GetCurrentDirectory(&orig_cwd)); |
| + ASSERT_TRUE(base::SetCurrentDirectory(base::FilePath("/"))); |
| + |
| + base::FilePath tmp_dir; |
| + ASSERT_TRUE(base::GetTempDir(&tmp_dir)); |
| + |
| + base::LaunchOptions options; |
| + options.current_directory = tmp_dir; |
| + |
| + base::Process process(SpawnChildWithOptions("CheckCwdProcess", options)); |
| + ASSERT_TRUE(process.IsValid()); |
| + |
| + int exit_code = 42; |
| + EXPECT_TRUE(process.WaitForExit(&exit_code)); |
| + EXPECT_EQ(kSuccess, exit_code); |
| + |
| + 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.
|
| +} |
| + |
| +TEST_F(ProcessUtilTest, InvalidCurrentDirectory) { |
| + base::LaunchOptions options; |
| + 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.
|
| + |
| + base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); |
| + ASSERT_TRUE(process.IsValid()); |
| + |
| + int exit_code = 42; |
| + EXPECT_TRUE(process.WaitForExit(&exit_code)); |
| + 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.
|
| +} |
| #endif |