summaryrefslogtreecommitdiffstats
path: root/base/process_util_unittest.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 04:02:34 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 04:02:34 +0000
commit3b9f5aa2dba5e4374ced0b20a7fc14e57de08c21 (patch)
treef501952c4f6143819b2269793229567fae99b9e2 /base/process_util_unittest.cc
parent72e8a0d3d8e67bf982cda8ba44fad975e2348ea1 (diff)
downloadchromium_src-3b9f5aa2dba5e4374ced0b20a7fc14e57de08c21.zip
chromium_src-3b9f5aa2dba5e4374ced0b20a7fc14e57de08c21.tar.gz
chromium_src-3b9f5aa2dba5e4374ced0b20a7fc14e57de08c21.tar.bz2
Revert 53903 - Revert 52613 - Revert 52608 - Add and alternative GetAppOutput() to process_util that takes a timeout.
[For those keeping track, this removes it again. The failure wasn't a flake. :(] [Undoing the revert to see if the failure wasn't a flake.... Revert if the original failure, below, occurs again.] ["base_unittests" didn't exit cleanly on "Chromium Linux x64" but was killed due to timeout.] Contributed by tessamac@chromium.org TEST=none BUG=47356 Review URL: http://codereview.chromium.org/2810014 Patch from Tessa MacDuff <tessamac@chromium.org>. TBR=viettrungluu@chromium.org, tessamac@chromium.org Review URL: http://codereview.chromium.org/3012004 TBR=viettrungluu@chromium.org, tessamac@chromium.org Review URL: http://codereview.chromium.org/3036023 TBR=viettrungluu@chromium.org, tessamac@chromium.org Review URL: http://codereview.chromium.org/3045018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_unittest.cc')
-rw-r--r--base/process_util_unittest.cc82
1 files changed, 8 insertions, 74 deletions
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 675f38f..481c759 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -436,85 +436,19 @@ TEST_F(ProcessUtilTest, AlterEnvironment) {
delete[] e;
}
-TEST_F(ProcessUtilTest, GetAppOutput_Success) {
- std::string output;
- EXPECT_TRUE(base::GetAppOutput(CommandLine(FilePath(
- FILE_PATH_LITERAL("true"))), &output));
- EXPECT_STREQ("", output.c_str());
-
- CommandLine command_line(FilePath(FILE_PATH_LITERAL("echo")));
- command_line.AppendLooseValue(L"foobar42");
- EXPECT_TRUE(base::GetAppOutput(command_line, &output));
- EXPECT_STREQ("foobar42\n", output.c_str());
-}
-
-TEST_F(ProcessUtilTest, GetAppOutput_Failure) {
+TEST_F(ProcessUtilTest, GetAppOutput) {
std::string output;
- EXPECT_FALSE(base::GetAppOutput(CommandLine(FilePath(
- FILE_PATH_LITERAL("false"))), &output));
+ EXPECT_TRUE(base::GetAppOutput(CommandLine(FilePath("true")), &output));
EXPECT_STREQ("", output.c_str());
- // Make sure we capture output in case of failure.
- std::vector<std::string> argv;
- argv.push_back("/bin/sh");
- argv.push_back("-c");
- argv.push_back("echo hello && false");
- EXPECT_FALSE(base::GetAppOutput(CommandLine(argv), &output));
- EXPECT_STREQ("hello\n", output.c_str());
-}
-
-TEST_F(ProcessUtilTest, GetAppOutputWithTimeout_SuccessWithinTimeout) {
- CommandLine command_line(FilePath(FILE_PATH_LITERAL("echo")));
- command_line.AppendLooseValue(L"hello");
- std::string output;
- bool timed_out;
-
- EXPECT_TRUE(base::GetAppOutputWithTimeout(
- command_line, &output, &timed_out,
- std::numeric_limits<int>::max()));
- EXPECT_EQ("hello\n", output);
- EXPECT_FALSE(timed_out);
-}
+ EXPECT_FALSE(base::GetAppOutput(CommandLine(FilePath("false")), &output));
-TEST_F(ProcessUtilTest, GetAppOutputWithTimeout_FailureWithinTimeout) {
std::vector<std::string> argv;
- argv.push_back("/bin/sh");
- argv.push_back("-c");
- argv.push_back("echo hello && false");
- std::string output;
- bool timed_out;
-
- EXPECT_FALSE(base::GetAppOutputWithTimeout(
- CommandLine(argv), &output, &timed_out,
- std::numeric_limits<int>::max()));
- EXPECT_EQ("hello\n", output);
- EXPECT_FALSE(timed_out);
-}
-
-TEST_F(ProcessUtilTest, WaitForExitCodeWithTimeout) {
- CommandLine command_line(FilePath(FILE_PATH_LITERAL("sleep")));
- command_line.AppendLooseValue(L"10000");
-
- base::ProcessHandle process_handle;
- EXPECT_TRUE(base::LaunchApp(command_line, false, false,
- &process_handle));
- int exit_code = 42;
- EXPECT_FALSE(base::WaitForExitCodeWithTimeout(process_handle, &exit_code, 1));
- EXPECT_EQ(42, exit_code); // exit_code is unchanged if timeout triggers.
-}
-
-TEST_F(ProcessUtilTest, GetAppOutputWithTimeout_TimedOutWhileOutputing) {
- std::vector<std::string> argv;
- argv.push_back("/bin/sh");
- argv.push_back("-c");
- argv.push_back("echo asleep && sleep 10 && echo awake");
- std::string output;
- bool timed_out;
-
- EXPECT_FALSE(base::GetAppOutputWithTimeout(CommandLine(argv), &output,
- &timed_out, 1000));
- EXPECT_EQ("asleep\n", output); // Timed out before printing "awake".
- EXPECT_TRUE(timed_out);
+ argv.push_back("/bin/echo");
+ argv.push_back("-n");
+ argv.push_back("foobar42");
+ EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output));
+ EXPECT_STREQ("foobar42", output.c_str());
}
TEST_F(ProcessUtilTest, GetAppOutputRestricted) {