Fix: sessiond: notification: use after free of trigger object
[lttng-tools.git] / tests / regression / tools / notification / test_notification_multi_app
index 9468d0a0db19c8aeb66486cc2a3352a850eb3c8a..5d5427c9d03759eee3797cc326f8131c0457edec 100755 (executable)
@@ -32,6 +32,7 @@ NUM_TEST_KERNEL=50
 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)
@@ -43,54 +44,6 @@ print_test_banner "$TEST_DESC"
 
 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
@@ -101,8 +54,9 @@ function start_client {
        local buffer_usage_threshold_type=$6
        local buffer_usage_threshold_value=$7
        local nr_expected_notification=$8
+       local use_action_group=$9
 
-       ${CURDIR}/base_client ${session_name} ${channel_name} ${domain_type} ${buffer_usage_type} ${buffer_usage_threshold_type} ${buffer_usage_threshold_value} ${nr_expected_notification} > ${output_file} &
+       ${CURDIR}/base_client ${session_name} ${channel_name} ${domain_type} ${buffer_usage_type} ${buffer_usage_threshold_type} ${buffer_usage_threshold_value} ${nr_expected_notification} ${use_action_group} > ${output_file} &
        pid=$!
 
        app_pids+=("$pid")
@@ -224,8 +178,8 @@ function test_multi_app ()
        for (( i = 0; i < $nr_client_app; i++ )); do
                low_app_output_file=$output_dir/${low_output_file_pattern}${i}
                high_app_output_file=$output_dir/${high_output_file_pattern}${i}
-               start_client $low_app_output_file $SESSION_NAME $CHANNEL_NAME $domain_string LOW RATIO 0.0 $nr_notification_expected
-               start_client $high_app_output_file $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 $nr_notification_expected
+               start_client $low_app_output_file $SESSION_NAME $CHANNEL_NAME $domain_string LOW RATIO 0.0 $nr_notification_expected $(( $i % 2))
+               start_client $high_app_output_file $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 $nr_notification_expected $(( $i % 2))
        done
 
        wait_for_message $output_dir "${low_output_file_pattern}" "sync: ready"
@@ -300,12 +254,12 @@ function test_multi_app ()
 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
 }
@@ -315,13 +269,13 @@ function test_multi_app_kernel ()
        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
 
@@ -333,12 +287,12 @@ function test_on_register_evaluation_ust ()
        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
 
@@ -350,13 +304,13 @@ function test_on_register_evaluation_kernel()
 
        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
 
@@ -409,7 +363,7 @@ function test_on_register_evaluation ()
 
        high_app_output_file=${high_output_file_pattern}.first_receiver
        high_app_output_path=$output_dir/${high_app_output_file}
-       start_client $high_app_output_path $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 1
+       start_client $high_app_output_path $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 1 0
 
        wait_for_message $output_dir "${high_app_output_file}" "sync: ready"
 
@@ -426,7 +380,7 @@ function test_on_register_evaluation ()
        # notification on subscription
        high_app_output_file=${high_output_file_pattern}.second_receiver
        high_app_output_path=$output_dir/${high_app_output_file}
-       start_client $high_app_output_path $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 1
+       start_client $high_app_output_path $SESSION_NAME $CHANNEL_NAME $domain_string HIGH RATIO 0.420 1 0
        wait_for_message $output_dir "${high_app_output_file}" "sync: ready"
        wait_for_message $output_dir "${high_app_output_file}" "notification: high 0"
 
@@ -447,7 +401,7 @@ function test_on_register_evaluation ()
        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
This page took 0.026231 seconds and 4 git commands to generate.