Gen-ust-events: use options instead of arguments
[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 21EVENT_NAME="sched_switch"
f4e40ab6
DG
22SESSION_NAME=""
23
173af62f
DG
24TRACE_PATH=$(mktemp -d)
25
7972aab2 26NUM_TESTS=10
d346ccad 27
9ac429ef 28source $TESTDIR/utils/utils.sh
f4e40ab6 29
f4e40ab6
DG
30function test_kernel_before_start ()
31{
d346ccad 32 diag "Test kernel streaming with event enable BEFORE start"
f0d43d3d 33 create_lttng_session_uri $SESSION_NAME net://localhost
f4e40ab6 34 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
e563bbdb 35 start_lttng_tracing_ok $SESSION_NAME
f4e40ab6
DG
36 # Give a second
37 sleep 1
96340a01 38 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 39 destroy_lttng_session_ok $SESSION_NAME
f4e40ab6
DG
40}
41
173af62f
DG
42# Deactivated since this feature is not yet available where we can enable
43# an event AFTERE tracing has started.
f4e40ab6
DG
44function test_kernel_after_start ()
45{
d346ccad 46 diag "Test kernel streaming with event enable AFTER start"
f0d43d3d 47 create_lttng_session_uri $SESSION_NAME net://localhost
e563bbdb 48 start_lttng_tracing_ok $SESSION_NAME
f4e40ab6
DG
49 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
50 # Give a second
51 sleep 1
96340a01 52 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 53 destroy_lttng_session_ok $SESSION_NAME
f4e40ab6
DG
54}
55
d346ccad 56plan_tests $NUM_TESTS
f4e40ab6 57
e3bef725
CB
58print_test_banner "$TEST_DESC"
59
d346ccad
CB
60if [ "$(id -u)" == "0" ]; then
61 isroot=1
62else
63 isroot=0
64fi
f4e40ab6 65
d346ccad
CB
66skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
67{
9c8a3964
JR
68 validate_lttng_modules_present
69
d346ccad 70 start_lttng_relayd "-o $TRACE_PATH"
7972aab2 71 start_lttng_sessiond
d346ccad
CB
72
73 tests=( test_kernel_before_start )
74
75 for fct_test in ${tests[@]};
76 do
77 SESSION_NAME=$(randstring 16 0)
78 ${fct_test}
79
80 # Validate test
81 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
82 if [ $? -eq 0 ]; then
83 # Only delete if successful
84 rm -rf $TRACE_PATH
85 else
86 break
87 fi
88 done
f4e40ab6 89
d346ccad
CB
90 stop_lttng_sessiond
91 stop_lttng_relayd
92}
This page took 0.056087 seconds and 5 git commands to generate.