| 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 | NR_ITER=5 |
| 22 | NR_USEC_WAIT=0 |
| 23 | TESTAPP_PATH="$TESTDIR/utils/testapp" |
| 24 | TESTAPP_NAME="gen-ust-events" |
| 25 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" |
| 26 | EVENT_NAME="tp:tptest" |
| 27 | |
| 28 | TRACE_PATH=$(mktemp -d) |
| 29 | |
| 30 | NUM_TESTS=32 |
| 31 | |
| 32 | source $TESTDIR/utils/utils.sh |
| 33 | |
| 34 | if [ ! -x "$TESTAPP_BIN" ]; then |
| 35 | BAIL_OUT "No UST events binary detected." |
| 36 | fi |
| 37 | |
| 38 | function ust_app_stream_base_path () |
| 39 | { |
| 40 | local session_name=$(randstring 16 0) |
| 41 | local base_path="my/custom/path1" |
| 42 | |
| 43 | diag "Test base path override for trace streaming" |
| 44 | create_lttng_session_uri $session_name net://localhost/$base_path |
| 45 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 46 | |
| 47 | start_lttng_tracing_ok $session_name |
| 48 | |
| 49 | $TESTAPP_BIN > /dev/null 2>&1 |
| 50 | |
| 51 | stop_lttng_tracing_ok $session_name |
| 52 | destroy_lttng_session_ok $session_name |
| 53 | |
| 54 | # validate test |
| 55 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path |
| 56 | if [ $? -eq 0 ]; then |
| 57 | # only delete if successful |
| 58 | rm -rf $TRACE_PATH |
| 59 | fi |
| 60 | } |
| 61 | |
| 62 | function ust_app_snapshot_create_base_path () |
| 63 | { |
| 64 | local session_name=$(randstring 16 0) |
| 65 | local base_path="my/custom/path2" |
| 66 | |
| 67 | diag "Test base path override for remote trace snapshot (URI on create)" |
| 68 | create_lttng_session_uri $session_name net://localhost/$base_path \ |
| 69 | --snapshot |
| 70 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 71 | |
| 72 | start_lttng_tracing_ok $session_name |
| 73 | |
| 74 | $TESTAPP_BIN > /dev/null 2>&1 |
| 75 | |
| 76 | stop_lttng_tracing_ok $session_name |
| 77 | |
| 78 | lttng_snapshot_record $session_name |
| 79 | |
| 80 | destroy_lttng_session_ok $session_name |
| 81 | |
| 82 | # validate test |
| 83 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path |
| 84 | if [ $? -eq 0 ]; then |
| 85 | # only delete if successful |
| 86 | rm -rf $TRACE_PATH |
| 87 | fi |
| 88 | } |
| 89 | |
| 90 | function ust_app_snapshot_base_path () |
| 91 | { |
| 92 | local session_name=$(randstring 16 0) |
| 93 | local base_path="my/custom/path3" |
| 94 | |
| 95 | diag "Test base path override for remote trace snapshot (URI on snapshot)" |
| 96 | create_lttng_session_no_output $session_name --snapshot |
| 97 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 98 | |
| 99 | start_lttng_tracing_ok $session_name |
| 100 | |
| 101 | $TESTAPP_BIN > /dev/null 2>&1 |
| 102 | |
| 103 | stop_lttng_tracing_ok $session_name |
| 104 | |
| 105 | lttng_snapshot_record $session_name net://localhost/$base_path |
| 106 | |
| 107 | destroy_lttng_session_ok $session_name |
| 108 | |
| 109 | # validate test |
| 110 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path |
| 111 | if [ $? -eq 0 ]; then |
| 112 | # only delete if successful |
| 113 | rm -rf $TRACE_PATH |
| 114 | fi |
| 115 | } |
| 116 | |
| 117 | function ust_app_snapshot_add_output_base_path () |
| 118 | { |
| 119 | local session_name=$(randstring 16 0) |
| 120 | local base_path="my/custom/path3" |
| 121 | |
| 122 | diag "Test base path override for remote trace snapshot (URI on add-output)" |
| 123 | create_lttng_session_no_output $session_name --snapshot |
| 124 | enable_ust_lttng_event_ok $session_name $EVENT_NAME |
| 125 | |
| 126 | start_lttng_tracing_ok $session_name |
| 127 | |
| 128 | $TESTAPP_BIN > /dev/null 2>&1 |
| 129 | |
| 130 | stop_lttng_tracing_ok $session_name |
| 131 | |
| 132 | lttng_snapshot_add_output_ok $session_name net://localhost/$base_path |
| 133 | lttng_snapshot_record $session_name |
| 134 | |
| 135 | destroy_lttng_session_ok $session_name |
| 136 | |
| 137 | # validate test |
| 138 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path |
| 139 | if [ $? -eq 0 ]; then |
| 140 | # only delete if successful |
| 141 | rm -rf $TRACE_PATH |
| 142 | fi |
| 143 | } |
| 144 | |
| 145 | plan_tests $NUM_TESTS |
| 146 | |
| 147 | print_test_banner "$TEST_DESC" |
| 148 | |
| 149 | start_lttng_relayd "-o $TRACE_PATH" |
| 150 | start_lttng_sessiond |
| 151 | |
| 152 | tests=( ust_app_stream_base_path |
| 153 | ust_app_snapshot_create_base_path |
| 154 | ust_app_snapshot_base_path |
| 155 | ust_app_snapshot_add_output_base_path ) |
| 156 | for fct_test in ${tests[@]}; |
| 157 | do |
| 158 | ${fct_test} |
| 159 | done |
| 160 | |
| 161 | stop_lttng_sessiond |
| 162 | stop_lttng_relayd |