Live unit test
[lttng-tools.git] / tests / regression / tools / live / test_kernel
CommitLineData
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
19TEST_DESC="Live - Kernel space tracing"
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
30
31SESSION_NAME="live"
32EVENT_NAME="sched_switch"
33
34TRACE_PATH=$(mktemp -d)
35
36DIR=$(readlink -f $TESTDIR)
37
38source $TESTDIR/utils/utils.sh
39
40function setup_live_tracing()
41{
42 # Create session with default path
43 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \
44 -U net://localhost >/dev/null 2>&1
45
46 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$EVENT_NAME" -s $SESSION_NAME -k >/dev/null 2>&1
47 $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $SESSION_NAME >/dev/null 2>&1
48}
49
50function clean_live_tracing()
51{
52 $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $SESSION_NAME >/dev/null 2>&1
53 $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $SESSION_NAME >/dev/null 2>&1
54 rm -rf $TRACE_PATH
55}
56
57# Need root access for kernel tracing.
58if [ "$(id -u)" == "0" ]; then
59 isroot=1
60else
61 echo "Root access is needed. Skipping all tests."
62 exit 0
63fi
64
65if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
66 $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"
67 if [ $? -eq 1 ]; then
68 echo "Fail to start lttng-sessiond"
69 exit 1
70 fi
71 # Wait for sessiond to bootstrap
72 sleep 2
73fi
74
75opt="-o $TRACE_PATH"
76if [ -z $(pidof lt-$RELAYD_BIN) ]; then
77 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
78 if [ $? -eq 1 ]; then
79 echo "Fail to start lttng-relayd (opt: $opt)"
80 return 1
81 fi
82fi
83
84setup_live_tracing
85
86# Start the live test
87$TESTDIR/regression/tools/live/live_test
88
89clean_live_tracing
90
91# Kill the relayd
92PID_RELAYD=`pidof lt-$RELAYD_BIN`
93kill $PID_RELAYD >/dev/null 2>&1
94if [ $? -eq 1 ]; then
95 echo "Kill lttng-relayd (pid: $PID_RELAYD)"
96 exit 1
97else
98 out=1
99 while [ -n "$out" ]; do
100 out=$(pidof lt-$RELAYD_BIN)
101 sleep 0.5
102 done
103fi
104
105# Kill the sessiond
106PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
107kill $PID_SESSIOND >/dev/null 2>&1
108if [ $? -eq 1 ]; then
109 echo "Kill sessiond daemon"
110 exit 1
111else
112 out=1
113 while [ -n "$out" ]; do
114 out=$(pidof lt-$SESSIOND_BIN)
115 sleep 0.5
116 done
117fi
This page took 0.02877 seconds and 4 git commands to generate.