Skip to contentSkip to conversation

Test kernel wildcards

PATCH New Mathieu Desnoyers 2 participants 4 messages Sep 4, 2015 – Sep 6, 2015 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Test kernel wildcards

---
 .../regression/tools/wildcard/test_event_wildcard  | 87 ++++++++++++++++------
 tests/utils/utils.sh                               | 37 +++++++--
 2 files changed, 96 insertions(+), 28 deletions(-)
tests/regression/tools/wildcard/test_event_wildcard +66 -21
index 7fbfc18..126bdae 100755
@@ -16,37 +16,47 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-TEST_DESC="UST tracer - Event wildcard"
+TEST_DESC="LTTng - Event wildcard test"
 
 CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
+TESTDIR=$CURDIR/../../..
 LTTNG_BIN="lttng"
 TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 SESSION_NAME="wildcard"
-EVENT_NAME="tp:tptest"
-NUM_TESTS=39
 NR_ITER=100
+NUM_GLOBAL_TESTS=2
+NUM_UST_TESTS=37
+NUM_KERNEL_TESTS=37
+NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
 
 source $TESTDIR/utils/utils.sh
 
-if [ ! -x "$TESTAPP_BIN" ]; then
-	BAIL_OUT "No UST nevents binary detected."
-fi
+function run_ust
+{
+	$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+}
+
+function run_kernel
+{
+	# Trigger the event for 100 iterations
+	echo -n "100" > /proc/lttng-test-filter-event
+}
 
 function test_event_wildcard()
 {
 	TRACE_PATH=$(mktemp -d)
-	FIND="${1}"
-	WILDCARD="${2}"
+	DOMAIN="$1"
+	FIND="$2"
+	WILDCARD="$3"
 
 	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-	enable_ust_lttng_event_ok $SESSION_NAME "$WILDCARD"
+	enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD"
 
 	start_lttng_tracing_ok
 
-	$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+	run_${DOMAIN}
 	ok $? "Traced application stopped."
 
 	stop_lttng_tracing_ok
@@ -64,16 +74,16 @@ function test_event_wildcard()
 function test_event_wildcard_fail()
 {
 	TRACE_PATH=$(mktemp -d)
-	WILDCARD="${1}"
+	DOMAIN="$1"
+	WILDCARD="$2"
 
 	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-	enable_ust_lttng_event_fail $SESSION_NAME "$WILDCARD"
+	enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
 	destroy_lttng_session_ok $SESSION_NAME
 
 	rm -rf $TRACE_PATH
 }
 
-
 # MUST set TESTDIR before calling those functions
 plan_tests $NUM_TESTS
 
@@ -81,13 +91,48 @@ print_test_banner "$TEST_DESC"
 
 start_lttng_sessiond
 
-test_event_wildcard 1 'tp:tp*'
-test_event_wildcard 1 '*'
-test_event_wildcard 1 'tp:tptest*'
-test_event_wildcard 0 'tp:abc*'
+diag "Test UST wildcard"
+
+if [ ! -x "$TESTAPP_BIN" ]; then
+	BAIL_OUT "No UST nevents binary detected."
+fi
+
+EVENT_NAME="tp:tptest"
+
+test_event_wildcard ust 1 'tp:tp*'
+test_event_wildcard ust 1 '*'
+test_event_wildcard ust 1 'tp:tptest*'
+test_event_wildcard ust 0 'tp:abc*'
+
+test_event_wildcard_fail ust 'tp:*tp'
+test_event_wildcard_fail ust 'tp:tp**'
+test_event_wildcard_fail ust '*tp:tp*'
+
+
+if [ "$(id -u)" == "0" ]; then
+	isroot=1
+else
+	isroot=0
+fi
 
-test_event_wildcard_fail 'tp:*tp'
-test_event_wildcard_fail 'tp:tp**'
-test_event_wildcard_fail '*tp:tp*'
+skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
+{
+	diag "Test kernel wildcards"
+
+	modprobe lttng-test
+
+	EVENT_NAME="lttng_test_filter_event"
+
+	test_event_wildcard kernel 1 'lttng_test_*'
+	test_event_wildcard kernel 1 '*'
+	test_event_wildcard kernel 1 'lttng_test_filter_event*'
+	test_event_wildcard kernel 0 'lttng_test_asdfasdf*'
+
+	test_event_wildcard_fail kernel 'tp_*tp'
+	test_event_wildcard_fail kernel 'tp_tp**'
+	test_event_wildcard_fail kernel '*tp_tp*'
+
+	rmmod lttng-test
+}
 
 stop_lttng_sessiond
tests/utils/utils.sh +30 -7
index 1e1e791..d466ee6 100644
@@ -86,18 +86,19 @@ function randstring()
 	echo
 }
 
