3 # Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 # This library is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation; version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 TEST_DESC
="UST - Blocking mode"
21 TESTDIR
=$CURDIR/..
/..
/..
22 SESSION_NAME
="blocking"
24 TESTAPP_PATH
="$TESTDIR/utils/testapp"
25 TESTAPP_NAME
="gen-ust-events"
26 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27 EVENT_NAME
="tp:tptest"
31 source $TESTDIR/utils
/utils.sh
33 # MUST set TESTDIR before calling those functions
34 # Run app on CPU 0 to ensure we only write in a single ring buffer.
37 taskset
0x00000001 $TESTAPP_BIN $NUM_EVENT
38 ok $?
"Application done"
41 function test_ust_implicit_no_blocking
()
44 diag
"UST implicit non-blocking mode (default): will hang if fails"
46 # Test without the plugin
48 create_lttng_session_no_output
$SESSION_NAME
49 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
50 start_lttng_tracing_ok
$SESSION_NAME
52 stop_lttng_tracing_ok
$SESSION_NAME
53 destroy_lttng_session_ok
$SESSION_NAME
59 function test_ust_explicit_no_blocking
()
62 diag
"UST explicit non-blocking mode: will hang if fails"
64 # Test without the plugin
66 create_lttng_session_no_output
$SESSION_NAME
67 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
68 start_lttng_tracing_ok
$SESSION_NAME
69 LTTNG_UST_BLOCKING_RETRY_TIMEOUT
=0 run_app
70 stop_lttng_tracing_ok
$SESSION_NAME
71 destroy_lttng_session_ok
$SESSION_NAME
77 function test_ust_timeout_no_blocking
()
80 diag
"UST 1ms timeout retry mode: will hang if fails"
83 create_lttng_session_no_output
$SESSION_NAME
84 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
85 start_lttng_tracing_ok
$SESSION_NAME
87 LTTNG_UST_BLOCKING_RETRY_TIMEOUT
=1 run_app
88 stop_lttng_tracing_ok
$SESSION_NAME
89 destroy_lttng_session_ok
$SESSION_NAME
95 function test_ust_snapshot_no_blocking
()
98 diag
"UST blocking mode: don't block in snapshot mode"
100 # Test without the plugin
102 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
103 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
104 start_lttng_tracing_ok
$SESSION_NAME
105 LTTNG_UST_BLOCKING_RETRY_TIMEOUT
=-1 run_app
106 stop_lttng_tracing_ok
$SESSION_NAME
107 destroy_lttng_session_ok
$SESSION_NAME
113 function test_ust_blocking_no_discard
()
116 diag
"UST blocking mode: no event discarded"
118 # Test without the plugin
120 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
121 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
122 start_lttng_tracing_ok
$SESSION_NAME
123 # infinite retry timeout
124 LTTNG_UST_BLOCKING_RETRY_TIMEOUT
=-1 run_app
125 stop_lttng_tracing_ok
$SESSION_NAME
126 destroy_lttng_session_ok
$SESSION_NAME
129 nr_events
=$
(babeltrace
$TRACE_PATH 2>/dev
/null |
wc -l)
131 test $nr_events -eq $NUM_EVENT
132 ok $?
"No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
135 plan_tests
$NUM_TESTS
137 print_test_banner
"$TEST_DESC"
140 "test_ust_implicit_no_blocking"
141 "test_ust_explicit_no_blocking"
142 "test_ust_timeout_no_blocking"
143 "test_ust_snapshot_no_blocking"
144 "test_ust_blocking_no_discard"
147 TEST_COUNT
=${#TESTS[@]}
150 while [ "$i" -lt "$TEST_COUNT" ]; do
152 TRACE_PATH
=$
(mktemp
-d)