Tests: PID_RELAYD is never used
[lttng-tools.git] / tests / regression / tools / snapshots / test_kernel_streaming
CommitLineData
26402e0c
DG
1#!/bin/bash
2#
3# Copyright (C) - 2013 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
17TEST_DESC="Streaming - Snapshot Kernel tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21EVENT_NAME="sched_switch"
26402e0c
DG
22SESSION_NAME=""
23CHANNEL_NAME="chan1"
24
25TRACE_PATH=$(mktemp -d)
26
25d6f007 27NUM_TESTS=36
26402e0c
DG
28
29source $TESTDIR/utils/utils.sh
30
26402e0c
DG
31function snapshot_add_output ()
32{
33 local sess_name=$1
34 local trace_path=$2
35 local name=$3
36 local extra_opt=""
37
38 if [ ! -z $name ]; then
39 extra_opt="-n $name"
40 fi
41
42 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name $extra_opt $trace_path >/dev/null 2>&1
43 ok $? "Added snapshot output $trace_path"
44}
45
46# Test a snapshot using a default name for the output destination.
47function test_kernel_default_name_with_del()
48{
49 diag "Test kernel snapshot streaming with default name with delete output"
50 create_lttng_session_no_output $SESSION_NAME
51 enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
52 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
e563bbdb 53 start_lttng_tracing_ok $SESSION_NAME
26402e0c
DG
54 snapshot_add_output $SESSION_NAME "net://localhost"
55 lttng_snapshot_record $SESSION_NAME
56
57 # Validate test
58 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
59 if [ $? -ne 0 ]; then
60 return $?
61 fi
62
31580dc7 63 lttng_snapshot_del_output_ok $SESSION_NAME 1
26402e0c 64 snapshot_add_output $SESSION_NAME "net://localhost"
26402e0c
DG
65 lttng_snapshot_record $SESSION_NAME
66
67 # Validate test with the next ID since a del output was done prior.
68 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2*
69 if [ $? -ne 0 ]; then
70 return $?
71 fi
72
96340a01 73 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 74 destroy_lttng_session_ok $SESSION_NAME
26402e0c
DG
75
76 return 0
77}
78
79# Test a snapshot using a default name for the output destination.
80function test_kernel_default_name()
81{
82 diag "Test kernel snapshot streaming with default name"
83 create_lttng_session_no_output $SESSION_NAME
84 enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
85 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
e563bbdb 86 start_lttng_tracing_ok $SESSION_NAME
26402e0c
DG
87 snapshot_add_output $SESSION_NAME "net://localhost"
88 lttng_snapshot_record $SESSION_NAME
96340a01 89 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 90 destroy_lttng_session_ok $SESSION_NAME
26402e0c
DG
91 # Validate test
92 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
93 out=$?
94
95 return $out
96}
97
98# Test a snapshot using a custom name for the output destination.
99function test_kernel_custom_name()
100{
101 local out
102 local name="asnapshotname"
103
104 diag "Test kernel snapshot streaming with custom name"
105 create_lttng_session_no_output $SESSION_NAME
106 enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
107 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
e563bbdb 108 start_lttng_tracing_ok $SESSION_NAME
26402e0c
DG
109 snapshot_add_output $SESSION_NAME "net://localhost" $name
110 lttng_snapshot_record $SESSION_NAME
96340a01 111 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 112 destroy_lttng_session_ok $SESSION_NAME
26402e0c
DG
113
114 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev/null; then
115 ok 0 "Custom name snapshot exists"
116 # Validate test
117 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
118 out=$?
119 else
120 fail "No custom name snapshot found"
121 out=1
122 fi
123
124 return $out
125}
126
127plan_tests $NUM_TESTS
128
129print_test_banner "$TEST_DESC"
130
131if [ "$(id -u)" == "0" ]; then
132 isroot=1
133else
134 isroot=0
135fi
136
137skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
138{
9c8a3964
JR
139 validate_lttng_modules_present
140
26402e0c
DG
141 start_lttng_relayd "-o $TRACE_PATH"
142 start_lttng_sessiond
143
144 tests=( test_kernel_default_name test_kernel_custom_name \
145 test_kernel_default_name_with_del )
146
147 for fct_test in ${tests[@]};
148 do
149 SESSION_NAME=$(randstring 16 0)
150 ${fct_test}
151 if [ $? -eq 0 ]; then
152 # Only delete if successful
25d6f007 153 rm -rf $TRACE_PATH
26402e0c
DG
154 else
155 break
156 fi
157 done
158
159 stop_lttng_sessiond
160 stop_lttng_relayd
161}
This page took 0.048265 seconds and 4 git commands to generate.