Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
laurenw-arm | afdc3bc | 2022-09-14 15:31:42 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2022, Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | set -e |
| 9 | |
| 10 | in_red() { |
| 11 | echo "$(tput setaf 1)${1:?}$(tput sgr0)" |
| 12 | } |
| 13 | export -f in_red |
| 14 | |
| 15 | in_green() { |
| 16 | echo "$(tput setaf 2)${1:?}$(tput sgr0)" |
| 17 | } |
| 18 | export -f in_green |
| 19 | |
| 20 | in_yellow() { |
| 21 | echo "$(tput setaf 3)${1:?}$(tput sgr0)" |
| 22 | } |
| 23 | export -f in_yellow |
| 24 | |
| 25 | print_success() { |
| 26 | in_green "$1: SUCCESS" |
| 27 | } |
| 28 | export -f print_success |
| 29 | |
| 30 | print_failure() { |
| 31 | in_red "$1: FAILURE" |
| 32 | } |
| 33 | export -f print_failure |
| 34 | |
| 35 | print_unstable() { |
| 36 | in_yellow "$1: UNSTABLE" |
| 37 | } |
| 38 | export -f print_unstable |
| 39 | |
| 40 | gen_makefile() { |
| 41 | local num="$(find -name "*.test" -type f | wc -l)" |
| 42 | local i=0 |
| 43 | |
| 44 | cat <<EOF >Makefile |
| 45 | SHELL=/bin/bash |
| 46 | |
| 47 | all: |
| 48 | |
| 49 | EOF |
| 50 | |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 51 | # If we're using local checkouts for either TF-A or TFTF, we must |
| 52 | # serialise builds |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 53 | while [ "$i" -lt "$num" ]; do |
| 54 | { |
Sandrine Bailleux | 4694fd3 | 2022-04-15 14:04:35 +0200 | [diff] [blame] | 55 | printf "all: %04d_run %04d_build\n" "$i" "$i" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 56 | if upon "$serialize_builds" && [ "$i" -gt 0 ]; then |
Sandrine Bailleux | 4694fd3 | 2022-04-15 14:04:35 +0200 | [diff] [blame] | 57 | printf "%04d_build: %04d_build\n" "$i" "$((i - 1))" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 58 | fi |
| 59 | echo |
| 60 | } >>Makefile |
| 61 | let "++i" |
| 62 | done |
| 63 | |
| 64 | cat <<EOF >>Makefile |
| 65 | |
| 66 | %_run: %_build |
| 67 | @run_one_test "\$@" |
| 68 | |
| 69 | %_build: |
| 70 | @run_one_test "\$@" |
| 71 | EOF |
| 72 | } |
| 73 | |
| 74 | # This function is invoked from the Makefile. Descriptor 5 points to the active |
| 75 | # terminal. |
| 76 | run_one_test() { |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 77 | source "$ci_root/utils.sh" |
| 78 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 79 | id="${1%%_*}" |
| 80 | action="${1##*_}" |
Boyan Karatotev | d509032 | 2025-10-01 10:06:37 +0100 | [diff] [blame] | 81 | # Subdirectories could change while traversing but all our files are in |
| 82 | # the top level directory. |
| 83 | test_file="$(find -maxdepth 1 -name "$id*.test" -printf "%f\n")" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 84 | |
| 85 | mkdir -p "$id" |
| 86 | |
| 87 | # Copy the test_file into the workspace directory with the name |
| 88 | # TEST_DESC, just like Jenkins would. |
| 89 | export TEST_DESC="$(basename "$test_file")" |
| 90 | cp "$test_file" "$id/TEST_DESC" |
| 91 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 92 | workspace="$id" test_desc="$test_file" cc_enable="$cc_enable" "$ci_root/script/parse_test.sh" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 93 | |
| 94 | set -a |
| 95 | source "$id/env" |
| 96 | set +a |
| 97 | |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 98 | run_config_tfa="$(echo "$RUN_CONFIG" | awk -F, '{print $1}')" |
| 99 | run_config_tfut="$(echo "$RUN_CONFIG" | awk -F, '{print $2}')" |
| 100 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 101 | # Makefiles don't like commas and colons in file names. We therefore |
| 102 | # replace them with _ |
| 103 | config_subst="$(echo "$TEST_CONFIG" | tr ',:' '_')" |
| 104 | config_string="$id: $TEST_GROUP/$TEST_CONFIG" |
| 105 | workspace="$workspace/$TEST_GROUP/$config_subst" |
| 106 | mkdir -p "$workspace" |
| 107 | |
| 108 | log_file="$workspace/artefacts/build.log" |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 109 | # fd 5 is the terminal where run_local_ci.sh is running. *Only* status |
| 110 | # of the run is printed as this is shared for all jobs and this may |
| 111 | # happen in parallel. |
| 112 | # Each job has its own verbose output as well. This will be progress |
| 113 | # messages but also any debugging prints. This is the default and it |
| 114 | # gets redirected to a file per job for archiving and disambiguation |
| 115 | # when running in parallel. |
Boyan Karatotev | f2e145b | 2025-08-27 15:51:46 +0100 | [diff] [blame] | 116 | console_file="$workspace/console.log" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 117 | if [ "$parallel" -gt 1 ]; then |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 118 | exec >> $console_file 2>&1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 119 | else |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 120 | # when running in serial, no scrambling is possible so print to |
| 121 | # stdout |
Boyan Karatotev | 34b0596 | 2025-10-07 15:15:01 +0100 | [diff] [blame^] | 122 | exec > >(tee -a $console_file >&5) 2>&1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 123 | fi |
| 124 | |
| 125 | # Unset make flags for build script |
| 126 | MAKEFLAGS= |
| 127 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 128 | if [ $import_cc -eq 1 ]; then |
| 129 | # Path to plugin if there is no local reference |
| 130 | cc_path_spec=$workspace/cc_plugin |
| 131 | fi |
| 132 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 133 | case "$action" in |
| 134 | "build") |
| 135 | echo "building: $config_string" >&5 |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 136 | if ! ccpathspec="$cc_path_spec" bash $minus_x "$ci_root/script/build_package.sh"; then { |
| 137 | print_failure "$config_string (build)" >&5 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 138 | if [ "$console_file" ]; then |
| 139 | echo " see $console_file" |
| 140 | fi |
| 141 | } >&5 |
| 142 | exit 1 |
| 143 | fi |
| 144 | ;; |
| 145 | |
| 146 | "run") |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 147 | #Run unit tests (TFUT) |
Boyan Karatotev | 56d72ea | 2025-08-27 15:11:16 +0100 | [diff] [blame] | 148 | if config_valid "$run_config_tfut"; then |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 149 | echo "running TFUT: $config_string" >&5 |
Boyan Karatotev | 56d72ea | 2025-08-27 15:11:16 +0100 | [diff] [blame] | 150 | |
| 151 | if upon "$skip_tfut_runs"; then |
| 152 | #No run config for TFUT |
| 153 | if grep -q -e "--BUILD UNSTABLE--" "$log_file"; then |
| 154 | print_unstable "$config_string (tfut) (not run)" >&5 |
| 155 | else |
| 156 | print_success "$config_string (tfut) (not run)" >&5 |
| 157 | fi |
| 158 | exit 0 |
| 159 | fi |
| 160 | |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 161 | if bash $minus_x "$ci_root/script/run_unit_tests.sh"; then |
| 162 | if grep -q -e "--BUILD UNSTABLE--" \ |
| 163 | "$log_file"; then |
| 164 | print_unstable "$config_string (tfut)" >&5 |
| 165 | else |
| 166 | print_success "$config_string (tfut)" >&5 |
| 167 | fi |
Boyan Karatotev | 56d72ea | 2025-08-27 15:11:16 +0100 | [diff] [blame] | 168 | exit 0 |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 169 | else |
| 170 | { |
| 171 | print_failure "$config_string (tfut) (run)" >&5 |
| 172 | if [ "$console_file" ]; then |
| 173 | echo " see $console_file" |
| 174 | fi |
| 175 | } >&5 |
| 176 | exit 1 |
| 177 | fi |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 178 | fi |
| 179 | |
| 180 | #Run TF-A |
| 181 | if echo "$run_config_tfa" | grep -q "^\(fvp\|qemu\)" && \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 182 | not_upon "$skip_runs"; then |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 183 | # Local runs for FVP, QEMU, or arm_fpga unless asked not to |
| 184 | echo "running TF-A: $config_string" >&5 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 185 | if [ -n "$cc_enable" ]; then |
| 186 | # Enable of code coverage during run |
| 187 | if cc_enable="$cc_enable" trace_file_prefix=tr \ |
| 188 | coverage_trace_plugin=$cc_path_spec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov/model-plugin/CoverageTrace.so \ |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 189 | bash $minus_x "$ci_root/script/run_package.sh"; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 190 | if grep -q -e "--BUILD UNSTABLE--" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 191 | "$log_file"; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 192 | print_unstable "$config_string" >&5 |
| 193 | else |
| 194 | print_success "$config_string" >&5 |
| 195 | if [ -d "$workspace/artefacts/release" ] && \ |
laurenw-arm | afdc3bc | 2022-09-14 15:31:42 -0500 | [diff] [blame] | 196 | [ -f "$workspace/artefacts/release/tr-FVP_Base_RevC_2xAEMvA.cluster0.cpu0.log" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 197 | cp $workspace/artefacts/release/*.log $workspace/artefacts/debug |
| 198 | fi |
| 199 | # Setting environmental variables for run of code coverage |
| 200 | OBJDUMP=$TOOLCHAIN/bin/aarch64-none-elf-objdump \ |
| 201 | READELF=$TOOLCHAIN/bin/aarch64-none-elf-readelf \ |
| 202 | ELF_FOLDER=$workspace/artefacts/debug \ |
| 203 | TRACE_FOLDER=$workspace/artefacts/debug \ |
| 204 | workspace=$workspace \ |
| 205 | TRACE_PREFIX=tr python \ |
| 206 | $cc_path_spec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov/report/gen-coverage-report.py --config \ |
| 207 | $cc_path_spec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov/report/config_atf.py |
| 208 | fi |
| 209 | exit 0 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 210 | else |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 211 | { |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 212 | print_failure "$config_string (run)" >&5 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 213 | if [ "$console_file" ]; then |
| 214 | echo " see $console_file" |
| 215 | fi |
| 216 | } >&5 |
| 217 | exit 1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 218 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 219 | else |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 220 | if bash $minus_x "$ci_root/script/run_package.sh"; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 221 | if grep -q -e "--BUILD UNSTABLE--" \ |
| 222 | "$log_file"; then |
| 223 | print_unstable "$config_string" >&5 |
| 224 | else |
| 225 | print_success "$config_string" >&5 |
| 226 | fi |
| 227 | exit 0 |
| 228 | else |
| 229 | { |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 230 | print_failure "$config_string (run)" >&5 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 231 | if [ "$console_file" ]; then |
| 232 | echo " see $console_file" |
| 233 | fi |
| 234 | } >&5 |
| 235 | exit 1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 236 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 237 | fi |
| 238 | else |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 239 | # Local runs for arm_fpga platform |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 240 | if echo "$run_config_tfa" | grep -q "^arm_fpga" && \ |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 241 | not_upon "$skip_runs"; then |
| 242 | echo "running: $config_string" >&5 |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 243 | if bash $minus_x "$ci_root/script/test_fpga_payload.sh"; then |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 244 | if grep -q -e "--BUILD UNSTABLE--" \ |
| 245 | "$log_file"; then |
| 246 | print_unstable "$config_string" >&5 |
| 247 | else |
| 248 | print_success "$config_string" >&5 |
| 249 | fi |
| 250 | exit 0 |
| 251 | else |
| 252 | { |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 253 | print_failure "$config_string (run)" >&5 |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 254 | if [ "$console_file" ]; then |
| 255 | echo " see $console_file" |
| 256 | fi |
| 257 | } >&5 |
| 258 | exit 1 |
| 259 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 260 | else |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 261 | if grep -q -e "--BUILD UNSTABLE--" \ |
| 262 | "$log_file"; then |
| 263 | print_unstable "$config_string (not run)" >&5 |
| 264 | else |
| 265 | print_success "$config_string (not run)" >&5 |
| 266 | fi |
| 267 | exit 0 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 268 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 269 | fi |
| 270 | ;; |
| 271 | |
| 272 | *) |
| 273 | in_red "Invalid action: $action!" >&5 |
| 274 | exit 1 |
| 275 | ;; |
| 276 | esac |
| 277 | } |
| 278 | export -f run_one_test |
| 279 | |
| 280 | workspace="${workspace:?}" |
Boyan Karatotev | 5180006 | 2025-05-01 16:55:44 +0100 | [diff] [blame] | 281 | if [[ "$retain_paths" -eq 0 ]]; then |
Jayanth Dodderi Chidanand | 985bb2f | 2025-04-09 17:02:39 +0100 | [diff] [blame] | 282 | gcc_space="${gcc_space:?Environment variable 'gcc_space' must be set}" |
| 283 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 284 | ci_root="$(readlink -f "$(dirname "$0")/..")" |
| 285 | |
| 286 | # If this script was invoked with bash -x, have subsequent build/run invocations |
| 287 | # to use -x as well. |
| 288 | if echo "$-" | grep -q "x"; then |
| 289 | export minus_x="-x" |
| 290 | fi |
| 291 | |
Leonardo Sandoval | 8f9cea6 | 2020-07-10 11:08:55 -0500 | [diff] [blame] | 292 | # if test_groups variable is not present, check if it can be formed at least from 'test_group' and 'tf_config' |
| 293 | # environment variables |
| 294 | if [ -z "${test_groups}" ]; then |
| 295 | if [ -n "${test_group}" -a -n "${tf_config}" ]; then |
| 296 | |
| 297 | # default the rest to nil if not present |
| 298 | tftf_config="${tftf_config:-nil}" |
Manish Pandey | b466cf2 | 2021-02-12 13:15:40 +0000 | [diff] [blame] | 299 | spm_config="${spm_config:-nil}" |
Leonardo Sandoval | 8f9cea6 | 2020-07-10 11:08:55 -0500 | [diff] [blame] | 300 | run_config="${run_config:-nil}" |
| 301 | |
Manish Pandey | b466cf2 | 2021-02-12 13:15:40 +0000 | [diff] [blame] | 302 | # construct the 'long form' so it takes into account all possible configurations |
Chris Kay | 4f7846a | 2025-08-04 19:56:35 +0100 | [diff] [blame] | 303 | if echo ${test_group} | grep -q '^spm-'; then |
| 304 | tg=$(printf "%s/%s,%s,%s:%s" "${test_group}" "${spm_config}" "${tf_config}" "${tftf_config}" "${run_config}") |
Manish V Badarkhe | 5248c7f | 2025-04-11 13:22:16 +0100 | [diff] [blame] | 305 | elif echo ${test_group} | grep -q '^rmm-'; then |
Chris Kay | 4f7846a | 2025-08-04 19:56:35 +0100 | [diff] [blame] | 306 | tg=$(printf "%s/%s,%s,%s,%s:%s" "${test_group}" "${rmm_config}" "${tf_config}" "${tftf_config}" "${spm_config}" "${run_config}") |
Manish Pandey | b466cf2 | 2021-02-12 13:15:40 +0000 | [diff] [blame] | 307 | else |
Chris Kay | 4f7846a | 2025-08-04 19:56:35 +0100 | [diff] [blame] | 308 | tg=$(printf "%s/%s,%s,%s:%s" "${test_group}" "${tf_config}" "${tftf_config}" "${spm_config}" "${run_config}") |
Manish Pandey | b466cf2 | 2021-02-12 13:15:40 +0000 | [diff] [blame] | 309 | fi |
Leonardo Sandoval | 8f9cea6 | 2020-07-10 11:08:55 -0500 | [diff] [blame] | 310 | |
| 311 | # trim any ',nil:' from it |
Manish Pandey | b466cf2 | 2021-02-12 13:15:40 +0000 | [diff] [blame] | 312 | tg="${tg/,nil:/:}" tg="${tg/,nil:/:}"; tg="${tg/,nil:/:}"; tg="${tg/,nil:/:}" |
Leonardo Sandoval | 8f9cea6 | 2020-07-10 11:08:55 -0500 | [diff] [blame] | 313 | |
| 314 | # finally exported |
| 315 | export test_groups="${tg}" |
| 316 | fi |
| 317 | fi |
| 318 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 319 | # For a local run, when some variables as specified as "?", launch zenity to |
| 320 | # prompt for test config via. GUI. If it's "??", then choose a directory. |
| 321 | if [ "$test_groups" = "?" -o "$test_groups" = "??" ]; then |
| 322 | zenity_opts=( |
| 323 | --file-selection |
| 324 | --filename="$ci_root/group/README" |
| 325 | --multiple |
| 326 | --title "Choose test config" |
| 327 | ) |
| 328 | |
| 329 | if [ "$test_groups" = "??" ]; then |
| 330 | zenity_opts+=("--directory") |
| 331 | fi |
| 332 | |
| 333 | # In case of multiple selections, zenity returns absolute paths of files |
| 334 | # separated by '|'. We remove the pipe characters, and make the paths |
| 335 | # relative to the group directory. |
| 336 | selections="$(cd "$ci_root"; zenity ${zenity_opts[*]})" |
| 337 | test_groups="$(echo "$selections" | tr '|' ' ')" |
| 338 | test_groups="$(echo "$test_groups" | sed "s#$ci_root/group/##g")" |
| 339 | fi |
| 340 | |
| 341 | test_groups="${test_groups:?}" |
| 342 | local_count=0 |
| 343 | |
| 344 | if [ -z "$tf_root" ]; then |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 345 | in_red "NOTE: NOT using local work tree for TF-A" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 346 | else |
| 347 | tf_root="$(readlink -f $tf_root)" |
| 348 | tf_refspec= |
Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame] | 349 | in_green "Using local work tree for TF-A" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 350 | let "++local_count" |
| 351 | fi |
| 352 | |
| 353 | if [ -z "$tftf_root" ]; then |
| 354 | in_red "NOTE: NOT using local work tree for TFTF" |
| 355 | tforg_user="${tforg_user:?}" |
| 356 | else |
| 357 | tftf_root="$(readlink -f $tftf_root)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 358 | tftf_refspec= |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 359 | in_green "Using local work tree for TFTF" |
| 360 | let "++local_count" |
| 361 | fi |
| 362 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 363 | if [ -n "$cc_enable" ]; then |
| 364 | in_green "Code Coverage enabled" |
| 365 | if [ -z "$TOOLCHAIN" ]; then |
| 366 | in_red "TOOLCHAIN not set for code coverage: ex: export TOOLCHAIN=<path to toolchain>/gcc-arm-<gcc version>-x86_64-aarch64-none-elf" |
| 367 | exit 1 |
| 368 | fi |
| 369 | if [ -n "$cc_path" ]; then |
| 370 | in_green "Code coverage plugin path specified" |
| 371 | cc_path_spec=$cc_path |
| 372 | import_cc=0 |
| 373 | else |
| 374 | in_red "Code coverage plugin path not specified" |
| 375 | cc_path_spec="$workspace/cc_plugin" |
| 376 | import_cc=1 |
| 377 | fi |
Jimmy Brisson | 4347d8a | 2020-07-24 10:26:16 -0500 | [diff] [blame] | 378 | else |
| 379 | in_green "Code coverage disabled" |
| 380 | import_cc=1 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 381 | fi |
| 382 | |
Olivier Deprez | f1d1fcd | 2019-12-16 14:09:43 +0100 | [diff] [blame] | 383 | if [ -z "$spm_root" ]; then |
| 384 | in_red "NOTE: NOT using local work tree for SPM" |
| 385 | else |
| 386 | spm_root="$(readlink -f $spm_root)" |
| 387 | spm_refspec= |
| 388 | in_green "Using local work tree for SPM" |
| 389 | let "++local_count" |
| 390 | fi |
| 391 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 392 | if [ -z "$rmm_root" ]; then |
| 393 | in_red "NOTE: NOT using local work tree for RMM" |
| 394 | else |
| 395 | rmm_root="$(readlink -f $rmm_root)" |
| 396 | rmm_refspec= |
| 397 | in_green "Using local work tree for RMM" |
| 398 | let "++local_count" |
| 399 | fi |
| 400 | |
| 401 | if [ -z "$tfm_tests_root" ]; then |
| 402 | in_red "NOTE: NOT using local work tree for TF-M-TESTS" |
| 403 | else |
| 404 | tfm_tests_root="$(readlink -f $tfm_tests_root)" |
| 405 | tfm_tests_refspec= |
| 406 | in_green "Using local work tree for TF-M-TESTS" |
| 407 | let "++local_count" |
| 408 | fi |
| 409 | |
| 410 | if [ -z "$tfm_extras_root" ]; then |
| 411 | in_red "NOTE: NOT using local work tree for TF-M-EXTRAS" |
| 412 | else |
| 413 | tfm_extras_root="$(readlink -f $tfm_extras_root)" |
| 414 | tfm_extras_refspec= |
| 415 | in_green "Using local work tree for TF-M-EXTRAS" |
| 416 | let "++local_count" |
| 417 | fi |
| 418 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 419 | # User preferences |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 420 | [ "$connect_debugger" ] && [ "$connect_debugger" -eq 1 ] && user_connect_debugger=1 |
| 421 | user_test_run="${user_connect_debugger:-$test_run}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 422 | user_keep_going="$keep_going" |
| 423 | user_primary_live="$primary_live" |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 424 | user_connect_debugger="${user_connect_debugger:-0}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 425 | |
| 426 | export ci_root |
Boyan Karatotev | ffedd18 | 2025-10-02 08:47:45 +0100 | [diff] [blame] | 427 | export dont_clean="${dont_clean:-0}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 428 | export local_ci=1 |
| 429 | export parallel |
| 430 | export test_run=0 |
| 431 | export primary_live=0 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 432 | export cc_path_spec |
| 433 | export import_cc |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 434 | export connect_debugger="$user_connect_debugger" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 435 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 436 | source "$ci_root/utils.sh" |
| 437 | |
Boyan Karatotev | ffedd18 | 2025-10-02 08:47:45 +0100 | [diff] [blame] | 438 | if not_upon "$dont_clean"; then |
| 439 | rm -rf "$workspace" |
| 440 | fi |
| 441 | mkdir -p "$workspace" |
| 442 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 443 | # Enable of code coverage and whether there is a local plugin |
| 444 | if upon "$cc_enable" && not_upon "$cc_path"; then |
| 445 | no_cc_t=1 |
| 446 | else |
| 447 | no_cc_t=0 |
| 448 | fi |
| 449 | |
| 450 | # Use clone_repos.sh to clone and share repositories that aren't local. |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 451 | no_tf="$tf_root" no_tftf="$tftf_root" no_spm="$spm_root" no_rmm="$rmm_root" \ |
| 452 | no_ci="$ci_root" no_cc="$import_cc" no_tfm_tests="$tfm_tests_root" no_tfm_extras="$tfm_extras_root" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 453 | bash $minus_x "$ci_root/script/clone_repos.sh" |
| 454 | |
| 455 | set -a |
| 456 | source "$workspace/env" |
| 457 | set +a |
| 458 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 459 | export -f upon not_upon |
| 460 | |
| 461 | # Generate test descriptions |
| 462 | "$ci_root/script/gen_test_desc.py" |
| 463 | |
| 464 | # Iterate through test files in workspace |
| 465 | pushd "$workspace" |
| 466 | |
| 467 | if not_upon "$parallel" || echo "$parallel" | grep -vq "[0-9]"; then |
| 468 | parallel=1 |
| 469 | test_run="$user_test_run" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 470 | primary_live="$user_primary_live" |
| 471 | fi |
| 472 | |
| 473 | if [ "$parallel" -gt 1 ]; then |
| 474 | msg="Running at most $parallel jobs in parallel" |
| 475 | if upon "$serialize_builds"; then |
| 476 | msg+=" (builds serialized)" |
| 477 | fi |
| 478 | msg+="..." |
| 479 | fi |
| 480 | |
| 481 | # Generate Makefile |
| 482 | gen_makefile |
| 483 | |
| 484 | if upon "$msg"; then |
| 485 | echo "$msg" |
| 486 | echo |
| 487 | fi |
| 488 | |
| 489 | keep_going="${user_keep_going:-1}" |
| 490 | if not_upon "$keep_going"; then |
| 491 | keep_going= |
| 492 | fi |
| 493 | |
Boyan Karatotev | 4910680 | 2025-05-02 10:08:43 +0100 | [diff] [blame] | 494 | MAKEFLAGS= make -r -j "$parallel" ${keep_going+-k} 5>&1 |& tee "make.log" |