Fix concurrency issues while overwriting tracefiles in live
[lttng-tools.git] / tests / regression / tools / live / test_ust_tracefile_count
CommitLineData
cef0f7d5
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
19TEST_DESC="Live - User space tracing with tracefile_count"
20
21CURDIR=$(dirname $0)/
22TESTDIR=$CURDIR/../../../
23SESSIOND_BIN="lttng-sessiond"
24RELAYD_BIN="lttng-relayd"
25LTTNG_BIN="lttng"
26BABELTRACE_BIN="babeltrace"
27NR_ITER=1
28NR_USEC_WAIT=1
29DELAY_USEC=2000000
30TESTAPP_PATH="$TESTDIR/utils/testapp"
31TESTAPP_NAME="gen-ust-events"
32TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
33
34SESSION_NAME="live"
35EVENT_NAME="tp:tptest"
36
37TRACE_PATH=$(mktemp -d)
38
39DIR=$(readlink -f $TESTDIR)
40
41source $TESTDIR/utils/utils.sh
42
43echo "$TEST_DESC"
44
45function 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-channel --subbuf-size 16k -C 16k -W 10 -u chan1
52 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$EVENT_NAME" -s $SESSION_NAME -u -c chan1 >/dev/null 2>&1
53 $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $SESSION_NAME >/dev/null 2>&1
54}
55
56function clean_live_tracing()
57{
58 $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $SESSION_NAME >/dev/null 2>&1
59 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $SESSION_NAME >/dev/null 2>&1
60 rm -rf $TRACE_PATH
61}
62
63if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
64 $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"
65 if [ $? -eq 1 ]; then
66 echo "Fail to start lttng-sessiond"
67 exit 1
68 fi
69 # Wait for sessiond to bootstrap
70 sleep 2
71fi
72
73opt="-o $TRACE_PATH"
74if [ -z $(pidof lt-$RELAYD_BIN) ]; then
75 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
76 if [ $? -eq 1 ]; then
77 echo "Fail to start lttng-relayd (opt: $opt)"
78 return 1
79 fi
80fi
81
82setup_live_tracing
83
84# Run app in background
85$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
86# Wait for app to complete
87while [ -n "$(pidof $TESTAPP_NAME)" ]; do
88 sleep 0.5
89done
90
91# Start the live test
92$TESTDIR/regression/tools/live/live_test
93
94clean_live_tracing
95
96# Kill the relayd
97PID_RELAYD=`pidof lt-$RELAYD_BIN`
98kill $PID_RELAYD >/dev/null 2>&1
99if [ $? -eq 1 ]; then
100 echo "Kill lttng-relayd (pid: $PID_RELAYD)"
101 exit 1
102else
103 out=1
104 while [ -n "$out" ]; do
105 out=$(pidof lt-$RELAYD_BIN)
106 sleep 0.5
107 done
108fi
109
110# Kill the sessiond
111PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
112kill $PID_SESSIOND >/dev/null 2>&1
113if [ $? -eq 1 ]; then
114 echo "Kill sessiond daemon"
115 exit 1
116else
117 out=1
118 while [ -n "$out" ]; do
119 out=$(pidof lt-$SESSIOND_BIN)
120 sleep 0.5
121 done
122fi
This page took 0.029238 seconds and 5 git commands to generate.