tests: Implement tests for lttng-ust LTTNG_UST_BLOCKING_RETRY_TIMEOUT
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 8 Nov 2016 22:59:12 +0000 (17:59 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 1 Dec 2016 21:53:35 +0000 (16:53 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: "Carlos O'Donell" <carlos@redhat.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/fast_regression
tests/regression/Makefile.am
tests/regression/ust/Makefile.am
tests/regression/ust/blocking/Makefile.am [new file with mode: 0644]
tests/regression/ust/blocking/test_blocking [new file with mode: 0755]

index 8b2decc714aae051d5ee5498a74728bce209e944..6badbf9e6bfb7a397e034f3c922f7c565015aa78 100644 (file)
@@ -1023,6 +1023,7 @@ AC_CONFIG_FILES([
        tests/regression/ust/clock-override/Makefile
        tests/regression/ust/type-declarations/Makefile
        tests/regression/ust/rotation-destroy-flush/Makefile
+       tests/regression/ust/blocking/Makefile
        tests/stress/Makefile
        tests/unit/Makefile
        tests/unit/ini_config/Makefile
index 23211f49a27b4d603d10deac587b000996c67485..bbce068f72d5cd1688e039fef3a4682e60b1fa40 100644 (file)
@@ -29,6 +29,7 @@ regression/ust/python-logging/test_python_logging
 regression/ust/getcpu-override/test_getcpu_override
 regression/ust/clock-override/test_clock_override
 regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
+regression/ust/blocking/test_blocking
 regression/ust/test_event_basic
 regression/ust/test_event_tracef
 regression/ust/test_event_perf
index 01cff148cc2c595e60bf585781f18f17ca8d24fd..86a55634b4c67209fad078d172765cca2d69dd61 100644 (file)
@@ -39,7 +39,8 @@ TESTS += ust/before-after/test_before_after \
        ust/clock-override/test_clock_override \
        ust/test_event_basic \
        ust/test_event_tracef \
-       ust/test_event_perf
+       ust/test_event_perf \
+       ust/blocking/test_blocking
 endif # HAVE_LIBLTTNG_UST_CTL
 
 if PYTHON_BINDING
index 76862514b8112ecb8d7517cb80ffd0383ad0bb8f..06cf97a4720c25bc4a957b8a9c0f00230a97724a 100644 (file)
@@ -3,7 +3,7 @@ SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
                overlap buffers-pid linking daemon exit-fast fork libc-wrapper \
                periodical-metadata-flush java-jul java-log4j python-logging \
                getcpu-override clock-override type-declarations \
-               rotation-destroy-flush
+               rotation-destroy-flush blocking
 
 if HAVE_OBJCOPY
 SUBDIRS += baddr-statedump ust-dl
diff --git a/tests/regression/ust/blocking/Makefile.am b/tests/regression/ust/blocking/Makefile.am
new file mode 100644 (file)
index 0000000..178cc45
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_SCRIPTS = test_blocking
+EXTRA_DIST = test_blocking
+
+all-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       cp -f $(srcdir)/$$script $(builddir); \
+               done; \
+       fi
+
+clean-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       rm -f $(builddir)/$$script; \
+               done; \
+       fi
diff --git a/tests/regression/ust/blocking/test_blocking b/tests/regression/ust/blocking/test_blocking
new file mode 100755 (executable)
index 0000000..261e0b8
--- /dev/null
@@ -0,0 +1,160 @@
+#!/bin/bash
+#
+# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+# Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="UST - Blocking mode"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+SESSION_NAME="blocking"
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+EVENT_NAME="tp:tptest"
+
+NUM_TESTS=45
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+# Run app on CPU 0 to ensure we only write in a single ring buffer.
+function run_app()
+{
+       taskset 0x00000001 $TESTAPP_BIN $NUM_EVENT
+       ok $? "Application done"
+}
+
+function test_ust_implicit_no_blocking()
+{
+       NUM_EVENT=500000
+       diag "UST implicit non-blocking mode (default): will hang if fails"
+
+       # Test without the plugin
+       start_lttng_sessiond
+       create_lttng_session_no_output $SESSION_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
+       start_lttng_tracing_ok $SESSION_NAME
+       run_app
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       stop_lttng_sessiond
+
+       ok 0 "Does not hang"
+}
+
+function test_ust_explicit_no_blocking()
+{
+       NUM_EVENT=500000
+       diag "UST explicit non-blocking mode: will hang if fails"
+
+       # Test without the plugin
+       start_lttng_sessiond
+       create_lttng_session_no_output $SESSION_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
+       start_lttng_tracing_ok $SESSION_NAME
+       LTTNG_UST_BLOCKING_RETRY_TIMEOUT=0 run_app
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       stop_lttng_sessiond
+
+       ok 0 "Does not hang"
+}
+
+function test_ust_timeout_no_blocking()
+{
+       NUM_EVENT=12500
+       diag "UST 1ms timeout retry mode: will hang if fails"
+
+       start_lttng_sessiond
+       create_lttng_session_no_output $SESSION_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
+       start_lttng_tracing_ok $SESSION_NAME
+       # retry timeout 1ms
+       LTTNG_UST_BLOCKING_RETRY_TIMEOUT=1 run_app
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       stop_lttng_sessiond
+
+       ok 0 "Does not hang"
+}
+
+function test_ust_snapshot_no_blocking()
+{
+       NUM_EVENT=500000
+       diag "UST blocking mode: don't block in snapshot mode"
+
+       # Test without the plugin
+       start_lttng_sessiond
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
+       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
+       start_lttng_tracing_ok $SESSION_NAME
+       LTTNG_UST_BLOCKING_RETRY_TIMEOUT=-1 run_app
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       stop_lttng_sessiond
+
+       ok 0 "Does not hang"
+}
+
+function test_ust_blocking_no_discard()
+{
+       NUM_EVENT=500000
+       diag "UST blocking mode: no event discarded"
+
+       # Test without the plugin
+       start_lttng_sessiond
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
+       start_lttng_tracing_ok $SESSION_NAME
+       # infinite retry timeout
+       LTTNG_UST_BLOCKING_RETRY_TIMEOUT=-1 run_app
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       stop_lttng_sessiond
+
+       nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
+
+       test $nr_events -eq $NUM_EVENT
+       ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
+}
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+TESTS=(
+       "test_ust_implicit_no_blocking"
+       "test_ust_explicit_no_blocking"
+       "test_ust_timeout_no_blocking"
+       "test_ust_snapshot_no_blocking"
+       "test_ust_blocking_no_discard"
+)
+
+TEST_COUNT=${#TESTS[@]}
+i=0
+
+while [ "$i" -lt "$TEST_COUNT" ]; do
+
+       TRACE_PATH=$(mktemp -d)
+
+       # Execute test
+       ${TESTS[$i]}
+
+       rm -rf $TRACE_PATH
+
+       let "i++"
+done
This page took 0.028667 seconds and 4 git commands to generate.