diff --git a/scripts/telecom_testing.sh b/scripts/telecom_testing.sh index e6423a3e7..0ece427ea 100644 --- a/scripts/telecom_testing.sh +++ b/scripts/telecom_testing.sh @@ -1,6 +1,6 @@ -lite_test_telecom() { +_lite_test_general() { usage=" - Usage: lite_test_telecom [-c CLASSNAME] [-d] [-a | -i] [-e], where + Usage: $0 [-c CLASSNAME] [-d] [-a | -i] [-e], where -c CLASSNAME Run tests only for the specified class/method. CLASSNAME should be of the form SomeClassTest or SomeClassTest#testMethod. @@ -15,12 +15,13 @@ lite_test_telecom() { local OPTIND=1 local class= + local project= local install=false local installwdep=false local debug=false local coverage=false - while getopts "c:hadie" opt; do + while getopts "c:p:hadie" opt; do case "$opt" in h) echo "$usage" @@ -39,9 +40,28 @@ lite_test_telecom() { installwdep=true;; e) coverage=true;; + p) + project=$OPTARG;; esac done + local build_dir= + local apk_loc= + local package_prefix= + local instrumentation= + case "$project" in + "telecom") + build_dir="packages/services/Telecomm/tests" + apk_loc="data/app/TelecomUnitTests/TelecomUnitTests.apk" + package_prefix="com.android.server.telecom.tests" + instrumentation="android.test.InstrumentationTestRunner";; + "telephony") + build_dir="frameworks/opt/telephony/tests/" + apk_loc="data/app/FrameworksTelephonyTests/FrameworksTelephonyTests.apk" + package_prefix="com.android.frameworks.telephonytests" + instrumentation="android.support.test.runner.AndroidJUnitRunner";; + esac + local T=$(gettop) if [ $install = true ] ; then @@ -57,9 +77,9 @@ lite_test_telecom() { fi if [ $installwdep = true ] ; then - (export ${emma_opt}; mmma -j40 "packages/services/Telecomm/tests") + (export ${emma_opt}; mmma -j40 "$build_dir") else - (export ${emma_opt}; mmm "packages/services/Telecomm/tests") + (export ${emma_opt}; mmm "$build_dir") fi if [ $? -ne 0 ] ; then echo "Make failed! try using -a instead of -i if building with coverage" @@ -69,7 +89,7 @@ lite_test_telecom() { # Strip off any possible aosp_ prefix from the target product local canonical_product=$(sed 's/^aosp_//' <<< "$TARGET_PRODUCT") - adb install -r -t "out/target/product/$canonical_product/data/app/TelecomUnitTests/TelecomUnitTests.apk" + adb install -r -t "out/target/product/$canonical_product/$apk_loc" if [ $? -ne 0 ] ; then cd "$olddir" return $? @@ -79,17 +99,22 @@ lite_test_telecom() { local e_options="" if [ -n "$class" ] ; then - e_options="${e_options} -e class com.android.server.telecom.tests.${class}" + if [[ "$class" =~ "\." ]] ; then + e_options="${e_options} -e class ${class}" + else + e_options="${e_options} -e class ${package_prefix}.${class}" + fi fi if [ $debug = true ] ; then e_options="${e_options} -e debug 'true'" fi - if [ $coverage = true ] ; then + if [ $coverage = true ] && [ $project =~ "telecom" ] ; then e_options="${e_options} -e coverage 'true'" fi - adb shell am instrument ${e_options} -w com.android.server.telecom.tests/android.test.InstrumentationTestRunner + adb shell am instrument ${e_options} -w "$package_prefix/$instrumentation" - if [ $coverage = true ] ; then + # Code coverage only enabled for Telecom. + if [ $coverage = true ] && [ $project =~ "telecom" ] ; then adb root adb wait-for-device adb pull /data/user/0/com.android.server.telecom.tests/files/coverage.ec /tmp/ @@ -103,3 +128,11 @@ lite_test_telecom() { --source-dir "$T/packages/services/Telecomm/src/" fi } + +lite_test_telecom() { + _lite_test_general -p telecom $@ +} + +lite_test_telephony() { + _lite_test_general -p telephony $@ +}