Juan Pablo Conde | 6eb0d1e | 2023-12-08 13:52:21 -0600 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2024 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | # Runs the built unit tests |
| 9 | |
| 10 | set -e |
| 11 | |
| 12 | ci_root="$(readlink -f "$(dirname "$0")/..")" |
| 13 | source "$ci_root/script/run_common.sh" |
| 14 | source "$ci_root/utils.sh" |
| 15 | |
| 16 | artefacts="${artefacts-$workspace/artefacts}" |
| 17 | |
| 18 | run_root="$workspace/unit_tests/run" |
| 19 | |
| 20 | mkdir -p "$run_root" |
| 21 | |
| 22 | export run_root |
| 23 | |
| 24 | export tfut_root="${tfut_root:-$workspace/tfut}" |
| 25 | |
| 26 | |
| 27 | run_test() { |
| 28 | test="${1:?}" |
| 29 | echo "Running test $test..." |
| 30 | "./$@" |
| 31 | } |
| 32 | |
| 33 | export -f run_test |
| 34 | |
| 35 | # Accept BIN_MODE from environment, or default to release. If bin_mode is set |
| 36 | # and non-empty (intended to be set from command line), that takes precedence. |
| 37 | pkg_bin_mode="${BIN_MODE:-release}" |
| 38 | bin_mode="${bin_mode:-$pkg_bin_mode}" |
| 39 | |
| 40 | # Change directory so that all binaries can be accessed realtive to where they |
| 41 | # lie |
| 42 | run_cwd="$artefacts/$bin_mode" |
| 43 | cd "$run_cwd" |
| 44 | |
| 45 | run_sh="$run_root/run.sh" |
| 46 | |
| 47 | #Generate run.sh file |
| 48 | echo "echo \"Running unit tests\"" > "$run_sh" |
| 49 | echo "pwd" >> "$run_sh" |
| 50 | cat "tfut_artefacts.txt" | while read test; do |
| 51 | if upon "$test_run"; then |
| 52 | echo "run_test $test \$@" >> "$run_sh" |
| 53 | fi |
| 54 | done |
| 55 | chmod +x "$run_sh" |
| 56 | |
| 57 | # Run the unit tests directly |
| 58 | if upon "$test_run"; then |
| 59 | echo |
| 60 | "$run_sh" "$@" -v -c |
| 61 | exit 0 |
| 62 | fi |