| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) - 2019 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | # |
| 5 | # This library is free software; you can redistribute it and/or modify it under |
| 6 | # the terms of the GNU Lesser General Public License as published by the Free |
| 7 | # Software Foundation; version 2.1 of the License. |
| 8 | # |
| 9 | # This library is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 12 | # details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU Lesser General Public License |
| 15 | # along with this library; if not, write to the Free Software Foundation, Inc., |
| 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | TEST_DESC="Streaming Base Path Override - User space tracing" |
| 18 | |
| 19 | CURDIR=$(dirname "$0")/ |
| 20 | TESTDIR=$CURDIR/../../.. |
| 21 | TESTAPP_PATH="$TESTDIR/utils/testapp" |
| 22 | TESTAPP_NAME="gen-ust-events" |
| 23 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" |
| 24 | EVENT_NAME="tp:tptest" |
| 25 | |
| 26 | TRACE_PATH=$(mktemp -d) |
| 27 | |
| 28 | NUM_TESTS=37 |
| 29 | |
| 30 | source "$TESTDIR/utils/utils.sh" |
| 31 | |
| 32 | if [ ! -x "$TESTAPP_BIN" ]; then |
| 33 | BAIL_OUT "No UST events binary detected." |
| 34 | fi |
| 35 | |
| 36 | function ust_app_stream_base_path () |
| 37 | { |
| 38 | local session_name="ust_app_stream_base_path" |
| 39 | local base_path="my/custom/path1" |
| 40 | |
| 41 | diag "Test base path override for trace streaming" |
| 42 | create_lttng_session_uri $session_name net://localhost/$base_path |
| 43 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 44 | |
| 45 | start_lttng_tracing_ok $session_name |
| 46 | |
| 47 | $TESTAPP_BIN > /dev/null 2>&1 |
| 48 | |
| 49 | stop_lttng_tracing_ok $session_name |
| 50 | destroy_lttng_session_ok $session_name |
| 51 | |
| 52 | # validate test |
| 53 | if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then |
| 54 | # only delete if successful |
| 55 | rm -rf "$TRACE_PATH" |
| 56 | fi |
| 57 | } |
| 58 | |
| 59 | function ust_app_snapshot_create_base_path () |
| 60 | { |
| 61 | local session_name="ust_app_snapshot_create_base_path" |
| 62 | local base_path="my/custom/path2" |
| 63 | |
| 64 | diag "Test base path override for remote trace snapshot (URI on create)" |
| 65 | create_lttng_session_uri $session_name net://localhost/$base_path \ |
| 66 | --snapshot |
| 67 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 68 | |
| 69 | start_lttng_tracing_ok $session_name |
| 70 | |
| 71 | $TESTAPP_BIN > /dev/null 2>&1 |
| 72 | |
| 73 | stop_lttng_tracing_ok $session_name |
| 74 | |
| 75 | lttng_snapshot_record $session_name |
| 76 | |
| 77 | destroy_lttng_session_ok $session_name |
| 78 | |
| 79 | # validate test |
| 80 | if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then |
| 81 | # only delete if successful |
| 82 | rm -rf "$TRACE_PATH" |
| 83 | fi |
| 84 | } |
| 85 | |
| 86 | function ust_app_snapshot_base_path () |
| 87 | { |
| 88 | local session_name="ust_app_snapshot_base_path" |
| 89 | local base_path="my/custom/path3" |
| 90 | |
| 91 | diag "Test base path override for remote trace snapshot (URI on snapshot)" |
| 92 | create_lttng_session_no_output $session_name --snapshot |
| 93 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 94 | |
| 95 | start_lttng_tracing_ok $session_name |
| 96 | |
| 97 | $TESTAPP_BIN > /dev/null 2>&1 |
| 98 | |
| 99 | stop_lttng_tracing_ok $session_name |
| 100 | |
| 101 | lttng_snapshot_record $session_name net://localhost/$base_path |
| 102 | |
| 103 | destroy_lttng_session_ok $session_name |
| 104 | |
| 105 | # validate test |
| 106 | if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then |
| 107 | # only delete if successful |
| 108 | rm -rf "$TRACE_PATH" |
| 109 | fi |
| 110 | } |
| 111 | |
| 112 | function ust_app_snapshot_add_output_base_path () |
| 113 | { |
| 114 | local session_name="ust_app_snapshot_add_output_base_path" |
| 115 | local base_path="my/custom/path4" |
| 116 | |
| 117 | diag "Test base path override for remote trace snapshot (URI on add-output)" |
| 118 | create_lttng_session_no_output $session_name --snapshot |
| 119 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 120 | |
| 121 | start_lttng_tracing_ok $session_name |
| 122 | |
| 123 | $TESTAPP_BIN > /dev/null 2>&1 |
| 124 | |
| 125 | stop_lttng_tracing_ok $session_name |
| 126 | |
| 127 | lttng_snapshot_add_output_ok $session_name net://localhost/$base_path |
| 128 | lttng_snapshot_record $session_name |
| 129 | |
| 130 | destroy_lttng_session_ok $session_name |
| 131 | |
| 132 | # validate test |
| 133 | if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then |
| 134 | # only delete if successful |
| 135 | rm -rf "$TRACE_PATH" |
| 136 | fi |
| 137 | } |
| 138 | |
| 139 | function ust_app_stream_base_path_via_load () |
| 140 | { |
| 141 | local session_name="load-stream-extra-path" |
| 142 | local base_path="my/custom/path5" |
| 143 | |
| 144 | diag "Test base path override for trace streaming using lttng load" |
| 145 | lttng_load_ok "-i $CURDIR/$session_name.lttng" |
| 146 | start_lttng_tracing_ok $session_name |
| 147 | |
| 148 | $TESTAPP_BIN > /dev/null 2>&1 |
| 149 | |
| 150 | stop_lttng_tracing_ok $session_name |
| 151 | destroy_lttng_session_ok $session_name |
| 152 | |
| 153 | # validate test |
| 154 | if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then |
| 155 | # only delete if successful |
| 156 | rm -rf "$TRACE_PATH" |
| 157 | fi |
| 158 | } |
| 159 | |
| 160 | plan_tests $NUM_TESTS |
| 161 | |
| 162 | print_test_banner "$TEST_DESC" |
| 163 | |
| 164 | start_lttng_relayd "-o $TRACE_PATH" |
| 165 | start_lttng_sessiond |
| 166 | |
| 167 | tests=( ust_app_stream_base_path |
| 168 | ust_app_snapshot_create_base_path |
| 169 | ust_app_snapshot_base_path |
| 170 | ust_app_snapshot_add_output_base_path |
| 171 | ust_app_stream_base_path_via_load |
| 172 | ) |
| 173 | for fct_test in "${tests[@]}"; |
| 174 | do |
| 175 | ${fct_test} |
| 176 | done |
| 177 | |
| 178 | stop_lttng_sessiond |
| 179 | stop_lttng_relayd |