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" | |
23 | ||
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" | |
28 | ||
29 | NUM_TESTS=45 | |
30 | ||
31 | source $TESTDIR/utils/utils.sh | |
32 | ||
33 | # MUST set TESTDIR before calling those functions | |
34 | # Run app on CPU 0 to ensure we only write in a single ring buffer. | |
35 | function run_app() | |
36 | { | |
37 | taskset 0x00000001 $TESTAPP_BIN $NUM_EVENT | |
38 | ok $? "Application done" | |
39 | } | |
40 | ||
41 | function test_ust_implicit_no_blocking() | |
42 | { | |
43 | NUM_EVENT=500000 | |
44 | diag "UST implicit non-blocking mode (default): will hang if fails" | |
45 | ||
46 | # Test without the plugin | |
47 | start_lttng_sessiond | |
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 | |
51 | run_app | |
52 | stop_lttng_tracing_ok $SESSION_NAME | |
53 | destroy_lttng_session_ok $SESSION_NAME | |
54 | stop_lttng_sessiond | |
55 | ||
56 | ok 0 "Does not hang" | |
57 | } | |
58 | ||
59 | function test_ust_explicit_no_blocking() | |
60 | { | |
61 | NUM_EVENT=500000 | |
62 | diag "UST explicit non-blocking mode: will hang if fails" | |
63 | ||
64 | # Test without the plugin | |
65 | start_lttng_sessiond | |
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 | |
72 | stop_lttng_sessiond | |
73 | ||
74 | ok 0 "Does not hang" | |
75 | } | |
76 | ||
77 | function test_ust_timeout_no_blocking() | |
78 | { | |
79 | NUM_EVENT=12500 | |
80 | diag "UST 1ms timeout retry mode: will hang if fails" | |
81 | ||
82 | start_lttng_sessiond | |
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 | |
86 | # retry timeout 1ms | |
87 | LTTNG_UST_BLOCKING_RETRY_TIMEOUT=1 run_app | |
88 | stop_lttng_tracing_ok $SESSION_NAME | |
89 | destroy_lttng_session_ok $SESSION_NAME | |
90 | stop_lttng_sessiond | |
91 | ||
92 | ok 0 "Does not hang" | |
93 | } | |
94 | ||
95 | function test_ust_snapshot_no_blocking() | |
96 | { | |
97 | NUM_EVENT=500000 | |
98 | diag "UST blocking mode: don't block in snapshot mode" | |
99 | ||
100 | # Test without the plugin | |
101 | start_lttng_sessiond | |
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 | |
108 | stop_lttng_sessiond | |
109 | ||
110 | ok 0 "Does not hang" | |
111 | } | |
112 | ||
113 | function test_ust_blocking_no_discard() | |
114 | { | |
115 | NUM_EVENT=500000 | |
116 | diag "UST blocking mode: no event discarded" | |
117 | ||
118 | # Test without the plugin | |
119 | start_lttng_sessiond | |
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 | |
127 | stop_lttng_sessiond | |
128 | ||
129 | nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) | |
130 | ||
131 | test $nr_events -eq $NUM_EVENT | |
132 | ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT" | |
133 | } | |
134 | ||
135 | plan_tests $NUM_TESTS | |
136 | ||
137 | print_test_banner "$TEST_DESC" | |
138 | ||
139 | TESTS=( | |
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" | |
145 | ) | |
146 | ||
147 | TEST_COUNT=${#TESTS[@]} | |
148 | i=0 | |
149 | ||
150 | while [ "$i" -lt "$TEST_COUNT" ]; do | |
151 | ||
152 | TRACE_PATH=$(mktemp -d) | |
153 | ||
154 | # Execute test | |
155 | ${TESTS[$i]} | |
156 | ||
157 | rm -rf $TRACE_PATH | |
158 | ||
159 | let "i++" | |
160 | done |