Fix: sessiond: bad fd used while rotating exiting app's buffers
[lttng-tools.git] / tests / regression / ust / blocking / test_blocking
1 #!/bin/bash
2 #
3 # Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 #
6 # SPDX-License-Identifier: LGPL-2.1-only
7
8 TEST_DESC="UST - Blocking mode"
9
10 CURDIR=$(dirname $0)/
11 TESTDIR=$CURDIR/../../..
12 SESSION_NAME="blocking"
13 CHANNEL_NAME="testchan"
14
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"
19
20 NUM_TESTS=49
21
22 # shellcheck source=../utils/utils.sh
23 source "$TESTDIR/utils/utils.sh"
24
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.
27 function run_app()
28 {
29 taskset --cpu-list "$(get_any_available_cpu)" $TESTAPP_BIN -i $NUM_EVENT
30 ok $? "Application done"
31 }
32
33 function test_ust_implicit_no_blocking()
34 {
35 NUM_EVENT=5000000
36 diag "UST implicit non-blocking mode (default): will hang if fails"
37
38 start_lttng_sessiond
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
43 run_app
44 stop_lttng_tracing_ok $SESSION_NAME
45 destroy_lttng_session_ok $SESSION_NAME
46 stop_lttng_sessiond
47
48 ok 0 "Does not hang"
49 }
50
51 function test_ust_implicit_no_blocking_with_channel_blocking()
52 {
53 NUM_EVENT=5000000
54 diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
55
56 start_lttng_sessiond
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
62 run_app
63 stop_lttng_tracing_ok $SESSION_NAME
64 destroy_lttng_session_ok $SESSION_NAME
65 stop_lttng_sessiond
66
67 ok 0 "Does not hang"
68 }
69
70 function test_ust_timeout_no_blocking()
71 {
72 NUM_EVENT=12500
73 diag "UST 1ms timeout blocking mode: will hang if fails"
74
75 start_lttng_sessiond
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
85 stop_lttng_sessiond
86
87 ok 0 "Does not hang"
88 }
89
90 function test_ust_snapshot_no_blocking()
91 {
92 NUM_EVENT=5000000
93 diag "UST blocking mode: don't block in snapshot mode"
94
95 # Test without the plugin
96 start_lttng_sessiond
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
105 stop_lttng_sessiond
106
107 ok 0 "Does not hang"
108 }
109
110 function test_ust_blocking_no_discard()
111 {
112 NUM_EVENT=5000000
113 diag "UST blocking mode: no event discarded"
114
115 # Test without the plugin
116 start_lttng_sessiond
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
125 stop_lttng_sessiond
126
127 nr_events=$("$BABELTRACE_BIN" $TRACE_PATH 2>/dev/null | wc -l)
128
129 test $nr_events -eq $NUM_EVENT
130 ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
131 }
132
133 plan_tests $NUM_TESTS
134
135 print_test_banner "$TEST_DESC"
136
137 bail_out_if_no_babeltrace
138
139 TESTS=(
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"
145 )
146
147 TEST_COUNT=${#TESTS[@]}
148 i=0
149
150 while [ "$i" -lt "$TEST_COUNT" ]; do
151
152 TRACE_PATH=$(mktemp -d -t tmp.test_blocking_ust_trace_path.XXXXXX)
153
154 # Execute test
155 ${TESTS[$i]}
156
157 rm -rf $TRACE_PATH
158
159 let "i++"
160 done
This page took 0.044845 seconds and 4 git commands to generate.