Tests: ctf: add basic `metadata-info` query test
[babeltrace.git] / tests / plugins / src.ctf.fs / query / test_query_metadata_info
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
4 # Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; only version 2
9 # of the License.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 SH_TAP=1
21
22 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
23 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
24 else
25 UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
26 fi
27
28 # shellcheck source=../../../utils/utils.sh
29 source "$UTILSSH"
30
31 this_dir_relative="plugins/src.ctf.fs/query"
32 this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative"
33 succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed"
34 expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
35
36 test_query_metadata_info() {
37 local name="$1"
38 local ret=0
39 local trace_path="$succeed_trace_dir/$name"
40 local expected_stdout="$expect_dir/metadata-info-$name.expect"
41 local temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)"
42 local temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
43 local query=("query" "src.ctf.fs" "metadata-info" "--params" "path=\"$trace_path\"")
44
45 bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \
46 "${query[@]}"
47
48 bt_diff "$expected_stdout" "$temp_stdout_output_file"
49 ret_stdout=$?
50
51 bt_diff /dev/null "$temp_stderr_output_file"
52 ret_stderr=$?
53
54 if ((ret_stdout != 0 || ret_stderr != 0)); then
55 ret=1
56 fi
57
58 ok $ret "Trace '$name' \`metadata-info\` query gives the expected output"
59 rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
60 }
61
62 plan_tests 1
63 test_query_metadata_info succeed1
This page took 0.033362 seconds and 5 git commands to generate.