Fix: tests: conditionally skip Python bindings test that requires Python plugins...
[babeltrace.git] / tests / plugins / sink.ctf.fs / test-stream-names.sh
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
faf5c654
SM
33if [ "$BT_TESTS_ENABLE_PYTHON_PLUGINS" != "1" ]; then
34 plan_skip_all "This test requires the Python plugin provider"
35 exit
36fi
37
d19b245b
SM
38plan_tests 9
39
40bt_cli "$temp_stdout" "$temp_stderr" \
41 "--plugin-path=${data_dir}" \
42 -c src.foo.TheSource \
43 -c sink.ctf.fs -p "path=\"${temp_output_dir}\""
44ok "$?" "run babeltrace"
45
46# Check stdout.
a0baab4a 47if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
c169867c
SM
48 # shellcheck disable=SC2028
49 echo "Created CTF trace \`$(cygpath -m "${temp_output_dir}")\\trace\`." > "$temp_expected_stdout"
d19b245b
SM
50else
51 echo "Created CTF trace \`${trace_dir}\`." > "$temp_expected_stdout"
52fi
53bt_diff "$temp_expected_stdout" "$temp_stdout"
54ok "$?" "expected message on stdout"
55
56# Check stderr.
57bt_diff "/dev/null" "$temp_stderr"
58ok "$?" "stderr is empty"
59
60# Verify only the expected files exist.
61files=("$trace_dir"/*)
62num_files=${#files[@]}
63is "$num_files" "4" "expected number of files in output directory"
64
65test -f "$trace_dir/metadata"
66ok "$?" "metadata file exists"
67
68test -f "$trace_dir/metadata-0"
69ok "$?" "metadata-0 file exists"
70
71test -f "$trace_dir/the-stream"
72ok "$?" "the-stream file exists"
73
74test -f "$trace_dir/the-stream-0"
75ok "$?" "the-stream-0 file exists"
76
77# Read back the output trace to make sure it's properly formed.
78cat <<- 'END' > "$temp_expected_stdout"
79the-event:
80the-event:
81the-event:
82END
83bt_diff_cli "$temp_expected_stdout" /dev/null "$trace_dir"
84ok "$?" "read back output trace"
85
86rm -f "$temp_stdout"
87rm -f "$temp_stderr"
88rm -f "$temp_expected_stdout"
89rm -f "$trace_dir/metadata"
90rm -f "$trace_dir/metadata-0"
91rm -f "$trace_dir/the-stream"
92rm -f "$trace_dir/the-stream-0"
93rmdir "$trace_dir"
94rmdir "$temp_output_dir"
This page took 0.043846 seconds and 4 git commands to generate.