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