Tomás González | 010b637 | 2025-04-29 17:13:47 +0100 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2025 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | echo '----------------------------------------------' |
| 9 | echo '-- Running Cargo tests --' |
| 10 | echo '----------------------------------------------' |
| 11 | |
| 12 | export LOG_TEST_FILENAME=$(pwd)/next-generic-checks.log |
| 13 | export 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 |
| 18 | export GERRIT_BRANCH=${GERRIT_BRANCH:="tfa-next"} |
| 19 | |
| 20 | if [ "$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 |
| 28 | fi |
| 29 | |
| 30 | TEST_CASE="cargo test checks" |
| 31 | |
| 32 | echo "# ${TEST_CASE}" |
| 33 | echo >> "$LOG_TEST_FILENAME" |
| 34 | echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME" |
| 35 | echo >> "$LOG_TEST_FILENAME" |
| 36 | |
| 37 | cd rust |
| 38 | |
| 39 | ERROR_COUNT=0 |
| 40 | |
| 41 | # Run cargo test |
| 42 | |
| 43 | declare -a all_features=($(make PLAT=${platform} --silent list_features)) |
| 44 | # append empty features by default |
| 45 | all_features+=("") |
| 46 | |
| 47 | for 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 |
| 59 | done |
| 60 | |
| 61 | echo |
| 62 | |
| 63 | cd - |
| 64 | if [ "$ERROR_COUNT" != 0 ]; then |
| 65 | echo "Some cargo tests checks have failed." |
| 66 | exit 1 |
| 67 | fi |
| 68 | |
| 69 | exit 0 |