+# Source the shell TAP utilities if `SH_TAP` is `1`
+if [ "${SH_TAP:-}" = 1 ]; then
+ # shellcheck source=./tap/tap.sh
+ . "${BT_TESTS_SRCDIR}/utils/tap/tap.sh"
+fi
+
+# Removes the CR characters from the file having the path `$1`.
+#
+# This is sometimes needed on Windows with text files.
+#
+# We can't use the `--string-trailing-cr` option of `diff` because
+# Solaris doesn't have it.
+bt_remove_cr() {
+ "$BT_TESTS_SED_BIN" -i'' -e 's/\r//g' "$1"
+}
+
+# Prints `$1` without CR characters.
+bt_remove_cr_inline() {
+ "$BT_TESTS_SED_BIN" 's/\r//g' "$1"
+}
+
+# Runs the `$BT_TESTS_BT2_BIN` command within an environment which can
+# import the `bt2` Python package, redirecting the standard output to
+# the `$1` file and the standard error to the `$2` file.
+#
+# The remaining arguments are forwarded to the `$BT_TESTS_BT2_BIN`
+# command.
+#
+# Returns the exit status of the executed `$BT_TESTS_BT2_BIN`.
+bt_cli() {
+ local -r stdout_file="$1"
+ local -r stderr_file="$2"
+ shift 2
+ local -r args=("$@")