From c0b210ee445f489f34a6565f51adb62f10988562 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Fri, 17 Apr 2009 09:57:52 +0000 Subject: 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 --- base/process_util_unittest.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'base/process_util_unittest.cc') 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 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 -- cgit v1.1