tools/crash/test_crash \
tools/regen-metadata/test_ust \
tools/regen-statedump/test_ust \
- tools/notification/test_notification_ust \
- tools/notification/test_notification_kernel \
+ tools/notification/test_notification_ust_error \
+ tools/notification/test_notification_ust_buffer_usage \
+ tools/notification/test_notification_kernel_error \
+ tools/notification/test_notification_kernel_buffer_usage \
tools/notification/test_notification_multi_app \
tools/rotation/test_ust \
tools/rotation/test_kernel \
if NO_SHARED
CLEANFILES = libpause_consumer.so libpause_consumer.so.debug
-EXTRA_DIST = test_notification_ust test_notification_kernel 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
else
rotation_SOURCES = rotation.c
rotation_LDADD = $(LIB_LTTNG_CTL) $(LIBTAP) -lm
-noinst_SCRIPTS = test_notification_ust test_notification_kernel test_notification_multi_app test_rotation
-EXTRA_DIST = test_notification_ust test_notification_kernel 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
+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
all-local:
int main(int argc, const char *argv[])
{
+ int test_scenario;
const char *session_name = NULL;
const char *channel_name = NULL;
const char *domain_type_string = NULL;
enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
- plan_tests(NUM_TESTS);
-
- /* Argument 6 and upward are named pipe location for consumerd control */
- named_pipe_args_start = 6;
-
- if (argc < 7) {
- fail("Missing parameter for tests to run %d", argc);
+ if (argc < 3) {
+ fail("Missing test scenario and/or domain type argument(s)");
goto error;
}
- nb_args = argc;
-
- domain_type_string = argv[1];
- session_name = argv[2];
- channel_name = argv[3];
- app_pid = (pid_t) atoi(argv[4]);
- app_state_file = argv[5];
+ test_scenario = atoi(argv[1]);
+ domain_type_string = argv[2];
if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string)) {
domain_type = LTTNG_DOMAIN_UST;
goto error;
}
- /*
- * Test cases are responsible for resuming the app when needed and
- * making sure it's suspended when returning.
- */
- suspend_application();
+ switch (test_scenario) {
+ case 1:
+ {
+ plan_tests(7);
+ /* Test cases that need gen-ust-event testapp. */
+ diag("Test basic notification error paths for domain %s",
+ domain_type_string);
+ test_invalid_channel_subscription(domain_type);
+ break;
+ }
+ case 2:
+ {
+ /* Test cases that need a tracing session enabled. */
+ plan_tests(99);
- diag("Test trigger for domain %s with buffer_usage_low condition", domain_type_string);
- test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
- diag("Test trigger for domain %s with buffer_usage_high condition", domain_type_string);
- test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
+ /*
+ * Argument 7 and upward are named pipe location for consumerd
+ * control.
+ */
+ named_pipe_args_start = 7;
+
+ if (argc < 8) {
+ fail("Missing parameter for tests to run %d", argc);
+ goto error;
+ }
- /* Basic error path check. */
- test_invalid_channel_subscription(domain_type);
- test_subscription_twice(session_name, channel_name, domain_type);
+ nb_args = argc;
+
+ session_name = argv[3];
+ channel_name = argv[4];
+ app_pid = (pid_t) atoi(argv[5]);
+ app_state_file = argv[6];
+
+ /*
+ * Test cases are responsible for resuming the app when needed
+ * and making sure it's suspended when returning.
+ */
+ suspend_application();
+
+ test_subscription_twice(session_name, channel_name,
+ domain_type);
+
+ diag("Test trigger for domain %s with buffer_usage_low condition",
+ domain_type_string);
+ test_triggers_buffer_usage_condition(session_name, channel_name,
+ domain_type,
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
+
+ diag("Test trigger for domain %s with buffer_usage_high condition",
+ domain_type_string);
+ test_triggers_buffer_usage_condition(session_name, channel_name,
+ domain_type,
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
+
+ diag("Test buffer usage notification channel api for domain %s",
+ domain_type_string);
+ test_buffer_usage_notification_channel(session_name, channel_name,
+ domain_type, argv);
+ break;
+ }
+ default:
+ abort();
+ }
- diag("Test buffer usage notification channel api for domain %s", domain_type_string);
- test_buffer_usage_notification_channel(session_name, channel_name, domain_type, argv);
error:
return exit_status();
}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-only
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../../../
-
-TMPDIR=$(mktemp -d)
-
-#This is needed since the testpoint create a pipe with the consumerd type suffixed
-TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
-TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
-TESTPOINT=$(readlink -f ${CURDIR}/.libs/libpause_consumer.so)
-
-
-TESTAPP_PATH="$TESTDIR/utils/testapp"
-TESTAPP_NAME="gen-ust-events"
-TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
-TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
-
-NR_ITER=-1
-NR_USEC_WAIT=5
-
-SESSION_NAME="my_session"
-CHANNEL_NAME="my_channel"
-
-TRACE_PATH=$(mktemp -d)
-PAGE_SIZE=$(getconf PAGE_SIZE)
-
-DIR=$(readlink -f $TESTDIR)
-NUM_TESTS=104
-
-source $TESTDIR/utils/utils.sh
-
-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 2> /dev/null
- fi
- done
-}
-
-function kernel_test
-{
- local consumerd_pipe=()
- local event_name="lttng_test_filter_event"
-
- modprobe lttng-test
-
- LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
- start_lttng_sessiond_notap
-
- create_lttng_session_notap $SESSION_NAME $TRACE_PATH
-
- lttng_enable_kernel_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
- enable_kernel_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
-
- #This is needed since the testpoint create a pipe with the consumer type suffixed
- for f in "$TESTPOINT_BASE_PATH"*; do
- consumerd_pipe+=("$f")
- done
-
- kernel_event_generator $TESTAPP_STATE_PATH &
- APP_PID=$!
-
- $CURDIR/notification LTTNG_DOMAIN_KERNEL $SESSION_NAME $CHANNEL_NAME $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
-
- destroy_lttng_session_notap $SESSION_NAME
- stop_lttng_sessiond_notap
-
- kill -9 $APP_PID
- wait $APP_PID 2> /dev/null
-
-
- modprobe --remove lttng-test
-
- rm -rf ${consumerd_pipe[@]} 2> /dev/null
-}
-
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
- kernel_test
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
-
-# Just in case cleanup
-rm -rf $TRACE_PATH
-rm -rf $TMPDIR
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../../
+
+TMPDIR=$(mktemp -d)
+
+#This is needed since the testpoint create a pipe with the consumerd type suffixed
+TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
+TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
+TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_consumer.so")
+TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
+
+
+SESSION_NAME="my_session"
+CHANNEL_NAME="my_channel"
+
+NUM_TESTS=104
+
+# 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
+}
+
+function test_buffer_usage_notification
+{
+ local event_name="lttng_test_filter_event"
+ local trace_path
+ local page_size
+ local consumerd_pipe=()
+
+ trace_path=$(mktemp -d)
+ page_size=$(getconf PAGE_SIZE)
+
+ create_lttng_session_notap $SESSION_NAME "$trace_path"
+
+ lttng_enable_kernel_channel_notap $SESSION_NAME $CHANNEL_NAME \
+ --subbuf-size="$page_size"
+ enable_kernel_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
+
+ kernel_event_generator generate_filter_events "$TESTAPP_STATE_PATH" &
+ APP_PID=$!
+
+ # This is needed since the testpoint create a pipe with the consumer
+ # type suffixed.
+ for f in "$TESTPOINT_BASE_PATH"*; do
+ consumerd_pipe+=("$f")
+ done
+
+ "$CURDIR/notification" 2 LTTNG_DOMAIN_KERNEL $SESSION_NAME $CHANNEL_NAME \
+ $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
+
+ destroy_lttng_session_notap $SESSION_NAME
+
+ kill -9 $APP_PID
+ wait $APP_PID 2> /dev/null
+}
+
+if [ "$(id -u)" == "0" ]; then
+
+ validate_lttng_modules_present
+
+
+ modprobe lttng-test
+
+ # Used on sessiond launch.
+ LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \
+ CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \
+ LD_PRELOAD=${TESTPOINT}"
+ start_lttng_sessiond_notap
+
+ test_buffer_usage_notification
+
+ stop_lttng_sessiond_notap
+ rmmod lttng-test
+
+ rm -rf "${consumerd_pipe[@]}" 2> /dev/null
+else
+ # Kernel tests are skipped.
+ plan_tests $NUM_TESTS
+ skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
+fi
+
+rm -rf "$TMPDIR"
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../../
+
+TMPDIR=$(mktemp -d)
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
+
+NUM_TESTS=44
+
+# shellcheck source=../../../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
+
+function test_basic_error_path
+{
+ $CURDIR/notification 1 LTTNG_DOMAIN_KERNEL
+}
+
+
+if [ "$(id -u)" == "0" ]; then
+ validate_lttng_modules_present
+
+ modprobe lttng-test
+
+ start_lttng_sessiond_notap
+
+ test_basic_error_path
+
+ stop_lttng_sessiond_notap
+ rmmod lttng-test
+
+else
+ # Kernel tests are skipped.
+ plan_tests $NUM_TESTS
+ skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
+fi
+
+# Just in case cleanup
+rm -rf "$TMPDIR"
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-only
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../../../
-
-TMPDIR=$(mktemp -d)
-
-#This is needed since the testpoint create a pipe with the consumerd type suffixed
-TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
-TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
-TESTPOINT=$(readlink -f ${CURDIR}/.libs/libpause_consumer.so)
-
-
-TESTAPP_PATH="$TESTDIR/utils/testapp"
-TESTAPP_NAME="gen-ust-events"
-TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
-TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
-
-NR_ITER=5
-NR_USEC_WAIT=5
-
-SESSION_NAME="my_session"
-CHANNEL_NAME="my_channel"
-
-TRACE_PATH=$(mktemp -d)
-PAGE_SIZE=$(getconf PAGE_SIZE)
-
-DIR=$(readlink -f $TESTDIR)
-
-
-source $TESTDIR/utils/utils.sh
-
-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
-
- 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 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
- fi
- done
-}
-
-consumerd_pipe=()
-file_sync_after_first_event=$(mktemp -u)
-event_name="tp:tptest"
-
-LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
-start_lttng_sessiond_notap
-
-create_lttng_session_notap $SESSION_NAME $TRACE_PATH
-
-enable_ust_lttng_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
-enable_ust_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
-
-#This is needed since the testpoint create a pipe with the consumer type suffixed
-for f in "$TESTPOINT_BASE_PATH"*; do
- consumerd_pipe+=("$f")
-done
-
-
-ust_event_generator $TESTAPP_STATE_PATH &
-APP_PID=$!
-
-$CURDIR/notification LTTNG_DOMAIN_UST $SESSION_NAME $CHANNEL_NAME $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
-
-destroy_lttng_session_notap $SESSION_NAME
-stop_lttng_sessiond_notap
-
-# On ungraceful kill the app is cleaned up via the full_cleanup call
-# Suppress kill message
-kill -9 $APP_PID
-wait $APP_PID 2> /dev/null
-
-rm -rf $TMPDIR
-
-# Just in case cleanup
-rm -rf $TRACE_PATH
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../../
+
+TMPDIR=$(mktemp -d)
+
+#This is needed since the testpoint create a pipe with the consumerd type suffixed
+TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
+TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
+TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_consumer.so")
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+
+GEN_UST_EVENTS_TESTAPP_NAME="gen-ust-events"
+GEN_UST_EVENTS_TESTAPP_BIN="$TESTAPP_PATH/$GEN_UST_EVENTS_TESTAPP_NAME/$GEN_UST_EVENTS_TESTAPP_NAME"
+
+TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
+
+SESSION_NAME="my_session"
+CHANNEL_NAME="my_channel"
+
+TRACE_PATH=$(mktemp -d)
+PAGE_SIZE=$(getconf PAGE_SIZE)
+
+# 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
+}
+
+function test_buffer_usage_notification
+{
+ consumerd_pipe=()
+ event_name="tp:tptest"
+
+ create_lttng_session_notap $SESSION_NAME "$TRACE_PATH"
+
+ enable_ust_lttng_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size="$PAGE_SIZE"
+ enable_ust_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
+
+ # This is needed since the testpoint create a pipe with the consumer type suffixed
+ for f in "$TESTPOINT_BASE_PATH"*; do
+ consumerd_pipe+=("$f")
+ done
+
+ 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[@]}"
+
+ destroy_lttng_session_notap $SESSION_NAME
+
+ # On ungraceful kill the app is cleaned up via the full_cleanup call
+ # Suppress kill message
+ kill -9 $APP_PID
+ wait $APP_PID 2> /dev/null
+
+ # Just in case cleanup
+ rm -rf "$TRACE_PATH"
+}
+
+LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
+start_lttng_sessiond_notap
+
+test_buffer_usage_notification
+
+stop_lttng_sessiond_notap
+
+rm -rf "$TMPDIR"
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../../
+
+TMPDIR=$(mktemp -d)
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+
+GEN_UST_EVENTS_TESTAPP_NAME="gen-ust-events"
+GEN_UST_EVENTS_TESTAPP_BIN="$TESTAPP_PATH/$GEN_UST_EVENTS_TESTAPP_NAME/$GEN_UST_EVENTS_TESTAPP_NAME"
+
+TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
+
+# shellcheck source=../../../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
+
+function test_basic_error_path
+{
+ $CURDIR/notification 1 LTTNG_DOMAIN_UST
+}
+
+start_lttng_sessiond_notap
+
+test_basic_error_path
+
+stop_lttng_sessiond_notap