# Returns 0 if there's no difference, or 1 otherwise, also printing said
# difference to the standard error.
bt_diff_cli() {
# Returns 0 if there's no difference, or 1 otherwise, also printing said
# difference to the standard error.
bt_diff_cli() {
- local temp_stdout_output_file
- local temp_stderr_output_file
+ 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[@]}"
bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" "${args[@]}"
bt_diff "$expected_stdout_file" "$temp_stdout_output_file" "${args[@]}"
# Returns 0 if there's no difference, or 1 otherwise, also printing said
# difference to the standard error.
bt_diff_details_ctf_single() {
# Returns 0 if there's no difference, or 1 otherwise, also printing said
# difference to the standard error.
bt_diff_details_ctf_single() {
# The program `$1` receives the path to a temporary, empty directory
# where to write the CTF trace as its first argument.
bt_diff_details_ctf_gen_single() {
# The program `$1` receives the path to a temporary, empty directory
# where to write the CTF trace as its first argument.
bt_diff_details_ctf_gen_single() {
# Run the CTF trace generator program to get a CTF trace
if ! "$ctf_gen_prog_path" "$temp_trace_dir" 2>/dev/null; then
# Run the CTF trace generator program to get a CTF trace
if ! "$ctf_gen_prog_path" "$temp_trace_dir" 2>/dev/null; then
# 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[@]}}"
# 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[@]}}"
# ok() with the test name `$3` on the result of bt_grep() matching the
# pattern `$1` within the file `$2`.
bt_grep_ok() {
# ok() with the test name `$3` on the result of bt_grep() matching the
# pattern `$1` within the file `$2`.
bt_grep_ok() {
# Executes a command within an environment which can import the testing
# Python modules (in `tests/utils/python`) and the `bt2` Python package.
run_python_bt2() {
# Executes a command within an environment which can import the testing
# Python modules (in `tests/utils/python`) and the `bt2` Python package.
run_python_bt2() {
local -x "BABELTRACE_PLUGIN_PATH=${BT_TESTS_BABELTRACE_PLUGIN_PATH}"
local -x "LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=${BT_TESTS_PROVIDER_DIR}"
local -x "BT_TESTS_DATADIR=${BT_TESTS_DATADIR}"
local -x "BABELTRACE_PLUGIN_PATH=${BT_TESTS_BABELTRACE_PLUGIN_PATH}"
local -x "LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=${BT_TESTS_PROVIDER_DIR}"
local -x "BT_TESTS_DATADIR=${BT_TESTS_DATADIR}"
local -x "BT_PLUGINS_PATH=${_bt_tests_plugins_path}"
local -x "PYTHONPATH=${BT_TESTS_PYTHONPATH}${PYTHONPATH:+:}${PYTHONPATH:-}"
local -x "BT_PLUGINS_PATH=${_bt_tests_plugins_path}"
local -x "PYTHONPATH=${BT_TESTS_PYTHONPATH}${PYTHONPATH:+:}${PYTHONPATH:-}"
# override the user's value if it contains `detect_leaks=1`.
if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
if "${BT_TESTS_CC_BIN}" --version | head -n 1 | bt_grep -q '^gcc'; then
# override the user's value if it contains `detect_leaks=1`.
if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
if "${BT_TESTS_CC_BIN}" --version | head -n 1 | bt_grep -q '^gcc'; then
run_python "${BT_TESTS_PYTHON_BIN}" "${BT_TESTS_SRCDIR}/utils/python/mctf.py" \
--base-dir "${base_dir}" "${input_file}"
}
run_python "${BT_TESTS_PYTHON_BIN}" "${BT_TESTS_SRCDIR}/utils/python/mctf.py" \
--base-dir "${base_dir}" "${input_file}"
}