-function lttng_enable_kernel_event
+function enable_kernel_lttng_event
 {
-	local sess_name=$1
-	local event_name=$2
-	local channel_name=$3
+	local expected_to_fail="$1"
+	local sess_name="$2"
+	local event_name="$3"
+	local channel_name="$4"
 
-	if [ -z $event_name ]; then
+	if [ -z "$event_name" ]; then
 		# Enable all event if no event name specified
 		event_name="-a"
 	fi
 
-	if [ -z $channel_name ]; then
+	if [ -z "$channel_name" ]; then
 		# default channel if none specified
 		chan=""
 	else
@@ -105,7 +106,29 @@ function lttng_enable_kernel_event
 	fi
 
 	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
-	ok $? "Enable kernel event $event_name for session $sess_name"
+	ret=$?
+	if [[ $expected_to_fail -eq "1" ]]; then
+		test $ret -ne "0"
+		ok $? "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
+	else
+		ok $ret "Enable kernel event $event_name for session $sess_name"
+	fi
+}
+
+function enable_kernel_lttng_event_ok ()
+{
+	enable_kernel_lttng_event 0 "$@"
+}
+
+function enable_kernel_lttng_event_fail ()
+{
+	enable_kernel_lttng_event 1 "$@"
+}
+
+# Old interface
+function lttng_enable_kernel_event
+{
+	enable_kernel_lttng_event_ok "$@"
 }
 
 function lttng_enable_kernel_syscall()
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

This test hangs here on the latest lttng-modules (89406ecda) and Linux 4.1.6.

$ sudo ./tests/regression/tools/wildcard/test_event_wildcard
1..76
# LTTng - Event wildcard test
ok 1 - Start session daemon
# Test UST wildcard
ok 2 - Create session wildcard in /tmp/tmp.bMYvA8LmhA
ok 3 - Enable event tp:tp* for session wildcard
ok 4 - Start tracing for session
ok 5 - Traced application stopped.
ok 6 - Stop lttng tracing for session
ok 7 - Destroy session wildcard
ok 8 - Trace match
ok 9 - Create session wildcard in /tmp/tmp.40lme2ZfE2
ok 10 - Enable event * for session wildcard
ok 11 - Start tracing for session
ok 12 - Traced application stopped.
ok 13 - Stop lttng tracing for session
ok 14 - Destroy session wildcard
ok 15 - Trace match
ok 16 - Create session wildcard in /tmp/tmp.Px1eQtqdJX
ok 17 - Enable event tp:tptest* for session wildcard
ok 18 - Start tracing for session
ok 19 - Traced application stopped.
ok 20 - Stop lttng tracing for session
ok 21 - Destroy session wildcard
ok 22 - Trace match
ok 23 - Create session wildcard in /tmp/tmp.UExqHOU7iV
ok 24 - Enable event tp:abc* for session wildcard
ok 25 - Start tracing for session
ok 26 - Traced application stopped.
ok 27 - Stop lttng tracing for session
ok 28 - Destroy session wildcard
ok 29 - Validate empty trace
ok 30 - Create session wildcard in /tmp/tmp.Rvxoa79wgE
ok 31 - Enable ust event tp:*tp for session  on channel  failed as expected
ok 32 - Destroy session wildcard
ok 33 - Create session wildcard in /tmp/tmp.kQ9mPvTWXL
ok 34 - Enable ust event tp:tp** for session  on channel  failed as expected
ok 35 - Destroy session wildcard
ok 36 - Create session wildcard in /tmp/tmp.FBm6SWo0ov
ok 37 - Enable ust event *tp:tp* for session  on channel  failed as expected
ok 38 - Destroy session wildcard
# Test kernel wildcards
ok 39 - Create session wildcard in /tmp/tmp.BDcvQm9jEG

^ Hangs here.

