Commit | Line | Data |
---|---|---|
de7e372e MD |
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" | |
491d1539 | 23 | CHANNEL_NAME="testchan" |
de7e372e MD |
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 | ||
491d1539 | 30 | NUM_TESTS=49 |
de7e372e MD |
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 | { | |
6c4a91d6 | 38 | taskset 0x00000001 $TESTAPP_BIN -i $NUM_EVENT |
de7e372e MD |
39 | ok $? "Application done" |
40 | } | |
41 | ||
42 | function test_ust_implicit_no_blocking() | |
43 | { | |
491d1539 | 44 | NUM_EVENT=5000000 |
de7e372e MD |
45 | diag "UST implicit non-blocking mode (default): will hang if fails" |
46 | ||
de7e372e | 47 | start_lttng_sessiond |
491d1539 | 48 | # session in no-output mode |
de7e372e MD |
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 | ||
491d1539 | 60 | function test_ust_implicit_no_blocking_with_channel_blocking() |
de7e372e | 61 | { |
491d1539 | 62 | NUM_EVENT=5000000 |
63dd9b28 | 63 | diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails" |
de7e372e | 64 | |
de7e372e | 65 | start_lttng_sessiond |
491d1539 | 66 | # session in no-output mode |
de7e372e | 67 | create_lttng_session_no_output $SESSION_NAME |
63dd9b28 | 68 | enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf" |
491d1539 | 69 | enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME |
de7e372e | 70 | start_lttng_tracing_ok $SESSION_NAME |
491d1539 | 71 | run_app |
de7e372e MD |
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 | |
491d1539 | 82 | diag "UST 1ms timeout blocking mode: will hang if fails" |
de7e372e MD |
83 | |
84 | start_lttng_sessiond | |
491d1539 | 85 | # session in no-output mode |
de7e372e | 86 | create_lttng_session_no_output $SESSION_NAME |
491d1539 MD |
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 | |
de7e372e | 90 | start_lttng_tracing_ok $SESSION_NAME |
491d1539 | 91 | LTTNG_UST_ALLOW_BLOCKING=1 run_app |
de7e372e MD |
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 | { | |
491d1539 | 101 | NUM_EVENT=5000000 |
de7e372e MD |
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 | |
491d1539 MD |
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 | |
de7e372e | 110 | start_lttng_tracing_ok $SESSION_NAME |
491d1539 | 111 | LTTNG_UST_ALLOW_BLOCKING=1 run_app |
de7e372e MD |
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 | { | |
491d1539 | 121 | NUM_EVENT=5000000 |
de7e372e MD |
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 | |
491d1539 | 127 | # infinite blocking timeout |
63dd9b28 | 128 | enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf" |
491d1539 | 129 | enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME |
de7e372e | 130 | start_lttng_tracing_ok $SESSION_NAME |
491d1539 | 131 | LTTNG_UST_ALLOW_BLOCKING=1 run_app |
de7e372e MD |
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" | |
491d1539 | 148 | "test_ust_implicit_no_blocking_with_channel_blocking" |
de7e372e MD |
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 |