Tests for the regenerate statedump command
authorJulien Desfossez <jdesfossez@efficios.com>
Tue, 5 Jul 2016 14:54:37 +0000 (10:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 6 Jul 2016 19:59:56 +0000 (15:59 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/fast_regression
tests/regression/Makefile.am
tests/regression/tools/Makefile.am
tests/regression/tools/regen-statedump/Makefile.am [new file with mode: 0644]
tests/regression/tools/regen-statedump/test_kernel [new file with mode: 0755]
tests/regression/tools/regen-statedump/test_ust [new file with mode: 0755]
tests/root_regression
tests/utils/utils.sh

index 89a78587590acca91096adf179f2dd350294f4f1..6222e2bf0e1cc6640d78e5c7ee4f50892fae6aff 100644 (file)
@@ -981,6 +981,7 @@ AC_CONFIG_FILES([
        tests/regression/tools/wildcard/Makefile
        tests/regression/tools/crash/Makefile
        tests/regression/tools/regen-metadata/Makefile
+       tests/regression/tools/regen-statedump/Makefile
        tests/regression/ust/Makefile
        tests/regression/ust/nprocesses/Makefile
        tests/regression/ust/high-throughput/Makefile
index 262c846aae2a7e95606d4355e45eaf712568840c..8edbecaddfd2fe12e54c29f0811903ce2e6651d2 100644 (file)
@@ -17,6 +17,7 @@ regression/tools/mi/test_mi
 regression/tools/wildcard/test_event_wildcard
 regression/tools/crash/test_crash
 regression/tools/regen-metadata/test_ust
+regression/tools/regen-statedump/test_ust
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/multi-session/test_multi_session
index 2297ea1e3696b4ffcff968a35c12c2410b587ec2..f2fa9d7aa293a7e68235695d7550900e3d29e384 100644 (file)
@@ -22,7 +22,8 @@ TESTS = tools/filtering/test_invalid_filter \
        tools/mi/test_mi \
        tools/wildcard/test_event_wildcard \
        tools/crash/test_crash \
-       tools/regen-metadata/test_ust
+       tools/regen-metadata/test_ust \
+       tools/regen-statedump/test_ust
 
 if HAVE_LIBLTTNG_UST_CTL
 SUBDIRS += ust
index 91820ada42471e5503c6c7da3d982c2d0024c849..76374c75461ccfabe3268718605c4061c73c8656 100644 (file)
@@ -1,2 +1,2 @@
 SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi \
-               wildcard crash regen-metadata
+               wildcard crash regen-metadata regen-statedump
diff --git a/tests/regression/tools/regen-statedump/Makefile.am b/tests/regression/tools/regen-statedump/Makefile.am
new file mode 100644 (file)
index 0000000..d4a92eb
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_SCRIPTS = test_ust test_kernel
+EXTRA_DIST = test_ust test_kernel
+
+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/tools/regen-statedump/test_kernel b/tests/regression/tools/regen-statedump/test_kernel
new file mode 100755 (executable)
index 0000000..85afe76
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) - 2016 Julien Desfossez <jdesfossez@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="Regenerate the statedump - Kernel tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+EVENT_NAME="lttng_test_filter_event"
+PID_RELAYD=0
+SESSION_NAME=""
+EVENT_NAME="lttng_statedump_start,lttng_statedump_end"
+
+TRACE_PATH=$(mktemp -d)
+
+NUM_TESTS=11
+
+source $TESTDIR/utils/utils.sh
+
+# LTTng kernel modules check
+out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+if [ -z "$out" ]; then
+       BAIL_OUT "LTTng modules not detected."
+fi
+
+function test_kernel_local ()
+{
+       diag "Test kernel local with statedump regeneration"
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+       lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+       start_lttng_tracing_ok $SESSION_NAME
+       echo -n "100" > /proc/lttng-test-filter-event
+       regenerate_statedump_ok $SESSION_NAME
+       stop_lttng_tracing_ok $SESSION_NAME
+       validate_trace_count $EVENT_NAME $TRACE_PATH 4
+       if [ $? -eq 0 ]; then
+               # Only delete if successful
+               rm -rf $TRACE_PATH
+       fi
+       destroy_lttng_session_ok $SESSION_NAME
+}
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+{
+       start_lttng_sessiond
+       modprobe lttng-test
+
+       tests=( test_kernel_local )
+
+       for fct_test in ${tests[@]};
+       do
+               SESSION_NAME=$(randstring 16 0)
+               ${fct_test}
+       done
+
+       rmmod lttng-test
+       stop_lttng_sessiond
+}
diff --git a/tests/regression/tools/regen-statedump/test_ust b/tests/regression/tools/regen-statedump/test_ust
new file mode 100755 (executable)
index 0000000..486b9a5
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+# Copyright (C) - 2016 Julien Desfossez <jdesfossez@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="Regenerate the statedump - User-space tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=10
+NR_USEC_WAIT=0
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+SESSION_NAME="stream"
+EVENT_NAME="lttng_ust_statedump:start,lttng_ust_statedump:end"
+PID_RELAYD=0
+
+TRACE_PATH=$(mktemp -d)
+
+NUM_TESTS=11
+
+source $TESTDIR/utils/utils.sh
+
+if [ ! -x "$TESTAPP_BIN" ]; then
+       BAIL_OUT "No UST events binary detected."
+fi
+
+function test_ust_local ()
+{
+       local file_sync_after_first=$(mktemp -u)
+       local file_sync_before_last=$(mktemp -u)
+
+       diag "Test UST local with statedump regeneration"
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
+
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
+
+       start_lttng_tracing_ok $SESSION_NAME
+
+       while [ ! -f "${file_sync_after_first}" ]; do
+               sleep 0.5
+       done
+
+       regenerate_statedump_ok $SESSION_NAME
+
+       touch ${file_sync_before_last}
+
+       stop_lttng_tracing_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
+       # Validate test
+       validate_trace_count $EVENT_NAME $TRACE_PATH 4
+       if [ $? -eq 0 ]; then
+               # Only delete if successful
+               rm -rf $TRACE_PATH
+       fi
+       rm -f ${file_sync_after_first}
+       rm -f ${file_sync_before_last}
+}
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+start_lttng_sessiond
+
+tests=( test_ust_local )
+
+for fct_test in ${tests[@]};
+do
+       SESSION_NAME=$(randstring 16 0)
+       ${fct_test}
+done
+
+stop_lttng_sessiond
+
+exit $out
index e1ccdd41bd83c2fa3656e48c17f57af3a59f5b54..92edf92adeb544c655193a3ea8a69bf54c9bc62f 100644 (file)
@@ -16,4 +16,5 @@ regression/tools/filtering/test_unsupported_op
 regression/tools/filtering/test_valid_filter
 regression/tools/wildcard/test_event_wildcard
 regression/tools/regen-metadata/test_kernel
+regression/tools/regen-statedump/test_kernel
 regression/ust/test_event_perf
index 3d744e258cd631e6ce6e26b0baafdb775185d572..c56a8aa2855d5c63bce73d5fc71514553d389fed 100644 (file)
@@ -1294,6 +1294,35 @@ function validate_trace
        return $ret
 }
 
+function validate_trace_count
+{
+       local event_name=$1
+       local trace_path=$2
+       local expected_count=$3
+
+       which $BABELTRACE_BIN >/dev/null
+       if [ $? -ne 0 ]; then
+           skip 0 "Babeltrace binary not found. Skipping trace validation"
+       fi
+
+       cnt=0
+       OLDIFS=$IFS
+       IFS=","
+       for i in $event_name; do
+               traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l)
+               if [ "$traced" -ne 0 ]; then
+                       pass "Validate trace for event $i, $traced events"
+               else
+                       fail "Validate trace for event $i"
+                       diag "Found $traced occurences of $i"
+               fi
+               cnt=$(($cnt + $traced))
+       done
+       IFS=$OLDIFS
+       test $cnt -eq $expected_count
+       ok $? "Read a total of $cnt events, expected $expected_count"
+}
+
 function trace_first_line
 {
        local trace_path=$1
@@ -1391,6 +1420,31 @@ function regenerate_metadata_fail ()
        regenerate_metadata 1 "$@"
 }
 
+function regenerate_statedump ()
+{
+       local expected_to_fail=$1
+       local sess_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate statedump -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test "$ret" -ne "0"
+               ok $? "Expected fail on regenerate statedump $sess_name"
+       else
+               ok $ret "Metadata regenerate $sess_name"
+       fi
+}
+
+function regenerate_statedump_ok ()
+{
+       regenerate_statedump 0 "$@"
+}
+
+function regenerate_statedump_fail ()
+{
+       regenerate_statedump 1 "$@"
+}
+
 function destructive_tests_enabled ()
 {
        if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
This page took 0.032625 seconds and 4 git commands to generate.