Fix: sink.ctf.fs: fix logic of make_unique_stream_file_name
[babeltrace.git] / tests / plugins / sink.ctf.fs / test_stream_names
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 corner cases related to stream names:
9 #
10 # - two streams with the same name
11 # - a stream named "metadata"
12
13 SH_TAP=1
14
15 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
16 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
17 else
18 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
19 fi
20
21 # shellcheck source=../../utils/utils.sh
22 source "$UTILSSH"
23
24 # Directory containing the Python test source.
25 data_dir="$BT_TESTS_DATADIR/plugins/sink.ctf.fs/stream-names"
26
27 temp_stdout=$(mktemp)
28 temp_expected_stdout=$(mktemp)
29 temp_stderr=$(mktemp)
30 temp_output_dir=$(mktemp -d)
31 trace_dir="$temp_output_dir/trace"
32
33 plan_tests 9
34
35 bt_cli "$temp_stdout" "$temp_stderr" \
36 "--plugin-path=${data_dir}" \
37 -c src.foo.TheSource \
38 -c sink.ctf.fs -p "path=\"${temp_output_dir}\""
39 ok "$?" "run babeltrace"
40
41 # Check stdout.
42 if [ "$BT_OS_TYPE" = "mingw" ]; then
43 echo "Created CTF trace \`$(cygpath -m ${temp_output_dir})\\trace\`." > "$temp_expected_stdout"
44 else
45 echo "Created CTF trace \`${trace_dir}\`." > "$temp_expected_stdout"
46 fi
47 bt_diff "$temp_expected_stdout" "$temp_stdout"
48 ok "$?" "expected message on stdout"
49
50 # Check stderr.
51 bt_diff "/dev/null" "$temp_stderr"
52 ok "$?" "stderr is empty"
53
54 # Verify only the expected files exist.
55 files=("$trace_dir"/*)
56 num_files=${#files[@]}
57 is "$num_files" "4" "expected number of files in output directory"
58
59 test -f "$trace_dir/metadata"
60 ok "$?" "metadata file exists"
61
62 test -f "$trace_dir/metadata-0"
63 ok "$?" "metadata-0 file exists"
64
65 test -f "$trace_dir/the-stream"
66 ok "$?" "the-stream file exists"
67
68 test -f "$trace_dir/the-stream-0"
69 ok "$?" "the-stream-0 file exists"
70
71 # Read back the output trace to make sure it's properly formed.
72 cat <<- 'END' > "$temp_expected_stdout"
73 the-event:
74 the-event:
75 the-event:
76 END
77 bt_diff_cli "$temp_expected_stdout" /dev/null "$trace_dir"
78 ok "$?" "read back output trace"
79
80 rm -f "$temp_stdout"
81 rm -f "$temp_stderr"
82 rm -f "$temp_expected_stdout"
83 rm -f "$trace_dir/metadata"
84 rm -f "$trace_dir/metadata-0"
85 rm -f "$trace_dir/the-stream"
86 rm -f "$trace_dir/the-stream-0"
87 rmdir "$trace_dir"
88 rmdir "$temp_output_dir"
This page took 0.032727 seconds and 4 git commands to generate.