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