Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: testing/android/native_test/native_test_launcher.cc

Issue 2549363004: Multiprocess test client: Android child process launcher rework. (Closed)
Patch Set: Fixed tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
11 11
12 #include <android/log.h> 12 #include <android/log.h>
13 #include <signal.h> 13 #include <signal.h>
14 14
15 #include "base/android/base_jni_registrar.h" 15 #include "base/android/base_jni_registrar.h"
16 #include "base/android/context_utils.h" 16 #include "base/android/context_utils.h"
17 #include "base/android/fifo_utils.h" 17 #include "base/android/fifo_utils.h"
18 #include "base/android/jni_string.h" 18 #include "base/android/jni_string.h"
19 #include "base/android/scoped_java_ref.h" 19 #include "base/android/scoped_java_ref.h"
20 #include "base/at_exit.h" 20 #include "base/at_exit.h"
21 #include "base/base_switches.h" 21 #include "base/base_switches.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/files/file_path.h" 23 #include "base/files/file_path.h"
24 #include "base/files/file_util.h" 24 #include "base/files/file_util.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/test/android/test_support_jni_registrar.h"
27 #include "base/test/test_support_android.h" 28 #include "base/test/test_support_android.h"
28 #include "gtest/gtest.h" 29 #include "gtest/gtest.h"
29 #include "jni/NativeTest_jni.h" 30 #include "jni/NativeTest_jni.h"
30 #include "testing/android/native_test/native_test_util.h" 31 #include "testing/android/native_test/native_test_util.h"
31 32
32 using base::android::JavaParamRef; 33 using base::android::JavaParamRef;
33 34
34 // The main function of the program to be wrapped as a test apk. 35 // The main function of the program to be wrapped as a test apk.
35 extern int main(int argc, char** argv); 36 extern int main(int argc, char** argv);
36 37
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 "Native test waiting for GDB because flag %s was supplied", 118 "Native test waiting for GDB because flag %s was supplied",
118 switches::kWaitForDebugger); 119 switches::kWaitForDebugger);
119 base::debug::WaitForDebugger(24 * 60 * 60, true); 120 base::debug::WaitForDebugger(24 * 60 * 60, true);
120 } 121 }
121 122
122 base::FilePath test_data_dir( 123 base::FilePath test_data_dir(
123 base::android::ConvertJavaStringToUTF8(env, jtest_data_dir)); 124 base::android::ConvertJavaStringToUTF8(env, jtest_data_dir));
124 base::InitAndroidTestPaths(test_data_dir); 125 base::InitAndroidTestPaths(test_data_dir);
125 126
126 ScopedMainEntryLogger scoped_main_entry_logger; 127 ScopedMainEntryLogger scoped_main_entry_logger;
127 main(argc, &argv[0]); 128 main(argc, &(argv[0]));
Ken Rockot(use gerrit already) 2016/12/12 22:23:08 nit: unnecessary
Jay Civelli 2016/12/13 18:23:26 Done.
128 } 129 }
129 130
130 bool RegisterNativeTestJNI(JNIEnv* env) { 131 bool RegisterNativeTestJNI(JNIEnv* env) {
131 if (!base::android::RegisterJni(env)) { 132 if (!base::android::RegisterJni(env))
132 return false; 133 return false;
133 } 134 if (!base::android::RegisterTestSupportJni(env))
135 return false;
134 return RegisterNativesImpl(env); 136 return RegisterNativesImpl(env);
135 } 137 }
136 138
137 // TODO(nileshagrawal): now that we're using FIFO, test scripts can detect EOF. 139 // TODO(nileshagrawal): now that we're using FIFO, test scripts can detect EOF.
138 // Remove the signal handlers. 140 // Remove the signal handlers.
139 void InstallHandlers() { 141 void InstallHandlers() {
140 struct sigaction sa; 142 struct sigaction sa;
141 memset(&sa, 0, sizeof(sa)); 143 memset(&sa, 0, sizeof(sa));
142 144
143 sa.sa_sigaction = SignalHandler; 145 sa.sa_sigaction = SignalHandler;
144 sa.sa_flags = SA_SIGINFO; 146 sa.sa_flags = SA_SIGINFO;
145 147
146 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { 148 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) {
147 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); 149 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]);
148 } 150 }
149 } 151 }
150 152
151 } // namespace android 153 } // namespace android
152 } // namespace testing 154 } // namespace testing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698