blob: 937bb885b3e011a844cdb639c60e5b88605a971e [file] [log] [blame]
Juan Pablo Conde6eb0d1e2023-12-08 13:52:21 -06001#!/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
10set -e
11
12ci_root="$(readlink -f "$(dirname "$0")/..")"
13source "$ci_root/script/run_common.sh"
14source "$ci_root/utils.sh"
15
16artefacts="${artefacts-$workspace/artefacts}"
17
18run_root="$workspace/unit_tests/run"
19
20mkdir -p "$run_root"
21
22export run_root
23
24export tfut_root="${tfut_root:-$workspace/tfut}"
25
26
27run_test() {
28 test="${1:?}"
29 echo "Running test $test..."
30 "./$@"
31}
32
33export -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.
37pkg_bin_mode="${BIN_MODE:-release}"
38bin_mode="${bin_mode:-$pkg_bin_mode}"
39
40# Change directory so that all binaries can be accessed realtive to where they
41# lie
42run_cwd="$artefacts/$bin_mode"
43cd "$run_cwd"
44
45run_sh="$run_root/run.sh"
46
47#Generate run.sh file
48echo "echo \"Running unit tests\"" > "$run_sh"
49echo "pwd" >> "$run_sh"
50cat "tfut_artefacts.txt" | while read test; do
51 if upon "$test_run"; then
52 echo "run_test $test \$@" >> "$run_sh"
53 fi
54done
55chmod +x "$run_sh"
56
57# Run the unit tests directly
58if upon "$test_run"; then
59 echo
60 "$run_sh" "$@" -v -c
61 exit 0
62fi