blob: 1074fcb2878c9717475e523ba345d2389e5fede5 [file] [log] [blame]
Raef Coles8cbeed52024-03-11 16:24:57 +00001#!/bin/bash
2
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +00003# Copyright (c) 2024-2025, Arm Limited. All rights reserved.
Raef Coles8cbeed52024-03-11 16:24:57 +00004# 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() {
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +000018 echo "$0 --source_dir <source_dir> --build_dir <build_dir> [--filter_elfs \"foo.elf,bar.elf\"] --output_file <output_file> data_file [data_file ...]"
Raef Coles8cbeed52024-03-11 16:24:57 +000019}
20
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +000021set -e
Raef Coles8cbeed52024-03-11 16:24:57 +000022
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 ;;
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +000038 -f|--filter_elfs)
39 ELF_FILTER="--filter_elfs $2"
40 shift
41 shift
42 ;;
43 -b|--output_file)
44 OUTPUT_FILE="$2"
Raef Coles8cbeed52024-03-11 16:24:57 +000045 shift
46 shift
47 ;;
48 -h|--help)
49 usage
50 exit 0
51 ;;
52 *)
53 break
54 ;;
55 esac
56done
57
58if test -z "$SOURCE_DIR"
59then
60 usage
61 error "No source dir specified"
62fi
63
64if test -z "$BUILD_DIR"
65then
66 usage
67 error "No build dir specified"
68fi
69
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +000070if test -z "$OUTPUT_FILE"
Raef Coles8cbeed52024-03-11 16:24:57 +000071then
72 usage
73 error "No output dir specified"
74fi
75
76if ! test $# -gt 0
77then
78 usage
79 error "At least one data file must be input"
80fi
81
82info_dir=$(mktemp -d)
83
84for x in "$@"
85do
86 tmpdir=$(mktemp -d)
87
88 if ${SCRIPT_DIR}/ingest_tarmac.py \
89 --input_file "$x" \
90 --output_file "${tmpdir}/$(basename "$x").data"
91 then
92 input_file="${tmpdir}/$(basename "$x").data"
93 else
94 input_file="$x"
95 fi
96
97
98 ${SCRIPT_DIR}/generate_report_config_json.py \
99 --source_dir "${SOURCE_DIR}" \
100 --build_dir "${BUILD_DIR}" \
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +0000101 ${ELF_FILTER} \
Raef Coles8cbeed52024-03-11 16:24:57 +0000102 --output_config_file "${tmpdir}/$(basename "$x")_config.json" \
103 --output_intermediate_file "${tmpdir}/$(basename "$x")_intermediate.json" \
104 "$input_file"
105
106 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/intermediate_layer.py \
107 --config-json "${tmpdir}/$(basename "$x")_config.json"
108
109 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/generate_info_file.py \
110 --workspace ${SOURCE_DIR} \
111 --json "${tmpdir}/$(basename "$x")_intermediate.json" \
112 --info ${info_dir}/${RANDOM}${RANDOM}.info
113done
114
115info_file="$(mktemp).info"
116
117if test $(find "$info_dir" -type f | wc -l) -gt 1
118then
119 arguments=$(find "$info_dir" -type f | xargs -I{} echo "-a {}")
120
121 python3 ${SCRIPT_DIR}/qa-tools/coverage-tool/coverage-reporting/merge.py \
122 $arguments \
123 -o ${info_file}
124else
125 info_file=$(find "$info_dir" -type f)
126fi
127
Jackson Cooper-Driver2d736062025-03-05 12:37:09 +0000128cp "${info_file}" "${OUTPUT_FILE}"