Tests: PID_RELAYD is never used
[lttng-tools.git] / tests / regression / tools / snapshots / test_kernel_streaming
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
17 TEST_DESC="Streaming - Snapshot Kernel tracing"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 EVENT_NAME="sched_switch"
22 SESSION_NAME=""
23 CHANNEL_NAME="chan1"
24
25 TRACE_PATH=$(mktemp -d)
26
27 NUM_TESTS=36
28
29 source $TESTDIR/utils/utils.sh
30
31 function 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.
47 function 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
53 start_lttng_tracing_ok $SESSION_NAME
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
63 lttng_snapshot_del_output_ok $SESSION_NAME 1
64 snapshot_add_output $SESSION_NAME "net://localhost"
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
73 stop_lttng_tracing_ok $SESSION_NAME
74 destroy_lttng_session_ok $SESSION_NAME
75
76 return 0
77 }
78
79 # Test a snapshot using a default name for the output destination.
80 function 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
86 start_lttng_tracing_ok $SESSION_NAME
87 snapshot_add_output $SESSION_NAME "net://localhost"
88 lttng_snapshot_record $SESSION_NAME
89 stop_lttng_tracing_ok $SESSION_NAME
90 destroy_lttng_session_ok $SESSION_NAME
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.
99 function 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
108 start_lttng_tracing_ok $SESSION_NAME
109 snapshot_add_output $SESSION_NAME "net://localhost" $name
110 lttng_snapshot_record $SESSION_NAME
111 stop_lttng_tracing_ok $SESSION_NAME
112 destroy_lttng_session_ok $SESSION_NAME
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
127 plan_tests $NUM_TESTS
128
129 print_test_banner "$TEST_DESC"
130
131 if [ "$(id -u)" == "0" ]; then
132 isroot=1
133 else
134 isroot=0
135 fi
136
137 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
138 {
139 validate_lttng_modules_present
140
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
153 rm -rf $TRACE_PATH
154 else
155 break
156 fi
157 done
158
159 stop_lttng_sessiond
160 stop_lttng_relayd
161 }
This page took 0.035685 seconds and 4 git commands to generate.