3 # Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 # SPDX-License-Identifier: LGPL-2.1-only
8 TEST_DESC
="UST - Blocking mode"
11 TESTDIR
=$CURDIR/..
/..
/..
12 SESSION_NAME
="blocking"
13 CHANNEL_NAME
="testchan"
15 TESTAPP_PATH
="$TESTDIR/utils/testapp"
16 TESTAPP_NAME
="gen-ust-events"
17 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
18 EVENT_NAME
="tp:tptest"
22 # shellcheck source=../utils/utils.sh
23 source "$TESTDIR/utils/utils.sh"
25 # MUST set TESTDIR before calling those functions
26 # Run app on a single CPU to ensure we only write in a single ring buffer.
29 taskset
--cpu-list "$(get_any_available_cpu)" $TESTAPP_BIN -i $NUM_EVENT
30 ok $?
"Application done"
33 function test_ust_implicit_no_blocking
()
36 diag
"UST implicit non-blocking mode (default): will hang if fails"
39 # session in no-output mode
40 create_lttng_session_no_output
$SESSION_NAME
41 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME"
42 start_lttng_tracing_ok
$SESSION_NAME
44 stop_lttng_tracing_ok
$SESSION_NAME
45 destroy_lttng_session_ok
$SESSION_NAME
51 function test_ust_implicit_no_blocking_with_channel_blocking
()
54 diag
"UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
57 # session in no-output mode
58 create_lttng_session_no_output
$SESSION_NAME
59 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
60 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
61 start_lttng_tracing_ok
$SESSION_NAME
63 stop_lttng_tracing_ok
$SESSION_NAME
64 destroy_lttng_session_ok
$SESSION_NAME
70 function test_ust_timeout_no_blocking
()
73 diag
"UST 1ms timeout blocking mode: will hang if fails"
76 # session in no-output mode
77 create_lttng_session_no_output
$SESSION_NAME
78 # blocking timeout 1ms
79 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
80 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
81 start_lttng_tracing_ok
$SESSION_NAME
82 LTTNG_UST_ALLOW_BLOCKING
=1 run_app
83 stop_lttng_tracing_ok
$SESSION_NAME
84 destroy_lttng_session_ok
$SESSION_NAME
90 function test_ust_snapshot_no_blocking
()
93 diag
"UST blocking mode: don't block in snapshot mode"
95 # Test without the plugin
97 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH --snapshot
98 # blocking timeout 1ms
99 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
100 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
101 start_lttng_tracing_ok
$SESSION_NAME
102 LTTNG_UST_ALLOW_BLOCKING
=1 run_app
103 stop_lttng_tracing_ok
$SESSION_NAME
104 destroy_lttng_session_ok
$SESSION_NAME
110 function test_ust_blocking_no_discard
()
113 diag
"UST blocking mode: no event discarded"
115 # Test without the plugin
117 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
118 # infinite blocking timeout
119 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
120 enable_ust_lttng_event_ok
$SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
121 start_lttng_tracing_ok
$SESSION_NAME
122 LTTNG_UST_ALLOW_BLOCKING
=1 run_app
123 stop_lttng_tracing_ok
$SESSION_NAME
124 destroy_lttng_session_ok
$SESSION_NAME
127 nr_events
=$
("$BABELTRACE_BIN" $TRACE_PATH 2>/dev
/null |
wc -l)
129 test $nr_events -eq $NUM_EVENT
130 ok $?
"No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
133 plan_tests
$NUM_TESTS
135 print_test_banner
"$TEST_DESC"
137 bail_out_if_no_babeltrace
140 "test_ust_implicit_no_blocking"
141 "test_ust_implicit_no_blocking_with_channel_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 -t tmp.test_blocking_ust_trace_path.XXXXXX
)