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