Skip to content

Commit fec113f

Browse files
committed
[ot] scripts/opentitan: run-bazel-tests.sh: Add test timeout option
When testing a specific execution environment, you can set a maximum test timeout to use for that environment. For environments where tests are expected to be quick this can be used to decrease CI times (tests using unimplemented features may timeout, so this provides a smaller upper bound on test execution). For environments where tests may take a while when executed in parallel on a standard GitHub runner (maybe longer than 60 seconds), this can be used to increase the timeout for just executions in that environment. Signed-off-by: Alex Jones <[email protected]>
1 parent 34f76a8 commit fec113f

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/eg_regression.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
required: true
1515
default: qemu # Default tag, captures all QEMU exec envs in OpenTitan
1616
type: string
17+
test_timeout:
18+
description: The maximum timeout in seconds to use per executed test
19+
required: false
20+
type: string
1721
opentitan_repo:
1822
description: OpenTitan repository to be checked out
1923
required: true
@@ -62,6 +66,7 @@ jobs:
6266
set -o pipefail
6367
./qemu/scripts/opentitan/run-bazel-tests.sh ./ qemu \
6468
${{ inputs.exec_env }} \
69+
${{ inputs.test_timeout }} \
6570
| tee ${{ inputs.exec_env }}_test_results.txt
6671
6772
- name: Upload Bazel test results

docs/opentitan/regressions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ With a checkout of OpenTitan, the script can be run like this:
88

99
```sh
1010
./scripts/opentitan/run-bazel-tests.sh path/to/opentitan path/to/qemu \
11-
[execution_environment]
11+
[execution_environment] [timeout]
1212
```
1313

1414
The script will execute all QEMU-compatible tests using QEMU as it was built
@@ -33,4 +33,6 @@ Specifying an execution environment when running the script will restrict to
3333
only running and comparing against tests for that execution environment.
3434
This can be used for more granular testing to break down large test workloads.
3535
If you do not specify an execution environment, _all_ available QEMU tests
36-
will be executed.
36+
will be executed. When specifying an execution environment, a maximum test
37+
timeout (in seconds) to use for that environment can also be provided as
38+
a subsequent argument to the script.

scripts/opentitan/run-bazel-tests.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -e
77
# comparing the results with a list of expected passes.
88
#
99
# USAGE: run-bazel-tests.sh path/to/opentitan/repo path/to/qemu/repo \
10-
# [execution environment]
10+
# [execution environment] [test_timeout]
1111
#
1212
# There is a companion file `tests/opentitan/data/earlgrey-tests.txt` that
1313
# is read by this script.
@@ -29,13 +29,14 @@ GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/null}"
2929
opentitan_path="$1"
3030
qemu_path="$2"
3131
qemu_exec_env="$3"
32+
test_timeout="$4"
3233
if [ ! -d "$opentitan_path" ] || [ ! -d "$qemu_path" ]; then
33-
echo "USAGE: ${0} <OPENTITAN REPO> <QEMU REPO> [<EXEC ENV>]"
34+
echo "USAGE: ${0} <OPENTITAN REPO> <QEMU REPO> [<EXEC ENV>] [<TIMEOUT>]"
3435
exit 1
3536
fi
3637
opentitan_path="$(realpath "$opentitan_path")"
3738
qemu_path="$(realpath "$qemu_path")"
38-
if [ ! "$qemu_exec_env" ]; then
39+
if [ -z "$qemu_exec_env" ]; then
3940
# catch-all tag for all QEMU exec envs
4041
qemu_exec_env="qemu"
4142
echo "Using default 'qemu' tag to test all exec envs"
@@ -86,12 +87,18 @@ trap "cleanup" EXIT
8687
## RUN BAZEL TESTS
8788
cd "$opentitan_path" >/dev/null
8889

90+
test_args=""
91+
if [ -n "$test_timeout" ]; then
92+
test_args="--test_timeout=$test_timeout"
93+
fi
94+
8995
./bazelisk.sh test //... \
9096
--test_tag_filters="$qemu_exec_env" \
9197
--test_summary="short" \
9298
--test_output=all \
9399
--override_repository="+qemu+qemu_opentitan=${qemu_path}" \
94100
--build_tests_only \
101+
$test_args \
95102
| tee "$results"
96103

97104
## COMPARE RESULTS

0 commit comments

Comments
 (0)