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. |
11 | 11 |
12 #include <android/log.h> | 12 #include <android/log.h> |
13 #include <signal.h> | 13 #include <signal.h> |
14 #include <stdarg.h> | 14 #include <stdarg.h> |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 | 16 |
17 #include "base/android/base_jni_registrar.h" | 17 #include "base/android/base_jni_registrar.h" |
18 #include "base/android/jni_android.h" | 18 #include "base/android/jni_android.h" |
19 #include "base/android/jni_string.h" | 19 #include "base/android/jni_string.h" |
20 #include "base/android/locale_utils.h" | 20 #include "base/android/locale_utils.h" |
21 #include "base/android/path_utils.h" | 21 #include "base/android/path_utils.h" |
22 #include "base/android/scoped_java_ref.h" | 22 #include "base/android/scoped_java_ref.h" |
23 #include "base/at_exit.h" | 23 #include "base/at_exit.h" |
24 #include "base/base_switches.h" | 24 #include "base/base_switches.h" |
25 #include "base/command_line.h" | 25 #include "base/command_line.h" |
26 #include "base/file_path.h" | 26 #include "base/file_path.h" |
27 #include "base/file_util.h" | 27 #include "base/file_util.h" |
28 #include "base/logging.h" | 28 #include "base/logging.h" |
| 29 #include "base/string_util.h" |
29 #include "base/stringprintf.h" | 30 #include "base/stringprintf.h" |
30 #include "base/string_tokenizer.h" | 31 #include "base/strings/string_tokenizer.h" |
31 #include "base/string_util.h" | |
32 #include "gtest/gtest.h" | 32 #include "gtest/gtest.h" |
33 #include "testing/jni/ChromeNativeTestActivity_jni.h" | 33 #include "testing/jni/ChromeNativeTestActivity_jni.h" |
34 | 34 |
35 // 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. |
36 extern int main(int argc, char** argv); | 36 extern int main(int argc, char** argv); |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // These two command line flags are supported for DumpRenderTree, which needs | 40 // These two command line flags are supported for DumpRenderTree, which needs |
41 // three fifos rather than a combined one: one for stderr, stdin and stdout. | 41 // three fifos rather than a combined one: one for stderr, stdin and stdout. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 sa.sa_sigaction = SignalHandler; | 75 sa.sa_sigaction = SignalHandler; |
76 sa.sa_flags = SA_SIGINFO; | 76 sa.sa_flags = SA_SIGINFO; |
77 | 77 |
78 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { | 78 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { |
79 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); | 79 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 void ParseArgsFromString(const std::string& command_line, | 83 void ParseArgsFromString(const std::string& command_line, |
84 std::vector<std::string>* args) { | 84 std::vector<std::string>* args) { |
85 StringTokenizer tokenizer(command_line, kWhitespaceASCII); | 85 base::StringTokenizer tokenizer(command_line, kWhitespaceASCII); |
86 tokenizer.set_quote_chars("\""); | 86 tokenizer.set_quote_chars("\""); |
87 while (tokenizer.GetNext()) { | 87 while (tokenizer.GetNext()) { |
88 std::string token; | 88 std::string token; |
89 RemoveChars(tokenizer.token(), "\"", &token); | 89 RemoveChars(tokenizer.token(), "\"", &token); |
90 args->push_back(token); | 90 args->push_back(token); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void ParseArgsFromCommandLineFile(std::vector<std::string>* args) { | 94 void ParseArgsFromCommandLineFile(std::vector<std::string>* args) { |
95 // The test runner script writes the command line file in | 95 // The test runner script writes the command line file in |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 InstallHandlers(); | 228 InstallHandlers(); |
229 | 229 |
230 base::android::InitVM(vm); | 230 base::android::InitVM(vm); |
231 JNIEnv* env = base::android::AttachCurrentThread(); | 231 JNIEnv* env = base::android::AttachCurrentThread(); |
232 if (!RegisterNativesImpl(env)) { | 232 if (!RegisterNativesImpl(env)) { |
233 return -1; | 233 return -1; |
234 } | 234 } |
235 | 235 |
236 return JNI_VERSION_1_4; | 236 return JNI_VERSION_1_4; |
237 } | 237 } |
OLD | NEW |