Commit | Line | Data |
---|---|---|
eae79fb9 MD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com> | |
4 | # Copyright (C) - 2014, 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify it | |
7 | # under the terms of the GNU General Public License, version 2 only, as | |
8 | # published by the Free Software Foundation. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | # more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License along with | |
16 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
17 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | ||
19 | TEST_DESC="Kernel tracer - Rotation destroy flush" | |
20 | ||
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../.. | |
23 | SESSION_NAME="rotation_destroy_flush" | |
24 | ||
25 | NR_ITER=10 | |
26 | NUM_TESTS=$((13*$NR_ITER)) | |
27 | EVENT_NAME="lttng_test_filter_event" | |
28 | CHANNEL_NAME="testchan" | |
29 | PAGE_SIZE=$(getconf PAGE_SIZE) | |
30 | SIZE_LIMIT=$PAGE_SIZE | |
31 | ||
32 | TESTCMD="echo -n 10000 > /proc/lttng-test-filter-event" | |
33 | ||
34 | # Ensure the daemons invoke abort on error. | |
35 | export LTTNG_ABORT_ON_ERROR=1 | |
36 | ||
37 | source $TESTDIR/utils/utils.sh | |
38 | ||
39 | function signal_cleanup() | |
40 | { | |
41 | diag "*** Exiting ***" | |
3be453c9 MD |
42 | modprobe -r lttng-test |
43 | full_cleanup | |
eae79fb9 MD |
44 | } |
45 | ||
46 | function enable_kernel_lttng_channel_size_limit () | |
47 | { | |
48 | sess_name="$1" | |
49 | channel_name="$2" | |
50 | tracefile_size_limit="$3" | |
51 | ||
52 | test_name="Enable channel $channel_name " | |
53 | test_name+="for session $sess_name: " | |
54 | test_name+="$tracefile_size_limit bytes tracefile limit" | |
55 | ||
56 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \ | |
57 | -k $channel_name -s $sess_name \ | |
58 | -C $tracefile_size_limit >/dev/null 2>&1 | |
59 | ||
60 | ok $? "$test_name" | |
61 | } | |
62 | ||
63 | function enable_kernel_lttng_event_per_channel () | |
64 | { | |
65 | sess_name="$1" | |
66 | event_name="$2" | |
67 | channel_name="$3" | |
68 | ||
69 | test_name="Enable event $event_name " | |
70 | test_name+="for session $sess_name " | |
71 | test_name+="in channel $channel_name" | |
72 | ||
73 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \ | |
74 | -s $sess_name -k -c $channel_name >/dev/null 2>&1 | |
75 | ||
76 | ok $? "$test_name" | |
77 | } | |
78 | ||
79 | function test_rotation_destroy_flush_single() | |
80 | { | |
81 | start_lttng_sessiond | |
82 | modprobe lttng-test | |
83 | ||
84 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
85 | enable_kernel_lttng_channel_size_limit \ | |
86 | $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT | |
87 | enable_kernel_lttng_event_per_channel \ | |
88 | $SESSION_NAME $EVENT_NAME $CHANNEL_NAME | |
89 | start_lttng_tracing_ok $SESSION_NAME | |
90 | eval ${TESTCMD} | |
91 | # stop and destroy | |
92 | stop_lttng_tracing_ok $SESSION_NAME | |
93 | destroy_lttng_session_ok $SESSION_NAME | |
94 | ||
95 | rm -rf $TRACE_PATH | |
96 | ||
97 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
98 | enable_kernel_lttng_channel_size_limit \ | |
99 | $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT | |
100 | enable_kernel_lttng_event_per_channel \ | |
101 | $SESSION_NAME $EVENT_NAME $CHANNEL_NAME | |
102 | start_lttng_tracing_ok $SESSION_NAME | |
103 | eval ${TESTCMD} | |
104 | # destroy only | |
105 | destroy_lttng_session_ok $SESSION_NAME | |
106 | ||
107 | rm -rf $TRACE_PATH | |
108 | ||
3be453c9 | 109 | modprobe -r lttng-test |
eae79fb9 MD |
110 | stop_lttng_sessiond |
111 | } | |
112 | ||
113 | function test_rotation_destroy_flush() | |
114 | { | |
115 | for a in $(seq 1 ${NR_ITER}); do | |
116 | diag "Iteration ${a}/${NR_ITER}" | |
117 | test_rotation_destroy_flush_single | |
118 | done | |
119 | } | |
120 | ||
121 | # MUST set TESTDIR before calling those functions | |
122 | plan_tests $NUM_TESTS | |
123 | ||
124 | print_test_banner "$TEST_DESC" | |
125 | ||
126 | TESTS=( | |
127 | "test_rotation_destroy_flush" | |
128 | ) | |
129 | ||
130 | TEST_COUNT=${#TESTS[@]} | |
131 | i=0 | |
132 | ||
133 | if [ "$(id -u)" == "0" ]; then | |
134 | isroot=1 | |
135 | else | |
136 | isroot=0 | |
137 | fi | |
138 | ||
139 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
140 | { | |
141 | trap signal_cleanup SIGTERM SIGINT | |
142 | ||
143 | while [ "$i" -lt "$TEST_COUNT" ]; do | |
144 | ||
145 | TRACE_PATH=$(mktemp -d) | |
146 | ||
147 | # Execute test | |
148 | ${TESTS[$i]} | |
149 | ||
150 | let "i++" | |
151 | done | |
152 | } |