blob: 67c6ee9e6db7984ba77e89483631c27eb95e6a8e [file] [log] [blame]
Tomás González010b6372025-04-29 17:13:47 +01001#!/usr/bin/env bash
2#
3# Copyright (c) 2025 Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8echo '----------------------------------------------'
9echo '-- Running Cargo tests --'
10echo '----------------------------------------------'
11
12export LOG_TEST_FILENAME=$(pwd)/next-generic-checks.log
13export RUSTUP_HOME=/usr/local/rustup
14
15# For local runs, we require GERRIT_BRANCH to be set to get the merge-base/diff
16# between the checked out commit and the tip of $GERRIT_BRANCH - for running
17# next tests, usually this will be tfa-next
18export GERRIT_BRANCH=${GERRIT_BRANCH:="tfa-next"}
19
20if [ "$IS_CONTINUOUS_INTEGRATION" == 1 ]; then
21 # git operations e.g. ${get_merge_base} rely on access to tfa-next branch,
22 # we need to access via SSH for that to work currently
23 SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa -p 29418 -i ${CI_BOT_KEY}"
24 REPO_SSH_URL="ssh://${CI_BOT_USERNAME}@review.trustedfirmware.org:29418/TF-A/trusted-firmware-a"
25 export GIT_SSH_COMMAND="ssh ${SSH_PARAMS}"
26 git remote set-url origin ${REPO_SSH_URL}
27 git fetch origin
28fi
29
30TEST_CASE="cargo test checks"
31
32echo "# ${TEST_CASE}"
33echo >> "$LOG_TEST_FILENAME"
34echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
35echo >> "$LOG_TEST_FILENAME"
36
37cd rust
38
39ERROR_COUNT=0
40
41# Run cargo test
42
43declare -a all_features=($(make PLAT=${platform} --silent list_features))
44# append empty features by default
45all_features+=("")
46
47for features in "${all_features[@]}"; do
48 echo "cargo test features: '$features'" >> "$LOG_TEST_FILENAME" 2>&1
49 cargo test --features=$features >> "$LOG_TEST_FILENAME" 2>&1
50
51 if [ "$?" != 0 ]; then
52 echo "cargo test --features='$features': FAILURE"
53 ((ERROR_COUNT++))
54 else
55 echo "cargo test --features='$features': PASS"
56 fi
57
58 echo "-------------------------------------" >> "$LOG_TEST_FILENAME" 2>&1
59done
60
61echo
62
63cd -
64if [ "$ERROR_COUNT" != 0 ]; then
65 echo "Some cargo tests checks have failed."
66 exit 1
67fi
68
69exit 0