tests: use -z / -n to test for string empty / non-empty
[babeltrace.git] / tests / plugins / flt.lttng-utils.debug-info / test_succeed
CommitLineData
d3765576
FD
1#!/bin/bash
2#
0235b0db
MJ
3# SPDX-License-Identifier: GPL-2.0-only
4#
d3765576
FD
5# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
6# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
7#
d3765576
FD
8
9# This test validates that a `src.ctf.fs` component successfully reads
10# specific CTF traces and creates the expected messages.
11#
12# Such CTF traces to open either exist (in `tests/ctf-traces/succeed`)
13# or are generated by this test using local trace generators.
14
15SH_TAP=1
16
75e396f6 17if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
d3765576
FD
18 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
19else
20 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
21fi
22
ce0098bd 23# shellcheck source=../../utils/utils.sh
d3765576
FD
24source "$UTILSSH"
25
26this_dir_relative="plugins/flt.lttng-utils.debug-info"
d3765576
FD
27succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed"
28expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
29binary_artefact_dir="$BT_TESTS_DATADIR/$this_dir_relative"
8cca03c6 30data_dir="$BT_TESTS_DATADIR/$this_dir_relative"
d3765576
FD
31
32test_debug_info() {
33 local name="$1"
34 local local_args=(
35 "-c" "flt.lttng-utils.debug-info"
36 "-p" "target-prefix=\"$binary_artefact_dir/x86_64-linux-gnu/dwarf_full\""
37 "-c" "sink.text.details"
38 "-p" "with-trace-name=no,with-stream-name=no"
39 )
40
41 bt_diff_cli "$expect_dir/trace-$name.expect" "/dev/null" \
42 "$succeed_trace_dir/$name" "${local_args[@]}"
43 ok $? "Trace '$name' gives the expected output"
44}
45
140f7e02
FD
46test_compare_to_ctf_fs() {
47 # Compare the `sink.text.details` output of a graph with and without a
48 # `flt.lttng-utils.debug-info` component. Both should be identical for
49 # traces without LTTng debugging fields.
50 local test_name=$1
51 shift 1
52 local cli_args=("$@")
53 local debug_info_cli_args=("-c" "flt.lttng-utils.debug-info")
54 local details_cli_args=(
55 "-c" "sink.text.details"
56 "--params" "with-trace-name=false,with-stream-name=false,with-uuid=false"
57 )
ce0098bd
SM
58 local actual_stdout
59 local actual_stderr
60 local expected_stdout
61 local expected_stderr
140f7e02
FD
62 local ret=0
63
ce0098bd
SM
64 actual_stdout=$(mktemp -t test_debug_info_stdout_actual.XXXXXX)
65 actual_stderr=$(mktemp -t test_debug_info_stderr_actual.XXXXXX)
66 expected_stdout=$(mktemp -t test_debug_info_stdout_expected.XXXXXX)
67 expected_stderr=$(mktemp -t test_debug_info_stderr_expected.XXXXXX)
68
140f7e02
FD
69 # Create expected files using a graph without a `debug-info` component.
70 bt_cli "$expected_stdout" "$expected_stderr" "${cli_args[@]}" \
71 "${details_cli_args[@]}"
72
73 # Read the same trace with a `debug-info` component in the graph.
74 bt_cli "$actual_stdout" "$actual_stderr" "${cli_args[@]}" \
75 "${details_cli_args[@]}" "${debug_info_cli_args[@]}"
76
77 bt_diff "$expected_stdout" "$actual_stdout"
78 ok $? "Input '$test_name' gives the expected stdout"
79
80 bt_diff "$expected_stderr" "$actual_stderr"
81 ok $? "Input '$test_name' gives the expected stderr"
82
83 rm -f "$actual_stdout"
84 rm -f "$actual_stderr"
85 rm -f "$expected_stdout"
86 rm -f "$expected_stderr"
87}
88
89test_compare_ctf_src_trace() {
90 local trace_name=$1
91 local trace_path="$succeed_trace_dir/$trace_name"
92 local cli_args=("$trace_path")
93
94 diag "Comparing output with and without 'flt.lttng-utils.debug-info' on '$trace_name'"
95 test_compare_to_ctf_fs "src.ctf.fs with $trace_name trace" "${cli_args[@]}"
96}
97
8cca03c6
FD
98test_compare_complete_src_trace() {
99
100 local source_name="src.test_debug_info.CompleteSrc"
101 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name")
102 test_compare_to_ctf_fs "$source_name" "${cli_args[@]}"
103}
104
105plan_tests 9
d3765576
FD
106
107test_debug_info debug-info
140f7e02
FD
108
109test_compare_ctf_src_trace smalltrace
110test_compare_ctf_src_trace 2packets
111test_compare_ctf_src_trace session-rotation
8cca03c6
FD
112
113test_compare_complete_src_trace
This page took 0.04895 seconds and 4 git commands to generate.