Commit | Line | Data |
---|---|---|
1fba7c7b PP |
1 | #!/bin/bash |
2 | # | |
0235b0db | 3 | # SPDX-License-Identifier: GPL-2.0-only |
1fba7c7b | 4 | # |
0235b0db | 5 | # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com> |
1fba7c7b | 6 | # |
1fba7c7b PP |
7 | |
8 | # This test validates that a `src.ctf.fs` component successfully reads | |
9 | # specific CTF traces and creates the expected messages. | |
10 | # | |
11 | # Such CTF traces to open either exist (in `tests/ctf-traces/succeed`) | |
12 | # or are generated by this test using local trace generators. | |
13 | ||
14 | SH_TAP=1 | |
15 | ||
16 | if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then | |
17 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" | |
18 | else | |
19 | UTILSSH="$(dirname "$0")/../../../utils/utils.sh" | |
20 | fi | |
21 | ||
22 | # shellcheck source=../../../utils/utils.sh | |
23 | source "$UTILSSH" | |
24 | ||
25 | this_dir_relative="plugins/sink.ctf.fs/succeed" | |
26 | this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" | |
27 | expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" | |
45c51519 | 28 | succeed_traces="$BT_CTF_TRACES_PATH/succeed" |
1fba7c7b | 29 | |
45c51519 PP |
30 | test_ctf_single() { |
31 | local name="$1" | |
32 | local in_trace_dir="$2" | |
72c6811a SM |
33 | local temp_out_trace_dir |
34 | ||
35 | temp_out_trace_dir="$(mktemp -d)" | |
1fba7c7b PP |
36 | |
37 | diag "Converting trace '$name' to CTF through 'sink.ctf.fs'" | |
45c51519 | 38 | "$BT_TESTS_BT2_BIN" >/dev/null "$in_trace_dir" -o ctf -w "$temp_out_trace_dir" |
1fba7c7b PP |
39 | ret=$? |
40 | ok $ret "'sink.ctf.fs' component succeeds with input trace '$name'" | |
41 | converted_test_name="Converted trace '$name' gives the expected output" | |
42 | ||
43 | if [ $ret -eq 0 ]; then | |
53cc240b MJ |
44 | bt_diff_details_ctf_single "$expect_dir/trace-$name.expect" \ |
45 | "$temp_out_trace_dir" \ | |
45c51519 | 46 | '-p' 'with-uuid=no,with-trace-name=no,with-stream-name=no' |
1fba7c7b PP |
47 | ok $? "$converted_test_name" |
48 | else | |
49 | fail "$converted_test_name" | |
50 | fi | |
51 | ||
1fba7c7b PP |
52 | rm -rf "$temp_out_trace_dir" |
53 | } | |
54 | ||
45c51519 PP |
55 | test_ctf_existing_single() { |
56 | local name="$1" | |
57 | local trace_dir="$succeed_traces/$name" | |
58 | ||
59 | test_ctf_single "$name" "$trace_dir" | |
60 | } | |
61 | ||
62 | test_ctf_gen_single() { | |
63 | local name="$1" | |
72c6811a SM |
64 | local temp_gen_trace_dir |
65 | ||
66 | temp_gen_trace_dir="$(mktemp -d)" | |
45c51519 PP |
67 | |
68 | diag "Generating trace '$name'" | |
69 | ||
70 | if ! "$this_dir_build/gen-trace-$name" "$temp_gen_trace_dir"; then | |
71 | # this is not part of the test itself; it must not fail | |
72 | echo "ERROR: \"$this_dir_build/gen-trace-$name" "$temp_gen_trace_dir\" failed" >&2 | |
73 | rm -rf "$temp_gen_trace_dir" | |
74 | exit 1 | |
75 | fi | |
76 | ||
77 | test_ctf_single "$name" "$temp_gen_trace_dir" | |
78 | rm -rf "$temp_gen_trace_dir" | |
79 | } | |
80 | ||
81 | plan_tests 14 | |
1fba7c7b PP |
82 | |
83 | test_ctf_gen_single float | |
84 | test_ctf_gen_single double | |
45c51519 PP |
85 | test_ctf_existing_single meta-variant-no-underscore |
86 | test_ctf_existing_single meta-variant-one-underscore | |
87 | test_ctf_existing_single meta-variant-reserved-keywords | |
88 | test_ctf_existing_single meta-variant-same-with-underscore | |
89 | test_ctf_existing_single meta-variant-two-underscores |