tfa-next: adapt generic tests to support more repositories

This allows us to run `cargo test` on other repositories
that are not trusted-firmware.

Change-Id: I79242f3975f95f2e81c2a6d5c2033858e5a37461
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
index 67c6ee9..16f5283 100755
--- a/script/next-checks/next-checks-generic-tests.sh
+++ b/script/next-checks/next-checks-generic-tests.sh
@@ -5,6 +5,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
+set -ex
+
 echo '----------------------------------------------'
 echo '--           Running Cargo tests            --'
 echo '----------------------------------------------'
@@ -12,17 +14,22 @@
 export LOG_TEST_FILENAME=$(pwd)/next-generic-checks.log
 export RUSTUP_HOME=/usr/local/rustup
 
+REPO_SPACE=$1
+REPO_NAME=$2
 # 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 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/${REPO_SPACE}/${REPO_NAME}"
+export GIT_SSH_COMMAND="ssh ${SSH_PARAMS}"
+
+cd "${REPO_NAME}"
+
+if [ "$REPO_NAME" == "trusted-firmware-a" ] && ["$IS_CONTINUOUS_INTEGRATION" == 1 ]; then
     git remote set-url origin ${REPO_SSH_URL}
     git fetch origin
 fi
@@ -34,13 +41,17 @@
 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))
+if [ "$REPO_NAME" == "trusted-firmware-a" ]; then
+  cd rust
+  declare -a all_features=($(make PLAT=${platform} --silent list_features))
+else
+  declare -a all_features=($TEST_FEATURES)
+fi
+
 # append empty features by default
 all_features+=("")