blob: efae9fc0c15b02c73eae16bc8259b13bda477e23 [file] [log] [blame]
Hall Liu2ccf2042015-12-14 16:18:10 -08001lite_test_telecom() {
2 usage="
Brad Ebinger1c59a3b2015-12-15 14:28:01 -08003 Usage: lite_test_telecom [-c CLASSNAME] [-d] [-a | -i] [-e], where
Hall Liu2ccf2042015-12-14 16:18:10 -08004
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.
Brad Ebinger1c59a3b2015-12-15 14:28:01 -08008 -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).
Hall Liu2ccf2042015-12-14 16:18:10 -080011 -e Run code coverage. Coverage will be output into the coverage/
12 directory in the repo root.
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080013 -h This help message.
Hall Liu2ccf2042015-12-14 16:18:10 -080014 "
15
16 OPTIND=1
17 class=
18 install=false
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080019 installwdep=false
Hall Liu2ccf2042015-12-14 16:18:10 -080020 debug=false
21 coverage=false
22
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080023 while getopts "c:hadie" opt; do
Hall Liu2ccf2042015-12-14 16:18:10 -080024 case "$opt" in
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080025 h)
26 echo "$usage"
27 return 0;;
Brad Ebinger98a44dc2015-12-15 10:57:45 -080028 \?)
Hall Liu2ccf2042015-12-14 16:18:10 -080029 echo "$usage"
30 return 0;;
31 c)
32 class=$OPTARG;;
33 d)
34 debug=true;;
35 i)
36 install=true;;
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080037 a)
38 install=true
39 installwdep=true;;
Hall Liu2ccf2042015-12-14 16:18:10 -080040 e)
41 coverage=true;;
42 esac
43 done
44
45 T=$(gettop)
46
47 if [ $install = true ] ; then
48 olddir=$(pwd)
49 cd $T
50 if [ $coverage = true ] ; then
51 emma_opt="EMMA_INSTRUMENT_STATIC=true"
52 else
53 emma_opt="EMMA_INSTRUMENT_STATIC=false"
54 fi
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080055 # Build and exit script early if build fails
56 if [ $installwdep = true ] ; then
57 ANDROID_COMPILE_WITH_JACK=false mmma "packages/services/Telecomm/tests" ${emma_opt}
58 else
59 ANDROID_COMPILE_WITH_JACK=false mmm "packages/services/Telecomm/tests" ${emma_opt}
60 fi
61 if [ $? -ne 0 ] ; then
62 echo "Make failed! try using -a instead of -i if building with coverage"
63 return
64 fi
65
Hall Liu2ccf2042015-12-14 16:18:10 -080066 adb install -r -t "out/target/product/$TARGET_PRODUCT/data/app/TelecomUnitTests/TelecomUnitTests.apk"
67 if [ $? -ne 0 ] ; then
68 cd "$olddir"
69 return $?
70 fi
71 cd "$olddir"
72 fi
73
74 e_options=""
75 if [ -n "$class" ] ; then
76 e_options="${e_options} -e class com.android.server.telecom.tests.${class}"
77 fi
78 if [ $debug = true ] ; then
79 e_options="${e_options} -e debug 'true'"
80 fi
81 if [ $coverage = true ] ; then
82 e_options="${e_options} -e coverage 'true'"
83 fi
84 adb shell am instrument ${e_options} -w com.android.server.telecom.tests/android.test.InstrumentationTestRunner
85
86 if [ $coverage = true ] ; then
Brad Ebinger1c59a3b2015-12-15 14:28:01 -080087 adb root
88 adb wait-for-device
Hall Liu2ccf2042015-12-14 16:18:10 -080089 adb pull /data/user/0/com.android.server.telecom.tests/files/coverage.ec /tmp/
90 java -cp external/emma/lib/emma.jar emma report -r html -sp packages/services/Telecomm/src -in out/target/common/obj/APPS/TelecomUnitTests_intermediates/coverage.em -in /tmp/coverage.ec
91 fi
92}