Tests: Convert the tools filtering tests output to TAP
authorChristian Babeux <christian.babeux@efficios.com>
Fri, 22 Feb 2013 04:15:25 +0000 (23:15 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Fri, 22 Feb 2013 18:00:30 +0000 (13:00 -0500)
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
tests/regression/tools/filtering/test_invalid_filter
tests/regression/tools/filtering/test_unsupported_op
tests/regression/tools/filtering/test_valid_filter

index 48db698ddf7b0f135591c67fc58cc2aa9ca02024..700fa236940117fda9d85b78a272fef1a52cbb33 100755 (executable)
@@ -24,6 +24,7 @@ SESSION_NAME="filter-invalid"
 EVENT_NAME="bogus"
 ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr"
 TRACE_PATH=$(mktemp -d)
+NUM_TESTS=119
 
 source $TESTDIR/utils/utils.sh
 
@@ -34,16 +35,15 @@ 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,9 +52,8 @@ 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
@@ -72,8 +71,7 @@ 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
@@ -85,6 +83,8 @@ function test_bytecode_limit
        destroy_lttng_session $SESSION_NAME
 }
 
+plan_tests $NUM_TESTS
+
 IFS=$'\n'
 INVALID_FILTERS=(
                # Unsupported ops
index 9fac9dec82408e7ab3b5b3f8e02c086ac3d4d001..d0c6c862027a1a69ac47b2fb04d7dbea43d7d2b0 100755 (executable)
@@ -24,7 +24,7 @@ SESSION_NAME="filter-unsupported-ops"
 EVENT_NAME="bogus"
 ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable"
 TRACE_PATH=$(mktemp -d)
-
+NUM_TESTS=46
 source $TESTDIR/utils/utils.sh
 
 print_test_banner "$TEST_DESC"
@@ -35,16 +35,15 @@ function enable_ust_lttng_event_filter_unsupported
        event_name=$2
        filter=$3
 
-       echo -n "Enabling lttng event with filtering and unsupported operator "
        enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event"
        $enable_cmd $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 unsupported operator"
                return 1
        else
-               print_ok
+               pass "Enable lttng event with filtering and unsupported operator"
                return 0
        fi
 }
@@ -54,8 +53,7 @@ function test_unsupported_op
        test_op_str=$1
        test_op_tkn=$2
 
-       echo ""
-       echo -e "=== Testing filter expression with unsupported operator $test_op_str ($test_op_tkn)"
+       diag "Test filter expression with unsupported operator $test_op_str ($test_op_tkn)"
 
        # Create session
        create_lttng_session $SESSION_NAME $TRACE_PATH
@@ -71,14 +69,14 @@ function test_unsupported_op
        enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER"
 
        # Test stderr for unsupported operator
-       echo -n "Unsupported operator test $test_op_str ($test_op_tkn) "
+
        grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
 
        if [ $? -eq 1 ]; then
-               print_fail
+               fail "Unsupported operator test $test_op_str ($test_op_tkn)"
                return 1
        else
-               print_ok
+               pass "Unsupported operator test $test_op_str ($test_op_tkn)"
        fi
 
        # Destroy session
@@ -86,6 +84,8 @@ function test_unsupported_op
        return 0
 }
 
+plan_tests $NUM_TESTS
+
 # Unsupported operators
 OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
        "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
index 067d205e7c654efa2c2295230494051379b425f5..09ac8689e706a24807a0d7aef2a5a3cb3b02c2f9 100755 (executable)
@@ -25,14 +25,14 @@ STATS_BIN="babelstats.pl"
 SESSION_NAME="valid_filter"
 EVENT_NAME="tp:tptest"
 NR_ITER=100
+NUM_TESTS=198
 
 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,17 +40,10 @@ 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
@@ -60,12 +53,10 @@ function run_apps
 
 function wait_apps
 {
-       echo "Waiting for applications to end"
        while [ -n "$(pidof $BIN_NAME)" ]; do
-               echo -n "."
                sleep 1
        done
-       echo ""
+       pass "Wait for application end"
 }
 
 function test_valid_filter
@@ -73,8 +64,7 @@ function test_valid_filter
        filter="$1"
        validator="$2"
 
-       echo ""
-       echo -e "=== Testing valid filter: $1"
+       diag "Test valid filter: $1"
 
        trace_path=$(mktemp -d)
 
@@ -93,21 +83,15 @@ function test_valid_filter
        # Destroy session
        destroy_lttng_session $SESSION_NAME
 
-       echo -n "Validating filter output "
        stats=`babeltrace $trace_path | $CURDIR/$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
@@ -327,6 +311,8 @@ function validator_true_statement
        return $status
 }
 
+plan_tests $NUM_TESTS
+
 IFS=$'\n'
 
 issue_356_filter="intfield > 0 && intfield > 1 && "
This page took 0.028636 seconds and 4 git commands to generate.