blob: 93a6f5614a8f15740b3aee63395841a5737be2bb [file] [log] [blame]
Gilad Arnoldab3bb452012-05-22 09:08:12 -07001#!/bin/bash
2
3# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Builds, runs unit tests, then collects and processes coverage data for update
8# engine binaries. In the case where lcov/genhtml are missing, it will just
9# build and run the unit tests.
10
11DO_COVERAGE=$(which lcov genhtml > /dev/null 2>&1 && echo 1)
12
13set -ex
14
15./build debug=1
16if [[ $DO_COVERAGE ]]; then
17 lcov --directory . --zerocounters
18fi
19./run_unittests
20if [[ $DO_COVERAGE ]]; then
21 lcov --directory . --capture --output-file app.info
22
23 # We try to use genhtml with --no-function-coverage, if it is supported. The
24 # problem w/ function coverage is that every template instantiation of a
25 # method counts as a different method, so if we instantiate a method twice,
26 # once for testing and once for prod, the method is tested, but it shows only
27 # 50% function coverage b/c it thinks we didn't test the prod version.
28 GENHTML_NO_FUNC_COV=$(genhtml --help | grep -q function-coverage &&
29 echo --no-function-coverage)
30 genhtml $GENHTML_NO_FUNC_CONV --output-directory html app.info
31 ./local_coverage_rate
32fi