diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-12 20:06:39 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-13 09:08:03 +0200 |
commit | 8da0f9f79dd9f75ff215bade607d2a4b009009e5 (patch) | |
tree | ea1e638a900d9f4010eececffcfa45455f8e507f | |
parent | 513c7f0280ceec0728a6e72d8a412d26ec77c279 (diff) | |
download | NetworkManager-8da0f9f79dd9f75ff215bade607d2a4b009009e5.tar.gz |
gitlab-ci: assert that NM_TEST_SELECT_RUN is valid in "run-test.sh"
The script now fails, if the user passes an invalid "$NM_TEST_SELECT_RUN"
or if the script references an invalid name.
-rwxr-xr-x | .gitlab-ci/run-test.sh | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/.gitlab-ci/run-test.sh b/.gitlab-ci/run-test.sh index d991010dc1..e2f48e8b2d 100755 --- a/.gitlab-ci/run-test.sh +++ b/.gitlab-ci/run-test.sh @@ -2,6 +2,11 @@ set -ex +die() { + printf "%s\n" "$*" >&2 + exit 1 +} + export PAGER=cat export OMP_NUM_THREADS=1 @@ -44,9 +49,47 @@ meson --version # to run that test as part of the build. Disable it. export NMTST_SKIP_CHECK_GITLAB_CI=1 +# Assert that "$1" is one of the valid values for NM_TEST_SELECT_RUN. die() otherwise. +check_run_assert() { + { set +x; } 2>/dev/null + local run="$1" + local a + + # These are the supported $NM_TEST_SELECT_RUN values. + local _CHECK_RUN_LIST=( + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + ) + + if [ "$run" = '' ] ; then + set -x + return 0 + fi + + for a in "${_CHECK_RUN_LIST[@]}" ; do + if [ "$a" = "$run" ] ; then + set -x + return 0 + fi + done + die "invalid NM_TEST_SELECT_RUN value \"$1\"" +} + +check_run_assert "$NM_TEST_SELECT_RUN" + check_run() { local test_no="$1" + check_run_assert "$test_no" + # Usually, we run the build several times. However, for testing # the build script manually, it can be useful to explicitly select # one step to run. For example, if step 3 is known to fail, you @@ -55,7 +98,6 @@ check_run() { test -z "$NM_TEST_SELECT_RUN" -o "$NM_TEST_SELECT_RUN" = "$test_no" } - check_run_clean() { if ! check_run "$1" ; then return 1 |