diff options
author | peter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 00:43:49 +0000 |
---|---|---|
committer | peter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 00:43:49 +0000 |
commit | 94541e43d460e73e3273bc6b04f7e906ef34b554 (patch) | |
tree | c8f3216146e80febf30d6142b57f8458ab28f8d1 /testing/android/native_test_launcher.cc | |
parent | 631e6c9be8dafc728e29e0f2d4fec6851a697992 (diff) | |
download | chromium_src-94541e43d460e73e3273bc6b04f7e906ef34b554.zip chromium_src-94541e43d460e73e3273bc6b04f7e906ef34b554.tar.gz chromium_src-94541e43d460e73e3273bc6b04f7e906ef34b554.tar.bz2 |
Support creating a fifo for stdin and separating stderr in its own fifo for Android
This is necessary to properly support DumpRenderTree. Now that Chromium
also uses fifos for getting output from the device, WebKit can change to
using that.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10969010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing/android/native_test_launcher.cc')
-rw-r--r-- | testing/android/native_test_launcher.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc index 4a07acf..99d9b29 100644 --- a/testing/android/native_test_launcher.cc +++ b/testing/android/native_test_launcher.cc @@ -37,6 +37,11 @@ extern int main(int argc, char** argv); namespace { +// These two command line flags are supported for DumpRenderTree, which needs +// three fifos rather than a combined one: one for stderr, stdin and stdout. +const char kSeparateStderrFifo[] = "separate-stderr-fifo"; +const char kCreateStdinFifo[] = "create-stdin-fifo"; + const char kLogTag[] = "chromium"; const char kCrashedMarker[] = "[ CRASHED ]\n"; @@ -161,14 +166,6 @@ static void RunTests(JNIEnv* env, base::android::InitApplicationContext(scoped_context); base::android::RegisterJni(env); - FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); - // A few options, such "--gtest_list_tests", will just use printf directly - // Redirect stdout and stderr to a known file. - FilePath fifo_path(files_dir.Append(FilePath("test.fifo"))); - CreateFIFO(fifo_path.value().c_str()); - Redirect(stdout, fifo_path.value().c_str(), "w"); - Redirect(stderr, fifo_path.value().c_str(), "w"); - std::vector<std::string> args; ParseArgsFromCommandLineFile(&args); @@ -180,6 +177,38 @@ static void RunTests(JNIEnv* env, CommandLine::ForCurrentProcess()->AppendArguments( CommandLine(argc, &argv[0]), false); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); + + // A few options, such "--gtest_list_tests", will just use printf directly + // Always redirect stdout to a known file. + FilePath fifo_path(files_dir.Append(FilePath("test.fifo"))); + CreateFIFO(fifo_path.value().c_str()); + + FilePath stderr_fifo_path, stdin_fifo_path; + + // DumpRenderTree needs a separate fifo for the stderr output. For all + // other tests, insert stderr content to the same fifo we use for stdout. + if (command_line.HasSwitch(kSeparateStderrFifo)) { + stderr_fifo_path = files_dir.Append(FilePath("stderr.fifo")); + CreateFIFO(stderr_fifo_path.value().c_str()); + } + + // DumpRenderTree uses stdin to receive input about which test to run. + if (command_line.HasSwitch(kCreateStdinFifo)) { + stdin_fifo_path = files_dir.Append(FilePath("stdin.fifo")); + CreateFIFO(stdin_fifo_path.value().c_str()); + } + + // Only redirect the streams after all fifos have been created. + Redirect(stdout, fifo_path.value().c_str(), "w"); + if (!stdin_fifo_path.empty()) + Redirect(stdin, stdin_fifo_path.value().c_str(), "r"); + if (!stderr_fifo_path.empty()) + Redirect(stderr, stderr_fifo_path.value().c_str(), "w"); + else + dup2(STDOUT_FILENO, STDERR_FILENO); + if (command_line.HasSwitch(switches::kWaitForDebugger)) { std::string msg = StringPrintf("Native test waiting for GDB because " "flag %s was supplied", |