+# By default, it will not source tap.sh. If you want to output tap directly
+# from the test script, define the 'SH_TAP' variable to '1' before sourcing
+# this script.
+if [ "${SH_TAP:-}" = 1 ]; then
+ # shellcheck source=./tap/tap.sh
+ . "${BT_TESTS_SRCDIR}/utils/tap/tap.sh"
+fi
+
+
+# Remove CR characters in file "$1".
+
+bt_remove_cr() {
+ "$BT_TESTS_SED_BIN" -i 's/\r//g' "$1"
+}
+
+# Run the Babeltrace CLI, redirecting stdout and stderr to specified files.
+#
+# $1: file to redirect stdout to
+# $2: file to redirect stderr to
+# remaining args: arguments to pass to the CLI
+#
+# Return the exit code of the CLI.
+
+bt_cli() {
+ local stdout_file="$1"
+ local stderr_file="$2"
+ shift 2
+ local args=("$@")
+
+ echo "Running: $BT_TESTS_BT2_BIN ${args[*]}" >&2
+ run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" 1>"$stdout_file" 2>"$stderr_file"
+}