Commit | Line | Data |
---|---|---|
1b368955 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Julien Desfossez <julien.desfossez@efficios.com> | |
4 | # David Goulet <dgoulet@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 | ||
19 | TEST_DESC="Live - User space tracing" | |
20 | ||
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../../../ | |
23 | SESSIOND_BIN="lttng-sessiond" | |
24 | RELAYD_BIN="lttng-relayd" | |
25 | LTTNG_BIN="lttng" | |
26 | BABELTRACE_BIN="babeltrace" | |
27 | NR_ITER=1 | |
28 | NR_USEC_WAIT=1 | |
29 | DELAY_USEC=2000000 | |
30 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
31 | TESTAPP_NAME="gen-ust-events" | |
32 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
33 | ||
34 | SESSION_NAME="live" | |
35 | EVENT_NAME="tp:tptest" | |
36 | ||
37 | TRACE_PATH=$(mktemp -d) | |
38 | ||
39 | DIR=$(readlink -f $TESTDIR) | |
40 | ||
41 | source $TESTDIR/utils/utils.sh | |
42 | ||
43 | echo "$TEST_DESC" | |
44 | ||
45 | function setup_live_tracing() | |
46 | { | |
47 | # Create session with default path | |
48 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \ | |
49 | -U net://localhost >/dev/null 2>&1 | |
50 | ||
51 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$EVENT_NAME" -s $SESSION_NAME -u >/dev/null 2>&1 | |
52 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $SESSION_NAME >/dev/null 2>&1 | |
53 | } | |
54 | ||
55 | function clean_live_tracing() | |
56 | { | |
57 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $SESSION_NAME >/dev/null 2>&1 | |
58 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $SESSION_NAME >/dev/null 2>&1 | |
59 | rm -rf $TRACE_PATH | |
60 | } | |
61 | ||
62 | if [ -z $(pidof lt-$SESSIOND_BIN) ]; then | |
63 | $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" | |
64 | if [ $? -eq 1 ]; then | |
65 | echo "Fail to start lttng-sessiond" | |
66 | exit 1 | |
67 | fi | |
68 | # Wait for sessiond to bootstrap | |
69 | sleep 2 | |
70 | fi | |
71 | ||
72 | opt="-o $TRACE_PATH" | |
73 | if [ -z $(pidof lt-$RELAYD_BIN) ]; then | |
74 | $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 & | |
75 | if [ $? -eq 1 ]; then | |
76 | echo "Fail to start lttng-relayd (opt: $opt)" | |
77 | return 1 | |
78 | fi | |
79 | fi | |
80 | ||
81 | setup_live_tracing | |
82 | ||
83 | # Run app in background | |
84 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 & | |
85 | # Wait for app to complete | |
86 | while [ -n "$(pidof $TESTAPP_NAME)" ]; do | |
87 | sleep 0.5 | |
88 | done | |
89 | ||
90 | # Start the live test | |
91 | $TESTDIR/regression/tools/live/live_test | |
92 | ||
93 | clean_live_tracing | |
94 | ||
95 | # Kill the relayd | |
96 | PID_RELAYD=`pidof lt-$RELAYD_BIN` | |
97 | kill $PID_RELAYD >/dev/null 2>&1 | |
98 | if [ $? -eq 1 ]; then | |
99 | echo "Kill lttng-relayd (pid: $PID_RELAYD)" | |
100 | exit 1 | |
101 | else | |
102 | out=1 | |
103 | while [ -n "$out" ]; do | |
104 | out=$(pidof lt-$RELAYD_BIN) | |
105 | sleep 0.5 | |
106 | done | |
107 | fi | |
108 | ||
109 | # Kill the sessiond | |
110 | PID_SESSIOND=`pidof lt-$SESSIOND_BIN` | |
111 | kill $PID_SESSIOND >/dev/null 2>&1 | |
112 | if [ $? -eq 1 ]; then | |
113 | echo "Kill sessiond daemon" | |
114 | exit 1 | |
115 | else | |
116 | out=1 | |
117 | while [ -n "$out" ]; do | |
118 | out=$(pidof lt-$SESSIOND_BIN) | |
119 | sleep 0.5 | |
120 | done | |
121 | fi |