X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ffiltering%2Ftest_valid_filter;h=0a3a5a4436a0e5b071981674dc9511cad30130b4;hp=df4eb47e3687a6245488c9b5c8bcd443538ee176;hb=5da9cf86d63bcb9d4d077155efc707048df4fd0c;hpb=67b4c664e2c6c6dc19920555c0abf094ed6cbe00 diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter index df4eb47e3..0a3a5a443 100755 --- a/tests/regression/tools/filtering/test_valid_filter +++ b/tests/regression/tools/filtering/test_valid_filter @@ -20,41 +20,51 @@ TEST_DESC="Filtering - Valid filters" CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. LTTNG_BIN="lttng" -BIN_NAME="gen-ust-events" STATS_BIN="$TESTDIR/utils/babelstats.pl" SESSION_NAME="valid_filter" -EVENT_NAME="tp:tptest" NR_ITER=100 -NUM_TESTS=290 +NUM_GLOBAL_TESTS=2 +NUM_UST_TESTS=330 +NUM_KERNEL_TESTS=330 +NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS)) source $TESTDIR/utils/utils.sh -if [ ! -x "$CURDIR/$BIN_NAME" ]; then - BAIL_OUT "No UST nevents binary detected." -fi - -function enable_ust_lttng_event_filter() +function enable_lttng_event_filter() { - sess_name="$1" - event_name="$2" - filter="$3" + domain="$1" + sess_name="$2" + event_name="$3" + filter="$4" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name \ + -s $sess_name $domain --filter "$filter" 2>&1 >/dev/null + $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context \ + -s $sess_name $domain -t procname 2>&1 >/dev/null ok $? "Enable lttng event with filtering" } -function run_apps +function run_ust { ./$CURDIR/$BIN_NAME $NR_ITER >/dev/null 2>&1 } +function run_kernel +{ + # Trigger the event for 100 iterations + echo -n "100" > /proc/lttng-test-filter-event +} + function test_valid_filter { - filter="$1" - validator="$2" + domain_name="$1" + domain="$2" + event_name="$3" + filter="$4" + validator="$5" - diag "Test valid filter: $1" + diag "Test valid $domain_name filter: $filter" trace_path=$(mktemp -d) @@ -62,17 +72,17 @@ function test_valid_filter create_lttng_session_ok $SESSION_NAME $trace_path # Enable filter - enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter + enable_lttng_event_filter $domain $SESSION_NAME $event_name $filter # Trace apps start_lttng_tracing_ok $SESSION_NAME - run_apps + run_$domain_name stop_lttng_tracing_ok $SESSION_NAME # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $EVENT_NAME` + stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name` rm -rf $trace_path @@ -115,11 +125,13 @@ function validator_intfield validate_min_max "$stats" "netintfieldhex" "0x1" "0x63" status=$(($status|$?)) - validate_min_max "$stats" "floatfield" "2222" "2222" - status=$(($status|$?)) + if [ $KERNEL_CHECK -eq 0 ]; then + validate_min_max "$stats" "floatfield" "2222" "2222" + status=$(($status|$?)) - validate_min_max "$stats" "doublefield" "2" "2" - status=$(($status|$?)) + validate_min_max "$stats" "doublefield" "2" "2" + status=$(($status|$?)) + fi return $status } @@ -311,11 +323,13 @@ function validator_true_statement validate_min_max "$stats" "netintfieldhex" "0x0" "0x63" status=$(($status|$?)) - validate_min_max "$stats" "floatfield" "2222" "2222" - status=$(($status|$?)) + if [ $KERNEL_CHECK -eq 0 ]; then + validate_min_max "$stats" "floatfield" "2222" "2222" + status=$(($status|$?)) - validate_min_max "$stats" "doublefield" "2" "2" - status=$(($status|$?)) + validate_min_max "$stats" "doublefield" "2" "2" + status=$(($status|$?)) + fi validate_min_max "$stats" "stringfield" "\"test\"" "\"test\"" status=$(($status|$?)) @@ -338,9 +352,15 @@ issue_356_filter+="intfield > 4 && intfield > 5 && " issue_356_filter+="intfield > 6 && intfield > 7 && " issue_356_filter+="intfield > 8 || intfield > 0" +start_lttng_sessiond + +### UST TESTS + +BIN_NAME="gen-ust-events" + # One to one mapping between filters and validators -FILTERS=("intfield" #1 +UST_FILTERS=("intfield" #1 "intfield > 1" #2 "intfield >= 1" #3 "intfield < 2" #4 @@ -388,9 +408,22 @@ FILTERS=("intfield" #1 "\$ctx.procname == \"*\"" #46 "\"*\" != \$ctx.procname" #47 "\"*\" == \$ctx.procname" #48 + "!a.f.d" #49 + "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" #50 + "\$ctx.vtid.blah == 0" #51 + "asdf.asdfsd.sadf < 4" #52 + "0 == \$ctx.vtid.blah" #53 + "\$ctx.44 == 0" #54 + "0 == \$ctx.44" #55 ) -VALIDATOR=("validator_intfield" #1 +UST_FILTER_COUNT=${#UST_FILTERS[@]} + +if [ ! -x "$CURDIR/$BIN_NAME" ]; then + BAIL_OUT "No UST nevents binary detected." +fi + +UST_VALIDATOR=("validator_intfield" #1 "validator_intfield_gt" #2 "validator_intfield_ge" #3 "validator_intfield_lt" #4 @@ -438,16 +471,22 @@ VALIDATOR=("validator_intfield" #1 "validator_has_events" #46 "validator_has_no_event" #47 "validator_has_events" #48 + "validator_has_no_event" #49 + "validator_has_no_event" #50 + "validator_has_no_event" #51 + "validator_has_no_event" #52 + "validator_has_no_event" #53 + "validator_has_no_event" #54 + "validator_has_no_event" #55 ) -FILTER_COUNT=${#FILTERS[@]} -i=0 - -start_lttng_sessiond +diag "Test UST valid filters" -while [ "$i" -lt "$FILTER_COUNT" ]; do +KERNEL_CHECK=0 +i=0 +while [ "$i" -lt "$UST_FILTER_COUNT" ]; do - test_valid_filter "${FILTERS[$i]}" "${VALIDATOR[$i]}" + test_valid_filter ust -u "tp:tptest" "${UST_FILTERS[$i]}" "${UST_VALIDATOR[$i]}" if [ $? -eq 1 ]; then stop_lttng_sessiond @@ -457,4 +496,155 @@ while [ "$i" -lt "$FILTER_COUNT" ]; do let "i++" done + +### KERNEL TESTS + +BIN_NAME="test_valid_filt" # Current script name truncated by kernel + +# One to one mapping between filters and validators + +KERNEL_FILTERS=("intfield" #1 + "intfield > 1" #2 + "intfield >= 1" #3 + "intfield < 2" #4 + "intfield <= 2" #5 + "intfield == 1" #6 + "intfield != 99" #7 + "!intfield" #8 + "-intfield" #9 + "--intfield" #10 + "+intfield" #11 + "++intfield" #12 + "intfield > 1 && longfield > 42" #13 + "intfield >= 42 && longfield <= 42" #14 + "intfield < 1 || longfield > 98" #15 + "(stringfield == \"test\" || intfield != 10) && intfield > 33" #16 + "intfield < 42.4242424242" #17 + "\"test\" == \"test\"" #18 #Issue #342 + "stringfield == \"test\"" #19 + "stringfield == \"t*\"" #20 + "stringfield == \"*\"" #21 + $issue_356_filter #22 #Issue #356 + "intfield < 0xDEADBEEF" #23 + "intfield < 0x2" #24 + "intfield < 02" #25 + "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 + "!a.f.d" #49 + "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" #50 + "\$ctx.vtid.blah == 0" #51 + "asdf.asdfsd.sadf < 4" #52 + "0 == \$ctx.vtid.blah" #53 + "\$ctx.44 == 0" #54 + "0 == \$ctx.44" #55 +) + +KERNEL_FILTER_COUNT=${#KERNEL_FILTERS[@]} + +KERNEL_VALIDATOR=("validator_intfield" #1 + "validator_intfield_gt" #2 + "validator_intfield_ge" #3 + "validator_intfield_lt" #4 + "validator_intfield_le" #5 + "validator_intfield_eq" #6 + "validator_intfield_ne" #7 + "validator_intfield_not" #8 + "validator_intfield" #9 + "validator_intfield" #10 + "validator_intfield" #11 + "validator_intfield" #12 + "validator_intfield_gt_and_longfield_gt" #13 + "validator_intfield_ge_and_longfield_le" #14 + "validator_intfield_lt_or_longfield_gt" #15 + "validator_mixed_str_or_int_and_int" #16 + "validator_has_no_event" #17 #Unsupported by kernel + "validator_true_statement" #18 + "validator_true_statement" #19 + "validator_true_statement" #20 + "validator_true_statement" #21 + "validator_intfield" #22 + "validator_true_statement" #23 + "validator_intfield_lt" #24 + "validator_intfield_lt" #25 + "validator_true_statement" #26 + "validator_has_no_event" #27 #Unsupported by kernel + "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 + "validator_has_no_event" #49 + "validator_has_no_event" #50 + "validator_has_no_event" #51 + "validator_has_no_event" #52 + "validator_has_no_event" #53 + "validator_has_no_event" #54 + "validator_has_no_event" #55 +) + +if [ "$(id -u)" == "0" ]; then + isroot=1 +else + isroot=0 +fi + +skip $isroot "Root access is needed. Skipping all kernel valid filter tests." $NUM_KERNEL_TESTS || +{ + diag "Test kernel valid filters" + + KERNEL_CHECK=1 + modprobe lttng-test + i=0 + while [ "$i" -lt "$KERNEL_FILTER_COUNT" ]; do + + test_valid_filter kernel -k "lttng_test_filter_event" \ + "${KERNEL_FILTERS[$i]}" "${KERNEL_VALIDATOR[$i]}" + + if [ $? -eq 1 ]; then + stop_lttng_sessiond + exit 1 + fi + + let "i++" + done + rmmod lttng-test +} + stop_lttng_sessiond