src.ctf.lttng-live: remove some goto error-handling
[babeltrace.git] / tests / plugins / sink.ctf.fs / test_assume_single_trace
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2020 EfficiOS Inc.
6 #
7
8 # This file tests the assume-single-trace parameter of sink.ctf.fs.
9
10 SH_TAP=1
11
12 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
13 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
14 else
15 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
16 fi
17
18 # shellcheck source=../../utils/utils.sh
19 source "$UTILSSH"
20
21 # Directory containing the Python test source.
22 data_dir="$BT_TESTS_DATADIR/plugins/sink.ctf.fs/assume-single-trace"
23
24 temp_stdout=$(mktemp)
25 temp_expected_stdout=$(mktemp)
26 temp_stderr=$(mktemp)
27 temp_output_dir=$(mktemp -d)
28
29 trace_dir="$temp_output_dir/the-trace"
30
31 plan_tests 7
32
33 bt_cli "$temp_stdout" "$temp_stderr" \
34 "--plugin-path=${data_dir}" \
35 -c src.foo.TheSource \
36 -c sink.ctf.fs -p "path=\"${trace_dir}\"" -p 'assume-single-trace=true'
37 ok "$?" "run sink.ctf.fs with assume-single-trace=true"
38
39 # Check stdout.
40 if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
41 echo "Created CTF trace \`$(cygpath -m "${trace_dir}")\`." > "$temp_expected_stdout"
42 else
43 echo "Created CTF trace \`${trace_dir}\`." > "$temp_expected_stdout"
44 fi
45 bt_diff "$temp_expected_stdout" "$temp_stdout"
46 ok "$?" "expected message on stdout"
47
48 # Check stderr.
49 bt_diff "/dev/null" "$temp_stderr"
50 ok "$?" "stderr is empty"
51
52 # Verify only the expected files exist.
53 files=("$trace_dir"/*)
54 num_files=${#files[@]}
55 is "$num_files" "2" "expected number of files in output directory"
56
57 test -f "$trace_dir/metadata"
58 ok "$?" "metadata file exists"
59
60 test -f "$trace_dir/the-stream"
61 ok "$?" "the-stream file exists"
62
63 # Read back the output trace to make sure it's properly formed.
64 echo "the-event: " > "$temp_expected_stdout"
65 bt_diff_cli "$temp_expected_stdout" /dev/null "$trace_dir"
66 ok "$?" "read back output trace"
67
68 rm -f "$temp_stdout"
69 rm -f "$temp_stderr"
70 rm -f "$temp_expected_stdout"
71 rm -f "$trace_dir/metadata"
72 rm -f "$trace_dir/the-stream"
73 rmdir "$trace_dir"
74 rmdir "$temp_output_dir"
This page took 0.031362 seconds and 4 git commands to generate.