Fix all -Wmissing-declarations warning instances
[lttng-tools.git] / tests / regression / ust / blocking / test_blocking
CommitLineData
de7e372e
MD
1#!/bin/bash
2#
9d16b343
MJ
3# Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4# Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
de7e372e 5#
9d16b343
MJ
6# SPDX-License-Identifier: LGPL-2.1-only
7
de7e372e
MD
8TEST_DESC="UST - Blocking mode"
9
10CURDIR=$(dirname $0)/
11TESTDIR=$CURDIR/../../..
12SESSION_NAME="blocking"
491d1539 13CHANNEL_NAME="testchan"
de7e372e
MD
14
15TESTAPP_PATH="$TESTDIR/utils/testapp"
16TESTAPP_NAME="gen-ust-events"
17TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
18EVENT_NAME="tp:tptest"
19
491d1539 20NUM_TESTS=49
de7e372e
MD
21
22source $TESTDIR/utils/utils.sh
23
24# MUST set TESTDIR before calling those functions
25# Run app on CPU 0 to ensure we only write in a single ring buffer.
26function run_app()
27{
6c4a91d6 28 taskset 0x00000001 $TESTAPP_BIN -i $NUM_EVENT
de7e372e
MD
29 ok $? "Application done"
30}
31
32function test_ust_implicit_no_blocking()
33{
491d1539 34 NUM_EVENT=5000000
de7e372e
MD
35 diag "UST implicit non-blocking mode (default): will hang if fails"
36
de7e372e 37 start_lttng_sessiond
491d1539 38 # session in no-output mode
de7e372e
MD
39 create_lttng_session_no_output $SESSION_NAME
40 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
41 start_lttng_tracing_ok $SESSION_NAME
42 run_app
43 stop_lttng_tracing_ok $SESSION_NAME
44 destroy_lttng_session_ok $SESSION_NAME
45 stop_lttng_sessiond
46
47 ok 0 "Does not hang"
48}
49
491d1539 50function test_ust_implicit_no_blocking_with_channel_blocking()
de7e372e 51{
491d1539 52 NUM_EVENT=5000000
63dd9b28 53 diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
de7e372e 54
de7e372e 55 start_lttng_sessiond
491d1539 56 # session in no-output mode
de7e372e 57 create_lttng_session_no_output $SESSION_NAME
63dd9b28 58 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
491d1539 59 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
de7e372e 60 start_lttng_tracing_ok $SESSION_NAME
491d1539 61 run_app
de7e372e
MD
62 stop_lttng_tracing_ok $SESSION_NAME
63 destroy_lttng_session_ok $SESSION_NAME
64 stop_lttng_sessiond
65
66 ok 0 "Does not hang"
67}
68
69function test_ust_timeout_no_blocking()
70{
71 NUM_EVENT=12500
491d1539 72 diag "UST 1ms timeout blocking mode: will hang if fails"
de7e372e
MD
73
74 start_lttng_sessiond
491d1539 75 # session in no-output mode
de7e372e 76 create_lttng_session_no_output $SESSION_NAME
491d1539
MD
77 # blocking timeout 1ms
78 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
79 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
de7e372e 80 start_lttng_tracing_ok $SESSION_NAME
491d1539 81 LTTNG_UST_ALLOW_BLOCKING=1 run_app
de7e372e
MD
82 stop_lttng_tracing_ok $SESSION_NAME
83 destroy_lttng_session_ok $SESSION_NAME
84 stop_lttng_sessiond
85
86 ok 0 "Does not hang"
87}
88
89function test_ust_snapshot_no_blocking()
90{
491d1539 91 NUM_EVENT=5000000
de7e372e
MD
92 diag "UST blocking mode: don't block in snapshot mode"
93
94 # Test without the plugin
95 start_lttng_sessiond
96 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
491d1539
MD
97 # blocking timeout 1ms
98 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000"
99 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
de7e372e 100 start_lttng_tracing_ok $SESSION_NAME
491d1539 101 LTTNG_UST_ALLOW_BLOCKING=1 run_app
de7e372e
MD
102 stop_lttng_tracing_ok $SESSION_NAME
103 destroy_lttng_session_ok $SESSION_NAME
104 stop_lttng_sessiond
105
106 ok 0 "Does not hang"
107}
108
109function test_ust_blocking_no_discard()
110{
491d1539 111 NUM_EVENT=5000000
de7e372e
MD
112 diag "UST blocking mode: no event discarded"
113
114 # Test without the plugin
115 start_lttng_sessiond
116 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
491d1539 117 # infinite blocking timeout
63dd9b28 118 enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
491d1539 119 enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
de7e372e 120 start_lttng_tracing_ok $SESSION_NAME
491d1539 121 LTTNG_UST_ALLOW_BLOCKING=1 run_app
de7e372e
MD
122 stop_lttng_tracing_ok $SESSION_NAME
123 destroy_lttng_session_ok $SESSION_NAME
124 stop_lttng_sessiond
125
126 nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
127
128 test $nr_events -eq $NUM_EVENT
129 ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
130}
131
132plan_tests $NUM_TESTS
133
134print_test_banner "$TEST_DESC"
135
136TESTS=(
137 "test_ust_implicit_no_blocking"
491d1539 138 "test_ust_implicit_no_blocking_with_channel_blocking"
de7e372e
MD
139 "test_ust_timeout_no_blocking"
140 "test_ust_snapshot_no_blocking"
141 "test_ust_blocking_no_discard"
142)
143
144TEST_COUNT=${#TESTS[@]}
145i=0
146
147while [ "$i" -lt "$TEST_COUNT" ]; do
148
149 TRACE_PATH=$(mktemp -d)
150
151 # Execute test
152 ${TESTS[$i]}
153
154 rm -rf $TRACE_PATH
155
156 let "i++"
157done
This page took 0.034638 seconds and 4 git commands to generate.