• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14set -e
15
16DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
17TOP=$(realpath $DIR/../../../../../..)
18
19HOST_OUT=$TOP/out/ohos-arm-release/
20TEST_OUT=$HOST_OUT/tests/unittest/developtools/hdc/coverage
21mkdir -p $TEST_OUT
22
23# collect and convert all gcno and gcda to test.info
24lcov -c -d $HOST_OUT -o $TEST_OUT/hdc_ut_coverage.info --gcov-tool $DIR/gcov.sh
25if [ $? -ne 0 ]; then
26    echo "Install lcov: sudo apt install lcov"
27    exit -1
28fi
29
30# filter out system headers
31#lcov -r $TEST_OUT/hdc_ut_coverage.info \
32#    '/usr/include/*' \
33#    '*/third_party/*' \
34#    '*/utils/native/base/*' \
35#    '*/test/unittest/*' \
36#    '*/src/test/*' \
37#    '*/src/host/*' \
38#    '*/src/common/*' \
39#    '*/src/daemon/*_*' \
40#    '*/src/daemon/daemon*' \
41#    '*/src/daemon/shell*' \
42#    '[^jdwp]*' \
43#    '*.pb.h' \
44#    '*v1/*' \
45#    -o $TEST_OUT/hdc_ut_coverage.info
46
47lcov -e $TEST_OUT/hdc_ut_coverage.info \
48    '*/src/common/uart.*' \
49    '*/src/daemon/daemon_uart.*' \
50    '*/src/host/host_uart.*' \
51    -o $TEST_OUT/hdc_ut_coverage.info
52
53# generate html report
54genhtml --demangle-cpp --rc genhtml_hi_limit=70 --rc genhtml_med_limit=50  -o $TEST_OUT/html $TEST_OUT/hdc_ut_coverage.info
55tar -czf  $TEST_OUT/html.tar.gz -C $TEST_OUT html
56