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

Side by Side Diff: build/android/pylib/test_package_apk.py

Issue 10689132: [android] Upstream / sync most of build/android and build/android/pylib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/pylib/test_package.py ('k') | build/android/pylib/test_package_executable.py » ('j') | 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 5
6 import os 6 import os
7 import re
7 import sys 8 import sys
8 9
9 import cmd_helper 10 import cmd_helper
10 import logging 11 import logging
11 import shutil 12 import shutil
12 import tempfile 13 import tempfile
13 from test_package import TestPackage 14 from test_package import TestPackage
14 15
15 16
16 class TestPackageApk(TestPackage): 17 class TestPackageApk(TestPackage):
(...skipping 14 matching lines...) Expand all
31 APK_DATA_DIR = '/data/user/0/org.chromium.native_test/files/' 32 APK_DATA_DIR = '/data/user/0/org.chromium.native_test/files/'
32 33
33 def __init__(self, adb, device, test_suite, timeout, rebaseline, 34 def __init__(self, adb, device, test_suite, timeout, rebaseline,
34 performance_test, cleanup_test_files, tool, 35 performance_test, cleanup_test_files, tool,
35 dump_debug_info): 36 dump_debug_info):
36 TestPackage.__init__(self, adb, device, test_suite, timeout, 37 TestPackage.__init__(self, adb, device, test_suite, timeout,
37 rebaseline, performance_test, cleanup_test_files, 38 rebaseline, performance_test, cleanup_test_files,
38 tool, dump_debug_info) 39 tool, dump_debug_info)
39 40
40 def _CreateTestRunnerScript(self, options): 41 def _CreateTestRunnerScript(self, options):
41 tool_wrapper = self.tool.GetTestWrapper()
42 if tool_wrapper:
43 raise RuntimeError("TestPackageApk does not support custom wrappers.")
44 command_line_file = tempfile.NamedTemporaryFile() 42 command_line_file = tempfile.NamedTemporaryFile()
45 # GTest expects argv[0] to be the executable path. 43 # GTest expects argv[0] to be the executable path.
46 command_line_file.write(self.test_suite_basename + ' ' + options) 44 command_line_file.write(self.test_suite_basename + ' ' + options)
47 command_line_file.flush() 45 command_line_file.flush()
48 self.adb.PushIfNeeded(command_line_file.name, 46 self.adb.PushIfNeeded(command_line_file.name,
49 '/data/local/tmp/' + 47 '/data/local/tmp/' +
50 'chrome-native-tests-command-line') 48 'chrome-native-tests-command-line')
51 49
52 def _GetGTestReturnCode(self): 50 def _GetGTestReturnCode(self):
53 return None 51 return None
54 52
55 def GetAllTests(self): 53 def GetAllTests(self):
56 """Returns a list of all tests available in the test suite.""" 54 """Returns a list of all tests available in the test suite."""
57 self._CreateTestRunnerScript('--gtest_list_tests') 55 self._CreateTestRunnerScript('--gtest_list_tests')
58 self.adb.RunShellCommand( 56 try:
59 'am start -n ' 57 self.tool.SetupEnvironment()
60 'com.android.chrome.native_tests/' 58 # Clear and start monitoring logcat.
61 'android.app.NativeActivity') 59 self.adb.StartMonitoringLogcat(clear=True,
60 timeout=30 * self.tool.GetTimeoutScale())
61 self.adb.RunShellCommand(
62 'am start -n '
63 'org.chromium.native_test/'
64 'org.chromium.native_test.ChromeNativeTestActivity')
65 # Wait for native test to complete.
66 self.adb.WaitForLogMatch(re.compile('<<nativeRunTests'), None)
67 finally:
68 self.tool.CleanUpEnvironment()
69 # Copy stdout.txt and read contents.
62 stdout_file = tempfile.NamedTemporaryFile() 70 stdout_file = tempfile.NamedTemporaryFile()
63 ret = [] 71 ret = []
64 self.adb.Adb().Pull(TestPackageApk.APK_DATA_DIR + 'stdout.txt', 72 self.adb.Adb().Pull(TestPackageApk.APK_DATA_DIR + 'stdout.txt',
65 stdout_file.name) 73 stdout_file.name)
66 ret = self._ParseGTestListTests(stdout_file) 74 # We need to strip the trailing newline.
75 content = [line.rstrip() for line in open(stdout_file.name)]
76 ret = self._ParseGTestListTests(content)
67 return ret 77 return ret
68 78
69 def CreateTestRunnerScript(self, gtest_filter, test_arguments): 79 def CreateTestRunnerScript(self, gtest_filter, test_arguments):
70 self._CreateTestRunnerScript('--gtest_filter=%s %s' % (gtest_filter, 80 self._CreateTestRunnerScript('--gtest_filter=%s %s' % (gtest_filter,
71 test_arguments)) 81 test_arguments))
72 82
73 def RunTestsAndListResults(self): 83 def RunTestsAndListResults(self):
74 self.adb.StartMonitoringLogcat(clear=True, logfile=sys.stdout) 84 self.adb.StartMonitoringLogcat(clear=True, logfile=sys.stdout)
75 self.adb.RunShellCommand( 85 try:
76 'am start -n ' 86 self.tool.SetupEnvironment()
87 self.adb.RunShellCommand(
88 'am start -n '
77 'org.chromium.native_test/' 89 'org.chromium.native_test/'
78 'org.chromium.native_test.ChromeNativeTestActivity') 90 'org.chromium.native_test.ChromeNativeTestActivity')
91 finally:
92 self.tool.CleanUpEnvironment()
79 return self._WatchTestOutput(self.adb.GetMonitoredLogCat()) 93 return self._WatchTestOutput(self.adb.GetMonitoredLogCat())
80 94
81 def StripAndCopyExecutable(self): 95 def StripAndCopyExecutable(self):
82 # Always uninstall the previous one (by activity name); we don't 96 # Always uninstall the previous one (by activity name); we don't
83 # know what was embedded in it. 97 # know what was embedded in it.
84 logging.info('Uninstalling any activity with the test name') 98 logging.info('Uninstalling any activity with the test name')
85 self.adb.Adb().SendCommand('uninstall org.chromium.native_test', 99 self.adb.Adb().SendCommand('uninstall org.chromium.native_test',
86 timeout_time=60*5) 100 timeout_time=60*5)
87 logging.info('Installing new apk') 101 logging.info('Installing new apk')
88 self.adb.Adb().SendCommand('install -r ' + self.test_suite_full, 102 self.adb.Adb().SendCommand('install -r ' + self.test_suite_full,
89 timeout_time=60*5) 103 timeout_time=60*5)
90 logging.info('Install has completed.') 104 logging.info('Install has completed.')
91 105
92 def _GetTestSuiteBaseName(self): 106 def _GetTestSuiteBaseName(self):
93 """Returns the base name of the test suite.""" 107 """Returns the base name of the test suite."""
94 # APK test suite names end with '-debug.apk' 108 # APK test suite names end with '-debug.apk'
95 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] 109 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0]
OLDNEW
« no previous file with comments | « build/android/pylib/test_package.py ('k') | build/android/pylib/test_package_executable.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698