Commit | Line | Data |
---|---|---|
1b368955 JD |
1 | #!/bin/bash |
2 | # | |
9d16b343 MJ |
3 | # Copyright (C) 2013 Julien Desfossez <julien.desfossez@efficios.com> |
4 | # Copyright (C) 2013 David Goulet <dgoulet@efficios.com> | |
1b368955 | 5 | # |
9d16b343 | 6 | # SPDX-License-Identifier: LGPL-2.1-only |
1b368955 JD |
7 | |
8 | TEST_DESC="Live - Kernel space tracing" | |
9 | ||
10 | CURDIR=$(dirname $0)/ | |
11 | TESTDIR=$CURDIR/../../../ | |
1b368955 JD |
12 | DELAY_USEC=2000000 |
13 | ||
14 | SESSION_NAME="live" | |
bd37c3c5 | 15 | EVENT_NAME="lttng_test_filter_event" |
1b368955 | 16 | |
8d5a3312 | 17 | TRACE_PATH=$(mktemp -d -t tmp.test_lttng_live_kernel_trace_path.XXXXXX) |
1b368955 JD |
18 | |
19 | DIR=$(readlink -f $TESTDIR) | |
20 | ||
bd666153 | 21 | NUM_TESTS=11 |
1b368955 JD |
22 | |
23 | source $TESTDIR/utils/utils.sh | |
24 | ||
25 | # MUST set TESTDIR before calling those functions | |
26 | plan_tests $NUM_TESTS | |
27 | ||
28 | print_test_banner "$TEST_DESC" | |
29 | ||
30 | function setup_live_tracing() | |
31 | { | |
32 | # Create session with default path | |
33 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \ | |
34 | -U net://localhost >/dev/null 2>&1 | |
35 | ok $? "Create session in live mode with delay $DELAY_USEC" | |
36 | ||
37 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
e563bbdb | 38 | start_lttng_tracing_ok $SESSION_NAME |
1b368955 JD |
39 | } |
40 | ||
41 | function clean_live_tracing() | |
42 | { | |
96340a01 | 43 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 44 | destroy_lttng_session_ok $SESSION_NAME |
1b368955 JD |
45 | } |
46 | ||
47 | # Need root access for kernel tracing. | |
3a174400 | 48 | check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." || |
1b368955 | 49 | { |
bd37c3c5 FD |
50 | modprobe lttng-test |
51 | ||
1b368955 JD |
52 | start_lttng_sessiond |
53 | start_lttng_relayd "-o $TRACE_PATH" | |
54 | ||
55 | setup_live_tracing | |
56 | ||
bd37c3c5 | 57 | echo -n "1" > /proc/lttng-test-filter-event |
1b368955 JD |
58 | |
59 | clean_live_tracing | |
60 | ||
bd666153 | 61 | validate_trace_path_kernel_network "$TRACE_PATH" "$SESSION_NAME" |
1b368955 JD |
62 | validate_trace $EVENT_NAME $TRACE_PATH |
63 | rm -rf $TRACE_PATH | |
64 | ||
65 | stop_lttng_relayd | |
66 | stop_lttng_sessiond | |
bd37c3c5 FD |
67 | |
68 | modprobe --remove lttng-test | |
1b368955 | 69 | } |