Kristofer Jonsson | 3a353a3 | 2022-04-13 15:00:36 +0200 | [diff] [blame] | 1 | #!/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 | |
| 21 | set -o errexit |
| 22 | set -o pipefail |
| 23 | set -o errtrace |
| 24 | |
| 25 | GCDA=$1 |
| 26 | OUT_DIR=$2 |
| 27 | LDS_DIR="$(realpath "$(dirname "$(dirname "$(dirname "$0")")")")" |
| 28 | |
| 29 | usage() { |
| 30 | echo "Usage: $0 <gcov.tar.gz> <outdir>" >&2 |
| 31 | exit 1 |
| 32 | } |
| 33 | |
| 34 | # Verify arguments to the script |
| 35 | if [ ! -e "${GCDA}" ] || [ -z "${OUT_DIR}" ] |
| 36 | then |
| 37 | usage |
| 38 | fi |
| 39 | |
| 40 | # Recreate output directory |
| 41 | if [ -d "${OUT_DIR}" ] |
| 42 | then |
| 43 | rm -rf "${OUT_DIR}" |
| 44 | fi |
| 45 | |
| 46 | mkdir "${OUT_DIR}" |
| 47 | |
| 48 | # Extract gcda files from the archive |
| 49 | find "${LDS_DIR}/kernel" -name "*.gcda" -delete |
| 50 | tar -C "${LDS_DIR}" -zxf "${GCDA}" |
| 51 | |
| 52 | # Analyze coverage and generate HTML report |
| 53 | lcov -c -o "${OUT_DIR}/coverage.info" -d "${LDS_DIR}/kernel" |
| 54 | lcov --rc lcov_branch_coverage=1 --remove "${OUT_DIR}/coverage.info" \ |
| 55 | '*/kernel/arch/*' '*/kernel/include/*' \ |
| 56 | > "${OUT_DIR}/coverage.filtered.info" |
| 57 | genhtml -o "${OUT_DIR}" "${OUT_DIR}/coverage.filtered.info" |