Test: add match only event utils function
authorDavid Goulet <dgoulet@efficios.com>
Wed, 3 Sep 2014 18:21:41 +0000 (14:21 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 3 Sep 2014 18:21:46 +0000 (14:21 -0400)
This is linked to #831 where the JUL disable event test was NOT failing
but was using a bogus trace match function. It should have match a
specific number of event only.

This commit makes the test java JUL fail.

Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/regression/tools/live/test_lttng_ust
tests/regression/ust/before-after/test_before_after
tests/regression/ust/buffers-pid/test_buffers_pid
tests/regression/ust/java-jul/test_java_jul
tests/regression/ust/test_event_tracef
tests/utils/utils.sh

index 8a1aec639aafad4f1f6d366f6b5dc3ad7dcd1e91..da9bf9e6649043765008dc9a5bbe197373e02a65 100755 (executable)
@@ -82,7 +82,7 @@ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
 
 clean_live_tracing
 
-trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
 rm -rf $TRACE_PATH
 stop_lttng_relayd
 
index 66858517a6b38c2d7f18e7954d0f25c94e63b036..112f41a577b55b6c1e038efff28ba03a504d1da3 100755 (executable)
@@ -48,7 +48,7 @@ function test_before_apps()
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
 
        return $?
 }
index 6fab526c111c88ec3a7d5a3e43c5f20e00566de7..c7ee2d86c784f02fa0b1e3a8ac366c762c99bf88 100755 (executable)
@@ -73,7 +73,7 @@ test_after_multiple_apps() {
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
+       trace_match_only $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
 
        return $?
 }
@@ -134,7 +134,7 @@ test_after_app() {
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
 
        return $?
 }
@@ -203,7 +203,7 @@ test_multiple_channels() {
        ok $? "Start application to trace"
 
        stop_lttng_tracing $SESSION_NAME
-       trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
+       trace_match_only $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
        out=$?
 
        destroy_lttng_session $SESSION_NAME
index 9efda3915de38666cd870f04f2a3f2d527dc73fa..dc6e677f30a2966ac36c900d70779bd53693301f 100755 (executable)
@@ -94,7 +94,7 @@ function test_jul_before_start ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -115,7 +115,7 @@ function test_jul_after_start ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -136,7 +136,7 @@ function test_jul_loglevel ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -154,7 +154,7 @@ function test_jul_loglevel ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting 0 events.
-       trace_matches $EVENT_NAME 0 $TRACE_PATH
+       trace_match_only $EVENT_NAME 0 $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -172,7 +172,7 @@ function test_jul_loglevel ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
        return $?
 }
 
@@ -192,7 +192,7 @@ function test_jul_loglevel_multiple ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events times two.
-       trace_matches $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
+       trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -209,7 +209,7 @@ function test_jul_loglevel_multiple ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events times two.
-       trace_matches $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
+       trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -236,13 +236,13 @@ function test_jul_multi_session_loglevel()
        destroy_lttng_session $SESSION_NAME-2
 
        # Expecting 6 events being the main event plus the second tp.
-       trace_matches $EVENT_NAME $(($NR_ITER + 1)) $TRACE_PATH/$SESSION_NAME-1
+       trace_match_only $EVENT_NAME $(($NR_ITER + 1)) $TRACE_PATH/$SESSION_NAME-1
        if [ $? -ne 0 ]; then
                return $?
        fi
 
        # Expectin 5 events being the finest TP.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -271,13 +271,13 @@ function test_jul_multi_session_disable()
        destroy_lttng_session $SESSION_NAME-2
 
        # Validate test. Expecting one event of the second TP.
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1
        if [ $? -ne 0 ]; then
                return $?
        fi
 
        # Validate test. Expecting one event of the second TP.
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -304,13 +304,13 @@ function test_jul_multi_session()
        destroy_lttng_session $SESSION_NAME-2
 
        # Validate test. Expecting all events of first TP
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1
        if [ $? -ne 0 ]; then
                return $?
        fi
 
        # Validate test. Expecting one event of the second TP.
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -349,7 +349,7 @@ function test_jul_destroy_session()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting only one event num 2
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/second-sess
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -371,7 +371,7 @@ function test_jul_filtering()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting one event of the second TP only.
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -389,7 +389,7 @@ function test_jul_filtering()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting NR_ITER event of the main INFO tp.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -413,7 +413,7 @@ function test_jul_disable()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting one event of the second TP only.
-       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -437,7 +437,7 @@ function test_jul_disable_enable()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting NR_ITER event of the main INFO tp.
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
        if [ $? -ne 0 ]; then
                return $?
        fi
index 66528d154cb06086aaddc546a2c0a457cdab4dfd..c615b48d2e2659caf03fc22a1ae5b4d7cf597bf3 100755 (executable)
@@ -47,7 +47,7 @@ function test_event_tracef()
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
 
        return $?
 }
index 4b081a48ba365198b68a8873ae5964f0c1fb202c..fe552830cf5d89b9e73e29e13f6e2e96b0d5a04c 100644 (file)
@@ -539,6 +539,26 @@ function trace_matches ()
        fi
 }
 
+function trace_match_only()
+{
+       local event_name=$1
+       local nr_iter=$2
+       local trace_path=$3
+
+       which $BABELTRACE_BIN >/dev/null
+       skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+       local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+       local total=$($BABELTRACE_BIN $trace_path | wc -l)
+
+    if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
+        pass "Trace match with $total event $event_name"
+    else
+        fail "Trace match"
+        diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
+    fi
+}
+
 function validate_trace
 {
        local event_name=$1
This page took 0.030829 seconds and 4 git commands to generate.