From: Kienan Stewart Date: Wed, 11 Dec 2024 15:09:21 +0000 (-0500) Subject: Tests: Bail out of shell-based tests if bash version is not supported X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c1daf811e20a82e63ec39c9f0c4ca7d894e04c38;p=lttng-tools.git Tests: Bail out of shell-based tests if bash version is not supported Change-Id: Ibb3b6d3b6069dae522a00273dd5b2f7990c095f3 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index d291f5986..a6412ceab 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -68,6 +68,12 @@ if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then LTTNG_TEST_TEARDOWN_TIMEOUT=60 fi +# Some tests use recent bash syntax, e.g. `array_var[-1]` which was introduced +# in version 4.2. Bailout with a clear error if the bash version isn't supported. +if [[ "${BASH_VERSINFO[0]}" -lt "4" ]] || [[ "${BASH_VERSINFO[0]}" == "4" && "${BASH_VERSINFO[1]}" -lt "2" ]]; then + BAIL_OUT "Bash version '${BASH_VERSION}' is not supported by the test suite" +fi + # Enable job monitor mode. # Here we are mostly interested in the following from the monitor mode: # All processes run in a separate process group.