tests: fix unbound variables in env.sh
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 4 Mar 2024 15:57:21 +0000 (10:57 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 4 Mar 2024 20:53:25 +0000 (15:53 -0500)
When running a bash test script manually, the '_set_var_def' function
expands the variables using their simple form resulting in an unbound
variable error if they are undefined. Use the Default values form
instead in the eval to fix these errors:

    tests/utils/env.sh: line 12: BT_TESTS_AWK_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_GREP_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_PYTHON_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_PYTHON_CONFIG_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_SED_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_CC_BIN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_ENABLE_ASAN: unbound variable
    tests/utils/env.sh: line 12: BT_TESTS_ENABLE_PYTHON_PLUGINS: unbound variable

Change-Id: Ic4b2a3b97bd6a4d776ab6898959742ef77988332
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11999
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/utils/env.sh.in

index 184389df3540c21440d44cb7917c59ecf7d367c0..77e0c443ec9f00b8e96f3d27e48eba5091efc226 100644 (file)
@@ -9,7 +9,7 @@ _set_var_def() {
        local -r varname=$1
        local -r val=$2
 
-       if [[ -z $(eval echo "\$$varname") ]]; then
+       if [[ -z $(eval echo "\${$varname:-}") ]]; then
                eval "$varname='$val'"
        fi
 
This page took 0.024989 seconds and 4 git commands to generate.