Tests: use modprobe to test for the presence of lttng-modules
[lttng-tools.git] / tests / regression / tools / streaming / test_kernel
CommitLineData
f4e40ab6
DG
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
c38b5107 17TEST_DESC="Streaming - Kernel tracing"
f4e40ab6
DG
18
19CURDIR=$(dirname $0)/
9ac429ef 20TESTDIR=$CURDIR/../../..
f4e40ab6
DG
21EVENT_NAME="sched_switch"
22PID_RELAYD=0
23SESSION_NAME=""
24
173af62f
DG
25TRACE_PATH=$(mktemp -d)
26
7972aab2 27NUM_TESTS=10
d346ccad 28
9ac429ef 29source $TESTDIR/utils/utils.sh
f4e40ab6 30
785d2d0d 31function lttng_create_session_uri
f4e40ab6 32{
f4e40ab6 33 # Create session with default path
785d2d0d 34 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
d346ccad
CB
35
36 ok $? "Create session $SESSION_NAME"
f4e40ab6
DG
37}
38
39function test_kernel_before_start ()
40{
d346ccad 41 diag "Test kernel streaming with event enable BEFORE start"
785d2d0d 42 lttng_create_session_uri
f4e40ab6 43 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
e563bbdb 44 start_lttng_tracing_ok $SESSION_NAME
f4e40ab6
DG
45 # Give a second
46 sleep 1
96340a01 47 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 48 destroy_lttng_session_ok $SESSION_NAME
f4e40ab6
DG
49}
50
173af62f
DG
51# Deactivated since this feature is not yet available where we can enable
52# an event AFTERE tracing has started.
f4e40ab6
DG
53function test_kernel_after_start ()
54{
d346ccad 55 diag "Test kernel streaming with event enable AFTER start"
785d2d0d 56 lttng_create_session_uri
e563bbdb 57 start_lttng_tracing_ok $SESSION_NAME
f4e40ab6
DG
58 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
59 # Give a second
60 sleep 1
96340a01 61 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 62 destroy_lttng_session_ok $SESSION_NAME
f4e40ab6
DG
63}
64
d346ccad 65plan_tests $NUM_TESTS
f4e40ab6 66
e3bef725
CB
67print_test_banner "$TEST_DESC"
68
d346ccad
CB
69if [ "$(id -u)" == "0" ]; then
70 isroot=1
71else
72 isroot=0
73fi
f4e40ab6 74
d346ccad
CB
75skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
76{
9c8a3964
JR
77 validate_lttng_modules_present
78
d346ccad 79 start_lttng_relayd "-o $TRACE_PATH"
7972aab2 80 start_lttng_sessiond
d346ccad
CB
81
82 tests=( test_kernel_before_start )
83
84 for fct_test in ${tests[@]};
85 do
86 SESSION_NAME=$(randstring 16 0)
87 ${fct_test}
88
89 # Validate test
90 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
91 if [ $? -eq 0 ]; then
92 # Only delete if successful
93 rm -rf $TRACE_PATH
94 else
95 break
96 fi
97 done
f4e40ab6 98
d346ccad
CB
99 stop_lttng_sessiond
100 stop_lttng_relayd
101}
This page took 0.040071 seconds and 4 git commands to generate.