blob: ef7c86a9580a0b8a621dc568a2678f29e79f1e1c [file] [log] [blame]
Dan Albert98e2c642014-09-19 14:40:57 -07001#!/bin/sh
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16#
17# acov is a tool for gathering coverage information from a device and generating
18# a report from that information. To use:
19#
20# 1. sudo apt-get install lcov
21# 2. Build application/library with coverage information.
22# 3. Push the new binaries to the device.
23# 4. Run tests with the additional environment variables:
24# * GCOV_PREFIX=/data/local/tmp/gcov
25# * GCOV_PREFIX_STRIP=`echo $(ANDROID_BUILD_TOP) | grep -o / | wc -l`
26# 5. Run `acov`.
27#
28# acov will pull all coverage information from the device, push it to the right
29# directories, run lcov, and display the coverage report (currently by opening
30# it in your browser).
31#
32
Dan Albert7d133d22014-09-25 11:23:30 -070033which lcov >/dev/null 2>/dev/null
Dan Albert98e2c642014-09-19 14:40:57 -070034if [ $? -ne 0 ]; then
35 echo 'lcov not found: running `sudo apt-get install lcov`'
36 sudo apt-get install lcov
37fi
38
39cd $ANDROID_BUILD_TOP
40FILE=cov.info
41DIR=$(mktemp -d covreport-XXXXXX)
42adb pull /data/local/tmp/gcov
43lcov -c -d $ANDROID_PRODUCT_OUT -o $DIR/$FILE
44echo "Generating coverage report at $DIR"
45genhtml -q -o $DIR $DIR/$FILE
46xdg-open $DIR/index.html >/dev/null