OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/command_line.h" |
7 #include "base/multiprocess_test.h" | 8 #include "base/multiprocess_test.h" |
8 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
9 #include "base/process_util.h" | 10 #include "base/process_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 #if defined(OS_LINUX) | 13 #if defined(OS_LINUX) |
13 #include <dlfcn.h> | 14 #include <dlfcn.h> |
14 #endif | 15 #endif |
15 #if defined(OS_POSIX) | 16 #if defined(OS_POSIX) |
16 #include <fcntl.h> | 17 #include <fcntl.h> |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ASSERT_EQ(0, num_open_files); | 212 ASSERT_EQ(0, num_open_files); |
212 | 213 |
213 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); | 214 EXPECT_TRUE(WaitForSingleProcess(handle, 1000)); |
214 base::CloseProcessHandle(handle); | 215 base::CloseProcessHandle(handle); |
215 close(fds[0]); | 216 close(fds[0]); |
216 close(sockets[0]); | 217 close(sockets[0]); |
217 close(sockets[1]); | 218 close(sockets[1]); |
218 close(dev_null); | 219 close(dev_null); |
219 } | 220 } |
220 | 221 |
| 222 TEST_F(ProcessUtilTest, GetAppOutput) { |
| 223 std::string output; |
| 224 EXPECT_TRUE(GetAppOutput(CommandLine(L"true"), &output)); |
| 225 EXPECT_STREQ("", output.c_str()); |
| 226 |
| 227 EXPECT_FALSE(GetAppOutput(CommandLine(L"false"), &output)); |
| 228 |
| 229 std::vector<std::string> argv; |
| 230 argv.push_back("/bin/echo"); |
| 231 argv.push_back("-n"); |
| 232 argv.push_back("foobar42"); |
| 233 EXPECT_TRUE(GetAppOutput(CommandLine(argv), &output)); |
| 234 EXPECT_STREQ("foobar42", output.c_str()); |
| 235 } |
| 236 |
221 #endif // defined(OS_POSIX) | 237 #endif // defined(OS_POSIX) |
222 | 238 |
223 } // namespace base | 239 } // namespace base |
OLD | NEW |