Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Jackson Cooper-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 3 | # Copyright (c) 2024-2025, Arm Limited. All rights reserved. |
Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | error() |
| 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 | |
| 17 | usage() { |
Jackson Cooper-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 18 | 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 Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 19 | } |
| 20 | |
Jackson Cooper-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 21 | set -e |
Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 22 | |
| 23 | SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}")" |
| 24 | |
| 25 | # Parse arguments |
| 26 | while 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-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 38 | -f|--filter_elfs) |
| 39 | ELF_FILTER="--filter_elfs $2" |
| 40 | shift |
| 41 | shift |
| 42 | ;; |
| 43 | -b|--output_file) |
| 44 | OUTPUT_FILE="$2" |
Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 45 | shift |
| 46 | shift |
| 47 | ;; |
| 48 | -h|--help) |
| 49 | usage |
| 50 | exit 0 |
| 51 | ;; |
| 52 | *) |
| 53 | break |
| 54 | ;; |
| 55 | esac |
| 56 | done |
| 57 | |
| 58 | if test -z "$SOURCE_DIR" |
| 59 | then |
| 60 | usage |
| 61 | error "No source dir specified" |
| 62 | fi |
| 63 | |
| 64 | if test -z "$BUILD_DIR" |
| 65 | then |
| 66 | usage |
| 67 | error "No build dir specified" |
| 68 | fi |
| 69 | |
Jackson Cooper-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 70 | if test -z "$OUTPUT_FILE" |
Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 71 | then |
| 72 | usage |
| 73 | error "No output dir specified" |
| 74 | fi |
| 75 | |
| 76 | if ! test $# -gt 0 |
| 77 | then |
| 78 | usage |
| 79 | error "At least one data file must be input" |
| 80 | fi |
| 81 | |
| 82 | info_dir=$(mktemp -d) |
| 83 | |
| 84 | for x in "$@" |
| 85 | do |
| 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-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 101 | ${ELF_FILTER} \ |
Raef Coles | 8cbeed5 | 2024-03-11 16:24:57 +0000 | [diff] [blame] | 102 | --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 |
| 113 | done |
| 114 | |
| 115 | info_file="$(mktemp).info" |
| 116 | |
| 117 | if test $(find "$info_dir" -type f | wc -l) -gt 1 |
| 118 | then |
| 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} |
| 124 | else |
| 125 | info_file=$(find "$info_dir" -type f) |
| 126 | fi |
| 127 | |
Jackson Cooper-Driver | 2d73606 | 2025-03-05 12:37:09 +0000 | [diff] [blame^] | 128 | cp "${info_file}" "${OUTPUT_FILE}" |