Refactor: test: wrapper for destroy_lttng_session
[lttng-tools.git] / tests / regression / tools / filtering / test_invalid_filter
index 48db698ddf7b0f135591c67fc58cc2aa9ca02024..4ba4b8b400999e0a1971b9129e8b10f70d36d1fd 100755 (executable)
@@ -24,26 +24,24 @@ SESSION_NAME="filter-invalid"
 EVENT_NAME="bogus"
 ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr"
 TRACE_PATH=$(mktemp -d)
+NUM_TESTS=146
 
 source $TESTDIR/utils/utils.sh
 
-print_test_banner "$TEST_DESC"
-
 function enable_ust_lttng_event_filter
 {
        sess_name="$1"
        event_name="$2"
        filter="$3"
-       echo -n "Enabling lttng event with filtering and invalid filter "
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
 
        # Enable must fail
        if [ $? -eq 0 ]; then
-               print_fail
+               fail "Enable lttng event with filtering and invalid filter"
                return 1
        else
-               print_ok
+               pass "Enable lttng event with filtering and invalid filter"
                return 0
        fi
 }
@@ -52,18 +50,17 @@ function test_invalid_filter
 {
        test_invalid_filter="$1"
 
-       echo ""
-       echo -e "=== Testing filter expression with invalid filter"
-       echo -e "Filter: $test_invalid_filter"
+       diag "Test filter expression with invalid filter"
+       diag "Filter: $test_invalid_filter"
 
        # Create session
-       create_lttng_session $SESSION_NAME $TRACE_PATH
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
 
        # Apply filter
        enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$test_invalid_filter"
 
        # Destroy session
-       destroy_lttng_session $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME
 }
 
 function test_bytecode_limit
@@ -72,19 +69,22 @@ function test_bytecode_limit
        # Generate a huge bytecode with some perl-fu
        BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'`
 
-       echo ""
-       echo -e "=== Testing filter bytecode limits (64KiB)"
+       diag "Test filter bytecode limits (64KiB)"
 
        # Create session
-       create_lttng_session $SESSION_NAME $TRACE_PATH
+       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
 
        # Apply filter
        enable_ust_lttng_event_filter $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"
+
 IFS=$'\n'
 INVALID_FILTERS=(
                # Unsupported ops
@@ -118,7 +118,7 @@ INVALID_FILTERS=(
                "!a.f.d"
                "asdf.asdfsd.sadf < 4"
                "asdfasdf->asdfasdf < 2"
-               # String can't be root node
+               # String can\'t be root node
                "\"somestring\""
                # Unary op on string not allowed
                "!\"somestring\""
@@ -133,6 +133,18 @@ 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
+               "\$global.value == 0"
+               "0 == \$global.value"
+               # A wildcard should only appear as the last character in a string literal
+               "msg == \"my_event*_blah\""
                )
 
 start_lttng_sessiond
This page took 0.024821 seconds and 4 git commands to generate.