bt2c::Logger: remove unused cLevel() method
[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 [ -n "${BT_TESTS_SRCDIR:-}" ]; 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_TESTS_OS_TYPE" = "mingw" ]; then
43 # shellcheck disable=SC2028
44 echo "Created CTF trace \`$(cygpath -m "${temp_output_dir}")\\trace\`." > "$temp_expected_stdout"
45 else
46 echo "Created CTF trace \`${trace_dir}\`." > "$temp_expected_stdout"
47 fi
48 bt_diff "$temp_expected_stdout" "$temp_stdout"
49 ok "$?" "expected message on stdout"
50
51 # Check stderr.
52 bt_diff "/dev/null" "$temp_stderr"
53 ok "$?" "stderr is empty"
54
55 # Verify only the expected files exist.
56 files=("$trace_dir"/*)
57 num_files=${#files[@]}
58 is "$num_files" "4" "expected number of files in output directory"
59
60 test -f "$trace_dir/metadata"
61 ok "$?" "metadata file exists"
62
63 test -f "$trace_dir/metadata-0"
64 ok "$?" "metadata-0 file exists"
65
66 test -f "$trace_dir/the-stream"
67 ok "$?" "the-stream file exists"
68
69 test -f "$trace_dir/the-stream-0"
70 ok "$?" "the-stream-0 file exists"
71
72 # Read back the output trace to make sure it's properly formed.
73 cat <<- 'END' > "$temp_expected_stdout"
74 the-event:
75 the-event:
76 the-event:
77 END
78 bt_diff_cli "$temp_expected_stdout" /dev/null "$trace_dir"
79 ok "$?" "read back output trace"
80
81 rm -f "$temp_stdout"
82 rm -f "$temp_stderr"
83 rm -f "$temp_expected_stdout"
84 rm -f "$trace_dir/metadata"
85 rm -f "$trace_dir/metadata-0"
86 rm -f "$trace_dir/the-stream"
87 rm -f "$trace_dir/the-stream-0"
88 rmdir "$trace_dir"
89 rmdir "$temp_output_dir"
This page took 0.0313 seconds and 4 git commands to generate.