# SPDX-FileCopyrightText: 2021-2022 EfficiOS, Inc.
# SPDX-License-Identifier: GPL-2.0-only

# shellcheck shell=bash

# Sets the variable named `$1` to `$2` if it's not set (or empty), and
# exports it.
_set_var_def() {
	local -r varname=$1
	local -r val=$2

	if [[ -z $(eval echo "\${$varname:-}") ]]; then
		eval "$varname='$val'"
	fi

	export "${varname?}"
}

# Base source directory of tests, if not set
_set_var_def BT_TESTS_SRCDIR '/usr/lib/babeltrace2/ptest/tests'

# Base build directory of tests, if not set
_set_var_def BT_TESTS_BUILDDIR '/usr/lib/babeltrace2/ptest/tests'

# Name of the `awk` command to use when testing, if not set
_set_var_def BT_TESTS_AWK_BIN 'gawk'

# Name of the `grep` command to use when testing, if not set
_set_var_def BT_TESTS_GREP_BIN 'grep'

# Name of the `python3` command to use when testing, if not set
_set_var_def BT_TESTS_PYTHON_BIN 'python3'

# Name of the `python3-config` command to use when testing, if not set
_set_var_def BT_TESTS_PYTHON_CONFIG_BIN 'python3.13-config'

# Name of the `sed` command to use when testing, if not set
_set_var_def BT_TESTS_SED_BIN 'sed'

# Name of the `cc` command to use when testing, if not set
_set_var_def BT_TESTS_CC_BIN ''

# `1` if AddressSanitizer is used, if not set
_set_var_def BT_TESTS_ENABLE_ASAN ''

# `1` to run tests which depend on Python plugin support, if not set
_set_var_def BT_TESTS_ENABLE_PYTHON_PLUGINS ''

# No more
unset -f _set_var_def
