Gen-ust-events: use options instead of arguments
[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 # 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.
9 #
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
13 # details.
14 #
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"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 SESSION_NAME="blocking"
23 CHANNEL_NAME="testchan"
24
25 TESTAPP_PATH="$TESTDIR/utils/testapp"
26 TESTAPP_NAME="gen-ust-events"
27 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
28 EVENT_NAME="tp:tptest"
29
30 NUM_TESTS=49
31
32 source $TESTDIR/utils/utils.sh
33
34 # MUST set TESTDIR before calling those functions
35 # Run app on CPU 0 to ensure we only write in a single ring buffer.
36 function run_app()
37 {
38 taskset 0x00000001 $TESTAPP_BIN -i $NUM_EVENT
39 ok $? "Application done"
40 }
41
42 function test_ust_implicit_no_blocking()
43 {
44 NUM_EVENT=5000000
45 diag "UST implicit non-blocking mode (default): will hang if fails"
46
47 start_lttng_sessiond
48 # session in no-output mode
49 create_lttng_session_no_output $SESSION_NAME
50 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
51 start_lttng_tracing_ok $SESSION_NAME
52 run_app
53 stop_lttng_tracing_ok $SESSION_NAME
54 destroy_lttng_session_ok $SESSION_NAME
55 stop_lttng_sessiond
56
57 ok 0 "Does not hang"
58 }
59
60 function test_ust_implicit_no_blocking_with_channel_blocking()
61 {
62 NUM_EVENT=5000000
63 diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
64
65 start_lttng_sessiond
66 # session in no-output mode
67 create_lttng_session_no_output $SESSION_NAME
68 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
69 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
70 start_lttng_tracing_ok $SESSION_NAME
71 run_app
72 stop_lttng_tracing_ok $SESSION_NAME
73 destroy_lttng_session_ok $SESSION_NAME
74 stop_lttng_sessiond
75
76 ok 0 "Does not hang"
77 }
78
79 function test_ust_timeout_no_blocking()
80 {
81 NUM_EVENT=12500
82 diag "UST 1ms timeout blocking mode: will hang if fails"
83
84 start_lttng_sessiond
85 # session in no-output mode
86 create_lttng_session_no_output $SESSION_NAME
87 # blocking timeout 1ms
88 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
89 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
90 start_lttng_tracing_ok $SESSION_NAME
91 LTTNG_UST_ALLOW_BLOCKING=1 run_app
92 stop_lttng_tracing_ok $SESSION_NAME
93 destroy_lttng_session_ok $SESSION_NAME
94 stop_lttng_sessiond
95
96 ok 0 "Does not hang"
97 }
98
99 function test_ust_snapshot_no_blocking()
100 {
101 NUM_EVENT=5000000
102 diag "UST blocking mode: don't block in snapshot mode"
103
104 # Test without the plugin
105 start_lttng_sessiond
106 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
107 # blocking timeout 1ms
108 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
109 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
110 start_lttng_tracing_ok $SESSION_NAME
111 LTTNG_UST_ALLOW_BLOCKING=1 run_app
112 stop_lttng_tracing_ok $SESSION_NAME
113 destroy_lttng_session_ok $SESSION_NAME
114 stop_lttng_sessiond
115
116 ok 0 "Does not hang"
117 }
118
119 function test_ust_blocking_no_discard()
120 {
121 NUM_EVENT=5000000
122 diag "UST blocking mode: no event discarded"
123
124 # Test without the plugin
125 start_lttng_sessiond
126 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
127 # infinite blocking timeout
128 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
129 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
130 start_lttng_tracing_ok $SESSION_NAME
131 LTTNG_UST_ALLOW_BLOCKING=1 run_app
132 stop_lttng_tracing_ok $SESSION_NAME
133 destroy_lttng_session_ok $SESSION_NAME
134 stop_lttng_sessiond
135
136 nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
137
138 test $nr_events -eq $NUM_EVENT
139 ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
140 }
141
142 plan_tests $NUM_TESTS
143
144 print_test_banner "$TEST_DESC"
145
146 TESTS=(
147 "test_ust_implicit_no_blocking"
148 "test_ust_implicit_no_blocking_with_channel_blocking"
149 "test_ust_timeout_no_blocking"
150 "test_ust_snapshot_no_blocking"
151 "test_ust_blocking_no_discard"
152 )
153
154 TEST_COUNT=${#TESTS[@]}
155 i=0
156
157 while [ "$i" -lt "$TEST_COUNT" ]; do
158
159 TRACE_PATH=$(mktemp -d)
160
161 # Execute test
162 ${TESTS[$i]}
163
164 rm -rf $TRACE_PATH
165
166 let "i++"
167 done
This page took 0.049206 seconds and 5 git commands to generate.