3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
8 # This test validates that a `src.ctf.fs` component successfully reads
9 # specific CTF traces and creates the expected messages.
11 # Such CTF traces to open either exist (in `tests/ctf-traces/succeed`)
12 # or are generated by this test using local trace generators.
16 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
17 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
19 UTILSSH
="$(dirname "$0")/../../../utils/utils.sh"
22 # shellcheck source=../../../utils/utils.sh
25 this_dir_relative
="plugins/src.ctf.fs/succeed"
26 this_dir_build
="$BT_TESTS_BUILDDIR/$this_dir_relative"
27 succeed_trace_dir
="$BT_CTF_TRACES_PATH/succeed"
28 expect_dir
="$BT_TESTS_DATADIR/$this_dir_relative"
30 test_ctf_common_details_args
=("-p" "with-trace-name=no,with-stream-name=no")
32 test_ctf_gen_single
() {
35 diag
"Generating trace '$name'"
36 bt_diff_details_ctf_gen_single
"$this_dir_build/gen-trace-$name" \
37 "$expect_dir/trace-$name.expect" \
38 "${test_ctf_common_details_args[@]}" "-p" "with-uuid=no"
39 ok $?
"Generated trace '$name' gives the expected output"
45 bt_diff_details_ctf_single
"$expect_dir/trace-$name.expect" \
46 "$succeed_trace_dir/$name" "${test_ctf_common_details_args[@]}"
47 ok $?
"Trace '$name' gives the expected output"
52 local expected_stdout
="$expect_dir/trace-$name.expect"
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")
58 local temp_stdout_output_file
59 local temp_greped_stdout_output_file
60 local temp_stderr_output_file
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)"
66 bt_cli
"$temp_stdout_output_file" "$temp_stderr_output_file" \
67 "$succeed_trace_dir/$name" "${details_comp[@]}" \
70 "$BT_TESTS_GREP_BIN" "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file"
72 bt_diff
"$expected_stdout" "$temp_greped_stdout_output_file"
75 bt_diff
/dev
/null
"$temp_stderr_output_file"
78 if ((ret_stdout
!= 0 || ret_stderr
!= 0)); then
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"
86 test_force_origin_unix_epoch
() {
89 local expected_stdout
="$expect_dir/trace-$name1-$name2.expect"
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")
96 local temp_stdout_output_file
97 local temp_stderr_output_file
99 temp_stdout_output_file
="$(mktemp -t actual_stdout.XXXXXX)"
100 temp_stderr_output_file
="$(mktemp -t actual_stderr.XXXXXX)"
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[@]}"
107 bt_diff
"$expected_stdout" "$temp_stdout_output_file"
110 if ((ret_stdout
!= 0)); then
114 ok
$ret "Trace '$name1' and '$name2' give the expected stdout"
116 bt_diff
/dev
/null
"$temp_stderr_output_file"
119 if ((ret_stderr
!= 0)); then
123 ok
$ret "Trace '$name1' and '$name2' give the expected stderr"
125 rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
130 test_force_origin_unix_epoch
2packets barectf-event-before-packet
131 test_ctf_gen_single simple
132 test_ctf_single smalltrace
133 test_ctf_single
2packets
134 test_ctf_single barectf-event-before-packet
135 test_ctf_single session-rotation
136 test_ctf_single lttng-tracefile-rotation
137 test_ctf_single array-align-elem
138 test_ctf_single struct-array-align-elem
139 test_ctf_single meta-ctx-sequence
140 test_packet_end lttng-event-after-packet
141 test_packet_end lttng-crash