summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeff Gaston <jeffrygaston@google.com>2017-04-18 18:12:45 -0700
committerJeff Gaston <jeffrygaston@google.com>2017-07-17 13:57:59 -0700
commitdbfa9dbd9b2f1ab07d848f2e34d8b0149337d1c4 (patch)
treef63b598c307b67144e6775e1a020617c34c01621 /tests
parent67e0154135d3939410174cba18c1b9167b6abd9f (diff)
Switch to Jacoco for code coverage
Bug: 36792868 Test: ./coverage.sh /tmp/outdir Change-Id: I0386ab95ca116d51c3c5767fa478a55b45c98d73
Diffstat (limited to 'tests')
-rwxr-xr-xtests/wifitests/coverage.sh54
1 files changed, 31 insertions, 23 deletions
diff --git a/tests/wifitests/coverage.sh b/tests/wifitests/coverage.sh
index bf50dee80..c81af5611 100755
--- a/tests/wifitests/coverage.sh
+++ b/tests/wifitests/coverage.sh
@@ -1,8 +1,7 @@
#!/usr/bin/env bash
-if [[ ! ( ($# == 1) || ($# == 2 && ($2 == "HTML" || $2 == "XML" || $2 == "CSV"))) ]]; then
- echo "$0: usage: coverage.sh OUTPUT_DIR [REPORT_TYPE]"
- echo "REPORT_TYPE [HTML | XML | CSV] : the type of the report (default is HTML)"
+if [[ ! ($# == 1) ]]; then
+ echo "$0: usage: coverage.sh OUTPUT_DIR"
exit 1
fi
@@ -11,32 +10,38 @@ if [ -z $ANDROID_BUILD_TOP ]; then
exit 1
fi
-REPORTER_JAR=$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack-jacoco-reporter.jar
+cd "$(dirname $0)" #cd to directory containing this script
+
+
+REPORTER_JAR=$ANDROID_HOST_OUT/framework/jacoco-cli.jar
OUTPUT_DIR=$1
-if [[ $# == 2 ]]; then
- REPORT_TYPE=$2
-else
- REPORT_TYPE="HTML"
-fi
echo "Running tests and generating coverage report"
echo "Output dir: $OUTPUT_DIR"
-echo "Report type: $REPORT_TYPE"
REMOTE_COVERAGE_OUTPUT_FILE=/data/data/com.android.server.wifi.test/files/coverage.ec
COVERAGE_OUTPUT_FILE=$OUTPUT_DIR/wifi_coverage.ec
-COVERAGE_METADATA_FILE=$ANDROID_BUILD_TOP/out/target/common/obj/APPS/FrameworksWifiTests_intermediates/coverage.em
set -e # fail early
-
-echo "+ EMMA_INSTRUMENT_STATIC=true mmma -j32 $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests"
-# NOTE Don't actually run the command above since this shell doesn't inherit functions from the
-# caller.
-EMMA_INSTRUMENT_STATIC=true make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk MODULES-IN-frameworks-opt-net-wifi-tests
-
set -x # print commands
+# build this module so we can run its tests, and
+# build system/core so we can invoke `adb`, and
+# build jacoco-report-classes.jar so we can generate the report
+make \
+ EMMA_INSTRUMENT=true \
+ EMMA_INSTRUMENT_FRAMEWORK=false \
+ EMMA_INSTRUMENT_STATIC=true \
+ ANDROID_COMPILE_WITH_JACK=false \
+ SKIP_BOOT_JARS_CHECK=true \
+ -j32 \
+ -C $ANDROID_BUILD_TOP \
+ -f build/core/main.mk \
+ MODULES-IN-frameworks-opt-net-wifi-tests \
+ MODULES-IN-system-core \
+ FrameworksWifiTests
+
adb root
adb wait-for-device
@@ -51,9 +56,12 @@ mkdir -p $OUTPUT_DIR
adb pull $REMOTE_COVERAGE_OUTPUT_FILE $COVERAGE_OUTPUT_FILE
java -jar $REPORTER_JAR \
- --report-dir $OUTPUT_DIR \
- --metadata-file $COVERAGE_METADATA_FILE \
- --coverage-file $COVERAGE_OUTPUT_FILE \
- --report-type $REPORT_TYPE \
- --source-dir $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests/wifitests/src \
- --source-dir $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/service/java
+ report \
+ -classfiles $ANDROID_PRODUCT_OUT/../../common/obj/APPS/FrameworksWifiTests_intermediates/jacoco/report-resources/jacoco-report-classes.jar \
+ -html $OUTPUT_DIR \
+ -sourcefiles $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests/wifitests/src -sourcefiles $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/service/java \
+ -name wifi-coverage \
+ $COVERAGE_OUTPUT_FILE
+
+echo Created report at $OUTPUT_DIR/index.html
+