X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fnotification%2Ftest_notification_notifier_discarded_count;h=fa7ad1e40ff680163997a003ffe7966a508e6bbe;hb=695f70446965aeac8b1118bb08d572630c96114d;hp=dc75f8543f4ec4683cdf081b0a23ce24b9e33cb6;hpb=50ad08620ff49e3c27e6eb3fea5151e744ae13ec;p=lttng-tools.git diff --git a/tests/regression/tools/notification/test_notification_notifier_discarded_count b/tests/regression/tools/notification/test_notification_notifier_discarded_count index dc75f8543..fa7ad1e40 100755 --- a/tests/regression/tools/notification/test_notification_notifier_discarded_count +++ b/tests/regression/tools/notification/test_notification_notifier_discarded_count @@ -7,14 +7,14 @@ CURDIR=$(dirname "$0")/ TESTDIR=$CURDIR/../../../ -TMPDIR=$(mktemp -d) +TEST_TMPDIR=$(mktemp --tmpdir -d tmp.test_notifier_discarded_count.XXXXXX) TESTAPP_PATH="$TESTDIR/utils/testapp" TESTAPP_NAME="gen-ust-events" TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" -TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n") -TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX") +TESTPOINT_BASE_PATH=$(readlink -f "$TEST_TMPDIR/lttng.t_p_n") +TESTPOINT_PIPE_PATH=$(mktemp -u --tmpdir="$TEST_TMPDIR" "lttng.t_p_n.XXXXXX") TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_sessiond.so") SH_TAP=1 @@ -28,7 +28,7 @@ FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" FULL_LTTNG_SESSIOND_BIN="${TESTDIR}/../src/bin/lttng-sessiond/lttng-sessiond" UST_NUM_TESTS=15 -DESTRUCTIVE_TESTS_NUM=8 +DESTRUCTIVE_TESTS_NUM=12 KERNEL_NUM_TESTS=$((14 + $DESTRUCTIVE_TESTS_NUM)) NUM_TESTS=$(($UST_NUM_TESTS + $KERNEL_NUM_TESTS)) @@ -37,7 +37,7 @@ plan_tests $NUM_TESTS function trigger_get_discarded_notif_number() { local trigger_name="$1" - local list_triggers_stdout=$(mktemp -t list_triggers_stdout.XXXXXX) + local list_triggers_stdout=$(mktemp --tmpdir="$TEST_TMPDIR" "list_triggers_stdout.XXXXXX") "$FULL_LTTNG_BIN" list-triggers > "$list_triggers_stdout" @@ -60,7 +60,7 @@ function test_kernel_notifier_discarded_count { local sessiond_pipe=() local trigger_name="my_trigger" - local list_triggers_stdout=$(mktemp -t list_triggers_stdout.XXXXXX) + local list_triggers_stdout=$(mktemp --tmpdir="$TEST_TMPDIR" "list_triggers_stdout.XXXXXX") # Used on sessiond launch. LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \ @@ -78,7 +78,7 @@ function test_kernel_notifier_discarded_count done lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --kernel --name=lttng_test_filter_event \ + --condition event-rule-matches --type=kernel --name=lttng_test_filter_event \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -107,7 +107,7 @@ function test_kernel_notifier_discarded_count # Enable another notifier and list it to confirm the counter was cleared. lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --kernel --name=lttng_test_filter_event \ + --condition event-rule-matches --type=kernel --name=lttng_test_filter_event \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -129,13 +129,13 @@ function test_kernel_notifier_discarded_count_max_bucket diag "Kernel event notifer error counter bucket limit" for i in $(seq 3); do lttng_add_trigger_ok "$i" \ - --condition event-rule-matches --kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --type=kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done for i in $(seq 4 5); do lttng_add_trigger_fail "$i" \ - --condition event-rule-matches --kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --type=kernel --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done @@ -180,7 +180,7 @@ function test_ust_notifier_discarded_count done lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --userspace --name=tp:tptest \ + --condition event-rule-matches --type=user --name=tp:tptest \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -200,13 +200,13 @@ function test_ust_notifier_discarded_count # Remove the notifier. lttng_remove_trigger_ok "$trigger_name" - # Confirm that no notifier is enabled. + # Confirm that no trigger is enabled. list_triggers_line_count=$("$FULL_LTTNG_BIN" list-triggers | wc -l) is "$list_triggers_line_count" "0" "No \`event-rule-matches\` userspace notifier enabled as expected" # Enable another notifier and list it to confirm the counter was cleared. lttng_add_trigger_ok "$trigger_name" \ - --condition event-rule-matches --userspace --name=tp:tptest \ + --condition event-rule-matches --type=user --name=tp:tptest \ --action notify trigger_discarded_nb=$(trigger_get_discarded_notif_number "$trigger_name") @@ -226,13 +226,13 @@ function test_ust_notifier_discarded_count_max_bucket diag "UST event notifer error counter bucket limit" for i in $(seq 3); do lttng_add_trigger_ok "$i" \ - --condition event-rule-matches --userspace --name=my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --type=user --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done for i in $(seq 4 5); do lttng_add_trigger_fail "$i" \ - --condition event-rule-matches --userspace --name=my_event_that_doesnt_need_to_really_exist_$i \ + --condition event-rule-matches --type=user --name=my_event_that_doesnt_need_to_really_exist_$i \ --action notify done @@ -244,7 +244,7 @@ function test_ust_notifier_discarded_count_multi_uid local sessiond_pipe=() local root_trigger_name="root_trigger" local user_trigger_name="user_trigger" - local list_triggers_stdout=$(mktemp -t list_triggers_stdout.XXXXXX) + local list_triggers_stdout=$(mktemp --tmpdir="$TEST_TMPDIR" "list_triggers_stdout.XXXXXX") local NR_USEC_WAIT=0 local PIPE_SIZE local NR_ITER @@ -284,11 +284,11 @@ function test_ust_notifier_discarded_count_multi_uid done lttng_add_trigger_ok "$root_trigger_name" \ - --condition on-event --userspace tp:tptest \ + --condition event-rule-matches --type=user --name tp:tptest \ --action notify - lttng_add_trigger_ok "$user_trigger_name" --user-id "$new_uid" \ - --condition on-event --userspace tp:tptest \ + lttng_add_trigger_ok "$user_trigger_name" --owner-uid "$new_uid" \ + --condition event-rule-matches --type=user --name tp:tptest \ --action notify # Stop consumption of notifier tracer notifications. @@ -304,12 +304,81 @@ function test_ust_notifier_discarded_count_multi_uid user_trigger_discarded_nb=$(trigger_get_discarded_notif_number "$user_trigger_name") isnt $root_trigger_discarded_nb 0 \ - "Root trigger discard notifications number ($root_trigger_discarded_nb) is non-zero" + "Root trigger discarded notifications number ($root_trigger_discarded_nb) is non-zero" isnt $user_trigger_discarded_nb 0 \ - "User trigger discard notifications number ($user_trigger_discarded_nb) is non-zero" + "User trigger discarded notifications number ($user_trigger_discarded_nb) is non-zero" + + lttng_remove_trigger_ok "$root_trigger_name" + lttng_remove_trigger_ok "$user_trigger_name" --owner-uid "$new_uid" + + stop_lttng_sessiond_notap + + unset LTTNG_SESSIOND_ENV_VARS + + userdel "$new_user" + rm -f "$list_triggers_stdout" +} + +function test_ust_notifier_discarded_regardless_trigger_owner +{ + local sessiond_pipe=() + local root_trigger_name="root_trigger" + local user_trigger_name="user_trigger" + local list_triggers_stdout=$(mktemp --tmpdir="$TEST_TMPDIR" "list_triggers_stdout.XXXXXX") + local NR_USEC_WAIT=0 + local PIPE_SIZE + local NR_ITER + local new_user="dummy_lttng_test_user" + + PIPE_SIZE=$("$CURDIR"/default_pipe_size_getter) + if [ $? -ne 0 ]; then + BAIL_OUT "Failed to get system default pipe size" + else + diag "Default system pipe size: $PIPE_SIZE bytes" + fi + + # Find the number of events needed to overflow the event notification + # pipe buffer. Each LTTng-UST notification is at least 42 bytes long. + # Double that number to ensure enough events are created to overflow + # the buffer. + NR_ITER=$(( (PIPE_SIZE / 42) * 2 )) + diag "Test applications will emit $NR_ITER events" + + diag "UST event notifer error counter persists when a root trigger is present" + + # Create a dummy user to run test apps as. + useradd --no-create-home "$new_user" + new_uid=$(id -u "$new_user") + + # Used on sessiond launch. + LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \ + NOTIFIER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \ + LD_PRELOAD=${TESTPOINT}" + + start_lttng_sessiond_notap + + # This is needed since the testpoint create a pipe with the sessiond + # type suffixed. + for f in "$TESTPOINT_BASE_PATH"*; do + sessiond_pipe+=("$f") + done + + lttng_add_trigger_ok "$root_trigger_name" \ + --condition event-rule-matches --type=user --name tp:tptest \ + --action notify + + # Stop consumption of notifier tracer notifications. + echo -n 1 > $sessiond_pipe + + su "$new_user" -c "$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT" + ok $? "Generating $NR_ITER tracer notifications as UID: $new_uid" + + root_trigger_discarded_nb=$(trigger_get_discarded_notif_number "$root_trigger_name") + + isnt $root_trigger_discarded_nb 0 \ + "Root trigger discarded notifications number ($root_trigger_discarded_nb) is non-zero" lttng_remove_trigger_ok "$root_trigger_name" - lttng_remove_trigger_ok "$user_trigger_name" --user-id "$new_uid" stop_lttng_sessiond_notap @@ -332,10 +401,11 @@ if [ "$(id -u)" == "0" ]; then test_kernel_notifier_discarded_count_max_bucket if destructive_tests_enabled ; then - # This test adds a new user on the system. Since it's a quite + # Those tests add a new user on the system. Since it's a quite # intrusive change to the system, we decide to only run it when # the user knows what they are doing. test_ust_notifier_discarded_count_multi_uid + test_ust_notifier_discarded_regardless_trigger_owner else skip 0 "You need to set the LTTNG_ENABLE_DESTRUCTIVE_TESTS environment variable to \"will-break-my-system\" to run this test" $DESTRUCTIVE_TESTS_NUM fi @@ -348,4 +418,4 @@ else skip 0 "Root access is needed. Skipping all kernel notification tests." $KERNEL_NUM_TESTS fi -rm -rf "$TMPDIR" +rm -f "$TEST_TMPDIR"