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 15DIR=$(dirname $(realpath ${BASH_SOURCE[0]})) 16TOP=$(realpath $DIR/../../../../../..) 17 18HOST_OUT=$TOP/out/ohos-arm-release/ 19TEST_OUT=$HOST_OUT/tests/unittest/developtools/hiperf/coverage 20mkdir -p $TEST_OUT 21 22# collect and convert all gcno and gcda to test.info 23lcov -c -d $HOST_OUT -o $TEST_OUT/hiperf_ut_coverage.info --gcov-tool $DIR/gcov.sh 24if [ $? -ne 0 ]; then 25 echo "Install lcov: sudo apt install lcov" 26fi 27 28# filter out system headers 29lcov -r $TEST_OUT/hiperf_ut_coverage.info \ 30 '/usr/include/*' \ 31 '*/third_party/*' \ 32 '*/utils/native/base/*' \ 33 '*/test/unittest/*' \ 34 '*.pb.h' \ 35 '*v1/*' \ 36 -o $TEST_OUT/hiperf_ut_coverage.info 37 38# generate html report 39genhtml --demangle-cpp -o $TEST_OUT/html $TEST_OUT/hiperf_ut_coverage.info 40