lib: remove some unnecessary uses of `GString`
[babeltrace.git] / tests / plugins / sink.ctf.fs / test-assume-single-trace.sh
CommitLineData
72d458a3
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 the assume-single-trace parameter of sink.ctf.fs.
9
10SH_TAP=1
11
75e396f6 12if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
72d458a3
SM
13 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
14else
15 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
16fi
17
18# shellcheck source=../../utils/utils.sh
19source "$UTILSSH"
20
21# Directory containing the Python test source.
22data_dir="$BT_TESTS_DATADIR/plugins/sink.ctf.fs/assume-single-trace"
23
24temp_stdout=$(mktemp)
25temp_expected_stdout=$(mktemp)
26temp_stderr=$(mktemp)
27temp_output_dir=$(mktemp -d)
28
29trace_dir="$temp_output_dir/the-trace"
30
faf5c654
SM
31if [ "$BT_TESTS_ENABLE_PYTHON_PLUGINS" != "1" ]; then
32 plan_skip_all "This test requires the Python plugin provider"
33 exit
34fi
35
72d458a3
SM
36plan_tests 7
37
38bt_cli "$temp_stdout" "$temp_stderr" \
39 "--plugin-path=${data_dir}" \
40 -c src.foo.TheSource \
41 -c sink.ctf.fs -p "path=\"${trace_dir}\"" -p 'assume-single-trace=true'
42ok "$?" "run sink.ctf.fs with assume-single-trace=true"
43
44# Check stdout.
a0baab4a 45if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
c169867c 46 echo "Created CTF trace \`$(cygpath -m "${trace_dir}")\`." > "$temp_expected_stdout"
72d458a3
SM
47else
48 echo "Created CTF trace \`${trace_dir}\`." > "$temp_expected_stdout"
49fi
50bt_diff "$temp_expected_stdout" "$temp_stdout"
51ok "$?" "expected message on stdout"
52
53# Check stderr.
54bt_diff "/dev/null" "$temp_stderr"
55ok "$?" "stderr is empty"
56
57# Verify only the expected files exist.
58files=("$trace_dir"/*)
59num_files=${#files[@]}
60is "$num_files" "2" "expected number of files in output directory"
61
62test -f "$trace_dir/metadata"
63ok "$?" "metadata file exists"
64
65test -f "$trace_dir/the-stream"
66ok "$?" "the-stream file exists"
67
68# Read back the output trace to make sure it's properly formed.
69echo "the-event: " > "$temp_expected_stdout"
70bt_diff_cli "$temp_expected_stdout" /dev/null "$trace_dir"
71ok "$?" "read back output trace"
72
73rm -f "$temp_stdout"
74rm -f "$temp_stderr"
75rm -f "$temp_expected_stdout"
76rm -f "$trace_dir/metadata"
77rm -f "$trace_dir/the-stream"
78rmdir "$trace_dir"
79rmdir "$temp_output_dir"
This page took 0.044632 seconds and 4 git commands to generate.