diff options
| author | 2018-10-05 12:28:43 -0700 | |
|---|---|---|
| committer | 2018-10-05 12:28:43 -0700 | |
| commit | b8027a44b8fae98c58eff1d8477dc04c51262ed8 (patch) | |
| tree | d5cbf67b4aad2c34508c4c471a0e647fcc8b9afd | |
| parent | 6d231690b9fc50193c0c3b15d3f2fe8bfa6fa6ca (diff) | |
| parent | 5d0f45932a6745ce52e0fa1eeb26e976ee84622e (diff) | |
Merge "Refine frameworks/base/services/tests/runtest.py" am: 8bbf0181f6 am: 10623937df
am: 5d0f45932a
Change-Id: I12492934128e5217b01593b200d34a67f448a19c
| -rwxr-xr-x | services/tests/runtests.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/services/tests/runtests.py b/services/tests/runtests.py index 7980dc23e8e2..f19cc5d567ec 100755 --- a/services/tests/runtests.py +++ b/services/tests/runtests.py @@ -22,8 +22,7 @@ INSTRUMENTED_PACKAGE_RUNNER = ('com.android.frameworks.servicestests/' 'android.support.test.runner.AndroidJUnitRunner') PACKAGE_WHITELIST = ( - 'android.net', - 'com.android.server.connectivity', + "com.android.server", ) COLOR_RED = '\033[0;31m' @@ -37,14 +36,27 @@ def run(shell_command, echo=True): COLOR_NONE) return subprocess.check_call(shell_command, shell=True) - +# usage: +# ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/runtests.py : run tests in com.android.server +# ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/runtests.py -e package [package name, e.g. com.android.server] +# ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/runtests.py -e class [class name, e.g. com.android.server.MountServiceTests] +# +# The available INSTRUMENTED_PACKAGE_RUNNER may differ in different environments. +# In this case, use "adb shell pm list instrumentation" to query available runners +# and use the environment variable INSTRUMENTED_PACKAGE_RUNNER to overwrite +# the default one, e.g., +# INSTRUMENTED_PACKAGE_RUNNER=com.android.frameworks.servicestests/androidx.test.runner.AndroidJUnitRunner \ +# ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/runtests.py +# def main(): build_top = os.environ.get('ANDROID_BUILD_TOP', None) out_dir = os.environ.get('OUT', None) + runner = os.environ.get('INSTRUMENTED_PACKAGE_RUNNER', None) if build_top is None or out_dir is None: print 'You need to source and lunch before you can use this script' return 1 - + if runner is None: + runner = INSTRUMENTED_PACKAGE_RUNNER print 'Building tests...' run('make -j32 -C %s -f build/core/main.mk ' 'MODULES-IN-frameworks-base-services-tests-servicestests' % build_top, @@ -57,19 +69,19 @@ def main(): apk_path = ( '%s/data/app/FrameworksServicesTests/FrameworksServicesTests.apk' % out_dir) - run('adb install -r -g "%s"' % apk_path) + run('adb install -t -r -g "%s"' % apk_path) print 'Running tests...' if len(sys.argv) != 1: run('adb shell am instrument -w %s "%s"' % - (' '.join(sys.argv[1:]), INSTRUMENTED_PACKAGE_RUNNER)) + (' '.join(sys.argv[1:]), runner)) return 0 # It would be nice if the activity manager accepted a list of packages, but # in lieu of that... for package in PACKAGE_WHITELIST: run('adb shell am instrument -w -e package %s %s' % - (package, INSTRUMENTED_PACKAGE_RUNNER)) + (package, runner)) return 0 |