blob: af8eeece8401a38fceb005cfd2b16a7f4302993c [file] [log] [blame]
Miles Dai395e4512022-07-01 15:24:31 -04001#!/bin/bash
2# Copyright lowRISC contributors.
3# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4# SPDX-License-Identifier: Apache-2.0
5#
Alexander Williamsb05d61d2022-08-23 15:47:23 -07006# A shell script for executing rust-based tests for functional and e2e tests,
7# especially for harnesses built atop opentitanlib.
8#
9# There are three components that make up the harness invocation:
10# - test harness
11# - arguments
12# - test commands
13#
14# The test harness is invoked with arguments first, then the test commands.
15# The test harness and test commands are both passed in by environment variables.
16# Note that bazel passes user-specified test_arg arguments as arguments to this
17# script, and because the user-specified test_arg arguments come after the bazel
18# rule's arguments, they can override the ones coming from the bazel rule.
19# Thus, the test harness and test script represent portions of the invocation
20# that cannot be overridden, but the arguments in the middle can.
Miles Dai395e4512022-07-01 15:24:31 -040021
22set -e
23
24if [ -z "$TEST_HARNESS" ]; then
25 echo "TEST_HARNESS variable needs to be specified."
26 exit 1
27fi
28
Alexander Williamsb05d61d2022-08-23 15:47:23 -070029# eval the environment variable string to break up the components and have bash
30# interpret quotes and other special characters in arguments. This happens
31# during the invocation line.
32eval "TEST_CMDS_ARRAY=( ${TEST_CMDS} )"
33
34echo Invoking test: "${TEST_HARNESS}" "$@" "${TEST_CMDS_ARRAY[@]}"
35RUST_BACKTRACE=1 ${TEST_HARNESS} "$@" "${TEST_CMDS_ARRAY[@]}"