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