Tests: add UST namespace contexts tests
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 1 Apr 2019 15:51:52 +0000 (11:51 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 23 Oct 2019 21:18:33 +0000 (17:18 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/regression/Makefile.am
tests/regression/ust/Makefile.am
tests/regression/ust/namespaces/Makefile.am [new file with mode: 0644]
tests/regression/ust/namespaces/test_ns_contexts [new file with mode: 0755]

index 7212ed1957449b6bebd3a2dcfa6c021958c59b44..466017a9340c97f3529e28528a93bb08f3e5510c 100644 (file)
@@ -1167,6 +1167,7 @@ AC_CONFIG_FILES([
        tests/regression/ust/type-declarations/Makefile
        tests/regression/ust/rotation-destroy-flush/Makefile
        tests/regression/ust/blocking/Makefile
+       tests/regression/ust/namespaces/Makefile
        tests/stress/Makefile
        tests/unit/Makefile
        tests/unit/ini_config/Makefile
index 29201ed30421fa9b606c144f0900b777609ca05d..403cf295a16bed42482cb5d245afa13b43aa8b66 100644 (file)
@@ -53,6 +53,7 @@ TESTS += ust/before-after/test_before_after \
        ust/blocking/test_blocking \
        ust/multi-lib/test_multi_lib \
        ust/rotation-destroy-flush/test_rotation_destroy_flush \
+       ust/namespaces/test_ns_contexts \
        tools/metadata/test_ust
 endif # HAVE_LIBLTTNG_UST_CTL
 
index 6237b1610653c12b90f957817fd7e2d1bfc5979e..cf6f20dd4a1ae279e6af5a9320a60dc6aafc55ec 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 blocking multi-lib
+               rotation-destroy-flush blocking multi-lib namespaces
 
 if HAVE_OBJCOPY
 SUBDIRS += baddr-statedump ust-dl
diff --git a/tests/regression/ust/namespaces/Makefile.am b/tests/regression/ust/namespaces/Makefile.am
new file mode 100644 (file)
index 0000000..11f4d85
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_SCRIPTS = test_ns_contexts
+EXTRA_DIST = test_ns_contexts
+
+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/namespaces/test_ns_contexts b/tests/regression/ust/namespaces/test_ns_contexts
new file mode 100755 (executable)
index 0000000..91852a0
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Michael Jeanson <mjeanson@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 - Namespace contexts"
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/../../..
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+NUM_EVENT=10000
+EVENT_NAME="tp:tptest"
+
+TESTS_PER_NS=13
+
+NUM_TESTS=$((TESTS_PER_NS * 7))
+
+source "$TESTDIR/utils/utils.sh"
+
+# MUST set TESTDIR before calling those functions
+function run_app()
+{
+       $TESTAPP_BIN $NUM_EVENT
+       ok $? "Application done"
+}
+
+function test_ns()
+{
+       local ns=$1
+
+       local session_name="${ns}_ns"
+       local chan_name="${ns}_ns"
+       local context_name="${ns}_ns"
+
+       local trace_path
+       local ns_inode
+
+       # Check if the kernel has support for this ns type
+       if [ ! -f "/proc/$$/ns/$ns" ]; then
+               skip 0 "System has no $ns namespace support" $TESTS_PER_NS
+               return
+       fi
+
+       # Get the current ns inode number
+       ns_inode=$(stat -c '%i' -L "/proc/$$/ns/$ns")
+       ok $? "Get current $ns namespace inode: $ns_inode"
+
+       trace_path=$(mktemp -d)
+
+       start_lttng_sessiond
+
+       create_lttng_session_ok "$session_name" "$trace_path"
+       enable_ust_lttng_channel_ok "$session_name" "$chan_name"
+       add_context_ust_ok "$session_name" "$chan_name" "$context_name"
+       enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$chan_name"
+       start_lttng_tracing_ok "$session_name"
+
+       run_app
+
+       # stop and destroy
+       stop_lttng_tracing_ok "$session_name"
+       destroy_lttng_session_ok "$session_name"
+       stop_lttng_sessiond
+
+       # Check that the events contain the right namespace inode number
+       validate_trace_count "${ns}_ns = $ns_inode" "$trace_path" $NUM_EVENT
+
+       rm -rf "$trace_path"
+}
+
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+system_has_ns=0
+if [ -d "/proc/$$/ns" ]; then
+       system_has_ns=1
+fi
+
+skip $system_has_ns "System does not support namespaces" $NUM_TESTS && exit 0
+
+test_ns cgroup
+test_ns ipc
+test_ns mnt
+test_ns net
+test_ns pid
+test_ns user
+test_ns uts
This page took 0.02845 seconds and 4 git commands to generate.