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 18 matching lines...) Expand all Loading... | |
29 #include "testing/android/native_test/native_test_util.h" | 29 #include "testing/android/native_test/native_test_util.h" |
30 | 30 |
31 // The main function of the program to be wrapped as a test apk. | 31 // The main function of the program to be wrapped as a test apk. |
32 extern int main(int argc, char** argv); | 32 extern int main(int argc, char** argv); |
33 | 33 |
34 namespace testing { | 34 namespace testing { |
35 namespace android { | 35 namespace android { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 // The test runner script writes the command line file in | |
40 // "/data/local/tmp". | |
41 static const char kCommandLineFilePath[] = | |
42 "/data/local/tmp/chrome-native-tests-command-line"; | |
43 | |
44 const char kLogTag[] = "chromium"; | 39 const char kLogTag[] = "chromium"; |
45 const char kCrashedMarker[] = "[ CRASHED ]\n"; | 40 const char kCrashedMarker[] = "[ CRASHED ]\n"; |
46 | 41 |
47 // The list of signals which are considered to be crashes. | 42 // The list of signals which are considered to be crashes. |
48 const int kExceptionSignals[] = { | 43 const int kExceptionSignals[] = { |
49 SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1 | 44 SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1 |
50 }; | 45 }; |
51 | 46 |
52 struct sigaction g_old_sa[NSIG]; | 47 struct sigaction g_old_sa[NSIG]; |
53 | 48 |
(...skipping 28 matching lines...) Expand all Loading... | |
82 | 77 |
83 // Set the application context in base. | 78 // Set the application context in base. |
84 base::android::InitApplicationContext(env, app_context); | 79 base::android::InitApplicationContext(env, app_context); |
85 base::android::RegisterJni(env); | 80 base::android::RegisterJni(env); |
86 | 81 |
87 std::vector<std::string> args; | 82 std::vector<std::string> args; |
88 | 83 |
89 const std::string command_line_file_path( | 84 const std::string command_line_file_path( |
90 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); | 85 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); |
91 if (command_line_file_path.empty()) | 86 if (command_line_file_path.empty()) |
92 ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); | 87 args.push_back("_"); |
Yaron
2015/10/20 18:03:02
Just wondering if this breaks a possible dev flow:
jbudorick
2015/10/20 18:08:49
The test runner currently doesn't overwrite the fi
agrieve
2015/10/20 18:11:07
Yeah, tried to code search this as much as I could
| |
93 else | 88 else |
94 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); | 89 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); |
95 | 90 |
96 const std::string command_line_flags( | 91 const std::string command_line_flags( |
97 base::android::ConvertJavaStringToUTF8(env, jcommand_line_flags)); | 92 base::android::ConvertJavaStringToUTF8(env, jcommand_line_flags)); |
98 ParseArgsFromString(command_line_flags, &args); | 93 ParseArgsFromString(command_line_flags, &args); |
99 | 94 |
100 std::vector<char*> argv; | 95 std::vector<char*> argv; |
101 int argc = ArgsToArgv(args, &argv); | 96 int argc = ArgsToArgv(args, &argv); |
102 | 97 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 sa.sa_sigaction = SignalHandler; | 145 sa.sa_sigaction = SignalHandler; |
151 sa.sa_flags = SA_SIGINFO; | 146 sa.sa_flags = SA_SIGINFO; |
152 | 147 |
153 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { | 148 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { |
154 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); | 149 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); |
155 } | 150 } |
156 } | 151 } |
157 | 152 |
158 } // namespace android | 153 } // namespace android |
159 } // namespace testing | 154 } // namespace testing |
OLD | NEW |