| 1 | # SPDX-FileCopyrightText: 2021-2022 EfficiOS, Inc. |
| 2 | # SPDX-License-Identifier: GPL-2.0-only |
| 3 | |
| 4 | # shellcheck shell=bash |
| 5 | |
| 6 | # Sets the variable named `$1` to `$2` if it's not set (or empty), and |
| 7 | # exports it. |
| 8 | _set_var_def() { |
| 9 | local -r varname=$1 |
| 10 | local -r val=$2 |
| 11 | |
| 12 | if [[ -z $(eval echo "\${$varname:-}") ]]; then |
| 13 | eval "$varname='$val'" |
| 14 | fi |
| 15 | |
| 16 | export "${varname?}" |
| 17 | } |
| 18 | |
| 19 | # Base source directory of tests, if not set |
| 20 | _set_var_def BT_TESTS_SRCDIR '@abs_top_srcdir@/tests' |
| 21 | |
| 22 | # Base build directory of tests, if not set |
| 23 | _set_var_def BT_TESTS_BUILDDIR '@abs_top_builddir@/tests' |
| 24 | |
| 25 | # Name of the `awk` command to use when testing, if not set |
| 26 | _set_var_def BT_TESTS_AWK_BIN '@AWK@' |
| 27 | |
| 28 | # Name of the `grep` command to use when testing, if not set |
| 29 | _set_var_def BT_TESTS_GREP_BIN '@GREP@' |
| 30 | |
| 31 | # Name of the `python3` command to use when testing, if not set |
| 32 | _set_var_def BT_TESTS_PYTHON_BIN '@PYTHON@' |
| 33 | |
| 34 | # Name of the `python3-config` command to use when testing, if not set |
| 35 | _set_var_def BT_TESTS_PYTHON_CONFIG_BIN '@PYTHON_CONFIG@' |
| 36 | |
| 37 | # Name of the `sed` command to use when testing, if not set |
| 38 | _set_var_def BT_TESTS_SED_BIN '@SED@' |
| 39 | |
| 40 | # Name of the `cc` command to use when testing, if not set |
| 41 | _set_var_def BT_TESTS_CC_BIN '@CC@' |
| 42 | |
| 43 | # `1` if AddressSanitizer is used, if not set |
| 44 | _set_var_def BT_TESTS_ENABLE_ASAN '@ENABLE_ASAN@' |
| 45 | |
| 46 | # `1` to run tests which depend on Python plugin support, if not set |
| 47 | _set_var_def BT_TESTS_ENABLE_PYTHON_PLUGINS '@ENABLE_PYTHON_PLUGINS@' |
| 48 | |
| 49 | # No more |
| 50 | unset -f _set_var_def |