Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 1 | lite_test_telecom() { |
| 2 | usage=" |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 3 | Usage: lite_test_telecom [-c CLASSNAME] [-d] [-a | -i] [-e], where |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 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. |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 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). |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 11 | -e Run code coverage. Coverage will be output into the coverage/ |
| 12 | directory in the repo root. |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 13 | -h This help message. |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 14 | " |
| 15 | |
| 16 | OPTIND=1 |
| 17 | class= |
| 18 | install=false |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 19 | installwdep=false |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 20 | debug=false |
| 21 | coverage=false |
| 22 | |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 23 | while getopts "c:hadie" opt; do |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 24 | case "$opt" in |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 25 | h) |
| 26 | echo "$usage" |
| 27 | return 0;; |
Brad Ebinger | 98a44dc | 2015-12-15 10:57:45 -0800 | [diff] [blame] | 28 | \?) |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 29 | echo "$usage" |
| 30 | return 0;; |
| 31 | c) |
| 32 | class=$OPTARG;; |
| 33 | d) |
| 34 | debug=true;; |
| 35 | i) |
| 36 | install=true;; |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 37 | a) |
| 38 | install=true |
| 39 | installwdep=true;; |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 40 | 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 Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 55 | # Build and exit script early if build fails |
| 56 | if [ $installwdep = true ] ; then |
Hall Liu | 5b058df | 2015-12-16 16:30:29 -0800 | [diff] [blame] | 57 | ANDROID_COMPILE_WITH_JACK=false mmma -j40 "packages/services/Telecomm/tests" ${emma_opt} |
Brad Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 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 Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 66 | 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 Ebinger | 1c59a3b | 2015-12-15 14:28:01 -0800 | [diff] [blame] | 87 | adb root |
| 88 | adb wait-for-device |
Hall Liu | 2ccf204 | 2015-12-14 16:18:10 -0800 | [diff] [blame] | 89 | 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 | } |