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

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

Issue 10398049: Put commandline for apk tests in /data/local/tmp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « build/android/test_package_apk.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logcat) markers identifying the 6 // android application. It outputs (to logcat) markers identifying the
7 // START/END/CRASH of the test suite, FAILURE/SUCCESS of individual tests etc. 7 // START/END/CRASH of the test suite, FAILURE/SUCCESS of individual tests etc.
8 // These markers are read by the test runner script to generate test results. 8 // These markers are read by the test runner script to generate test results.
9 // It injects an event listener in gtest to detect various test stages and 9 // It injects an event listener in gtest to detect various test stages and
10 // installs signal handlers to detect crashes. 10 // installs signal handlers to detect crashes.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 std::vector<std::string>* args) { 66 std::vector<std::string>* args) {
67 StringTokenizer tokenizer(command_line, kWhitespaceASCII); 67 StringTokenizer tokenizer(command_line, kWhitespaceASCII);
68 tokenizer.set_quote_chars("\""); 68 tokenizer.set_quote_chars("\"");
69 while (tokenizer.GetNext()) { 69 while (tokenizer.GetNext()) {
70 std::string token; 70 std::string token;
71 RemoveChars(tokenizer.token(), "\"", &token); 71 RemoveChars(tokenizer.token(), "\"", &token);
72 args->push_back(token); 72 args->push_back(token);
73 } 73 }
74 } 74 }
75 75
76 void ParseArgsFromCommandLineFile(const FilePath& internal_data_path, 76 void ParseArgsFromCommandLineFile(std::vector<std::string>* args) {
77 std::vector<std::string>* args) { 77 // The test runner script can write to "/data/local/tmp".
78 static const char kCommandLineFile[] = "chrome-native-tests-command-line"; 78 static const char kCommandLineFilePath[] =
79 FilePath command_line(internal_data_path.Append(FilePath(kCommandLineFile))); 79 "/data/local/tmp/chrome-native-tests-command-line";
80 FilePath command_line(kCommandLineFilePath);
80 std::string command_line_string; 81 std::string command_line_string;
81 if (file_util::ReadFileToString(command_line, &command_line_string)) { 82 if (file_util::ReadFileToString(command_line, &command_line_string)) {
82 ParseArgsFromString(command_line_string, args); 83 ParseArgsFromString(command_line_string, args);
83 } 84 }
84 } 85 }
85 86
86 void ArgsToArgv(const std::vector<std::string>& args, 87 void ArgsToArgv(const std::vector<std::string>& args,
87 std::vector<char*>* argv) { 88 std::vector<char*>* argv) {
88 // We need to pass in a non-const char**. 89 // We need to pass in a non-const char**.
89 int argc = args.size(); 90 int argc = args.size();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 void LibraryLoadedOnMainThread(JNIEnv* env) { 161 void LibraryLoadedOnMainThread(JNIEnv* env) {
161 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; 162 static const char* const kInitialArgv[] = { "ChromeTestActivity" };
162 163
163 { 164 {
164 // We need a test suite to be created before we do any tracing or 165 // We need a test suite to be created before we do any tracing or
165 // logging: it creates a global at_exit_manager and initializes 166 // logging: it creates a global at_exit_manager and initializes
166 // internal gtest data structures based on the command line. 167 // internal gtest data structures based on the command line.
167 // It needs to be scoped as it also resets the CommandLine. 168 // It needs to be scoped as it also resets the CommandLine.
168 std::vector<std::string> args; 169 std::vector<std::string> args;
169 FilePath path("/data/user/0/org.chromium.native_test/files/"); 170 ParseArgsFromCommandLineFile(&args);
170 ParseArgsFromCommandLineFile(path, &args);
171 std::vector<char*> argv; 171 std::vector<char*> argv;
172 ArgsToArgv(args, &argv); 172 ArgsToArgv(args, &argv);
173 base::TestSuite test_suite(argv.size(), &argv[0]); 173 base::TestSuite test_suite(argv.size(), &argv[0]);
174 } 174 }
175 175
176 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); 176 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);
177 177
178 logging::InitLogging(NULL, 178 logging::InitLogging(NULL,
179 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 179 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
180 logging::DONT_LOCK_LOG_FILE, 180 logging::DONT_LOCK_LOG_FILE,
(...skipping 18 matching lines...) Expand all
199 jobject obj, 199 jobject obj,
200 jstring jfiles_dir, 200 jstring jfiles_dir,
201 jobject app_context) { 201 jobject app_context) {
202 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); 202 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir));
203 // A few options, such "--gtest_list_tests", will just use printf directly 203 // A few options, such "--gtest_list_tests", will just use printf directly
204 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file. 204 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file.
205 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt"))); 205 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt")));
206 freopen(stdout_path.value().c_str(), "w", stdout); 206 freopen(stdout_path.value().c_str(), "w", stdout);
207 207
208 std::vector<std::string> args; 208 std::vector<std::string> args;
209 ParseArgsFromCommandLineFile(files_dir, &args); 209 ParseArgsFromCommandLineFile(&args);
210 210
211 // We need to pass in a non-const char**. 211 // We need to pass in a non-const char**.
212 std::vector<char*> argv; 212 std::vector<char*> argv;
213 ArgsToArgv(args, &argv); 213 ArgsToArgv(args, &argv);
214 214
215 int argc = argv.size(); 215 int argc = argv.size();
216 // This object is owned by gtest. 216 // This object is owned by gtest.
217 AndroidLogPrinter* log = new AndroidLogPrinter(); 217 AndroidLogPrinter* log = new AndroidLogPrinter();
218 log->Init(&argc, &argv[0]); 218 log->Init(&argc, &argv[0]);
219 219
(...skipping 13 matching lines...) Expand all
233 233
234 base::android::InitVM(vm); 234 base::android::InitVM(vm);
235 JNIEnv* env = base::android::AttachCurrentThread(); 235 JNIEnv* env = base::android::AttachCurrentThread();
236 if (!RegisterNativesImpl(env)) { 236 if (!RegisterNativesImpl(env)) {
237 return -1; 237 return -1;
238 } 238 }
239 LibraryLoadedOnMainThread(env); 239 LibraryLoadedOnMainThread(env);
240 240
241 return JNI_VERSION_1_4; 241 return JNI_VERSION_1_4;
242 } 242 }
OLDNEW
« no previous file with comments | « build/android/test_package_apk.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698