Refactor: test: wrapper for destroy_lttng_session
[lttng-tools.git] / tests / regression / tools / live / test_lttng_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"
26DELAY_USEC=2000000
27
28SESSION_NAME="live"
29EVENT_NAME="sched_switch"
30
31TRACE_PATH=$(mktemp -d)
32
33DIR=$(readlink -f $TESTDIR)
34
35NUM_TESTS=10
36
37source $TESTDIR/utils/utils.sh
38
39# MUST set TESTDIR before calling those functions
40plan_tests $NUM_TESTS
41
42print_test_banner "$TEST_DESC"
43
44function setup_live_tracing()
45{
46 # Create session with default path
47 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \
48 -U net://localhost >/dev/null 2>&1
49 ok $? "Create session in live mode with delay $DELAY_USEC"
50
51 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
e563bbdb 52 start_lttng_tracing_ok $SESSION_NAME
1b368955
JD
53}
54
55function clean_live_tracing()
56{
96340a01 57 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 58 destroy_lttng_session_ok $SESSION_NAME
1b368955
JD
59}
60
61# Need root access for kernel tracing.
62if [ "$(id -u)" == "0" ]; then
63 isroot=1
64else
65 isroot=0
66fi
67
68skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
69{
70 start_lttng_sessiond
71 start_lttng_relayd "-o $TRACE_PATH"
72
73 setup_live_tracing
74
75 # Just hit some events
76 sleep 2
77
78 clean_live_tracing
79
80 validate_trace $EVENT_NAME $TRACE_PATH
81 rm -rf $TRACE_PATH
82
83 stop_lttng_relayd
84 stop_lttng_sessiond
85}
This page took 0.031935 seconds and 5 git commands to generate.