# Export it so that executed commands can use it.
if [[ -z ${BT_TESTS_OS_TYPE:-} ]]; then
BT_TESTS_OS_TYPE=$(uname -s)
+
case $BT_TESTS_OS_TYPE in
MINGW*)
BT_TESTS_OS_TYPE=mingw
;;
esac
fi
+
export BT_TESTS_OS_TYPE
# Sets and exports, if not set:
if [[ -z ${BT_TESTS_SRCDIR:-} ]]; then
BT_TESTS_SRCDIR=$testsdir
fi
+
export BT_TESTS_SRCDIR
# Base build directory of tests
if [[ -z ${BT_TESTS_BUILDDIR:-} ]]; then
BT_TESTS_BUILDDIR=$testsdir
fi
+
export BT_TESTS_BUILDDIR
}
# Path to the `babeltrace2` command, if not set
if [[ -z ${BT_TESTS_BT2_BIN:-} ]]; then
BT_TESTS_BT2_BIN=$BT_TESTS_BUILDDIR/../src/cli/babeltrace2
+
if [[ $BT_TESTS_OS_TYPE == mingw ]]; then
BT_TESTS_BT2_BIN+=.exe
fi
fi
+
export BT_TESTS_BT2_BIN
# This doesn't need to be exported, but it needs to remain set for
if [[ -z ${BT_TESTS_BABELTRACE_PLUGIN_PATH:-} ]]; then
BT_TESTS_BABELTRACE_PLUGIN_PATH=$_bt_tests_plugins_path/ctf:$_bt_tests_plugins_path/utils:$_bt_tests_plugins_path/text:$_bt_tests_plugins_path/lttng-utils
fi
+
export BT_TESTS_BABELTRACE_PLUGIN_PATH
# Directory containing the Python plugin provider library, if not set
if [[ -z ${BT_TESTS_PROVIDER_DIR:-} ]]; then
BT_TESTS_PROVIDER_DIR=$BT_TESTS_BUILDDIR/../src/python-plugin-provider/.libs
fi
+
export BT_TESTS_PROVIDER_DIR
# Directory containing the built `bt2` Python package, if not set
if [[ -z ${BT_TESTS_PYTHONPATH:-} ]]; then
BT_TESTS_PYTHONPATH=$BT_TESTS_BUILDDIR/../src/bindings/python/bt2/build/build_lib
fi
+
export BT_TESTS_PYTHONPATH
# Name of the `awk` command to use when testing, if not set
if [[ -z ${BT_TESTS_AWK_BIN:-} ]]; then
BT_TESTS_AWK_BIN="awk"
fi
+
export BT_TESTS_AWK_BIN
# Name of the `grep` command to use when testing, if not set
if [[ -z ${BT_TESTS_GREP_BIN:-} ]]; then
BT_TESTS_GREP_BIN="grep"
fi
+
export BT_TESTS_GREP_BIN
# Name of the `python3` command to use when testing, if not set
if [[ -z ${BT_TESTS_PYTHON_BIN:-} ]]; then
BT_TESTS_PYTHON_BIN=python3
fi
+
export BT_TESTS_PYTHON_BIN
# Major and minor version of the `python3` command to use when testing.
if [[ -z ${BT_TESTS_PYTHON_CONFIG_BIN:-} ]]; then
BT_TESTS_PYTHON_CONFIG_BIN=python3-config
fi
+
export BT_TESTS_PYTHON_CONFIG_BIN
# Name of the `sed` command to use when testing, if not set
if [[ -z ${BT_TESTS_SED_BIN:-} ]]; then
BT_TESTS_SED_BIN="sed"
fi
+
export BT_TESTS_SED_BIN
# Name of the `cc` command to use when testing, if not set
if [[ -z ${BT_TESTS_CC_BIN:-} ]]; then
BT_TESTS_CC_BIN=cc
fi
+
export BT_TESTS_CC_BIN
# Whether or not to enable AddressSanitizer, `0` (disabled) if not set.
bt_cli() {
local -r stdout_file=$1
local -r stderr_file=$2
+
shift 2
+
local -r args=("$@")
echo "Running: \`$BT_TESTS_BT2_BIN ${args[*]}\`" >&2
bt_diff_cli() {
local -r expected_stdout_file=$1
local -r expected_stderr_file=$2
+
shift 2
- local -r args=("$@")
+ local -r args=("$@")
local -r temp_stdout_output_file=$(mktemp -t actual-stdout.XXXXXX)
local -r temp_stderr_output_file=$(mktemp -t actual-stderr.XXXXXX)
bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" "${args[@]}"
-
bt_diff "$expected_stdout_file" "$temp_stdout_output_file" "${args[@]}"
+
local -r ret_stdout=$?
+
bt_diff "$expected_stderr_file" "$temp_stderr_output_file" "${args[@]}"
+
local -r ret_stderr=$?
rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
-
return $((ret_stdout || ret_stderr))
}
bt_diff_details_ctf_single() {
local -r expected_stdout_file=$1
local -r trace_dir=$2
+
shift 2
+
local -r extra_details_args=("$@")
# Compare using the CLI with `sink.text.details`
bt_diff_details_ctf_gen_single() {
local -r ctf_gen_prog_path=$1
local -r expected_stdout_file=$2
+
shift 2
- local -r extra_details_args=("$@")
+ local -r extra_details_args=("$@")
local -r temp_trace_dir=$(mktemp -d)
# Run the CTF trace generator program to get a CTF trace
# Compare using the CLI with `sink.text.details`
bt_diff_details_ctf_single "$expected_stdout_file" "$temp_trace_dir" \
"${extra_details_args[@]+${extra_details_args[@]}}"
+
local -r ret=$?
+
rm -rf "$temp_trace_dir"
return $ret
}
local -x BT_CTF_TRACES_PATH=$BT_CTF_TRACES_PATH
local -x BT_PLUGINS_PATH=$_bt_tests_plugins_path
local -x PYTHONPATH=$BT_TESTS_PYTHONPATH${PYTHONPATH:+:}${PYTHONPATH:-}
-
local -r main_lib_path=$BT_TESTS_BUILDDIR/../src/lib/.libs
# Set the library search path so that the Python 3 interpreter can
run_python_bt2_test() {
local -r test_dir=$1
local -r test_pattern=${2:-*}
-
local python_exec
if [[ ${BT_TESTS_COVERAGE:-} == 1 ]]; then
fi
run_python_bt2 \
- "$python_exec" \
- "$BT_TESTS_SRCDIR/utils/python/testrunner.py" \
- --pattern "$test_pattern" \
- "$test_dir" \
+ "$python_exec" "$BT_TESTS_SRCDIR/utils/python/testrunner.py" \
+ --pattern "$test_pattern" "$test_dir"
local -r ret=$?