From c1daf811e20a82e63ec39c9f0c4ca7d894e04c38 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Wed, 11 Dec 2024 10:09:21 -0500 Subject: [PATCH] Tests: Bail out of shell-based tests if bash version is not supported MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ibb3b6d3b6069dae522a00273dd5b2f7990c095f3 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 6 ++++++ 1 file changed, 6 insertions(+) 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. -- 2.39.5