Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_kernel
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
17 TEST_DESC="Streaming - Kernel tracing"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 EVENT_NAME="lttng_test_filter_event"
22 SESSION_NAME=""
23
24 TRACE_PATH=$(mktemp -d)
25
26 NUM_TESTS=18
27
28 source $TESTDIR/utils/utils.sh
29
30 function test_kernel_streaming ()
31 {
32 diag "Test kernel streaming with metadata regeneration"
33 create_lttng_session_uri $SESSION_NAME net://localhost
34 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
35 start_lttng_tracing_ok $SESSION_NAME
36 echo -n "100" > /proc/lttng-test-filter-event
37 regenerate_metadata_ok $SESSION_NAME
38 stop_lttng_tracing_ok $SESSION_NAME
39 # Validate test
40 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
41 if [ $? -eq 0 ]; then
42 # Only delete if successful
43 rm -rf $TRACE_PATH
44 else
45 break
46 fi
47 destroy_lttng_session_ok $SESSION_NAME
48 }
49
50 function test_kernel_local ()
51 {
52 diag "Test kernel local with metadata regeneration"
53 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
54 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
55 start_lttng_tracing_ok $SESSION_NAME
56 echo -n "100" > /proc/lttng-test-filter-event
57 regenerate_metadata_ok $SESSION_NAME
58 stop_lttng_tracing_ok $SESSION_NAME
59 validate_trace $EVENT_NAME $TRACE_PATH
60 if [ $? -eq 0 ]; then
61 # Only delete if successful
62 rm -rf $TRACE_PATH
63 fi
64 destroy_lttng_session_ok $SESSION_NAME
65 }
66
67 plan_tests $NUM_TESTS
68
69 print_test_banner "$TEST_DESC"
70
71 if [ "$(id -u)" == "0" ]; then
72 isroot=1
73 else
74 isroot=0
75 fi
76
77 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
78 {
79 validate_lttng_modules_present
80
81 start_lttng_relayd "-o $TRACE_PATH"
82 start_lttng_sessiond
83 modprobe lttng-test
84
85 tests=( test_kernel_streaming test_kernel_local )
86
87 for fct_test in ${tests[@]};
88 do
89 SESSION_NAME=$(randstring 16 0)
90 ${fct_test}
91 done
92
93 rmmod lttng-test
94 stop_lttng_sessiond
95 stop_lttng_relayd
96 }
This page took 0.0318 seconds and 5 git commands to generate.