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

Unified Diff: base/process/process_util_unittest.cc

Issue 885423003: Add the ability to change directories before execing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
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..5ed15d2ae6b70bce2a0b9e6fcb90c27eff49f21c 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -1023,4 +1023,42 @@ 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) {
+ // TODO(rickyz): Add support for passing arguments to multiprocess children,
+ // then create a special directory for this test.
+ 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);
+}
+
+TEST_F(ProcessUtilTest, InvalidCurrentDirectory) {
+ base::LaunchOptions options;
+ options.current_directory = base::FilePath("/dev/null");
+
+ base::Process process(SpawnChildWithOptions("SimpleChildProcess", options));
+ ASSERT_TRUE(process.IsValid());
+
+ int exit_code = kSuccess;
+ EXPECT_TRUE(process.WaitForExit(&exit_code));
+ EXPECT_NE(kSuccess, exit_code);
+}
#endif

Powered by Google App Engine
This is Rietveld 408576698