next-checks: add cargo test checks
Currently, we are not running unit tests on trusted-firmware.
* Add a script to run `cargo test`.
`cargo test` does not require building fip or any other component
and is platform independent, so the test is added to a script
instead of using the `groups`/`run-config` framework.
Change-Id: I7ffb7bb9f8581f588fb62a96b3d234d576b33f3f
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
diff --git a/script/next-checks/next-checks-generic-tests.sh b/script/next-checks/next-checks-generic-tests.sh
new file mode 100755
index 0000000..67c6ee9
--- /dev/null
+++ b/script/next-checks/next-checks-generic-tests.sh
@@ -0,0 +1,69 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2025 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+echo '----------------------------------------------'
+echo '-- Running Cargo tests --'
+echo '----------------------------------------------'
+
+export LOG_TEST_FILENAME=$(pwd)/next-generic-checks.log
+export RUSTUP_HOME=/usr/local/rustup
+
+# For local runs, we require GERRIT_BRANCH to be set to get the merge-base/diff
+# between the checked out commit and the tip of $GERRIT_BRANCH - for running
+# next tests, usually this will be tfa-next
+export GERRIT_BRANCH=${GERRIT_BRANCH:="tfa-next"}
+
+if [ "$IS_CONTINUOUS_INTEGRATION" == 1 ]; then
+ # git operations e.g. ${get_merge_base} rely on access to tfa-next branch,
+ # we need to access via SSH for that to work currently
+ SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa -p 29418 -i ${CI_BOT_KEY}"
+ REPO_SSH_URL="ssh://${CI_BOT_USERNAME}@review.trustedfirmware.org:29418/TF-A/trusted-firmware-a"
+ export GIT_SSH_COMMAND="ssh ${SSH_PARAMS}"
+ git remote set-url origin ${REPO_SSH_URL}
+ git fetch origin
+fi
+
+TEST_CASE="cargo test checks"
+
+echo "# ${TEST_CASE}"
+echo >> "$LOG_TEST_FILENAME"
+echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
+echo >> "$LOG_TEST_FILENAME"
+
+cd rust
+
+ERROR_COUNT=0
+
+# Run cargo test
+
+declare -a all_features=($(make PLAT=${platform} --silent list_features))
+# append empty features by default
+all_features+=("")
+
+for features in "${all_features[@]}"; do
+ echo "cargo test features: '$features'" >> "$LOG_TEST_FILENAME" 2>&1
+ cargo test --features=$features >> "$LOG_TEST_FILENAME" 2>&1
+
+ if [ "$?" != 0 ]; then
+ echo "cargo test --features='$features': FAILURE"
+ ((ERROR_COUNT++))
+ else
+ echo "cargo test --features='$features': PASS"
+ fi
+
+ echo "-------------------------------------" >> "$LOG_TEST_FILENAME" 2>&1
+done
+
+echo
+
+cd -
+if [ "$ERROR_COUNT" != 0 ]; then
+ echo "Some cargo tests checks have failed."
+ exit 1
+fi
+
+exit 0