Commit | Line | Data |
---|---|---|
b34bfe00 FD |
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" | |
b34bfe00 FD |
32 | succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" |
33 | expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" | |
34 | ||
35 | test_query_metadata_info() { | |
36 | local name="$1" | |
37 | local ret=0 | |
38 | local trace_path="$succeed_trace_dir/$name" | |
39 | local expected_stdout="$expect_dir/metadata-info-$name.expect" | |
ba9ea7f5 SM |
40 | local temp_stdout_output_file |
41 | local temp_stderr_output_file | |
b34bfe00 FD |
42 | local query=("query" "src.ctf.fs" "metadata-info" "--params" "path=\"$trace_path\"") |
43 | ||
ba9ea7f5 SM |
44 | temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)" |
45 | temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)" | |
46 | ||
b34bfe00 FD |
47 | bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \ |
48 | "${query[@]}" | |
49 | ||
50 | bt_diff "$expected_stdout" "$temp_stdout_output_file" | |
51 | ret_stdout=$? | |
52 | ||
53 | bt_diff /dev/null "$temp_stderr_output_file" | |
54 | ret_stderr=$? | |
55 | ||
56 | if ((ret_stdout != 0 || ret_stderr != 0)); then | |
57 | ret=1 | |
58 | fi | |
59 | ||
60 | ok $ret "Trace '$name' \`metadata-info\` query gives the expected output" | |
61 | rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" | |
62 | } | |
63 | ||
64 | plan_tests 1 | |
65 | test_query_metadata_info succeed1 |