Add a function that simply runs the CLI, redirecting stdout and
stderr to the specified files. This will allow more flexible tests than
the existing "diff" function.
Change-Id: I8319c4a74a0baa3b40afb871bfb0605ac81c3270
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1837
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
BT_TESTS_DATADIR="${BT_TESTS_SRCDIR}/data"
BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces"
BT_TESTS_DATADIR="${BT_TESTS_SRCDIR}/data"
BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces"
+# 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=("$@")
+
+ run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" 1>"$stdout_file" 2>"$stderr_file"
+}
temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
# Run the CLI to get a detailed file.
temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
# Run the CLI to get a detailed file.
- run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" 1>"$temp_stdout_output_file" 2>"$temp_stderr_output_file"
+ bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" "${args[@]}"
bt_diff "$expected_stdout_file" "$temp_stdout_output_file" "$expected_stderr_file" "$temp_stderr_output_file" "${args[@]}"
ret=$?
bt_diff "$expected_stdout_file" "$temp_stdout_output_file" "$expected_stderr_file" "$temp_stderr_output_file" "${args[@]}"
ret=$?
temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
# Run the CLI to get a detailed file.
temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
# Run the CLI to get a detailed file.
- run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" 1>"$temp_stdout_output_file" 2>"$temp_stderr_output_file"
+ bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" "${args[@]}"
# Sort the stdout file, use a subshell to do it in-place
# shellcheck disable=SC2005
# Sort the stdout file, use a subshell to do it in-place
# shellcheck disable=SC2005