Commit | Line | Data |
---|---|---|
e30aed9e PP |
1 | #!/bin/bash |
2 | # | |
0235b0db | 3 | # SPDX-License-Identifier: GPL-2.0-only |
e30aed9e | 4 | # |
0235b0db | 5 | # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com> |
e30aed9e | 6 | # |
e30aed9e 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 | ||
644e0364 | 14 | SH_TAP=1 |
e30aed9e | 15 | |
644e0364 MJ |
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/src.ctf.fs/succeed" | |
26 | this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" | |
bbff0ab4 | 27 | succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" |
644e0364 | 28 | expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" |
e30aed9e | 29 | |
53cc240b | 30 | test_ctf_common_details_args=("-p" "with-trace-name=no,with-stream-name=no") |
e30aed9e PP |
31 | |
32 | test_ctf_gen_single() { | |
33 | name="$1" | |
34 | ||
35 | diag "Generating trace '$name'" | |
36 | bt_diff_details_ctf_gen_single "$this_dir_build/gen-trace-$name" \ | |
644e0364 | 37 | "$expect_dir/trace-$name.expect" \ |
53cc240b | 38 | "${test_ctf_common_details_args[@]}" "-p" "with-uuid=no" |
e30aed9e PP |
39 | ok $? "Generated trace '$name' gives the expected output" |
40 | } | |
41 | ||
42 | test_ctf_single() { | |
43 | name="$1" | |
44 | ||
53cc240b MJ |
45 | bt_diff_details_ctf_single "$expect_dir/trace-$name.expect" \ |
46 | "$succeed_trace_dir/$name" "${test_ctf_common_details_args[@]}" | |
e30aed9e PP |
47 | ok $? "Trace '$name' gives the expected output" |
48 | } | |
49 | ||
8e03dac5 FD |
50 | test_packet_end() { |
51 | local name="$1" | |
52 | local expected_stdout="$expect_dir/trace-$name.expect" | |
53 | local ret=0 | |
54 | local ret_stdout | |
55 | local ret_stderr | |
56 | local details_comp=("-c" "sink.text.details") | |
57 | local details_args=("-p" "with-trace-name=no,with-stream-name=no,with-metadata=no,compact=yes") | |
bbb716d3 SM |
58 | local temp_stdout_output_file |
59 | local temp_greped_stdout_output_file | |
60 | local temp_stderr_output_file | |
61 | ||
62 | temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)" | |
63 | temp_greped_stdout_output_file="$(mktemp -t greped_stdout.XXXXXX)" | |
64 | temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)" | |
8e03dac5 FD |
65 | |
66 | bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \ | |
67 | "$succeed_trace_dir/$name" "${details_comp[@]}" \ | |
68 | "${details_args[@]}" | |
69 | ||
70 | "$BT_TESTS_GREP_BIN" "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file" | |
71 | ||
72 | bt_diff "$expected_stdout" "$temp_greped_stdout_output_file" | |
73 | ret_stdout=$? | |
74 | ||
75 | bt_diff /dev/null "$temp_stderr_output_file" | |
76 | ret_stderr=$? | |
77 | ||
78 | if ((ret_stdout != 0 || ret_stderr != 0)); then | |
79 | ret=1 | |
80 | fi | |
81 | ||
82 | ok $ret "Trace '$name' gives the expected output" | |
83 | rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" "$temp_greped_stdout_output_file" | |
84 | } | |
85 | ||
c0aa240b FD |
86 | test_force_origin_unix_epoch() { |
87 | local name1="$1" | |
88 | local name2="$2" | |
89 | local expected_stdout="$expect_dir/trace-$name1-$name2.expect" | |
90 | local ret=0 | |
91 | local ret_stdout | |
92 | local ret_stderr | |
93 | local src_ctf_fs_args=("-p" "force-clock-class-origin-unix-epoch=true") | |
94 | local details_comp=("-c" "sink.text.details") | |
95 | local details_args=("-p" "with-trace-name=no,with-stream-name=no,with-metadata=yes,compact=yes") | |
bbb716d3 SM |
96 | local temp_stdout_output_file |
97 | local temp_stderr_output_file | |
98 | ||
99 | temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)" | |
100 | temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)" | |
c0aa240b FD |
101 | |
102 | bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \ | |
103 | "$succeed_trace_dir/$name1" "${src_ctf_fs_args[@]}" \ | |
104 | "$succeed_trace_dir/$name2" "${src_ctf_fs_args[@]}" \ | |
105 | "${details_comp[@]}" "${details_args[@]}" | |
106 | ||
107 | bt_diff "$expected_stdout" "$temp_stdout_output_file" | |
108 | ret_stdout=$? | |
109 | ||
110 | if ((ret_stdout != 0)); then | |
111 | ret=1 | |
112 | fi | |
113 | ||
114 | ok $ret "Trace '$name1' and '$name2' give the expected stdout" | |
115 | ||
116 | bt_diff /dev/null "$temp_stderr_output_file" | |
117 | ret_stderr=$? | |
118 | ||
119 | if ((ret_stderr != 0)); then | |
120 | ret=1 | |
121 | fi | |
122 | ||
123 | ok $ret "Trace '$name1' and '$name2' give the expected stderr" | |
124 | ||
125 | rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" | |
126 | } | |
127 | ||
ce75de14 | 128 | plan_tests 10 |
e30aed9e | 129 | |
c0aa240b | 130 | test_force_origin_unix_epoch 2packets barectf-event-before-packet |
e30aed9e PP |
131 | test_ctf_gen_single simple |
132 | test_ctf_single smalltrace | |
da5a592a | 133 | test_ctf_single 2packets |
8e03dac5 | 134 | test_ctf_single barectf-event-before-packet |
493917ba | 135 | test_ctf_single session-rotation |
ce75de14 | 136 | test_ctf_single lttng-tracefile-rotation |
8e03dac5 FD |
137 | test_packet_end lttng-event-after-packet |
138 | test_packet_end lttng-crash |