1lite_test_telecom() { 2 usage=" 3 Usage: lite_test_telecom [-c CLASSNAME] [-d] [-a | -i] [-e], where 4 5 -c CLASSNAME Run tests only for the specified class/method. CLASSNAME 6 should be of the form SomeClassTest or SomeClassTest#testMethod. 7 -d Waits for a debugger to attach before starting to run tests. 8 -i Rebuild and reinstall the test apk before running tests (mmm). 9 -a Rebuild all dependencies and reinstall the test apk before/ 10 running tests (mmma). 11 -e Run code coverage. Coverage will be output into the coverage/ 12 directory in the repo root. 13 -h This help message. 14 " 15 16 local OPTIND=1 17 local class= 18 local install=false 19 local installwdep=false 20 local debug=false 21 local coverage=false 22 23 while getopts "c:hadie" opt; do 24 case "$opt" in 25 h) 26 echo "$usage" 27 return 0;; 28 \?) 29 echo "$usage" 30 return 0;; 31 c) 32 class=$OPTARG;; 33 d) 34 debug=true;; 35 i) 36 install=true;; 37 a) 38 install=true 39 installwdep=true;; 40 e) 41 coverage=true;; 42 esac 43 done 44 45 local T=$(gettop) 46 47 if [ $install = true ] ; then 48 local olddir=$(pwd) 49 local emma_opt= 50 cd $T 51 # Build and exit script early if build fails 52 53 if [ $coverage = true ] ; then 54 emma_opt="EMMA_INSTRUMENT=true LOCAL_EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true" 55 else 56 emma_opt="EMMA_INSTRUMENT=false" 57 fi 58 59 if [ $installwdep = true ] ; then 60 (export ${emma_opt}; mmma -j40 "packages/services/Telecomm/tests") 61 else 62 (export ${emma_opt}; mmm "packages/services/Telecomm/tests") 63 fi 64 if [ $? -ne 0 ] ; then 65 echo "Make failed! try using -a instead of -i if building with coverage" 66 return 67 fi 68 69 # Strip off any possible aosp_ prefix from the target product 70 local canonical_product=$(sed 's/^aosp_//' <<< "$TARGET_PRODUCT") 71 72 adb install -r -t "out/target/product/$canonical_product/data/app/TelecomUnitTests/TelecomUnitTests.apk" 73 if [ $? -ne 0 ] ; then 74 cd "$olddir" 75 return $? 76 fi 77 cd "$olddir" 78 fi 79 80 local e_options="" 81 if [ -n "$class" ] ; then 82 e_options="${e_options} -e class com.android.server.telecom.tests.${class}" 83 fi 84 if [ $debug = true ] ; then 85 e_options="${e_options} -e debug 'true'" 86 fi 87 if [ $coverage = true ] ; then 88 e_options="${e_options} -e coverage 'true'" 89 fi 90 adb shell am instrument ${e_options} -w com.android.server.telecom.tests/android.test.InstrumentationTestRunner 91 92 if [ $coverage = true ] ; then 93 adb root 94 adb wait-for-device 95 adb pull /data/user/0/com.android.server.telecom.tests/files/coverage.ec /tmp/ 96 if [ ! -d "$T/coverage" ] ; then 97 mkdir -p "$T/coverage" 98 fi 99 java -jar "$T/prebuilts/sdk/tools/jack-jacoco-reporter.jar" \ 100 --report-dir "$T/coverage/" \ 101 --metadata-file "$T/out/target/common/obj/APPS/TelecomUnitTests_intermediates/coverage.em" \ 102 --coverage-file "/tmp/coverage.ec" \ 103 --source-dir "$T/packages/services/Telecomm/src/" 104 fi 105} 106