X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ffiltering%2Ftest_valid_filter;h=9a9e31c83aaea4b64f6e8e9ad18e660a1f40e1d4;hp=067d205e7c654efa2c2295230494051379b425f5;hb=e563bbdb8fa6592790e9ac4e9db7d9decf022023;hpb=ef8343605f92072ca2ed7174b0cc2594ee33dfab diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter index 067d205e7..9a9e31c83 100755 --- a/tests/regression/tools/filtering/test_valid_filter +++ b/tests/regression/tools/filtering/test_valid_filter @@ -21,18 +21,16 @@ CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. LTTNG_BIN="lttng" BIN_NAME="gen-ust-events" -STATS_BIN="babelstats.pl" +STATS_BIN="$TESTDIR/utils/babelstats.pl" SESSION_NAME="valid_filter" EVENT_NAME="tp:tptest" NR_ITER=100 +NUM_TESTS=290 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then - echo -e "No UST nevents binary detected. Passing." - exit 0 + BAIL_OUT "No UST nevents binary detected." fi function enable_ust_lttng_event_filter() @@ -40,32 +38,15 @@ function enable_ust_lttng_event_filter() sess_name="$1" event_name="$2" filter="$3" - echo -n "Enabling lttng event with filtering " $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null - if [ $? -eq 0 ]; then - print_ok - return 0 - else - print_fail - return 1 - fi + ok $? "Enable lttng event with filtering" } function run_apps { - ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1 -} - -function wait_apps -{ - echo "Waiting for applications to end" - while [ -n "$(pidof $BIN_NAME)" ]; do - echo -n "." - sleep 1 - done - echo "" + ./$CURDIR/$BIN_NAME $NR_ITER >/dev/null 2>&1 } function test_valid_filter @@ -73,41 +54,33 @@ function test_valid_filter filter="$1" validator="$2" - echo "" - echo -e "=== Testing valid filter: $1" + diag "Test valid filter: $1" trace_path=$(mktemp -d) # Create session - create_lttng_session $SESSION_NAME $trace_path + create_lttng_session_ok $SESSION_NAME $trace_path # Enable filter enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter # Trace apps - start_lttng_tracing $SESSION_NAME + start_lttng_tracing_ok $SESSION_NAME run_apps - wait_apps stop_lttng_tracing $SESSION_NAME # Destroy session destroy_lttng_session $SESSION_NAME - echo -n "Validating filter output " - stats=`babeltrace $trace_path | $CURDIR/$STATS_BIN --tracepoint $EVENT_NAME` + stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $EVENT_NAME` rm -rf $trace_path $validator "$stats" - if [ $? -eq 0 ]; then - print_ok -# rm -rf $trace_path - return 0 - else - print_fail - return 1 - fi + ok $? "Validate trace filter output" + + rm -rf $trace_path } function validate_min_max @@ -162,6 +135,32 @@ function validator_intfield_gt return $status } +function validator_has_no_event +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "99" + status=$(($status|$?)) + + if [ $status -eq 0 ]; then + return 1 + else + return 0 + fi +} + +function validator_has_events +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "99" + status=$(($status|$?)) + + return $status +} + function validator_intfield_ge { stats="$1" @@ -327,6 +326,10 @@ function validator_true_statement return $status } +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + IFS=$'\n' issue_356_filter="intfield > 0 && intfield > 1 && " @@ -365,6 +368,26 @@ FILTERS=("intfield" #1 "stringfield2 == \"\\\*\"" #26 "1.0 || intfield || 1.0" #27 "1 < intfield" #28 + "\$ctx.vtid == 0" #29 + "\$ctx.vtid != 0" #30 + "0 == \$ctx.vtid" #31 + "0 != \$ctx.vtid" #32 + "\$ctx.vpid == 0" #33 + "\$ctx.vpid != 0" #34 + "0 == \$ctx.vpid" #35 + "0 != \$ctx.vpid" #36 + "\$ctx.procname != \"$BIN_NAME\"" #37 + "\$ctx.procname == \"$BIN_NAME\"" #38 + "\"$BIN_NAME\" != \$ctx.procname" #39 + "\"$BIN_NAME\" == \$ctx.procname" #40 + "\$ctx.procname != \"$BIN_NAME*\"" #41 + "\$ctx.procname == \"$BIN_NAME*\"" #42 + "\"$BIN_NAME*\" != \$ctx.procname" #43 + "\"$BIN_NAME*\" == \$ctx.procname" #44 + "\$ctx.procname != \"*\"" #45 + "\$ctx.procname == \"*\"" #46 + "\"*\" != \$ctx.procname" #47 + "\"*\" == \$ctx.procname" #48 ) VALIDATOR=("validator_intfield" #1 @@ -395,6 +418,26 @@ VALIDATOR=("validator_intfield" #1 "validator_true_statement" #26 "validator_true_statement" #27 "validator_intfield_gt" #28 + "validator_has_no_event" #29 + "validator_has_events" #30 + "validator_has_no_event" #31 + "validator_has_events" #32 + "validator_has_no_event" #33 + "validator_has_events" #34 + "validator_has_no_event" #35 + "validator_has_events" #36 + "validator_has_no_event" #36 + "validator_has_events" #37 + "validator_has_no_event" #38 + "validator_has_events" #39 + "validator_has_no_event" #41 + "validator_has_events" #42 + "validator_has_no_event" #43 + "validator_has_events" #44 + "validator_has_no_event" #45 + "validator_has_events" #46 + "validator_has_no_event" #47 + "validator_has_events" #48 ) FILTER_COUNT=${#FILTERS[@]}