Fix: Add arbitrary wait period for kernel streaming test
[lttng-tools.git] / tests / tools / streaming / run-ust
CommitLineData
f4e40ab6
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c38b5107 17TEST_DESC="Streaming - User space tracing"
f4e40ab6
DG
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../..
21BIN_NAME="gen-ust-events"
22SESSION_NAME="stream"
23EVENT_NAME="tp:tptest"
24PID_RELAYD=0
25
f02e1e8a
DG
26TRACE_PATH=$(mktemp -d)
27
f4e40ab6
DG
28source $TESTDIR/utils.sh
29
c38b5107 30print_test_banner "$TEST_DESC"
f4e40ab6
DG
31
32if [ ! -x "$CURDIR/$BIN_NAME" ]; then
33 echo -e "No UST nevents binary detected. Passing."
34 exit 0
35fi
36
37function lttng_create_session
38{
39 # Create session with default path
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
41}
42
43function lttng_enable_consumer
44{
45 # Create session with default path
2c46f0d2 46 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u net://localhost >/dev/null 2>&1
f4e40ab6
DG
47}
48
49function wait_apps
50{
51 echo -n "Waiting for applications to end"
52 while [ -n "$(pidof $BIN_NAME)" ]; do
53 echo -n "."
54 sleep 0.5
55 done
56 echo ""
57}
58
59# MUST set TESTDIR before calling those functions
60
61function test_ust_before_start ()
62{
63 echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
64 lttng_create_session
65 lttng_enable_consumer
66 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
67
68 # Run 5 times with a 1 second delay
69 ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
70
fb3268e3 71 start_lttng_tracing $SESSION_NAME
f4e40ab6
DG
72
73 wait_apps
fb3268e3 74 stop_lttng_tracing $SESSION_NAME
f4e40ab6
DG
75 destroy_lttng_session $SESSION_NAME
76}
77
78function test_ust_after_start ()
79{
80 echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
81 lttng_create_session
82 lttng_enable_consumer
83 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 84 start_lttng_tracing $SESSION_NAME
f4e40ab6
DG
85
86 # Run 5 times with a 1 second delay
87 ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
88
89 wait_apps
fb3268e3 90 stop_lttng_tracing $SESSION_NAME
f4e40ab6
DG
91 destroy_lttng_session $SESSION_NAME
92}
93
fb3268e3
CB
94start_lttng_sessiond
95start_lttng_relayd "-o $TRACE_PATH"
f4e40ab6
DG
96
97tests=( test_ust_before_start test_ust_after_start )
98
99for fct_test in ${tests[@]};
100do
101 SESSION_NAME=$(randstring 16 0)
102 ${fct_test}
103
104 # Validate test
f02e1e8a 105 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
f4e40ab6
DG
106 if [ $? -eq 0 ]; then
107 # Only delete if successful
f02e1e8a 108 rm -rf $TRACE_PATH
f4e40ab6
DG
109 else
110 break
111 fi
112done
113
114echo ""
fb3268e3
CB
115stop_lttng_sessiond
116stop_lttng_relayd
f4e40ab6
DG
117
118exit $out
This page took 0.032104 seconds and 4 git commands to generate.