From: David Goulet Date: Wed, 3 Sep 2014 18:21:41 +0000 (-0400) Subject: Test: add match only event utils function X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=d53addeb964039ae2f544de1d7d452fb5ad6da69;hp=eb82f91d0a44a7c51781d261a6b50d804246ff1e;p=lttng-tools.git Test: add match only event utils function 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 --- diff --git a/tests/regression/tools/live/test_lttng_ust b/tests/regression/tools/live/test_lttng_ust index 8a1aec639..da9bf9e66 100755 --- a/tests/regression/tools/live/test_lttng_ust +++ b/tests/regression/tools/live/test_lttng_ust @@ -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 diff --git a/tests/regression/ust/before-after/test_before_after b/tests/regression/ust/before-after/test_before_after index 66858517a..112f41a57 100755 --- a/tests/regression/ust/before-after/test_before_after +++ b/tests/regression/ust/before-after/test_before_after @@ -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 $? } diff --git a/tests/regression/ust/buffers-pid/test_buffers_pid b/tests/regression/ust/buffers-pid/test_buffers_pid index 6fab526c1..c7ee2d86c 100755 --- a/tests/regression/ust/buffers-pid/test_buffers_pid +++ b/tests/regression/ust/buffers-pid/test_buffers_pid @@ -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 diff --git a/tests/regression/ust/java-jul/test_java_jul b/tests/regression/ust/java-jul/test_java_jul index 9efda3915..dc6e677f3 100755 --- a/tests/regression/ust/java-jul/test_java_jul +++ b/tests/regression/ust/java-jul/test_java_jul @@ -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 diff --git a/tests/regression/ust/test_event_tracef b/tests/regression/ust/test_event_tracef index 66528d154..c615b48d2 100755 --- a/tests/regression/ust/test_event_tracef +++ b/tests/regression/ust/test_event_tracef @@ -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 $? } diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 4b081a48b..fe552830c 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -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