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

Side by Side Diff: base/process_util_unittest.cc

Issue 67226: Add GetAppOutput function, a better replacement for popen. (Closed)
Patch Set: fixes Created 11 years, 8 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 unified diff | Download patch
« base/process_util_posix.cc ('K') | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« base/process_util_posix.cc ('K') | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698