| Index: testing/android/native_test_launcher.cc
|
| diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc
|
| index 26553c9a05de00d163ad21e8794bfae0a940be90..191dfcd2ee9003e1c933e91973d4b7d04c793ebf 100644
|
| --- a/testing/android/native_test_launcher.cc
|
| +++ b/testing/android/native_test_launcher.cc
|
| @@ -38,11 +38,6 @@ 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";
|
| -
|
| // The test runner script writes the command line file in
|
| // "/data/local/tmp".
|
| static const char kCommandLineFilePath[] =
|
| @@ -88,39 +83,14 @@ void AndroidLog(int priority, const char* format, ...) {
|
| va_end(args);
|
| }
|
|
|
| -// Ensures that the fifo at |path| is created by deleting whatever is at |path|
|
| -// prior to (re)creating the fifo, otherwise logs the error and terminates the
|
| -// program.
|
| -void EnsureCreateFIFO(const base::FilePath& path) {
|
| - unlink(path.value().c_str());
|
| - if (base::android::CreateFIFO(path, 0666))
|
| - return;
|
| -
|
| - AndroidLog(ANDROID_LOG_ERROR, "Failed to create fifo %s: %s\n",
|
| - path.value().c_str(), strerror(errno));
|
| - exit(EXIT_FAILURE);
|
| -}
|
| -
|
| -// Ensures that |stream| is redirected to |path|, otherwise logs the error and
|
| -// terminates the program.
|
| -void EnsureRedirectStream(FILE* stream,
|
| - const base::FilePath& path,
|
| - const char* mode) {
|
| - if (base::android::RedirectStream(stream, path, mode))
|
| - return;
|
| -
|
| - AndroidLog(ANDROID_LOG_ERROR, "Failed to redirect stream to file: %s: %s\n",
|
| - path.value().c_str(), strerror(errno));
|
| - exit(EXIT_FAILURE);
|
| -}
|
| -
|
| } // namespace
|
|
|
| static void RunTests(JNIEnv* env,
|
| jobject obj,
|
| jstring jcommand_line_flags,
|
| jstring jcommand_line_file_path,
|
| - jstring jfiles_dir,
|
| + jstring jstdout_file_path,
|
| + jboolean jstdout_fifo,
|
| jobject app_context) {
|
| base::AtExitManager exit_manager;
|
|
|
| @@ -156,37 +126,25 @@ static void RunTests(JNIEnv* env,
|
| const base::CommandLine& command_line =
|
| *base::CommandLine::ForCurrentProcess();
|
|
|
| - base::FilePath files_dir(
|
| - base::android::ConvertJavaStringToUTF8(env, jfiles_dir));
|
| + base::FilePath stdout_file_path(
|
| + base::android::ConvertJavaStringToUTF8(env, jstdout_file_path));
|
|
|
| // A few options, such "--gtest_list_tests", will just use printf directly
|
| // Always redirect stdout to a known file.
|
| - base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo")));
|
| - EnsureCreateFIFO(fifo_path);
|
| -
|
| - base::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(base::FilePath("stderr.fifo"));
|
| - EnsureCreateFIFO(stderr_fifo_path);
|
| + unlink(stdout_file_path.value().c_str());
|
| + if (jstdout_fifo) {
|
| + if (!base::android::CreateFIFO(stdout_file_path, 0666)) {
|
| + AndroidLog(ANDROID_LOG_ERROR, "Failed to create fifo %s: %s\n",
|
| + stdout_file_path.value().c_str(), strerror(errno));
|
| + exit(EXIT_FAILURE);
|
| + }
|
| }
|
| -
|
| - // DumpRenderTree uses stdin to receive input about which test to run.
|
| - if (command_line.HasSwitch(kCreateStdinFifo)) {
|
| - stdin_fifo_path = files_dir.Append(base::FilePath("stdin.fifo"));
|
| - EnsureCreateFIFO(stdin_fifo_path);
|
| + if (!base::android::RedirectStream(stdout, stdout_file_path, "w")) {
|
| + AndroidLog(ANDROID_LOG_ERROR, "Failed to redirect stream to file: %s: %s\n",
|
| + stdout_file_path.value().c_str(), strerror(errno));
|
| + exit(EXIT_FAILURE);
|
| }
|
| -
|
| - // Only redirect the streams after all fifos have been created.
|
| - EnsureRedirectStream(stdout, fifo_path, "w");
|
| - if (!stdin_fifo_path.empty())
|
| - EnsureRedirectStream(stdin, stdin_fifo_path, "r");
|
| - if (!stderr_fifo_path.empty())
|
| - EnsureRedirectStream(stderr, stderr_fifo_path, "w");
|
| - else
|
| - dup2(STDOUT_FILENO, STDERR_FILENO);
|
| + dup2(STDOUT_FILENO, STDERR_FILENO);
|
|
|
| if (command_line.HasSwitch(switches::kWaitForDebugger)) {
|
| AndroidLog(ANDROID_LOG_VERBOSE,
|
|
|