blob: fe0853ab8678a6c83560b7249c9113bfcc38d03c [file] [log] [blame]
Raef Coles8cbeed52024-03-11 16:24:57 +00001#!/bin/bash
2
3# Copyright (c) 2024, Arm Limited. All rights reserved.
4# SPDX-License-Identifier: BSD-3-Clause
5
6error()
7{
8 printf "\e[31m[ERR] $1\e[0m\n" 1>&2
9 if test -n "$2"
10 then
11 exit $2
12 else
13 exit 1
14 fi
15}
16
17usage() {
18 echo "$0 --source_dir <source_dir> --build_dir <build_dir> --output_dir <output_dir> data_file [data_file ...]"
19}
20
21set -ex
22
23SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}")"
24
25# Parse arguments
26while test $# -gt 0; do
27 case $1 in
28 -s|--source_dir)
29 SOURCE_DIR="$2"
30 shift
31 shift
32 ;;
33 -b|--build_dir)
34 BUILD_DIR="$2"
35 shift
36 shift
37 ;;
38 -b|--output_dir)
39 OUTPUT_DIR="$2"
40 shift
41 shift
42 ;;
43 -h|--help)
44 usage
45 exit 0
46 ;;
47 *)
48 break
49 ;;
50 esac
51done
52
53if test -z "$SOURCE_DIR"
54then
55 usage
56 error "No source dir specified"
57fi
58
59if test -z "$BUILD_DIR"
60then
61 usage
62 error "No build dir specified"
63fi
64
65if test -z "$OUTPUT_DIR"
66then
67 usage
68 error "No output dir specified"
69fi
70
71if ! test $# -gt 0
72then
73 usage
74 error "At least one data file must be input"
75fi
76
77info_dir=$(mktemp -d)
78
79for x in "$@"
80do
81 tmpdir=$(mktemp -d)
82
83 if ${SCRIPT_DIR}/ingest_tarmac.py \
84 --input_file "$x" \
85 --output_file "${tmpdir}/$(basename "$x").data"
86 then
87 input_file="${tmpdir}/$(basename "$x").data"
88 else
89 input_file="$x"
90 fi
91
92
93 ${SCRIPT_DIR}/generate_report_config_json.py \
94 --source_dir "${SOURCE_DIR}" \
95 --build_dir "${BUILD_DIR}" \
96 --output_config_file "${tmpdir}/$(basename "$x")_config.json" \
97 --output_intermediate_file "${tmpdir}/$(basename "$x")_intermediate.json" \
98 "$input_file"
99
100 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/intermediate_layer.py \
101 --config-json "${tmpdir}/$(basename "$x")_config.json"
102
103 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/generate_info_file.py \
104 --workspace ${SOURCE_DIR} \
105 --json "${tmpdir}/$(basename "$x")_intermediate.json" \
106 --info ${info_dir}/${RANDOM}${RANDOM}.info
107done
108
109info_file="$(mktemp).info"
110
111if test $(find "$info_dir" -type f | wc -l) -gt 1
112then
113 arguments=$(find "$info_dir" -type f | xargs -I{} echo "-a {}")
114
115 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/merge.py \
116 $arguments \
117 -o ${info_file}
118else
119 info_file=$(find "$info_dir" -type f)
120fi
121
122genhtml --branch-coverage "${info_file}" --output-directory "$OUTPUT_DIR"