blob: 8ad56b69a8b5d7c7690826d7914f083f8feba485 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Saul Romero82bcfb02023-06-27 16:24:13 +01003# Copyright (c) 2019-2023, Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -e
Saul Romerocacda172023-03-10 14:23:41 +00009set -x
10export COVERAGE_ON=$((echo "$RUN_CONFIG" | grep -v 'aarch32' | grep -qE 'bmcov' && echo 1) ||
11 (echo "${TEST_GROUP}" | grep -v 'aarch32' | grep -qE 'code-coverage' && echo 1) ||
12 echo 0)
13echo "COVERAGE_ON=${COVERAGE_ON}"
Fathi Boudra422bf772019-12-02 11:10:16 +020014
Zelalem917b43e2020-08-04 11:39:55 -050015if [ $COVERAGE_ON -eq 1 ]; then
Saul Romerocacda172023-03-10 14:23:41 +000016 # Load code coverage binary
17 echo "Code coverage for binaries enabled..."
18 export OUTDIR=${WORKSPACE}/html
19 mkdir -p $OUTDIR
20 source "$CI_ROOT/script/qa-code-coverage.sh"
21fi
22
23
24if [ $COVERAGE_ON -eq 1 ]; then
25 LIST_OF_BINARIES=""
26 OBJDUMP="$(which 'aarch64-none-elf-objdump')"
27 READELF="$(which 'aarch64-none-elf-readelf')"
Saul Romerofe2b9c12024-06-02 21:22:13 +010028 FALLBACK_PLUGIN_URL="${FALLBACK_PLUGIN_URL:-https://downloads.trustedfirmware.org/coverage-plugin/qa-tools/coverage-tool}"
29 FALLBACK_PLUGIN_URL_ALT="${FALLBACK_PLUGIN_URL_ALT:-https://artifactory.eu02.arm.com/artifactory/trustedfirmware.downloads/coverage-plugin}"
30 FALLBACK_FILES="${FALLBACK_FILES:-coverage_trace.so,coverage_trace.o,plugin_utils.o}"
31 FALLBACK_FILES_ALT="${FALLBACK_FILES_ALT:-CoverageTrace.so,CoverageTrace.o,PluginUtils.o}"
Saul Romerocacda172023-03-10 14:23:41 +000032
33 if [[ "$TEST_GROUP" == scp* ]]; then
34 PROJECT="SCP"
35 LIST_OF_BINARIES="scp_ram.elf scp_rom.elf mcp_rom.elf mcp_ram.elf"
36 OBJDUMP="$(which 'arm-none-eabi-objdump')"
37 READELF="$(which 'arm-none-eabi-readelf')"
Saul Romerofe2b9c12024-06-02 21:22:13 +010038 FALLBACK_PLUGIN_URL="${FALLBACK_PLUGIN_URL_ALT}"
39 FALLBACK_FILES="${FALLBACK_FILES_ALT}"
Saul Romero82bcfb02023-06-27 16:24:13 +010040 elif [[ "$TEST_GROUP" == spm* ]];then
41 PROJECT="HAFNIUM"
42 LIST_OF_BINARIES="secure_hafnium.elf hafnium.elf"
Saul Romerocacda172023-03-10 14:23:41 +000043 elif [[ "$TEST_GROUP" == tf* ]];then
44 PROJECT="TF-A"
45 LIST_OF_BINARIES="bl1.elf bl2.elf bl31.elf"
Saul Romerofe2b9c12024-06-02 21:22:13 +010046 FALLBACK_PLUGIN_URL="${FALLBACK_PLUGIN_URL_ALT}"
47 FALLBACK_FILES="${FALLBACK_FILES_ALT}"
Saul Romerocacda172023-03-10 14:23:41 +000048 else
49 echo "No project assigned for $TEST_GROUP ..."
50 exit -1
51 fi
52 # Plugin has to be built before running model
53 build_tool
Zelalem917b43e2020-08-04 11:39:55 -050054fi
55
Fathi Boudra422bf772019-12-02 11:10:16 +020056"$CI_ROOT/script/build_package.sh"
Fathi Boudra422bf772019-12-02 11:10:16 +020057if [ "$skip_runs" ]; then
58 exit 0
59fi
60
61# Execute test locally for FVP configs
62if [ "$RUN_CONFIG" != "nil" ] && echo "$RUN_CONFIG" | grep -iq '^fvp'; then
Saul Romerocacda172023-03-10 14:23:41 +000063 export BIN_MODE=debug
Fathi Boudra422bf772019-12-02 11:10:16 +020064 "$CI_ROOT/script/run_package.sh"
Zelalem917b43e2020-08-04 11:39:55 -050065
Saul Romerocacda172023-03-10 14:23:41 +000066 if [ $COVERAGE_ON -eq 1 ]; then
Zelalem917b43e2020-08-04 11:39:55 -050067 sync
Saul Romerocacda172023-03-10 14:23:41 +000068 sleep 5 # wait for trace files to be written
69 ELF_FOLDER=$artefacts/$BIN_MODE
70 TRACE_FOLDER=$artefacts/$BIN_MODE
71 echo "Toolchain:$OBJDUMP"
72 create_intermediate_layer "${TRACE_FOLDER}" "${ELF_FOLDER}" "${LIST_OF_BINARIES}"
73 create_coverage_report
Zelalem917b43e2020-08-04 11:39:55 -050074 fi
Fathi Boudra422bf772019-12-02 11:10:16 +020075fi