| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // Only redirect the streams after all fifos have been created. | 135 // Only redirect the streams after all fifos have been created. |
| 136 RedirectStream(stdout, fifo_path.value().c_str(), "w"); | 136 RedirectStream(stdout, fifo_path.value().c_str(), "w"); |
| 137 if (!stdin_fifo_path.empty()) | 137 if (!stdin_fifo_path.empty()) |
| 138 RedirectStream(stdin, stdin_fifo_path.value().c_str(), "r"); | 138 RedirectStream(stdin, stdin_fifo_path.value().c_str(), "r"); |
| 139 if (!stderr_fifo_path.empty()) | 139 if (!stderr_fifo_path.empty()) |
| 140 RedirectStream(stderr, stderr_fifo_path.value().c_str(), "w"); | 140 RedirectStream(stderr, stderr_fifo_path.value().c_str(), "w"); |
| 141 else | 141 else |
| 142 dup2(STDOUT_FILENO, STDERR_FILENO); | 142 dup2(STDOUT_FILENO, STDERR_FILENO); |
| 143 | 143 |
| 144 if (command_line.HasSwitch(switches::kWaitForDebugger)) { | 144 if (command_line.HasSwitch(switches::kWaitForDebugger)) { |
| 145 std::string msg = StringPrintf("Native test waiting for GDB because " | 145 std::string msg = base::StringPrintf("Native test waiting for GDB because " |
| 146 "flag %s was supplied", | 146 "flag %s was supplied", |
| 147 switches::kWaitForDebugger); | 147 switches::kWaitForDebugger); |
| 148 __android_log_write(ANDROID_LOG_VERBOSE, kLogTag, msg.c_str()); | 148 __android_log_write(ANDROID_LOG_VERBOSE, kLogTag, msg.c_str()); |
| 149 base::debug::WaitForDebugger(24 * 60 * 60, false); | 149 base::debug::WaitForDebugger(24 * 60 * 60, false); |
| 150 } | 150 } |
| 151 | 151 |
| 152 ScopedMainEntryLogger scoped_main_entry_logger; | 152 ScopedMainEntryLogger scoped_main_entry_logger; |
| 153 main(argc, &argv[0]); | 153 main(argc, &argv[0]); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // This is called by the VM when the shared library is first loaded. | 156 // This is called by the VM when the shared library is first loaded. |
| 157 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 157 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| 158 // Install signal handlers to detect crashes. | 158 // Install signal handlers to detect crashes. |
| 159 InstallHandlers(); | 159 InstallHandlers(); |
| 160 | 160 |
| 161 base::android::InitVM(vm); | 161 base::android::InitVM(vm); |
| 162 JNIEnv* env = base::android::AttachCurrentThread(); | 162 JNIEnv* env = base::android::AttachCurrentThread(); |
| 163 if (!RegisterNativesImpl(env)) { | 163 if (!RegisterNativesImpl(env)) { |
| 164 return -1; | 164 return -1; |
| 165 } | 165 } |
| 166 | 166 |
| 167 return JNI_VERSION_1_4; | 167 return JNI_VERSION_1_4; |
| 168 } | 168 } |
| OLD | NEW |