| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // This class sets up the environment for running the native tests inside an | 5 // This class sets up the environment for running the native tests inside an | 
| 6 // android application. It outputs (to a fifo) markers identifying the | 6 // android application. It outputs (to a fifo) markers identifying the | 
| 7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, | 7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, | 
| 8 // etc. | 8 // etc. | 
| 9 // These markers are read by the test runner script to generate test results. | 9 // These markers are read by the test runner script to generate test results. | 
| 10 // It installs signal handlers to detect crashes. | 10 // It installs signal handlers to detect crashes. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102   ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); | 102   ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); | 
| 103 | 103 | 
| 104   std::vector<char*> argv; | 104   std::vector<char*> argv; | 
| 105   int argc = ArgsToArgv(args, &argv); | 105   int argc = ArgsToArgv(args, &argv); | 
| 106 | 106 | 
| 107   // Fully initialize command line with arguments. | 107   // Fully initialize command line with arguments. | 
| 108   CommandLine::ForCurrentProcess()->AppendArguments( | 108   CommandLine::ForCurrentProcess()->AppendArguments( | 
| 109       CommandLine(argc, &argv[0]), false); | 109       CommandLine(argc, &argv[0]), false); | 
| 110   const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 110   const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 
| 111 | 111 | 
| 112   FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); | 112   base::FilePath files_dir( | 
|  | 113       base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); | 
| 113 | 114 | 
| 114   // A few options, such "--gtest_list_tests", will just use printf directly | 115   // A few options, such "--gtest_list_tests", will just use printf directly | 
| 115   // Always redirect stdout to a known file. | 116   // Always redirect stdout to a known file. | 
| 116   FilePath fifo_path(files_dir.Append(FilePath("test.fifo"))); | 117   base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo"))); | 
| 117   CreateFIFO(fifo_path.value().c_str()); | 118   CreateFIFO(fifo_path.value().c_str()); | 
| 118 | 119 | 
| 119   FilePath stderr_fifo_path, stdin_fifo_path; | 120   base::FilePath stderr_fifo_path, stdin_fifo_path; | 
| 120 | 121 | 
| 121   // DumpRenderTree needs a separate fifo for the stderr output. For all | 122   // DumpRenderTree needs a separate fifo for the stderr output. For all | 
| 122   // other tests, insert stderr content to the same fifo we use for stdout. | 123   // other tests, insert stderr content to the same fifo we use for stdout. | 
| 123   if (command_line.HasSwitch(kSeparateStderrFifo)) { | 124   if (command_line.HasSwitch(kSeparateStderrFifo)) { | 
| 124     stderr_fifo_path = files_dir.Append(FilePath("stderr.fifo")); | 125     stderr_fifo_path = files_dir.Append(base::FilePath("stderr.fifo")); | 
| 125     CreateFIFO(stderr_fifo_path.value().c_str()); | 126     CreateFIFO(stderr_fifo_path.value().c_str()); | 
| 126   } | 127   } | 
| 127 | 128 | 
| 128   // DumpRenderTree uses stdin to receive input about which test to run. | 129   // DumpRenderTree uses stdin to receive input about which test to run. | 
| 129   if (command_line.HasSwitch(kCreateStdinFifo)) { | 130   if (command_line.HasSwitch(kCreateStdinFifo)) { | 
| 130     stdin_fifo_path = files_dir.Append(FilePath("stdin.fifo")); | 131     stdin_fifo_path = files_dir.Append(base::FilePath("stdin.fifo")); | 
| 131     CreateFIFO(stdin_fifo_path.value().c_str()); | 132     CreateFIFO(stdin_fifo_path.value().c_str()); | 
| 132   } | 133   } | 
| 133 | 134 | 
| 134   // Only redirect the streams after all fifos have been created. | 135   // Only redirect the streams after all fifos have been created. | 
| 135   RedirectStream(stdout, fifo_path.value().c_str(), "w"); | 136   RedirectStream(stdout, fifo_path.value().c_str(), "w"); | 
| 136   if (!stdin_fifo_path.empty()) | 137   if (!stdin_fifo_path.empty()) | 
| 137     RedirectStream(stdin, stdin_fifo_path.value().c_str(), "r"); | 138     RedirectStream(stdin, stdin_fifo_path.value().c_str(), "r"); | 
| 138   if (!stderr_fifo_path.empty()) | 139   if (!stderr_fifo_path.empty()) | 
| 139     RedirectStream(stderr, stderr_fifo_path.value().c_str(), "w"); | 140     RedirectStream(stderr, stderr_fifo_path.value().c_str(), "w"); | 
| 140   else | 141   else | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 158   InstallHandlers(); | 159   InstallHandlers(); | 
| 159 | 160 | 
| 160   base::android::InitVM(vm); | 161   base::android::InitVM(vm); | 
| 161   JNIEnv* env = base::android::AttachCurrentThread(); | 162   JNIEnv* env = base::android::AttachCurrentThread(); | 
| 162   if (!RegisterNativesImpl(env)) { | 163   if (!RegisterNativesImpl(env)) { | 
| 163     return -1; | 164     return -1; | 
| 164   } | 165   } | 
| 165 | 166 | 
| 166   return JNI_VERSION_1_4; | 167   return JNI_VERSION_1_4; | 
| 167 } | 168 } | 
| OLD | NEW | 
|---|