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..e506352e822d5534528de807f86ff13bdf097972 100644 |
--- a/base/process/process_util_unittest.cc |
+++ b/base/process/process_util_unittest.cc |
@@ -1023,4 +1023,38 @@ TEST(ForkWithFlagsTest, UpdatesPidCache) { |
ASSERT_TRUE(WIFEXITED(status)); |
EXPECT_EQ(kSuccess, WEXITSTATUS(status)); |
} |
+ |
+const char* kTmpDir = "/tmp"; |
jln (very slow on Chromium)
2015/01/30 23:48:11
Let's declare storage: const char kTmpDir[]
But y
rickyz (no longer on Chrome)
2015/01/30 23:58:37
Done, thanks for saving me a try failure :-)
|
+ |
+MULTIPROCESS_TEST_MAIN(CheckCwdProcess) { |
+ const base::FilePath expected(kTmpDir); |
+ base::FilePath actual; |
+ CHECK(base::GetCurrentDirectory(&actual)); |
+ CHECK(actual == expected); |
+ return kSuccess; |
+} |
+ |
+TEST_F(ProcessUtilTest, CurrentDirectory) { |
+ base::LaunchOptions options; |
jln (very slow on Chromium)
2015/01/30 23:48:11
I would change the CurrentDirectory to NOT the tem
rickyz (no longer on Chrome)
2015/01/30 23:58:37
I made this change, and tests seem to pass, but ar
jln (very slow on Chromium)
2015/01/31 00:21:55
Tests are never run concurrently in threads. What
rickyz (no longer on Chrome)
2015/01/31 00:59:37
Removing this and adding a TODO as we discussed du
|
+ options.current_directory = base::FilePath(kTmpDir); |
+ |
+ 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); |
+} |
+ |
+TEST_F(ProcessUtilTest, InvalidCurrentDirectory) { |
+ base::LaunchOptions options; |
+ options.current_directory = base::FilePath("/etc/passwd"); |
+ |
+ 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); |
+} |
#endif |