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 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 :-)
| |
| 1028 | |
| 1029 MULTIPROCESS_TEST_MAIN(CheckCwdProcess) { | |
| 1030 const base::FilePath expected(kTmpDir); | |
| 1031 base::FilePath actual; | |
| 1032 CHECK(base::GetCurrentDirectory(&actual)); | |
| 1033 CHECK(actual == expected); | |
| 1034 return kSuccess; | |
| 1035 } | |
| 1036 | |
| 1037 TEST_F(ProcessUtilTest, CurrentDirectory) { | |
| 1038 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
| |
| 1039 options.current_directory = base::FilePath(kTmpDir); | |
| 1040 | |
| 1041 base::Process process(SpawnChildWithOptions("CheckCwdProcess", options)); | |
| 1042 ASSERT_TRUE(process.IsValid()); | |
| 1043 | |
| 1044 int exit_code = 42; | |
| 1045 EXPECT_TRUE(process.WaitForExit(&exit_code)); | |
| 1046 EXPECT_EQ(kSuccess, exit_code); | |
| 1047 } | |
| 1048 | |
| 1049 TEST_F(ProcessUtilTest, InvalidCurrentDirectory) { | |
| 1050 base::LaunchOptions options; | |
| 1051 options.current_directory = base::FilePath("/etc/passwd"); | |
| 1052 | |
| 1053 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); | |
| 1054 ASSERT_TRUE(process.IsValid()); | |
| 1055 | |
| 1056 int exit_code = 42; | |
| 1057 EXPECT_TRUE(process.WaitForExit(&exit_code)); | |
| 1058 EXPECT_EQ(-1, exit_code); | |
| 1059 } | |
| 1026 #endif | 1060 #endif |
| OLD | NEW |