It eventually times out with:
Error: Condition timed out. The consumer thread was never ready. Killing it
Error: Fatal error spawning consumer control thread
PERROR - 17:07:40.767365 [6552/6555]: sendmsg: Broken pipe (in lttcomm_send_unix_sock() at unix.c:219)
Error: Failed to send data back to client

Any idea?

Jérémie

Quoted 209 lines · Mathieu Desnoyers
---
 .../regression/tools/wildcard/test_event_wildcard  | 87 ++++++++++++++++------
 tests/utils/utils.sh                               | 37 +++++++--
 2 files changed, 96 insertions(+), 28 deletions(-)
tests/regression/tools/wildcard/test_event_wildcard +66 -21
index 7fbfc18..126bdae 100755
@@ -16,37 +16,47 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-TEST_DESC="UST tracer - Event wildcard"
+TEST_DESC="LTTng - Event wildcard test"
 
 CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
+TESTDIR=$CURDIR/../../..
 LTTNG_BIN="lttng"
 TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 SESSION_NAME="wildcard"
-EVENT_NAME="tp:tptest"
-NUM_TESTS=39
 NR_ITER=100
+NUM_GLOBAL_TESTS=2
+NUM_UST_TESTS=37
+NUM_KERNEL_TESTS=37
+NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
 
 source $TESTDIR/utils/utils.sh
 
