X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Ffiltering%2Ftest_invalid_filter;h=ebf4c3bb1df7c1e1c96cc9bc2a0afe5b89f394de;hp=c639ff172672b52154e8586586a7506a72340425;hb=e0bd0ea37926566b1518e894f624d78e9526337f;hpb=bf6ae429bc7bf2fefdce61e48806768dab7567d5 diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter index c639ff172..ebf4c3bb1 100755 --- a/tests/regression/tools/filtering/test_invalid_filter +++ b/tests/regression/tools/filtering/test_invalid_filter @@ -24,17 +24,22 @@ SESSION_NAME="filter-invalid" EVENT_NAME="bogus" ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr" TRACE_PATH=$(mktemp -d) -NUM_TESTS=146 +NUM_GLOBAL_TESTS=2 +NUM_UST_TESTS=123 +NUM_KERNEL_TESTS=123 +NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS)) source $TESTDIR/utils/utils.sh -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> $ENABLE_EVENT_STDERR 1> /dev/null + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name \ + $domain --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null # Enable must fail if [ $? -eq 0 ]; then @@ -48,7 +53,8 @@ function enable_ust_lttng_event_filter function test_invalid_filter { - test_invalid_filter="$1" + domain="$1" + test_invalid_filter="$2" diag "Test filter expression with invalid filter" diag "Filter: $test_invalid_filter" @@ -57,14 +63,16 @@ function test_invalid_filter create_lttng_session_ok $SESSION_NAME $TRACE_PATH # Apply filter - enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$test_invalid_filter" + enable_lttng_event_filter $domain $SESSION_NAME $EVENT_NAME "$test_invalid_filter" # Destroy session - destroy_lttng_session $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME } function test_bytecode_limit { + domain="$1" + # Current bytecode limitation is 65536 bytes long. # Generate a huge bytecode with some perl-fu BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'` @@ -75,16 +83,17 @@ function test_bytecode_limit create_lttng_session_ok $SESSION_NAME $TRACE_PATH # Apply filter - enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT" + enable_lttng_event_filter $domain $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT" # Destroy session - destroy_lttng_session $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME } plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +OLDIFS="$IFS" IFS=$'\n' INVALID_FILTERS=( # Unsupported ops @@ -109,14 +118,10 @@ INVALID_FILTERS=( # Unmatched parenthesis "((((((((((((((intfield)))))))))))))" '0 || ("abc" != "def")) && (3 < 4)' - # Field dereference - "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" "a->" "a-->a" "a->a" "a.b.c->d.e.f+1" - "!a.f.d" - "asdf.asdfsd.sadf < 4" "asdfasdf->asdfasdf < 2" # String can\'t be root node "\"somestring\"" @@ -133,11 +138,6 @@ INVALID_FILTERS=( # Nesting of binary operator not allowed "1 | (1 | (1 | 1))" "1 > (1 > (1 > 1))" - # Exactly one chaining level under \$ctx allowed - "\$ctx.vtid.blah == 0" - "0 == \$ctx.vtid.blah" - "\$ctx.44 == 0" - "0 == \$ctx.44" "\$ctx == 0" "0 == \$ctx" # Only \$ctx is supported for now @@ -145,17 +145,39 @@ INVALID_FILTERS=( "0 == \$global.value" # A wildcard should only appear as the last character in a string literal "msg == \"my_event*_blah\"" - ) +) +IFS="$OLDIFS" start_lttng_sessiond -for FILTER in ${INVALID_FILTERS[@]}; -do - test_invalid_filter "$FILTER" +diag "Test UST filters" + +i=0 +while [ "$i" -lt "${#INVALID_FILTERS[@]}" ]; do + echo "${INVALID_FILTERS[$i]}" + test_invalid_filter -u "${INVALID_FILTERS[$i]}" + let "i++" done -test_bytecode_limit +test_bytecode_limit -u + +if [ "$(id -u)" == "0" ]; then + isroot=1 +else + isroot=0 +fi -unset IFS +skip $isroot "Root access is needed. Skipping all kernel invalid filter tests." $NUM_KERNEL_TESTS || +{ + diag "Test kernel filters" + i=0 + while [ "$i" -lt "${#INVALID_FILTERS[@]}" ]; do + echo "${INVALID_FILTERS[$i]}" + test_invalid_filter -k "${INVALID_FILTERS[$i]}" + let "i++" + done + + test_bytecode_limit -k +} stop_lttng_sessiond rm -f $ENABLE_EVENT_STDERR