if NO_SHARED
CLEANFILES = libpause_consumer.so libpause_consumer.so.debug
-EXTRA_DIST = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app base_client.c notification.c consumer_testpoints.c
+EXTRA_DIST = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app base_client.c notification.c consumer_testpoints.c util_event_generator.sh
else
rotation_SOURCES = rotation.c
rotation_LDADD = $(LIB_LTTNG_CTL) $(LIBTAP) -lm
-noinst_SCRIPTS = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app test_rotation
-EXTRA_DIST = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app test_rotation
+noinst_SCRIPTS = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app test_rotation util_event_generator.sh
+EXTRA_DIST = test_notification_ust_error test_notification_ust_buffer_usage test_notification_kernel_error test_notification_kernel_buffer_usage test_notification_multi_app test_rotation util_event_generator.sh
all-local:
# shellcheck source=../../../utils/utils.sh
source "$TESTDIR/utils/utils.sh"
-
-function kernel_event_generator_toggle_state
-{
- kernel_event_generator_suspended=$((kernel_event_generator_suspended==0))
-}
-
-function generate_filter_events
-{
- /bin/echo -n "10" > /proc/lttng-test-filter-event 2> /dev/null
-}
-
-function kernel_event_generator
-{
- command_to_run=$1
- state_file=$2
- kernel_event_generator_suspended=0
- trap kernel_event_generator_toggle_state SIGUSR1
-
- while (true); do
- if [[ $kernel_event_generator_suspended -eq "1" ]]; then
- touch $state_file
- sleep 0.5
- else
- if [[ -f $state_file ]]; then
- rm $state_file 2> /dev/null
- fi
- $command_to_run
- fi
- done
-}
+# shellcheck source=./util_event_generator.sh
+source "$CURDIR/util_event_generator.sh"
function test_buffer_usage_notification
{
destroy_lttng_session_notap $SESSION_NAME
- kill -9 $APP_PID
+ kill -SIGUSR2 $APP_PID
wait $APP_PID 2> /dev/null
}
NUM_TESTS=$(($NUM_TEST_UST + $NUM_TEST_KERNEL))
source $TESTDIR/utils/utils.sh
+source $CURDIR/util_event_generator.sh
consumerd_pipe=()
file_sync_after_first_event=$(mktemp -u)
app_pids=()
-function kernel_event_generator_toggle_state
-{
- kernel_event_generator_suspended=$((kernel_event_generator_suspended==0))
-
-}
-function kernel_event_generator
-{
- state_file=$1
- kernel_event_generator_suspended=0
- trap kernel_event_generator_toggle_state SIGUSR1
-
- while (true); do
- if [[ $kernel_event_generator_suspended -eq "1" ]]; then
- touch $state_file
- sleep 0.5
- else
- if [[ -f $state_file ]]; then
- rm $state_file 2> /dev/null
- fi
- echo -n "1000" > /proc/lttng-test-filter-event
- fi
- done
-}
-
-function ust_event_generator_toggle_state
-{
- ust_event_generator_suspended=$((ust_event_generator_suspended==0))
-
-}
-function ust_event_generator
-{
- state_file=$1
- ust_event_generator_suspended=0
- trap ust_event_generator_toggle_state SIGUSR1
- trap "exit" SIGTERM SIGINT
- while (true); do
- if [[ $ust_event_generator_suspended -eq "1" ]]; then
- touch $state_file
- sleep 0.5
- else
- if [[ -f $state_file ]]; then
- rm $state_file 2> /dev/null
- fi
- taskset -c 0 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
- fi
- done
-}
-
function start_client {
local pid=-1
local output_file=$1
function test_multi_app_ust ()
{
diag "Multi client app UST notification"
- ust_event_generator $TESTAPP_STATE_FILE &
+ ust_event_generator "$TESTAPP_BIN" "$TESTAPP_STATE_FILE" &
local generator_pid=$!
test_multi_app ust $generator_pid
- kill -s SIGTERM $generator_pid 2> /dev/null
+ kill -s SIGUSR2 $generator_pid 2> /dev/null
wait $generator_pid 2> /dev/null
rm -rf ${TESTAPP_STATE_FILE} 2> /dev/null
}
diag "Multi client app kernel notification"
modprobe lttng-test
- kernel_event_generator $TESTAPP_STATE_FILE &
+ kernel_event_generator generate_filter_events $TESTAPP_STATE_FILE &
local generator_pid=$!
test_multi_app kernel $generator_pid
- kill -s SIGTERM $generator_pid 2> /dev/null
+ kill -s SIGUSR2 $generator_pid 2> /dev/null
wait $generator_pid 2> /dev/null
rm -rf ${TESTAPP_STATE_FILE} 2> /dev/null
diag "On register notification UST"
# Start app in infinite loop
- ust_event_generator $TESTAPP_STATE_FILE &
+ ust_event_generator "$TESTAPP_BIN" "$TESTAPP_STATE_FILE" &
local generator_pid=$!
test_on_register_evaluation ust $generator_pid
- kill -s SIGTERM $generator_pid 2> /dev/null
+ kill -s SIGUSR2 $generator_pid 2> /dev/null
wait $generator_pid 2> /dev/null
rm -rf ${TESTAPP_STATE_FILE} 2> /dev/null
modprobe lttng-test
- kernel_event_generator $TESTAPP_STATE_FILE &
+ kernel_event_generator generate_filter_events $TESTAPP_STATE_FILE &
local generator_pid=$!
test_on_register_evaluation kernel $generator_pid
- kill -s SIGTERM $generator_pid 2> /dev/null
+ kill -s SIGUSR2 $generator_pid 2> /dev/null
wait $generator_pid 2> /dev/null
rm -rf ${TESTAPP_STATE_FILE} 2> /dev/null
destroy_lttng_session_ok $SESSION_NAME
stop_lttng_sessiond
- kill -s SIGTERM $generator_pid 2> /dev/null
+ kill -s SIGUSR2 $generator_pid 2> /dev/null
wait $generator_pid 2> /dev/null
for pipe in "${consumerd_pipe[@]}"; do
# shellcheck source=../../../utils/utils.sh
source "$TESTDIR/utils/utils.sh"
-
-function ust_event_generator_toggle_state
-{
- ust_event_generator_suspended=$((ust_event_generator_suspended==0))
-
-}
-function ust_event_generator
-{
- test_app=$1
- state_file=$2
- ust_event_generator_suspended=0
- trap ust_event_generator_toggle_state SIGUSR1
-
- while (true); do
- if [[ $ust_event_generator_suspended -eq "1" ]]; then
- touch $state_file
- sleep 0.5
- else
- if [[ -f $state_file ]]; then
- rm -rf $state_file 2> /dev/null
- fi
- taskset -c 0 $test_app -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
- fi
- done
-}
+# shellcheck source=./util_event_generator.sh
+source "$CURDIR/util_event_generator.sh"
function test_buffer_usage_notification
{
consumerd_pipe+=("$f")
done
- ust_event_generator $GEN_UST_EVENTS_TESTAPP_BIN $TESTAPP_STATE_PATH &
+ ust_event_generator "$GEN_UST_EVENTS_TESTAPP_BIN" "$TESTAPP_STATE_PATH" &
APP_PID=$!
"$CURDIR/notification" 2 LTTNG_DOMAIN_UST $SESSION_NAME $CHANNEL_NAME $APP_PID "$TESTAPP_STATE_PATH" "${consumerd_pipe[@]}"
# On ungraceful kill the app is cleaned up via the full_cleanup call
# Suppress kill message
- kill -9 $APP_PID
+ kill -SIGUSR2 $APP_PID
wait $APP_PID 2> /dev/null
# Just in case cleanup
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2020 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+GENERATOR_CURDIR=$(dirname "$0")/
+GENERATOR_TESTDIR=$GENERATOR_CURDIR/../../../
+TESTAPP_PATH=${TESTAPP_PATH:-"$GENERATOR_TESTDIR/utils/testapp"}
+
+SYSCALL_TESTAPP_NAME=${SYSCALL_TESTAPP_NAME:-"gen-syscall-events"}
+SYSCALL_TESTAPP_BIN=${SYSCALL_TESTAPP_BIN:-"$TESTAPP_PATH/$SYSCALL_TESTAPP_NAME/$SYSCALL_TESTAPP_NAME"}
+
+USERSPACE_PROBE_ELF_TESTAPP_NAME=${USERSPACE_PROBE_ELF_TESTAPP_NAME:-"userspace-probe-elf-binary"}
+USERSPACE_PROBE_ELF_TESTAPP_BIN=${USERSPACE_PROBE_ELF_TESTAPP_BIN:-"$TESTAPP_PATH/$USERSPACE_PROBE_ELF_TESTAPP_NAME/.libs/$USERSPACE_PROBE_ELF_TESTAPP_NAME"}
+
+function generate_filter_events
+{
+ local nr=$1
+ /bin/echo -n "$nr" > /proc/lttng-test-filter-event 2> /dev/null
+}
+
+function generate_syscalls
+{
+ local nr=$1
+ shift
+
+ for i in $(seq 1 "$nr"); do
+ # Pass /dev/null so to generate the syscall right away.
+ $SYSCALL_TESTAPP_BIN /dev/null "$@"
+ done
+}
+
+function userspace_probe_testapp
+{
+ local nr=$1
+ shift
+
+ for i in $(seq 1 "$nr"); do
+ $USERSPACE_PROBE_ELF_TESTAPP_BIN "$@"
+ done
+}
+
+function ust_event_generator_toggle_state
+{
+ ust_event_generator_suspended=$((ust_event_generator_suspended==0))
+}
+
+function generator_quit
+{
+ generator_quit=0
+}
+
+# Note: Only one generator can be used at a time per domain type
+function ust_event_generator_run_once_per_transition
+{
+ # Used by the signal trap
+ ust_event_generator_suspended=0
+ # Used by the signal trap for SIGUSR2 to end the generator
+ generator_quit=1
+
+ local test_app=$1
+ local state_file=$2
+ local nr_iter=$3
+ local nr_usec_wait=$4
+ local run=false
+
+ # Pass any of the remaining arguments to the generator.
+ shift 4
+
+ trap ust_event_generator_toggle_state SIGUSR1
+ trap generator_quit SIGUSR2
+
+ while [ $generator_quit -ne 0 ]; do
+ if [[ $ust_event_generator_suspended -eq "1" ]]; then
+ touch "$state_file"
+ # Reset the "run" state
+ run=true
+ sleep 0.5
+ elif [ "$run" = true ]; then
+ taskset -c 0 "$test_app" -i "$nr_iter" -w "$nr_usec_wait" "$@"> /dev/null 2>&1
+ run=false;
+ if [[ -f $state_file ]]; then
+ rm -rf "$state_file" 2> /dev/null
+ fi
+ else
+ # Wait for a "suspend" to reset the run state
+ sleep 0.1
+ fi
+ done
+}
+
+# Note: Only one generator can be used at a time per domain type
+function ust_event_generator
+{
+ # Used by the signal trap
+ ust_event_generator_suspended=0
+ # Used by the signal trap for SIGUSR2 to end the generator
+ generator_quit=1
+
+ local test_app=$1
+ local state_file=$2
+ local nr_iter=1000
+ local nr_usec_wait=5
+
+ # Pass any of the remaining arguments to the generator.
+ shift 2
+
+ trap ust_event_generator_toggle_state SIGUSR1
+ trap generator_quit SIGUSR2
+
+ while [ $generator_quit -ne 0 ]; do
+ if [[ $ust_event_generator_suspended -eq "1" ]]; then
+ touch "$state_file"
+ # Reset the "run" state
+ sleep 0.5
+ else
+ taskset -c 0 "$test_app" -i $nr_iter -w $nr_usec_wait "$@" > /dev/null 2>&1
+ if [[ -f $state_file ]]; then
+ rm -rf "$state_file" 2> /dev/null
+ fi
+ fi
+ done
+}
+
+function kernel_event_generator_toggle_state
+{
+ kernel_event_generator_suspended=$((kernel_event_generator_suspended==0))
+}
+
+function kernel_event_generator_run_once_per_transition
+{
+ # Used by the signal trap
+ kernel_event_generator_suspended=0
+ # Used by the signal trap for SIGUSR2 to end the generator
+ generator_quit=1
+
+ local generator=$1
+ local state_file=$2
+ local nr_iter=$3
+
+ # Pass any of the remaining arguments to the generator.
+ shift 3
+
+ local run=false
+ trap kernel_event_generator_toggle_state SIGUSR1
+ trap generator_quit SIGUSR2
+
+ while [ $generator_quit -ne 0 ]; do
+ if [[ $kernel_event_generator_suspended -eq "1" ]]; then
+ touch "$state_file"
+ run=true
+ sleep 0.5
+ elif [ "$run" = true ]; then
+ $generator "$nr_iter" "$@"
+ run=false
+ if [[ -f $state_file ]]; then
+ rm "$state_file" 2> /dev/null
+ fi
+ else
+ # Wait for a "suspend" to reset the run state
+ sleep 0.1
+ fi
+ done
+}
+
+function kernel_event_generator
+{
+ # Used by the signal trap
+ kernel_event_generator_suspended=0
+ # Used by the signal trap for SIGUSR2 to end the generator
+ generator_quit=1
+
+ local generator=$1
+ local state_file=$2
+
+ # Pass any of the remaining arguments to the generator.
+ shift 2
+
+ trap kernel_event_generator_toggle_state SIGUSR1
+ trap generator_quit SIGUSR2
+
+ while [ $generator_quit -ne 0 ]; do
+ if [[ $kernel_event_generator_suspended -eq "1" ]]; then
+ touch "$state_file"
+ sleep 0.5
+ else
+ $generator "10" "$@"
+ if [[ -f $state_file ]]; then
+ rm "$state_file" 2> /dev/null
+ fi
+ fi
+ done
+}