277807faa1ec4187b3dbd48333bc0c8b924b3c78
[lttng-tools.git] / tests / tools / streaming / run-ust
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
17 TEST_DESC="Streaming - User space tracing"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../..
21 BIN_NAME="gen-ust-events"
22 SESSION_NAME="stream"
23 EVENT_NAME="tp:tptest"
24 PID_RELAYD=0
25
26 TRACE_PATH=$(mktemp -d)
27
28 source $TESTDIR/utils.sh
29
30 print_test_banner "$TEST_DESC"
31
32 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
33 echo -e "No UST nevents binary detected. Passing."
34 exit 0
35 fi
36
37 function 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
43 function lttng_enable_consumer
44 {
45 # Create session with default path
46 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u net://localhost >/dev/null 2>&1
47 }
48
49 function 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
61 function 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
71 start_lttng_tracing $SESSION_NAME
72
73 wait_apps
74 stop_lttng_tracing $SESSION_NAME
75 destroy_lttng_session $SESSION_NAME
76 }
77
78 function 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
84 start_lttng_tracing $SESSION_NAME
85
86 # Run 5 times with a 1 second delay
87 ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
88
89 wait_apps
90 stop_lttng_tracing $SESSION_NAME
91 destroy_lttng_session $SESSION_NAME
92 }
93
94 start_lttng_sessiond
95 start_lttng_relayd "-o $TRACE_PATH"
96
97 tests=( test_ust_before_start test_ust_after_start )
98
99 for fct_test in ${tests[@]};
100 do
101 SESSION_NAME=$(randstring 16 0)
102 ${fct_test}
103
104 # Validate test
105 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
106 if [ $? -eq 0 ]; then
107 # Only delete if successful
108 rm -rf $TRACE_PATH
109 else
110 break
111 fi
112 done
113
114 echo ""
115 stop_lttng_sessiond
116 stop_lttng_relayd
117
118 exit $out
This page took 0.031354 seconds and 3 git commands to generate.