blob: 5acbca20145790d156629cd120bb3c10cfc4c369 [file] [log] [blame]
Kristofer Jonsson3a353a32022-04-13 15:00:36 +02001#!/usr/bin/env bash
2
3#
4# Copyright (c) 2022 Arm Limited.
5#
6# SPDX-License-Identifier: Apache-2.0
7#
8# Licensed under the Apache License, Version 2.0 (the License); you may
9# not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an AS IS BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
20
21set -o errexit
22set -o pipefail
23set -o errtrace
24
25GCDA=$1
26OUT_DIR=$2
27LDS_DIR="$(realpath "$(dirname "$(dirname "$(dirname "$0")")")")"
28
29usage() {
30 echo "Usage: $0 <gcov.tar.gz> <outdir>" >&2
31 exit 1
32}
33
34# Verify arguments to the script
35if [ ! -e "${GCDA}" ] || [ -z "${OUT_DIR}" ]
36then
37 usage
38fi
39
40# Recreate output directory
41if [ -d "${OUT_DIR}" ]
42then
43 rm -rf "${OUT_DIR}"
44fi
45
46mkdir "${OUT_DIR}"
47
48# Extract gcda files from the archive
49find "${LDS_DIR}/kernel" -name "*.gcda" -delete
50tar -C "${LDS_DIR}" -zxf "${GCDA}"
51
52# Analyze coverage and generate HTML report
53lcov -c -o "${OUT_DIR}/coverage.info" -d "${LDS_DIR}/kernel"
54lcov --rc lcov_branch_coverage=1 --remove "${OUT_DIR}/coverage.info" \
55 '*/kernel/arch/*' '*/kernel/include/*' \
56 > "${OUT_DIR}/coverage.filtered.info"
57genhtml -o "${OUT_DIR}" "${OUT_DIR}/coverage.filtered.info"