Tests: missing license header in rotation utils
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_kernel
CommitLineData
801236b0
JD
1#!/bin/bash
2#
3# Copyright (C) - 2015 Julien Desfossez <jdesfossez@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
17TEST_DESC="Streaming - Kernel tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21EVENT_NAME="lttng_test_filter_event"
22PID_RELAYD=0
23SESSION_NAME=""
24
25TRACE_PATH=$(mktemp -d)
26
27NUM_TESTS=18
28
29source $TESTDIR/utils/utils.sh
30
31# LTTng kernel modules check
32out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
33if [ -z "$out" ]; then
34 BAIL_OUT "LTTng modules not detected."
35fi
36
37function lttng_create_session_uri
38{
39 # Create session with default path
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
41
42 ok $? "Create session $SESSION_NAME"
43}
44
45function test_kernel_streaming ()
46{
47 diag "Test kernel streaming with metadata regeneration"
48 lttng_create_session_uri
49 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
50 start_lttng_tracing_ok $SESSION_NAME
51 echo -n "100" > /proc/lttng-test-filter-event
eded6438 52 regenerate_metadata_ok $SESSION_NAME
801236b0
JD
53 stop_lttng_tracing_ok $SESSION_NAME
54 # Validate test
55 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
56 if [ $? -eq 0 ]; then
57 # Only delete if successful
58 rm -rf $TRACE_PATH
59 else
60 break
61 fi
62 destroy_lttng_session_ok $SESSION_NAME
63}
64
65function test_kernel_local ()
66{
67 diag "Test kernel local with metadata regeneration"
68 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
69 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
70 start_lttng_tracing_ok $SESSION_NAME
71 echo -n "100" > /proc/lttng-test-filter-event
eded6438 72 regenerate_metadata_ok $SESSION_NAME
801236b0
JD
73 stop_lttng_tracing_ok $SESSION_NAME
74 validate_trace $EVENT_NAME $TRACE_PATH
75 if [ $? -eq 0 ]; then
76 # Only delete if successful
77 rm -rf $TRACE_PATH
78 fi
79 destroy_lttng_session_ok $SESSION_NAME
80}
81
82plan_tests $NUM_TESTS
83
84print_test_banner "$TEST_DESC"
85
86if [ "$(id -u)" == "0" ]; then
87 isroot=1
88else
89 isroot=0
90fi
91
92skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
93{
94 start_lttng_relayd "-o $TRACE_PATH"
95 start_lttng_sessiond
96 modprobe lttng-test
97
98 tests=( test_kernel_streaming test_kernel_local )
99
100 for fct_test in ${tests[@]};
101 do
102 SESSION_NAME=$(randstring 16 0)
103 ${fct_test}
104 done
105
106 rmmod lttng-test
107 stop_lttng_sessiond
108 stop_lttng_relayd
109}
This page took 0.033749 seconds and 5 git commands to generate.