• Home
  • History
  • Annotate
  • only in /packages/providers/CalendarProvider/tests/
NameDateSize

..04-Dec-20154 KiB

Android.mk04-Dec-2015371

AndroidManifest.xml04-Dec-20152 KiB

EMMA_README04-Dec-20153 KiB

src/04-Dec-20154 KiB

EMMA_README

1# This defines a shell function called run_emma_calp() that rebuilds
2# the Calendar provider with EMMA coverage, executes the Calendar CTS
3# tests, and generates results into ~/emmaReport/.  The previous emmaReport
4# directory, if any, will be removed.
5#
6# This expects that ". build/envsetup.sh" and an appropriate "lunch"
7# command have already been issued.
8#
9# Also, since we're doing this "the hard way", it's necessary to have
10# /system/framework/emma.jar in BOOTCLASSPATH.  Basic steps:
11# - edit system/core/rootdir/init.rc
12# - insert "/system/framework/emma.jar" right before framework.jar
13# - mmm -j8 external/emma
14# - make -j8
15# - adb reboot-bootloader
16# - fastboot flashall
17#
18# This also defines a no_emma_calp() function that rebuilds the provider
19# without emma.
20#
21# NOTE: interrupting execution may leave you in a different directory
22
23function run_emma_calp()
24{
25    # rebuild provider with emma coverage
26    _build_install_calp true
27    if [ $? -ne 0 ]; then
28        echo Build failed.
29        return 1
30    fi
31
32    # run the CTS tests; note we can't get success/failure result in $?
33    adb shell am instrument -w -e coverage true \
34        -e class android.provider.cts.CalendarTest \
35        -w 'com.android.cts.provider/android.provider.cts.CalendarTest\$CalendarEmmaTestRunner'
36
37    # this path is hard-coded into the CalendarEmmaTestRunner
38    output=/sdcard/calendar-provider.ec
39
40    # extract and generate the report
41    rm -rf ~/emmaReport
42    mkdir ~/emmaReport
43    pushd ~/emmaReport
44    adb pull $output coverage.ec
45    adb shell rm $output
46    java -cp ${ANDROID_BUILD_TOP}/external/emma/lib/emma.jar \
47        emma report -r html -in coverage.ec \
48        -sp ${ANDROID_BUILD_TOP}/packages/providers/CalendarProvider/src \
49        -in ${ANDROID_BUILD_TOP}/out/target/common/obj/APPS/CalendarProvider_intermediates/coverage.em
50    popd
51
52    echo "Report is in $HOME/emmaReport"
53
54    return 0
55}
56
57function no_emma_calp()
58{
59    # rebuild provider without emma coverage
60    _build_install_calp false
61}
62
63function _build_install_calp()
64{
65    emma=$1
66
67    # switch to root on userdebug builds - this may take a second to finish
68    adb root
69
70    pushd $ANDROID_BUILD_TOP
71
72    # force rebuild
73    rm -rf out/target/common/obj/APPS/CalendarProvider_intermediates
74    ##rm -rf out/target/common/obj/APPS/CalendarProviderTests_intermediates
75    rm -rf out/target/common/obj/APPS/CtsProviderTestCases_intermediates
76    EMMA_INSTRUMENT=$emma mmm -j4 packages/providers/CalendarProvider \
77        && EMMA_INSTRUMENT=$emma mmm -j4 cts/tests/tests/provider
78    if [ $? -ne 0 ]; then
79        popd
80        return 1
81    fi
82
83    # copy the instrumented APKs to the device
84    adb remount
85    adb push ${ANDROID_PRODUCT_OUT}/system/app/CalendarProvider.apk /system/app/
86    ##adb push ${ANDROID_PRODUCT_OUT}/data/app/CalendarProviderTests.apk /data/app/
87    adb push ${ANDROID_PRODUCT_OUT}/data/app/CtsProviderTestCases.apk /data/app/
88    popd
89
90    # give the device a couple of seconds to install the packages
91    sleep 2
92}
93
94