diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 09:57:52 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-17 09:57:52 +0000 |
commit | c0b210ee445f489f34a6565f51adb62f10988562 (patch) | |
tree | 0f9fd1d1061927fcd4865d0e951858473ceab398 /base/process_util_unittest.cc | |
parent | 3b3cc646c182ca1578e745c110ba47af34468b15 (diff) | |
download | chromium_src-c0b210ee445f489f34a6565f51adb62f10988562.zip chromium_src-c0b210ee445f489f34a6565f51adb62f10988562.tar.gz chromium_src-c0b210ee445f489f34a6565f51adb62f10988562.tar.bz2 |
Add GetAppOutput function, a better replacement for popen.
It will replace popen call in chrome_process_util_linux.
I don't see much benefit in having a Windows implementation
(not many useful programs you can launch and get output),
so POSIX-only.
Review URL: http://codereview.chromium.org/67226
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_unittest.cc')
-rw-r--r-- | base/process_util_unittest.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index acb60e0..fba7b2b 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -4,6 +4,7 @@ #define _CRT_SECURE_NO_WARNINGS +#include "base/command_line.h" #include "base/multiprocess_test.h" #include "base/platform_thread.h" #include "base/process_util.h" @@ -218,6 +219,21 @@ TEST_F(ProcessUtilTest, FDRemapping) { close(dev_null); } +TEST_F(ProcessUtilTest, GetAppOutput) { + std::string output; + EXPECT_TRUE(GetAppOutput(CommandLine(L"true"), &output)); + EXPECT_STREQ("", output.c_str()); + + EXPECT_FALSE(GetAppOutput(CommandLine(L"false"), &output)); + + std::vector<std::string> argv; + argv.push_back("/bin/echo"); + argv.push_back("-n"); + argv.push_back("foobar42"); + EXPECT_TRUE(GetAppOutput(CommandLine(argv), &output)); + EXPECT_STREQ("foobar42", output.c_str()); +} + #endif // defined(OS_POSIX) } // namespace base |