Remove part of last name to fit in a 80 character line
[lttng-tools.git] / tests / regression / tools / notification / test_notification_kernel
CommitLineData
854382b8
JR
1#!/bin/bash
2#
4942c256 3# Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
854382b8 4#
9d16b343 5# SPDX-License-Identifier: LGPL-2.1-only
854382b8
JR
6
7CURDIR=$(dirname $0)/
8TESTDIR=$CURDIR/../../../
9
345ed219
JR
10TMPDIR=$(mktemp -d)
11
854382b8 12#This is needed since the testpoint create a pipe with the consumerd type suffixed
345ed219 13TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
854382b8 14TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
854382b8
JR
15TESTPOINT=$(readlink -f ${CURDIR}/.libs/libpause_consumer.so)
16
17
18TESTAPP_PATH="$TESTDIR/utils/testapp"
19TESTAPP_NAME="gen-ust-events"
20TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
345ed219 21TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
854382b8
JR
22
23NR_ITER=-1
24NR_USEC_WAIT=5
25
26SESSION_NAME="my_session"
27CHANNEL_NAME="my_channel"
28
29TRACE_PATH=$(mktemp -d)
30PAGE_SIZE=$(getconf PAGE_SIZE)
31
32DIR=$(readlink -f $TESTDIR)
33NUM_TESTS=104
34
35source $TESTDIR/utils/utils.sh
36
cb723729 37function kernel_event_generator_toggle_state
854382b8
JR
38{
39 kernel_event_generator_suspended=$((kernel_event_generator_suspended==0))
40
41}
42function kernel_event_generator
43{
44 state_file=$1
45 kernel_event_generator_suspended=0
cb723729 46 trap kernel_event_generator_toggle_state SIGUSR1
3be453c9 47
854382b8
JR
48 while (true); do
49 if [[ $kernel_event_generator_suspended -eq "1" ]]; then
50 touch $state_file
51 sleep 0.5
52 else
53 if [[ -f $state_file ]]; then
54 rm $state_file 2> /dev/null
55 fi
56 echo -n "1000" > /proc/lttng-test-filter-event 2> /dev/null
57 fi
58 done
59}
60
61function kernel_test
62{
63 local consumerd_pipe=()
64 local event_name="lttng_test_filter_event"
65
66 modprobe lttng-test
67
68 LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
69 start_lttng_sessiond_notap
70
71 create_lttng_session_notap $SESSION_NAME $TRACE_PATH
72
73 lttng_enable_kernel_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
74 enable_kernel_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
75
76 #This is needed since the testpoint create a pipe with the consumer type suffixed
77 for f in "$TESTPOINT_BASE_PATH"*; do
78 consumerd_pipe+=("$f")
79 done
80
81 kernel_event_generator $TESTAPP_STATE_PATH &
82 APP_PID=$!
83
84 $CURDIR/notification LTTNG_DOMAIN_KERNEL $SESSION_NAME $CHANNEL_NAME $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
85
86 destroy_lttng_session_notap $SESSION_NAME
87 stop_lttng_sessiond_notap
88
89 kill -9 $APP_PID
90 wait $APP_PID 2> /dev/null
91
92
93 rmmod lttng-test
94
345ed219 95 rm -rf ${consumerd_pipe[@]} 2> /dev/null
854382b8
JR
96}
97
98if [ "$(id -u)" == "0" ]; then
5da3fc85 99 validate_lttng_modules_present
854382b8
JR
100 kernel_test
101else
102 # Kernel tests are skipped.
103 plan_tests $NUM_TESTS
104 skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
105fi
106
107# Just in case cleanup
108rm -rf $TRACE_PATH
345ed219 109rm -rf $TMPDIR
This page took 0.040569 seconds and 5 git commands to generate.