-if [ ! -x "$TESTAPP_BIN" ]; then
-       BAIL_OUT "No UST nevents binary detected."
-fi
+function run_ust
+{
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+}
+
+function run_kernel
+{
+       # Trigger the event for 100 iterations
+       echo -n "100" > /proc/lttng-test-filter-event
+}
 
 function test_event_wildcard()
 {
        TRACE_PATH=$(mktemp -d)
-       FIND="${1}"
-       WILDCARD="${2}"
+       DOMAIN="$1"
+       FIND="$2"
+       WILDCARD="$3"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event_ok $SESSION_NAME "$WILDCARD"
+       enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD"
 
        start_lttng_tracing_ok
 
-       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+       run_${DOMAIN}
        ok $? "Traced application stopped."
 
        stop_lttng_tracing_ok
@@ -64,16 +74,16 @@ function test_event_wildcard()
 function test_event_wildcard_fail()
 {
        TRACE_PATH=$(mktemp -d)
-       WILDCARD="${1}"
+       DOMAIN="$1"
+       WILDCARD="$2"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event_fail $SESSION_NAME "$WILDCARD"
+       enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
        destroy_lttng_session_ok $SESSION_NAME
 
        rm -rf $TRACE_PATH
 }
 
-
 # MUST set TESTDIR before calling those functions
 plan_tests $NUM_TESTS
 
@@ -81,13 +91,48 @@ print_test_banner "$TEST_DESC"
 
 start_lttng_sessiond
 
-test_event_wildcard 1 'tp:tp*'
-test_event_wildcard 1 '*'
-test_event_wildcard 1 'tp:tptest*'
-test_event_wildcard 0 'tp:abc*'
+diag "Test UST wildcard"
+
+if [ ! -x "$TESTAPP_BIN" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+EVENT_NAME="tp:tptest"
+
+test_event_wildcard ust 1 'tp:tp*'
+test_event_wildcard ust 1 '*'
+test_event_wildcard ust 1 'tp:tptest*'
+test_event_wildcard ust 0 'tp:abc*'
+
+test_event_wildcard_fail ust 'tp:*tp'
+test_event_wildcard_fail ust 'tp:tp**'
+test_event_wildcard_fail ust '*tp:tp*'
+
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
 
-test_event_wildcard_fail 'tp:*tp'
-test_event_wildcard_fail 'tp:tp**'
-test_event_wildcard_fail '*tp:tp*'
+skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
+{
+       diag "Test kernel wildcards"
+
+       modprobe lttng-test
+
+       EVENT_NAME="lttng_test_filter_event"
+
+       test_event_wildcard kernel 1 'lttng_test_*'
+       test_event_wildcard kernel 1 '*'
+       test_event_wildcard kernel 1 'lttng_test_filter_event*'
+       test_event_wildcard kernel 0 'lttng_test_asdfasdf*'
+
+       test_event_wildcard_fail kernel 'tp_*tp'
+       test_event_wildcard_fail kernel 'tp_tp**'
+       test_event_wildcard_fail kernel '*tp_tp*'
+
+       rmmod lttng-test
+}
 
 stop_lttng_sessiond
tests/utils/utils.sh +30 -8
index 1e1e791..d466ee6 100644
@@ -86,18 +86,19 @@ function randstring()
        echo
 }
 
-function lttng_enable_kernel_event
+function enable_kernel_lttng_event
 {
-       local sess_name=$1
-       local event_name=$2
-       local channel_name=$3
+       local expected_to_fail="$1"
+       local sess_name="$2"
+       local event_name="$3"
+       local channel_name="$4"
 
-       if [ -z $event_name ]; then
+       if [ -z "$event_name" ]; then
                # Enable all event if no event name specified
                event_name="-a"
        fi
 
-       if [ -z $channel_name ]; then
+       if [ -z "$channel_name" ]; then
                # default channel if none specified
                chan=""
        else
@@ -105,7 +106,29 @@ function lttng_enable_kernel_event
        fi
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
-       ok $? "Enable kernel event $event_name for session $sess_name"
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test $ret -ne "0"
+               ok $? "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
+       else
+               ok $ret "Enable kernel event $event_name for session $sess_name"
+       fi
+}
+
+function enable_kernel_lttng_event_ok ()
+{
+       enable_kernel_lttng_event 0 "$@"
+}
+
+function enable_kernel_lttng_event_fail ()
+{
+       enable_kernel_lttng_event 1 "$@"
+}
+
+# Old interface
+function lttng_enable_kernel_event
+{
+       enable_kernel_lttng_event_ok "$@"
 }
 
 function lttng_enable_kernel_syscall()
--

2.1.4

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CA+jJMxu3Lrd7OP0S1je4boksWnfg6o=z7AsTrcvgAGivV0dM5A@mail.gmail.com

#5 lore raw

Seems to be fixed by upgrading to the latest liburcu... I'll see if I can track down what caused this hang.

Merged and added to root_regression test list.

Thanks!
Jérémie

Quoted 278 lines · Jérémie Galarneau

This test hangs here on the latest lttng-modules (89406ecda) and Linux 4.1.6.

$ sudo ./tests/regression/tools/wildcard/test_event_wildcard
1..76
# LTTng - Event wildcard test
ok 1 - Start session daemon
# Test UST wildcard
ok 2 - Create session wildcard in /tmp/tmp.bMYvA8LmhA
ok 3 - Enable event tp:tp* for session wildcard
ok 4 - Start tracing for session
ok 5 - Traced application stopped.
ok 6 - Stop lttng tracing for session
ok 7 - Destroy session wildcard
ok 8 - Trace match
ok 9 - Create session wildcard in /tmp/tmp.40lme2ZfE2
ok 10 - Enable event * for session wildcard
ok 11 - Start tracing for session
ok 12 - Traced application stopped.
ok 13 - Stop lttng tracing for session
ok 14 - Destroy session wildcard
ok 15 - Trace match
ok 16 - Create session wildcard in /tmp/tmp.Px1eQtqdJX
ok 17 - Enable event tp:tptest* for session wildcard
ok 18 - Start tracing for session
ok 19 - Traced application stopped.
ok 20 - Stop lttng tracing for session
ok 21 - Destroy session wildcard
ok 22 - Trace match
ok 23 - Create session wildcard in /tmp/tmp.UExqHOU7iV
ok 24 - Enable event tp:abc* for session wildcard
ok 25 - Start tracing for session
ok 26 - Traced application stopped.
ok 27 - Stop lttng tracing for session
ok 28 - Destroy session wildcard
ok 29 - Validate empty trace
ok 30 - Create session wildcard in /tmp/tmp.Rvxoa79wgE
ok 31 - Enable ust event tp:*tp for session  on channel  failed as expected
ok 32 - Destroy session wildcard
ok 33 - Create session wildcard in /tmp/tmp.kQ9mPvTWXL
ok 34 - Enable ust event tp:tp** for session  on channel  failed as expected
ok 35 - Destroy session wildcard
ok 36 - Create session wildcard in /tmp/tmp.FBm6SWo0ov
ok 37 - Enable ust event *tp:tp* for session  on channel  failed as expected
ok 38 - Destroy session wildcard
# Test kernel wildcards
ok 39 - Create session wildcard in /tmp/tmp.BDcvQm9jEG

^ Hangs here.

It eventually times out with:
Error: Condition timed out. The consumer thread was never ready. Killing it
Error: Fatal error spawning consumer control thread
PERROR - 17:07:40.767365 [6552/6555]: sendmsg: Broken pipe (in lttcomm_send_unix_sock() at unix.c:219)
Error: Failed to send data back to client

Any idea?

Jérémie

Quoted 207 lines · Mathieu Desnoyers
---
 .../regression/tools/wildcard/test_event_wildcard  | 87 ++++++++++++++++------
 tests/utils/utils.sh                               | 37 +++++++--
 2 files changed, 96 insertions(+), 28 deletions(-)
tests/regression/tools/wildcard/test_event_wildcard +66 -21
index 7fbfc18..126bdae 100755
@@ -16,37 +16,47 @@
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-TEST_DESC="UST tracer - Event wildcard"
+TEST_DESC="LTTng - Event wildcard test"
 
 CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../..
+TESTDIR=$CURDIR/../../..
 LTTNG_BIN="lttng"
 TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 SESSION_NAME="wildcard"
-EVENT_NAME="tp:tptest"
-NUM_TESTS=39
 NR_ITER=100
+NUM_GLOBAL_TESTS=2
+NUM_UST_TESTS=37
+NUM_KERNEL_TESTS=37
+NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
 
 source $TESTDIR/utils/utils.sh
 
-if [ ! -x "$TESTAPP_BIN" ]; then
-       BAIL_OUT "No UST nevents binary detected."
-fi
+function run_ust
+{
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+}
+
+function run_kernel
+{
+       # Trigger the event for 100 iterations
+       echo -n "100" > /proc/lttng-test-filter-event
+}
 
 function test_event_wildcard()
 {
        TRACE_PATH=$(mktemp -d)
-       FIND="${1}"
-       WILDCARD="${2}"
+       DOMAIN="$1"
+       FIND="$2"
+       WILDCARD="$3"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event_ok $SESSION_NAME "$WILDCARD"
+       enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD"
 
        start_lttng_tracing_ok
 
-       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+       run_${DOMAIN}
        ok $? "Traced application stopped."
 
        stop_lttng_tracing_ok
@@ -64,16 +74,16 @@ function test_event_wildcard()
 function test_event_wildcard_fail()
 {
        TRACE_PATH=$(mktemp -d)
-       WILDCARD="${1}"
+       DOMAIN="$1"
+       WILDCARD="$2"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event_fail $SESSION_NAME "$WILDCARD"
+       enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
        destroy_lttng_session_ok $SESSION_NAME
 
        rm -rf $TRACE_PATH
 }
 
-
 # MUST set TESTDIR before calling those functions
 plan_tests $NUM_TESTS
 
@@ -81,13 +91,48 @@ print_test_banner "$TEST_DESC"
 
 start_lttng_sessiond
 
-test_event_wildcard 1 'tp:tp*'
-test_event_wildcard 1 '*'
-test_event_wildcard 1 'tp:tptest*'
-test_event_wildcard 0 'tp:abc*'
+diag "Test UST wildcard"
+
+if [ ! -x "$TESTAPP_BIN" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
+EVENT_NAME="tp:tptest"
+
+test_event_wildcard ust 1 'tp:tp*'
+test_event_wildcard ust 1 '*'
+test_event_wildcard ust 1 'tp:tptest*'
+test_event_wildcard ust 0 'tp:abc*'
+
+test_event_wildcard_fail ust 'tp:*tp'
+test_event_wildcard_fail ust 'tp:tp**'
+test_event_wildcard_fail ust '*tp:tp*'
+
+
+if [ "$(id -u)" == "0" ]; then
+       isroot=1
+else
+       isroot=0
+fi
 
-test_event_wildcard_fail 'tp:*tp'
-test_event_wildcard_fail 'tp:tp**'
-test_event_wildcard_fail '*tp:tp*'
+skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
+{
+       diag "Test kernel wildcards"
+
+       modprobe lttng-test
+
+       EVENT_NAME="lttng_test_filter_event"
+
+       test_event_wildcard kernel 1 'lttng_test_*'
+       test_event_wildcard kernel 1 '*'
+       test_event_wildcard kernel 1 'lttng_test_filter_event*'
+       test_event_wildcard kernel 0 'lttng_test_asdfasdf*'
+
+       test_event_wildcard_fail kernel 'tp_*tp'
+       test_event_wildcard_fail kernel 'tp_tp**'
+       test_event_wildcard_fail kernel '*tp_tp*'
+
+       rmmod lttng-test
+}
 
 stop_lttng_sessiond
tests/utils/utils.sh +30 -8
index 1e1e791..d466ee6 100644
@@ -86,18 +86,19 @@ function randstring()
        echo
 }
 
-function lttng_enable_kernel_event
+function enable_kernel_lttng_event
 {
-       local sess_name=$1
-       local event_name=$2
-       local channel_name=$3
+       local expected_to_fail="$1"
+       local sess_name="$2"
+       local event_name="$3"
+       local channel_name="$4"
 
-       if [ -z $event_name ]; then
+       if [ -z "$event_name" ]; then
                # Enable all event if no event name specified
                event_name="-a"
        fi
 
-       if [ -z $channel_name ]; then
+       if [ -z "$channel_name" ]; then
                # default channel if none specified
                chan=""
        else
@@ -105,7 +106,29 @@ function lttng_enable_kernel_event
        fi
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
-       ok $? "Enable kernel event $event_name for session $sess_name"
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test $ret -ne "0"
+               ok $? "Enable kernel event $event_name for session $session_name on channel $channel_name failed as expected"
+       else
+               ok $ret "Enable kernel event $event_name for session $sess_name"
+       fi
+}
+
+function enable_kernel_lttng_event_ok ()
+{
+       enable_kernel_lttng_event 0 "$@"
+}
+
+function enable_kernel_lttng_event_fail ()
+{
+       enable_kernel_lttng_event 1 "$@"
+}
+
+# Old interface
+function lttng_enable_kernel_event
+{
+       enable_kernel_lttng_event_ok "$@"
 }
 
 function lttng_enable_kernel_syscall()
--
Quoted 2 lines

2.1.4

--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#6 lore raw

Re: [PATCH lttng-tools 1/2] Tests: expand UST wildcard tests, move to regression/tools

In reply to a message not in the archive

Merged, thanks!

Jérémie

Quoted 221 lines · Mathieu Desnoyers
---
 configure.ac                                       |  1 +
 tests/fast_regression                              |  2 +-
 tests/long_regression                              |  2 +-
 tests/regression/tools/Makefile.am                 |  3 +-
 tests/regression/tools/wildcard/Makefile.am        | 26 ++++++++++
 .../{ust => tools/wildcard}/test_event_wildcard    | 59 ++++++++++++++++------
 tests/regression/ust/Makefile.am                   |  2 +-
 7 files changed, 75 insertions(+), 20 deletions(-)
 create mode 100644 tests/regression/tools/wildcard/Makefile.am
 rename tests/regression/{ust => tools/wildcard}/test_event_wildcard (53%)
configure.ac +1 -0
index 55977bc..1266431 100644
@@ -518,6 +518,7 @@ AC_CONFIG_FILES([
        tests/regression/tools/exclusion/Makefile
        tests/regression/tools/save-load/Makefile
        tests/regression/tools/mi/Makefile
+       tests/regression/tools/wildcard/Makefile
        tests/regression/ust/Makefile
        tests/regression/ust/nprocesses/Makefile
        tests/regression/ust/high-throughput/Makefile
tests/fast_regression +1 -1
index fa88621..420fffb 100644
@@ -14,6 +14,7 @@ regression/tools/snapshots/test_ust_streaming
 regression/tools/save-load/test_save
 regression/tools/save-load/test_load
 regression/tools/mi/test_mi
+regression/tools/wildcard/test_event_wildcard
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/multi-session/test_multi_session
@@ -26,5 +27,4 @@ regression/ust/getcpu-override/test_getcpu_override
 regression/ust/clock-override/test_clock_override
 regression/ust/test_event_basic
 regression/ust/test_event_tracef
-regression/ust/test_event_wildcard
 regression/ust/test_event_perf
tests/long_regression +1 -1
index 1fa8514..105dc51 100644
@@ -8,6 +8,7 @@ regression/tools/streaming/test_ust
 regression/tools/snapshots/test_ust_long
 regression/tools/tracefile-limits/test_tracefile_count
 regression/tools/tracefile-limits/test_tracefile_size
+regression/tools/wildcard/test_event_wildcard
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/high-throughput/test_high_throughput
@@ -17,4 +18,3 @@ regression/ust/nprocesses/test_nprocesses
 regression/ust/overlap/test_overlap
 regression/ust/test_event_basic
 regression/ust/test_event_tracef
-regression/ust/test_event_wildcard
tests/regression/tools/Makefile.am +2 -1
index 09f55b3..a798de3 100644
@@ -1 +1,2 @@
-SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi
+SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi \
+               wildcard
tests/regression/tools/wildcard/Makefile.am new file +26 -0
new file mode 100644
index 0000000..b95b495
@@ -0,0 +1,26 @@
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests -I$(srcdir) -O2 -g
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+LIBS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+LIBS += -lc
+endif
+
+noinst_SCRIPTS = test_event_wildcard
+EXTRA_DIST = test_event_wildcard
+
+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
tests/regression/tools/wildcard/test_event_wildcard renamed from tests/regression/ust/test_event_wildcard +43 -16
similarity index 53%
rename from tests/regression/ust/test_event_wildcard
rename to tests/regression/tools/wildcard/test_event_wildcard
index 1c0b27a..7fbfc18 100755
@@ -1,6 +1,7 @@
 #!/bin/bash
 #
 # Copyright (C) - 2013 Christian Babeux <[email protected]>
+# Copyright (C) - 2015 Mathieu Desnoyers <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License, version 2 only, as
@@ -20,40 +21,59 @@ TEST_DESC="UST tracer - Event wildcard"
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
 LTTNG_BIN="lttng"
-BIN_NAME="gen-ust-events"
-SESSION_NAME="valid_filter"
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+SESSION_NAME="wildcard"
 EVENT_NAME="tp:tptest"
-NUM_TESTS=9
+NUM_TESTS=39
+NR_ITER=100
 
 source $TESTDIR/utils/utils.sh
 
+if [ ! -x "$TESTAPP_BIN" ]; then
+       BAIL_OUT "No UST nevents binary detected."
+fi
+
 function test_event_wildcard()
 {
        TRACE_PATH=$(mktemp -d)
-       SESSION_NAME="ust_event_basic"
-       SESSION_NAME2="ust_event_basic2"
-       CHAN_NAME="mychan"
-       CHAN_NAME2="mychan2"
-       EVENT_NAME="*"
-       EVENT_NAME2="abc*"
+       FIND="${1}"
+       WILDCARD="${2}"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
-
-       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
-       enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME2"
+       enable_ust_lttng_event_ok $SESSION_NAME "$WILDCARD"
 
        start_lttng_tracing_ok
+
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
+       ok $? "Traced application stopped."
+
        stop_lttng_tracing_ok
+       destroy_lttng_session_ok $SESSION_NAME
+
+       if [ ${FIND} -eq 1 ]; then
+               trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       else
+               validate_trace_empty $TRACE_PATH
+       fi
+
+       rm -rf $TRACE_PATH
+}
 
-       TODO="Validate trace output is coherent"
-       ok 0 "Validate trace"
-       unset TODO
+function test_event_wildcard_fail()
+{
+       TRACE_PATH=$(mktemp -d)
+       WILDCARD="${1}"
 
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event_fail $SESSION_NAME "$WILDCARD"
        destroy_lttng_session_ok $SESSION_NAME
 
        rm -rf $TRACE_PATH
 }
 
+
 # MUST set TESTDIR before calling those functions
 plan_tests $NUM_TESTS
 
@@ -61,6 +81,13 @@ print_test_banner "$TEST_DESC"
 
 start_lttng_sessiond
 
-test_event_wildcard
+test_event_wildcard 1 'tp:tp*'
+test_event_wildcard 1 '*'
+test_event_wildcard 1 'tp:tptest*'
+test_event_wildcard 0 'tp:abc*'
+
+test_event_wildcard_fail 'tp:*tp'
+test_event_wildcard_fail 'tp:tp**'
+test_event_wildcard_fail '*tp:tp*'
 
 stop_lttng_sessiond
tests/regression/ust/Makefile.am +1 -2
index 2616dc7..f2afad5 100644
@@ -4,7 +4,7 @@ SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
                periodical-metadata-flush java-jul java-log4j python-logging \
                getcpu-override clock-override
 
-EXTRA_DIST = test_event_basic test_event_wildcard test_event_tracef test_event_perf
+EXTRA_DIST = test_event_basic test_event_tracef test_event_perf
 
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
--

2.1.4

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev