| 1 | #!/bin/bash |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | # |
| 5 | # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com> |
| 6 | # Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com> |
| 7 | # |
| 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 | |
| 15 | SH_TAP=1 |
| 16 | |
| 17 | if [ -n "${BT_TESTS_SRCDIR:-}" ]; then |
| 18 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" |
| 19 | else |
| 20 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" |
| 21 | fi |
| 22 | |
| 23 | # shellcheck source=../../utils/utils.sh |
| 24 | source "$UTILSSH" |
| 25 | |
| 26 | this_dir_relative="plugins/flt.lttng-utils.debug-info" |
| 27 | succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" |
| 28 | expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" |
| 29 | binary_artefact_dir="$BT_TESTS_DATADIR/$this_dir_relative" |
| 30 | data_dir="$BT_TESTS_DATADIR/$this_dir_relative" |
| 31 | |
| 32 | test_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 | |
| 46 | test_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 | ) |
| 58 | local actual_stdout |
| 59 | local actual_stderr |
| 60 | local expected_stdout |
| 61 | local expected_stderr |
| 62 | local ret=0 |
| 63 | |
| 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 | |
| 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 | |
| 89 | test_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 | |
| 98 | test_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 | |
| 105 | plan_tests 9 |
| 106 | |
| 107 | test_debug_info debug-info |
| 108 | |
| 109 | test_compare_ctf_src_trace smalltrace |
| 110 | test_compare_ctf_src_trace 2packets |
| 111 | test_compare_ctf_src_trace session-rotation |
| 112 | |
| 113 | test_compare_complete_src_trace |