blob: 4b43275ff27a4ac8ecd99ef2276a03e5c851ed2a [file] [log] [blame]
Hall Liu2ccf2042015-12-14 16:18:10 -08001lite_test_telecom() {
2 usage="
3 Usage: lite_test_telecom [-c CLASSNAME] [-d] [-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
9 -e Run code coverage. Coverage will be output into the coverage/
10 directory in the repo root.
11 "
12
13 OPTIND=1
14 class=
15 install=false
16 debug=false
17 coverage=false
18
19 while getopts "c:die?" opt; do
20 case "$opt" in
21 ?)
22 echo "$usage"
23 return 0;;
24 c)
25 class=$OPTARG;;
26 d)
27 debug=true;;
28 i)
29 install=true;;
30 e)
31 coverage=true;;
32 esac
33 done
34
35 T=$(gettop)
36
37 if [ $install = true ] ; then
38 olddir=$(pwd)
39 cd $T
40 if [ $coverage = true ] ; then
41 emma_opt="EMMA_INSTRUMENT_STATIC=true"
42 else
43 emma_opt="EMMA_INSTRUMENT_STATIC=false"
44 fi
45 ANDROID_COMPILE_WITH_JACK=false mmm "packages/services/Telecomm/tests" ${emma_opt}
46 adb install -r -t "out/target/product/$TARGET_PRODUCT/data/app/TelecomUnitTests/TelecomUnitTests.apk"
47 if [ $? -ne 0 ] ; then
48 cd "$olddir"
49 return $?
50 fi
51 cd "$olddir"
52 fi
53
54 e_options=""
55 if [ -n "$class" ] ; then
56 e_options="${e_options} -e class com.android.server.telecom.tests.${class}"
57 fi
58 if [ $debug = true ] ; then
59 e_options="${e_options} -e debug 'true'"
60 fi
61 if [ $coverage = true ] ; then
62 e_options="${e_options} -e coverage 'true'"
63 fi
64 adb shell am instrument ${e_options} -w com.android.server.telecom.tests/android.test.InstrumentationTestRunner
65
66 if [ $coverage = true ] ; then
67 adb pull /data/user/0/com.android.server.telecom.tests/files/coverage.ec /tmp/
68 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
69 fi
70}