From: Christian Babeux Date: Fri, 22 Feb 2013 04:11:53 +0000 (-0500) Subject: Tests: Rename the tools tests runners to test_ X-Git-Tag: v2.2.0-rc1~60^2~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ef8343605f92072ca2ed7174b0cc2594ee33dfab;p=lttng-tools.git Tests: Rename the tools tests runners to test_ Signed-off-by: Christian Babeux --- diff --git a/tests/regression/tools/filtering/Makefile.am b/tests/regression/tools/filtering/Makefile.am index e1e715da4..23bce0005 100644 --- a/tests/regression/tools/filtering/Makefile.am +++ b/tests/regression/tools/filtering/Makefile.am @@ -14,5 +14,5 @@ gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h gen_ust_events_LDADD = -llttng-ust endif -noinst_SCRIPTS = runall unsupported-ops invalid-filters valid-filters babelstats.pl -EXTRA_DIST = runall unsupported-ops invalid-filters valid-filters babelstats.pl +noinst_SCRIPTS = runall test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl +EXTRA_DIST = runall test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl diff --git a/tests/regression/tools/filtering/invalid-filters b/tests/regression/tools/filtering/invalid-filters deleted file mode 100755 index 48db698dd..000000000 --- a/tests/regression/tools/filtering/invalid-filters +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Filtering - Invalid filters" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -SESSION_NAME="filter-invalid" -EVENT_NAME="bogus" -ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr" -TRACE_PATH=$(mktemp -d) - -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 - return 1 - else - print_ok - return 0 - fi -} - -function test_invalid_filter -{ - test_invalid_filter="$1" - - echo "" - echo -e "=== Testing filter expression with invalid filter" - echo -e "Filter: $test_invalid_filter" - - # Create session - create_lttng_session $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 -} - -function test_bytecode_limit -{ - # Current bytecode limitation is 65536 bytes long. - # Generate a huge bytecode with some perl-fu - BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'` - - echo "" - echo -e "=== Testing filter bytecode limits (64KiB)" - - # Create session - create_lttng_session $SESSION_NAME $TRACE_PATH - - # Apply filter - enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT" - - # Destroy session - destroy_lttng_session $SESSION_NAME -} - -IFS=$'\n' -INVALID_FILTERS=( - # Unsupported ops - "intfield*1" - "intfield/1" - "intfield+1" - "intfield-1" - "intfield>>1" - "intfield<<1" - "intfield&1" - "intfield|1" - "intfield^1" - "~intfield" - "1+11111-3333+1" - "(1+2)*(55*666)" - "1+2*55*666" - "asdf + 1 > 1" - "asdfas < 2332 || asdf + 1 > 1" - "!+-+++-------+++++++++++-----!!--!44+1" - "aaa||(gg)+(333----1)" - "1+1" - # 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\"" - # Unary op on string not allowed - "!\"somestring\"" - # Comparison with string type not allowed - "\"somestring\" > 42" - "\"somestring\" > 42.0" - "42 > \"somestring\"" - "42.0 > \"somestring\"" - # Logical operator with string type not allowed - "\"somestring\" || 1" - "1 || \"somestring\"" - # Nesting of binary operator not allowed - "1 | (1 | (1 | 1))" - "1 > (1 > (1 > 1))" - ) - -start_lttng_sessiond -for FILTER in ${INVALID_FILTERS[@]}; -do - test_invalid_filter "$FILTER" -done - -test_bytecode_limit - -unset IFS -stop_lttng_sessiond - -rm -f $ENABLE_EVENT_STDERR -rm -rf $TRACE_PATH diff --git a/tests/regression/tools/filtering/runall b/tests/regression/tools/filtering/runall index c92e39988..cda9799ef 100755 --- a/tests/regression/tools/filtering/runall +++ b/tests/regression/tools/filtering/runall @@ -2,7 +2,7 @@ DIR=$(dirname $0) -tests=( $DIR/unsupported-ops $DIR/invalid-filters $DIR/valid-filters ) +tests=( $DIR/test_unsupported_op $DIR/test_invalid_filter $DIR/test_valid_filter ) exit_code=0 function start_tests () diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter new file mode 100755 index 000000000..48db698dd --- /dev/null +++ b/tests/regression/tools/filtering/test_invalid_filter @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Filtering - Invalid filters" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="filter-invalid" +EVENT_NAME="bogus" +ENABLE_EVENT_STDERR="/tmp/invalid-filters-stderr" +TRACE_PATH=$(mktemp -d) + +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 + return 1 + else + print_ok + return 0 + fi +} + +function test_invalid_filter +{ + test_invalid_filter="$1" + + echo "" + echo -e "=== Testing filter expression with invalid filter" + echo -e "Filter: $test_invalid_filter" + + # Create session + create_lttng_session $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 +} + +function test_bytecode_limit +{ + # Current bytecode limitation is 65536 bytes long. + # Generate a huge bytecode with some perl-fu + BYTECODE_LIMIT=`perl -e 'print "intfield" . " && 1" x5460'` + + echo "" + echo -e "=== Testing filter bytecode limits (64KiB)" + + # Create session + create_lttng_session $SESSION_NAME $TRACE_PATH + + # Apply filter + enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT" + + # Destroy session + destroy_lttng_session $SESSION_NAME +} + +IFS=$'\n' +INVALID_FILTERS=( + # Unsupported ops + "intfield*1" + "intfield/1" + "intfield+1" + "intfield-1" + "intfield>>1" + "intfield<<1" + "intfield&1" + "intfield|1" + "intfield^1" + "~intfield" + "1+11111-3333+1" + "(1+2)*(55*666)" + "1+2*55*666" + "asdf + 1 > 1" + "asdfas < 2332 || asdf + 1 > 1" + "!+-+++-------+++++++++++-----!!--!44+1" + "aaa||(gg)+(333----1)" + "1+1" + # 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\"" + # Unary op on string not allowed + "!\"somestring\"" + # Comparison with string type not allowed + "\"somestring\" > 42" + "\"somestring\" > 42.0" + "42 > \"somestring\"" + "42.0 > \"somestring\"" + # Logical operator with string type not allowed + "\"somestring\" || 1" + "1 || \"somestring\"" + # Nesting of binary operator not allowed + "1 | (1 | (1 | 1))" + "1 > (1 > (1 > 1))" + ) + +start_lttng_sessiond +for FILTER in ${INVALID_FILTERS[@]}; +do + test_invalid_filter "$FILTER" +done + +test_bytecode_limit + +unset IFS +stop_lttng_sessiond + +rm -f $ENABLE_EVENT_STDERR +rm -rf $TRACE_PATH diff --git a/tests/regression/tools/filtering/test_unsupported_op b/tests/regression/tools/filtering/test_unsupported_op new file mode 100755 index 000000000..9fac9dec8 --- /dev/null +++ b/tests/regression/tools/filtering/test_unsupported_op @@ -0,0 +1,114 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Filtering - Unsupported operators" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="filter-unsupported-ops" +EVENT_NAME="bogus" +ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable" +TRACE_PATH=$(mktemp -d) + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +function enable_ust_lttng_event_filter_unsupported +{ + sess_name=$1 + 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 + return 1 + else + print_ok + return 0 + fi +} + +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)" + + # Create session + create_lttng_session $SESSION_NAME $TRACE_PATH + + # Create filter + if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then + TEST_FILTER="${test_op_tkn}1" + else + TEST_FILTER="intfield $test_op_tkn 1" + fi + + # Apply filter + 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 + return 1 + else + print_ok + fi + + # Destroy session + destroy_lttng_session $SESSION_NAME + return 0 +} + +# Unsupported operators +OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT" + "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT") + +OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~") + +OP_COUNT=${#OP_STR[@]} +i=0 + +start_lttng_sessiond + +while [ "$i" -lt "$OP_COUNT" ]; do + test_unsupported_op "${OP_STR[$i]}" "${OP_TKN[$i]}" + + if [ $? -eq 1 ]; then + exit 1 + fi + + let "i++" +done + +stop_lttng_sessiond + +# Cleanup +rm -f $ENABLE_EVENT_STDERR +rm -rf $TRACE_PATH diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter new file mode 100755 index 000000000..067d205e7 --- /dev/null +++ b/tests/regression/tools/filtering/test_valid_filter @@ -0,0 +1,417 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Filtering - Valid filters" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +BIN_NAME="gen-ust-events" +STATS_BIN="babelstats.pl" +SESSION_NAME="valid_filter" +EVENT_NAME="tp:tptest" +NR_ITER=100 + +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 +fi + +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 +} + +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 "" +} + +function test_valid_filter +{ + filter="$1" + validator="$2" + + echo "" + echo -e "=== Testing valid filter: $1" + + trace_path=$(mktemp -d) + + # Create session + create_lttng_session $SESSION_NAME $trace_path + + # Enable filter + enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter + + # Trace apps + start_lttng_tracing $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` + + rm -rf $trace_path + + $validator "$stats" + + if [ $? -eq 0 ]; then + print_ok +# rm -rf $trace_path + return 0 + else + print_fail + return 1 + fi +} + +function validate_min_max +{ + stats="$1" + field=$2 + expected_min=$3 + expected_max=$4 + + echo $stats | grep -q "$field $expected_min $expected_max" + + return $? +} + +function validator_intfield +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "1" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "intfield2" "0x1" "0x63" + status=$(($status|$?)) + + validate_min_max "$stats" "longfield" "1" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "netintfield" "1" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "netintfieldhex" "0x1" "0x63" + status=$(($status|$?)) + + validate_min_max "$stats" "floatfield" "2222" "2222" + status=$(($status|$?)) + + validate_min_max "$stats" "doublefield" "2" "2" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_gt +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "2" "99" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_ge +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "1" "99" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_lt +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "1" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_le +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "2" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_eq +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "1" "1" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_ne +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "98" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_not +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "0" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_gt_and_longfield_gt +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "43" "99" + status=$(($status|$?)) + validate_min_max "$stats" "longfield" "43" "99" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_ge_and_longfield_le +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "42" "42" + status=$(($status|$?)) + validate_min_max "$stats" "longfield" "42" "42" + status=$(($status|$?)) + + return $status +} + +function validator_intfield_lt_or_longfield_gt +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "99" + status=$(($status|$?)) + validate_min_max "$stats" "longfield" "0" "99" + status=$(($status|$?)) + + return $status +} + +function validator_mixed_str_or_int_and_int +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "34" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "stringfield" "\"test\"" "\"test\"" + status=$(($status|$?)) + + return $status +} + +function validator_mixed_int_double +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "42" + status=$(($status|$?)) + + return $status +} + +function validator_true_statement +{ + stats="$1" + status=0 + + validate_min_max "$stats" "intfield" "0" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "intfield2" "0x0" "0x63" + status=$(($status|$?)) + + validate_min_max "$stats" "longfield" "0" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "netintfield" "0" "99" + status=$(($status|$?)) + + validate_min_max "$stats" "netintfieldhex" "0x0" "0x63" + status=$(($status|$?)) + + validate_min_max "$stats" "floatfield" "2222" "2222" + status=$(($status|$?)) + + validate_min_max "$stats" "doublefield" "2" "2" + status=$(($status|$?)) + + validate_min_max "$stats" "stringfield" "\"test\"" "\"test\"" + status=$(($status|$?)) + + validate_min_max "$stats" "stringfield2" ""\*"" ""\*"" + status=$(($status|$?)) + + return $status +} + +IFS=$'\n' + +issue_356_filter="intfield > 0 && intfield > 1 && " +issue_356_filter+="intfield > 2 && intfield > 3 && " +issue_356_filter+="intfield > 4 && intfield > 5 && " +issue_356_filter+="intfield > 6 && intfield > 7 && " +issue_356_filter+="intfield > 8 || intfield > 0" + +# One to one mapping between filters and validators + +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 +) + +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_mixed_int_double" #17 + "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_true_statement" #27 + "validator_intfield_gt" #28 +) + +FILTER_COUNT=${#FILTERS[@]} +i=0 + +start_lttng_sessiond + +while [ "$i" -lt "$FILTER_COUNT" ]; do + + test_valid_filter "${FILTERS[$i]}" "${VALIDATOR[$i]}" + + if [ $? -eq 1 ]; then + stop_lttng_sessiond + exit 1 + fi + + let "i++" +done + +stop_lttng_sessiond diff --git a/tests/regression/tools/filtering/unsupported-ops b/tests/regression/tools/filtering/unsupported-ops deleted file mode 100755 index 9fac9dec8..000000000 --- a/tests/regression/tools/filtering/unsupported-ops +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Filtering - Unsupported operators" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -SESSION_NAME="filter-unsupported-ops" -EVENT_NAME="bogus" -ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable" -TRACE_PATH=$(mktemp -d) - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -function enable_ust_lttng_event_filter_unsupported -{ - sess_name=$1 - 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 - return 1 - else - print_ok - return 0 - fi -} - -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)" - - # Create session - create_lttng_session $SESSION_NAME $TRACE_PATH - - # Create filter - if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then - TEST_FILTER="${test_op_tkn}1" - else - TEST_FILTER="intfield $test_op_tkn 1" - fi - - # Apply filter - 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 - return 1 - else - print_ok - fi - - # Destroy session - destroy_lttng_session $SESSION_NAME - return 0 -} - -# Unsupported operators -OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT" - "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT") - -OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~") - -OP_COUNT=${#OP_STR[@]} -i=0 - -start_lttng_sessiond - -while [ "$i" -lt "$OP_COUNT" ]; do - test_unsupported_op "${OP_STR[$i]}" "${OP_TKN[$i]}" - - if [ $? -eq 1 ]; then - exit 1 - fi - - let "i++" -done - -stop_lttng_sessiond - -# Cleanup -rm -f $ENABLE_EVENT_STDERR -rm -rf $TRACE_PATH diff --git a/tests/regression/tools/filtering/valid-filters b/tests/regression/tools/filtering/valid-filters deleted file mode 100755 index 067d205e7..000000000 --- a/tests/regression/tools/filtering/valid-filters +++ /dev/null @@ -1,417 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Filtering - Valid filters" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -BIN_NAME="gen-ust-events" -STATS_BIN="babelstats.pl" -SESSION_NAME="valid_filter" -EVENT_NAME="tp:tptest" -NR_ITER=100 - -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 -fi - -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 -} - -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 "" -} - -function test_valid_filter -{ - filter="$1" - validator="$2" - - echo "" - echo -e "=== Testing valid filter: $1" - - trace_path=$(mktemp -d) - - # Create session - create_lttng_session $SESSION_NAME $trace_path - - # Enable filter - enable_ust_lttng_event_filter $SESSION_NAME $EVENT_NAME $filter - - # Trace apps - start_lttng_tracing $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` - - rm -rf $trace_path - - $validator "$stats" - - if [ $? -eq 0 ]; then - print_ok -# rm -rf $trace_path - return 0 - else - print_fail - return 1 - fi -} - -function validate_min_max -{ - stats="$1" - field=$2 - expected_min=$3 - expected_max=$4 - - echo $stats | grep -q "$field $expected_min $expected_max" - - return $? -} - -function validator_intfield -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "1" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "intfield2" "0x1" "0x63" - status=$(($status|$?)) - - validate_min_max "$stats" "longfield" "1" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "netintfield" "1" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "netintfieldhex" "0x1" "0x63" - status=$(($status|$?)) - - validate_min_max "$stats" "floatfield" "2222" "2222" - status=$(($status|$?)) - - validate_min_max "$stats" "doublefield" "2" "2" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_gt -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "2" "99" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_ge -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "1" "99" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_lt -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "1" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_le -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "2" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_eq -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "1" "1" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_ne -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "98" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_not -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "0" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_gt_and_longfield_gt -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "43" "99" - status=$(($status|$?)) - validate_min_max "$stats" "longfield" "43" "99" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_ge_and_longfield_le -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "42" "42" - status=$(($status|$?)) - validate_min_max "$stats" "longfield" "42" "42" - status=$(($status|$?)) - - return $status -} - -function validator_intfield_lt_or_longfield_gt -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "99" - status=$(($status|$?)) - validate_min_max "$stats" "longfield" "0" "99" - status=$(($status|$?)) - - return $status -} - -function validator_mixed_str_or_int_and_int -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "34" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "stringfield" "\"test\"" "\"test\"" - status=$(($status|$?)) - - return $status -} - -function validator_mixed_int_double -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "42" - status=$(($status|$?)) - - return $status -} - -function validator_true_statement -{ - stats="$1" - status=0 - - validate_min_max "$stats" "intfield" "0" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "intfield2" "0x0" "0x63" - status=$(($status|$?)) - - validate_min_max "$stats" "longfield" "0" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "netintfield" "0" "99" - status=$(($status|$?)) - - validate_min_max "$stats" "netintfieldhex" "0x0" "0x63" - status=$(($status|$?)) - - validate_min_max "$stats" "floatfield" "2222" "2222" - status=$(($status|$?)) - - validate_min_max "$stats" "doublefield" "2" "2" - status=$(($status|$?)) - - validate_min_max "$stats" "stringfield" "\"test\"" "\"test\"" - status=$(($status|$?)) - - validate_min_max "$stats" "stringfield2" ""\*"" ""\*"" - status=$(($status|$?)) - - return $status -} - -IFS=$'\n' - -issue_356_filter="intfield > 0 && intfield > 1 && " -issue_356_filter+="intfield > 2 && intfield > 3 && " -issue_356_filter+="intfield > 4 && intfield > 5 && " -issue_356_filter+="intfield > 6 && intfield > 7 && " -issue_356_filter+="intfield > 8 || intfield > 0" - -# One to one mapping between filters and validators - -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 -) - -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_mixed_int_double" #17 - "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_true_statement" #27 - "validator_intfield_gt" #28 -) - -FILTER_COUNT=${#FILTERS[@]} -i=0 - -start_lttng_sessiond - -while [ "$i" -lt "$FILTER_COUNT" ]; do - - test_valid_filter "${FILTERS[$i]}" "${VALIDATOR[$i]}" - - if [ $? -eq 1 ]; then - stop_lttng_sessiond - exit 1 - fi - - let "i++" -done - -stop_lttng_sessiond diff --git a/tests/regression/tools/health/health_thread_exit b/tests/regression/tools/health/health_thread_exit deleted file mode 100755 index 79e0e051d..000000000 --- a/tests/regression/tools/health/health_thread_exit +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Health check - Thread exit" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -SESSION_NAME="health_thread_exit" -EVENT_NAME="bogus" -HEALTH_CHECK_BIN="health_check" -SESSIOND_PRELOAD=".libs/libhealthexit.so" - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then - echo -e "libhealthexit.so not available for this test. Skipping." - exit 0 -fi - -function test_thread_exit -{ - test_thread_exit_name="$1" - test_thread_exit_code="$2" - - echo "" - echo -e "=== Testing health failure with ${test_thread_exit_name}" - - # Activate testpoints - export LTTNG_TESTPOINT_ENABLE=1 - - # Activate specific thread exit - export ${test_thread_exit_name}_EXIT=1 - - # Spawn sessiond with preload healthexit lib - export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" - start_lttng_sessiond - - # Cleanup some env. var. - unset LD_PRELOAD - unset ${test_thread_exit_name}_EXIT - - # Check initial health status - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - echo -n "Validating thread ${test_thread_exit_name} failure... " - - # Wait - sleep 25 - - # Check health status, exit code should indicate failure - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - health_check_exit_code=$? - - if [ $health_check_exit_code -eq $test_thread_exit_code ]; then - print_ok - stop_lttng_sessiond - else - print_fail - echo -e "Health returned: $health_check_exit_code\n" - - stop_lttng_sessiond - return 1 - fi -} - -THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" - "LTTNG_THREAD_MANAGE_APPS" - "LTTNG_THREAD_REG_APPS" - "LTTNG_THREAD_MANAGE_KERNEL") - -# Exit code value to indicate specific thread failure -EXIT_CODE=(1 2 4 8) - -THREAD_COUNT=${#THREAD[@]} -i=0 -while [ "$i" -lt "$THREAD_COUNT" ]; do - test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}" - - if [ $? -eq 1 ]; then - exit 1 - fi - - let "i++" -done - -# Special case manage consumer, need to spawn consumer via commands. -#"LTTNG_THREAD_MANAGE_CONSUMER" diff --git a/tests/regression/tools/health/health_thread_stall b/tests/regression/tools/health/health_thread_stall deleted file mode 100755 index dc9d850f4..000000000 --- a/tests/regression/tools/health/health_thread_stall +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Health check - Thread stall" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -SESSION_NAME="health_thread_stall" -EVENT_NAME="bogus" -HEALTH_CHECK_BIN="health_check" -SESSIOND_PRELOAD=".libs/libhealthstall.so" - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then - echo -e "libhealthstall.so not available for this test. Skipping." - exit 0 -fi - -function test_thread_stall -{ - test_thread_stall_name="$1" - test_thread_exit_code="$2" - - echo "" - echo -e "=== Testing health failure with ${test_thread_stall_name}" - - # Activate testpoints - export LTTNG_TESTPOINT_ENABLE=1 - - # Activate specific thread exit - export ${test_thread_stall_name}_STALL=1 - - # Spawn sessiond with preload healthexit lib - export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" - start_lttng_sessiond - - # Cleanup some env. var. - unset LD_PRELOAD - unset ${test_thread_stall_name}_STALL - - # Check initial health status - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - echo -n "Validating that ${test_thread_stall_name} is stalled... " - - # Wait - sleep 25 - - # Check health status, exit code should indicate failure - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - health_check_exit_code=$? - - if [ $health_check_exit_code -eq $test_thread_exit_code ]; then - print_ok - else - print_fail - echo -e "Health returned: $health_check_exit_code\n" - - stop_lttng_sessiond - return 1 - fi - - echo -n "Validating that ${test_thread_stall_name} is no longer stalled... " - - # Wait - sleep 40 - - # Check health status, exit code should now pass - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - health_check_exit_code=$? - - if [ $health_check_exit_code -eq 0 ]; then - print_ok - stop_lttng_sessiond - else - print_fail - echo -e "Health returned: $health_check_exit_code\n" - stop_lttng_sessiond - return 1 - fi - - -} - -THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" - "LTTNG_THREAD_MANAGE_APPS" -# This thread is a little bit tricky to stall, -# need to send some commands and setup an app. -# "LTTNG_THREAD_REG_APPS" - "LTTNG_THREAD_MANAGE_KERNEL") - -# Exit code value to indicate specific thread failure -EXIT_CODE=(1 - 2 -# 4 - 8) - -THREAD_COUNT=${#THREAD[@]} -i=0 -while [ "$i" -lt "$THREAD_COUNT" ]; do - test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}" - - if [ $? -eq 1 ]; then - exit 1 - fi - - let "i++" -done diff --git a/tests/regression/tools/health/health_tp_fail b/tests/regression/tools/health/health_tp_fail deleted file mode 100755 index 0b474fa78..000000000 --- a/tests/regression/tools/health/health_tp_fail +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -TEST_DESC="Health check - Testpoint failure" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" -SESSION_NAME="health_tp_fail" -EVENT_NAME="bogus" -HEALTH_CHECK_BIN="health_check" -SESSIOND_PRELOAD=".libs/libhealthtpfail.so" - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then - echo -e "libhealthtpfail.so not available for this test. Skipping." - exit 0 -fi - -function test_tp_fail -{ - test_tp_fail_name="$1" - test_tp_fail_code="$2" - - echo "" - echo -e "=== Testing health failure with ${test_tp_fail_name}" - - # Activate testpoints - export LTTNG_TESTPOINT_ENABLE=1 - - # Activate specific testpoint failure - export ${test_tp_fail_name}_TP_FAIL=1 - - # Spawn sessiond with preload healthexit lib - export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" - start_lttng_sessiond - - # Cleanup some env. var. - unset LD_PRELOAD - unset ${test_tp_fail_name}_TP_FAIL - - echo -n "Validating thread ${test_tp_fail_name} failure... " - - # Check health status, exit code should indicate failure - $CURDIR/$HEALTH_CHECK_BIN &> /dev/null - - health_check_exit_code=$? - - if [ $health_check_exit_code -eq $test_tp_fail_code ]; then - print_ok - stop_lttng_sessiond - else - print_fail - echo -e "Health returned: $health_check_exit_code\n" - - stop_lttng_sessiond - return 1 - fi -} - -THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" - "LTTNG_THREAD_MANAGE_APPS" - "LTTNG_THREAD_MANAGE_KERNEL") - -# Exit code value to indicate specific thread failure -EXIT_CODE=(1 2 8) - -THREAD_COUNT=${#THREAD[@]} -i=0 -while [ "$i" -lt "$THREAD_COUNT" ]; do - test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}" - - if [ $? -eq 1 ]; then - exit 1 - fi - - let "i++" -done - -# Special case manage consumer, need to spawn consumer via commands. -#"LTTNG_THREAD_MANAGE_CONSUMER" diff --git a/tests/regression/tools/health/runall b/tests/regression/tools/health/runall index d1c8b3446..0ed0c8e83 100755 --- a/tests/regression/tools/health/runall +++ b/tests/regression/tools/health/runall @@ -2,7 +2,7 @@ DIR=$(dirname $0) -tests=( $DIR/health_thread_exit $DIR/health_thread_stall $DIR/health_tp_fail) +tests=( $DIR/test_thread_exit $DIR/test_thread_stall $DIR/test_tp_fail) exit_code=0 function start_tests () diff --git a/tests/regression/tools/health/test_thread_exit b/tests/regression/tools/health/test_thread_exit new file mode 100755 index 000000000..79e0e051d --- /dev/null +++ b/tests/regression/tools/health/test_thread_exit @@ -0,0 +1,105 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Health check - Thread exit" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="health_thread_exit" +EVENT_NAME="bogus" +HEALTH_CHECK_BIN="health_check" +SESSIOND_PRELOAD=".libs/libhealthexit.so" + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then + echo -e "libhealthexit.so not available for this test. Skipping." + exit 0 +fi + +function test_thread_exit +{ + test_thread_exit_name="$1" + test_thread_exit_code="$2" + + echo "" + echo -e "=== Testing health failure with ${test_thread_exit_name}" + + # Activate testpoints + export LTTNG_TESTPOINT_ENABLE=1 + + # Activate specific thread exit + export ${test_thread_exit_name}_EXIT=1 + + # Spawn sessiond with preload healthexit lib + export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" + start_lttng_sessiond + + # Cleanup some env. var. + unset LD_PRELOAD + unset ${test_thread_exit_name}_EXIT + + # Check initial health status + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + echo -n "Validating thread ${test_thread_exit_name} failure... " + + # Wait + sleep 25 + + # Check health status, exit code should indicate failure + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + health_check_exit_code=$? + + if [ $health_check_exit_code -eq $test_thread_exit_code ]; then + print_ok + stop_lttng_sessiond + else + print_fail + echo -e "Health returned: $health_check_exit_code\n" + + stop_lttng_sessiond + return 1 + fi +} + +THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" + "LTTNG_THREAD_MANAGE_APPS" + "LTTNG_THREAD_REG_APPS" + "LTTNG_THREAD_MANAGE_KERNEL") + +# Exit code value to indicate specific thread failure +EXIT_CODE=(1 2 4 8) + +THREAD_COUNT=${#THREAD[@]} +i=0 +while [ "$i" -lt "$THREAD_COUNT" ]; do + test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}" + + if [ $? -eq 1 ]; then + exit 1 + fi + + let "i++" +done + +# Special case manage consumer, need to spawn consumer via commands. +#"LTTNG_THREAD_MANAGE_CONSUMER" diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall new file mode 100755 index 000000000..dc9d850f4 --- /dev/null +++ b/tests/regression/tools/health/test_thread_stall @@ -0,0 +1,128 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Health check - Thread stall" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="health_thread_stall" +EVENT_NAME="bogus" +HEALTH_CHECK_BIN="health_check" +SESSIOND_PRELOAD=".libs/libhealthstall.so" + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then + echo -e "libhealthstall.so not available for this test. Skipping." + exit 0 +fi + +function test_thread_stall +{ + test_thread_stall_name="$1" + test_thread_exit_code="$2" + + echo "" + echo -e "=== Testing health failure with ${test_thread_stall_name}" + + # Activate testpoints + export LTTNG_TESTPOINT_ENABLE=1 + + # Activate specific thread exit + export ${test_thread_stall_name}_STALL=1 + + # Spawn sessiond with preload healthexit lib + export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" + start_lttng_sessiond + + # Cleanup some env. var. + unset LD_PRELOAD + unset ${test_thread_stall_name}_STALL + + # Check initial health status + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + echo -n "Validating that ${test_thread_stall_name} is stalled... " + + # Wait + sleep 25 + + # Check health status, exit code should indicate failure + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + health_check_exit_code=$? + + if [ $health_check_exit_code -eq $test_thread_exit_code ]; then + print_ok + else + print_fail + echo -e "Health returned: $health_check_exit_code\n" + + stop_lttng_sessiond + return 1 + fi + + echo -n "Validating that ${test_thread_stall_name} is no longer stalled... " + + # Wait + sleep 40 + + # Check health status, exit code should now pass + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + health_check_exit_code=$? + + if [ $health_check_exit_code -eq 0 ]; then + print_ok + stop_lttng_sessiond + else + print_fail + echo -e "Health returned: $health_check_exit_code\n" + stop_lttng_sessiond + return 1 + fi + + +} + +THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" + "LTTNG_THREAD_MANAGE_APPS" +# This thread is a little bit tricky to stall, +# need to send some commands and setup an app. +# "LTTNG_THREAD_REG_APPS" + "LTTNG_THREAD_MANAGE_KERNEL") + +# Exit code value to indicate specific thread failure +EXIT_CODE=(1 + 2 +# 4 + 8) + +THREAD_COUNT=${#THREAD[@]} +i=0 +while [ "$i" -lt "$THREAD_COUNT" ]; do + test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}" + + if [ $? -eq 1 ]; then + exit 1 + fi + + let "i++" +done diff --git a/tests/regression/tools/health/test_tp_fail b/tests/regression/tools/health/test_tp_fail new file mode 100755 index 000000000..0b474fa78 --- /dev/null +++ b/tests/regression/tools/health/test_tp_fail @@ -0,0 +1,98 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Health check - Testpoint failure" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="health_tp_fail" +EVENT_NAME="bogus" +HEALTH_CHECK_BIN="health_check" +SESSIOND_PRELOAD=".libs/libhealthtpfail.so" + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then + echo -e "libhealthtpfail.so not available for this test. Skipping." + exit 0 +fi + +function test_tp_fail +{ + test_tp_fail_name="$1" + test_tp_fail_code="$2" + + echo "" + echo -e "=== Testing health failure with ${test_tp_fail_name}" + + # Activate testpoints + export LTTNG_TESTPOINT_ENABLE=1 + + # Activate specific testpoint failure + export ${test_tp_fail_name}_TP_FAIL=1 + + # Spawn sessiond with preload healthexit lib + export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD" + start_lttng_sessiond + + # Cleanup some env. var. + unset LD_PRELOAD + unset ${test_tp_fail_name}_TP_FAIL + + echo -n "Validating thread ${test_tp_fail_name} failure... " + + # Check health status, exit code should indicate failure + $CURDIR/$HEALTH_CHECK_BIN &> /dev/null + + health_check_exit_code=$? + + if [ $health_check_exit_code -eq $test_tp_fail_code ]; then + print_ok + stop_lttng_sessiond + else + print_fail + echo -e "Health returned: $health_check_exit_code\n" + + stop_lttng_sessiond + return 1 + fi +} + +THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" + "LTTNG_THREAD_MANAGE_APPS" + "LTTNG_THREAD_MANAGE_KERNEL") + +# Exit code value to indicate specific thread failure +EXIT_CODE=(1 2 8) + +THREAD_COUNT=${#THREAD[@]} +i=0 +while [ "$i" -lt "$THREAD_COUNT" ]; do + test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}" + + if [ $? -eq 1 ]; then + exit 1 + fi + + let "i++" +done + +# Special case manage consumer, need to spawn consumer via commands. +#"LTTNG_THREAD_MANAGE_CONSUMER" diff --git a/tests/regression/tools/streaming/Makefile.am b/tests/regression/tools/streaming/Makefile.am index ddd092592..1949f669b 100644 --- a/tests/regression/tools/streaming/Makefile.am +++ b/tests/regression/tools/streaming/Makefile.am @@ -14,5 +14,5 @@ gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h gen_ust_events_LDADD = -llttng-ust endif -noinst_SCRIPTS = runall run-ust run-kernel uri_switch -EXTRA_DIST = runall run-ust run-kernel uri_switch +noinst_SCRIPTS = runall test_ust test_kernel test_uri_switch test_high_throughput_limits +EXTRA_DIST = runall test_ust test_kernel test_uri_switch test_high_throughput_limits diff --git a/tests/regression/tools/streaming/high_throughput_limits b/tests/regression/tools/streaming/high_throughput_limits deleted file mode 100755 index e2f094d22..000000000 --- a/tests/regression/tools/streaming/high_throughput_limits +++ /dev/null @@ -1,200 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# David Goulet -# -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -TEST_DESC="Streaming - High throughput with bandwidth limits" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -NR_APP_ITER=10 -NR_ITER=1000000 -BIN_NAME="gen-ust-events" -SESSION_NAME="high-throughput" -EVENT_NAME="tp:tptest" -SESSIOND_CTRL_PORT=5342 -SESSIOND_DATA_PORT=5343 -DEFAULT_IF="lo" - -TRACE_PATH=$(mktemp -d) - -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 -fi - -if [ "$(id -u)" != "0" ]; then - echo "This test must be running as root to set bandwidth limits. Aborting" - # Exit status 0 so the tests can continue - exit 0 -fi - -function set_bw_limit -{ - limit=$1 - ctrlportlimit=$(($limit/10)) - # failsafe to have at least 1kbit/s for control (in the case where $1 < 10) - [ $ctrlportlimit = 0 ] && ctrlportlimit=1 - # if $1 < 10, we might bust the limit set here, but the - # parent qdisc (1:) will always limit us to the right max value - dataportlimit=$((9*${ctrlportlimit})) - - echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... " - tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1 - - # the total bandwidth is the limit set by the user - tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1 - # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port - tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1 - # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused) - tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1 - - # filter to assign control traffic to the 1:10 class - tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1 - # filter to assign data traffic to the 1:11 class - tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1 - print_ok -} - -function reset_bw_limit -{ - echo -n "Resetting bandwidth limits... " - tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1 - print_ok -} - -function create_lttng_session_with_uri -{ - sess_name=$1 - uri=$2 - # Create session with custom URI - $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $uri $sess_name >/dev/null 2>&1 -} - -function enable_lttng_consumer -{ - uri=$1 - # Create session with custom URI - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $uri >/dev/null 2>&1 -} - -function run_apps -{ - for i in `seq 1 $NR_APP_ITER`; do - # With bandwidth limitation, unfortunately, application easily timeout - # due to very slow communication between the consumer and relayd making - # the status reply from the consumer quite slow thus delaying the - # registration done message. - LTTNG_UST_REGISTER_TIMEOUT=-1 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1 - done -} - -function wait_apps -{ - echo "Waiting for applications to end" - while [ -n "$(pidof $BIN_NAME)" ]; do - echo -n "." - sleep 1 - done - echo "" -} - -function test_high_throughput -{ - NETWORK_URI="net://localhost" - create_lttng_session_with_uri $SESSION_NAME $NETWORK_URI - enable_lttng_consumer $NETWORK_URI - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - run_apps - wait_apps - - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - validate_event_count -} - -function validate_event_count -{ - - TEMP_FILE=$(mktemp) - TEMP_FILE_2=$(mktemp) - - traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) - babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 - - cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE - - dropped=0 - while read line; - do - let dropped=$dropped+$line - done < $TEMP_FILE - - let total=$dropped+$traced - let wanted=$NR_APP_ITER*$NR_ITER - - if [ $wanted -ne $total ]; then - echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " - print_fail - return 1 - else - echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " - print_ok - - # Cleanup only if everything is ok and passes. - rm -rf $TRACE_PATH - rm $TEMP_FILE $TEMP_FILE_2 - - return 0 - fi -} - -function interrupt_cleanup() -{ - echo -en "\n*** Exiting ***\n" - stop_lttng_relayd - stop_lttng_sessiond - reset_bw_limit - exit 1 -} - -# Catch sigint and try to cleanup limits -trap interrupt_cleanup SIGINT - -BW_LIMITS=(3200 1600 800 400 200 100 50 25) -for BW in ${BW_LIMITS[@]}; -do - echo "" - echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits" - set_bw_limit $BW - - start_lttng_sessiond - start_lttng_relayd "-o $TRACE_PATH" - test_high_throughput - result=$? - stop_lttng_relayd - stop_lttng_sessiond - reset_bw_limit - - if [ $result -ne 0 ]; then - exit 1 - fi -done diff --git a/tests/regression/tools/streaming/run-kernel b/tests/regression/tools/streaming/run-kernel deleted file mode 100755 index f8b813d28..000000000 --- a/tests/regression/tools/streaming/run-kernel +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 David Goulet -# -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -TEST_DESC="Streaming - Kernel tracing" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -EVENT_NAME="sched_switch" -PID_RELAYD=0 -SESSION_NAME="" - -TRACE_PATH=$(mktemp -d) - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -if [ "$(id -u)" != "0" ]; then - echo "This test must be running as root. Aborting" - # Exit status 0 so the tests can continue - exit 0 -fi - -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - echo "LTTng modules not detected. Aborting kernel tests!" - echo "" - # Exit status 0 so the tests can continue - exit 0 -fi - -function lttng_create_session_uri -{ - echo -n "Creating session $SESSION_NAME... " - # Create session with default path - $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 - if [ $? -eq 1 ]; then - print_fail - return 1 - else - print_ok - fi -} - -function test_kernel_before_start () -{ - echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n" - lttng_create_session_uri - lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - # Give a second - sleep 1 - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - - # We can not predict _yet_ when the trace is available so we have to do a - # arbitratry sleep to validate the trace. - echo -n "Waiting 3 seconds for the trace to be written on disk " - for i in `seq 1 3`; do - echo -n "." - sleep 1 - done - echo "" -} - -# Deactivated since this feature is not yet available where we can enable -# an event AFTERE tracing has started. -function test_kernel_after_start () -{ - echo -e "\n=== Testing kernel streaming with event enable AFTER start\n" - lttng_create_session_uri - start_lttng_tracing $SESSION_NAME - lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME - # Give a second - sleep 1 - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME -} - -start_lttng_sessiond -start_lttng_relayd "-o $TRACE_PATH" - -tests=( test_kernel_before_start ) - -for fct_test in ${tests[@]}; -do - SESSION_NAME=$(randstring 16 0) - ${fct_test} - - # Validate test - validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* - if [ $? -eq 0 ]; then - # Only delete if successful - rm -rf $TRACE_PATH - else - break - fi -done - -echo "" -stop_lttng_sessiond -stop_lttng_relayd - - -exit $out diff --git a/tests/regression/tools/streaming/run-ust b/tests/regression/tools/streaming/run-ust deleted file mode 100755 index 6e6e5a752..000000000 --- a/tests/regression/tools/streaming/run-ust +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 David Goulet -# -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -TEST_DESC="Streaming - User space tracing" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -BIN_NAME="gen-ust-events" -SESSION_NAME="stream" -EVENT_NAME="tp:tptest" -PID_RELAYD=0 - -TRACE_PATH=$(mktemp -d) - -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 -fi - -function lttng_create_session_uri -{ - # Create session with default path - $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 -} - -function wait_apps -{ - echo -n "Waiting for applications to end" - while [ -n "$(pidof $BIN_NAME)" ]; do - echo -n "." - sleep 0.5 - done - echo "" -} - -# MUST set TESTDIR before calling those functions - -function test_ust_before_start () -{ - echo -e "\n=== Testing UST streaming BEFORE tracing starts\n" - lttng_create_session_uri - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - - # Run 5 times with a 1 second delay - ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 & - - start_lttng_tracing $SESSION_NAME - - wait_apps - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME -} - -function test_ust_after_start () -{ - echo -e "\n=== Testing UST streaming AFTER tracing starts\n" - lttng_create_session_uri - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - - # Run 5 times with a 1 second delay - ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 & - - wait_apps - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME -} - -start_lttng_sessiond -start_lttng_relayd "-o $TRACE_PATH" - -tests=( test_ust_before_start test_ust_after_start ) - -for fct_test in ${tests[@]}; -do - SESSION_NAME=$(randstring 16 0) - ${fct_test} - - # Validate test - validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* - if [ $? -eq 0 ]; then - # Only delete if successful - rm -rf $TRACE_PATH - else - break - fi -done - -echo "" -stop_lttng_sessiond -stop_lttng_relayd - -exit $out diff --git a/tests/regression/tools/streaming/runall b/tests/regression/tools/streaming/runall index dbf5228ce..809449bf3 100755 --- a/tests/regression/tools/streaming/runall +++ b/tests/regression/tools/streaming/runall @@ -2,7 +2,7 @@ DIR=$(dirname $0) -tests=( $DIR/unit_tests $DIR/run-kernel $DIR/run-ust ) +tests=( $DIR/test_uri_switch $DIR/test_kernel $DIR/test_ust ) exit_code=0 function start_tests () diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits new file mode 100755 index 000000000..e2f094d22 --- /dev/null +++ b/tests/regression/tools/streaming/test_high_throughput_limits @@ -0,0 +1,200 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# David Goulet +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +TEST_DESC="Streaming - High throughput with bandwidth limits" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +NR_APP_ITER=10 +NR_ITER=1000000 +BIN_NAME="gen-ust-events" +SESSION_NAME="high-throughput" +EVENT_NAME="tp:tptest" +SESSIOND_CTRL_PORT=5342 +SESSIOND_DATA_PORT=5343 +DEFAULT_IF="lo" + +TRACE_PATH=$(mktemp -d) + +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 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This test must be running as root to set bandwidth limits. Aborting" + # Exit status 0 so the tests can continue + exit 0 +fi + +function set_bw_limit +{ + limit=$1 + ctrlportlimit=$(($limit/10)) + # failsafe to have at least 1kbit/s for control (in the case where $1 < 10) + [ $ctrlportlimit = 0 ] && ctrlportlimit=1 + # if $1 < 10, we might bust the limit set here, but the + # parent qdisc (1:) will always limit us to the right max value + dataportlimit=$((9*${ctrlportlimit})) + + echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... " + tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1 + + # the total bandwidth is the limit set by the user + tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1 + # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port + tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1 + # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused) + tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1 + + # filter to assign control traffic to the 1:10 class + tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1 + # filter to assign data traffic to the 1:11 class + tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1 + print_ok +} + +function reset_bw_limit +{ + echo -n "Resetting bandwidth limits... " + tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1 + print_ok +} + +function create_lttng_session_with_uri +{ + sess_name=$1 + uri=$2 + # Create session with custom URI + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $uri $sess_name >/dev/null 2>&1 +} + +function enable_lttng_consumer +{ + uri=$1 + # Create session with custom URI + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $uri >/dev/null 2>&1 +} + +function run_apps +{ + for i in `seq 1 $NR_APP_ITER`; do + # With bandwidth limitation, unfortunately, application easily timeout + # due to very slow communication between the consumer and relayd making + # the status reply from the consumer quite slow thus delaying the + # registration done message. + LTTNG_UST_REGISTER_TIMEOUT=-1 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1 + done +} + +function wait_apps +{ + echo "Waiting for applications to end" + while [ -n "$(pidof $BIN_NAME)" ]; do + echo -n "." + sleep 1 + done + echo "" +} + +function test_high_throughput +{ + NETWORK_URI="net://localhost" + create_lttng_session_with_uri $SESSION_NAME $NETWORK_URI + enable_lttng_consumer $NETWORK_URI + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + run_apps + wait_apps + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + validate_event_count +} + +function validate_event_count +{ + + TEMP_FILE=$(mktemp) + TEMP_FILE_2=$(mktemp) + + traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) + babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 + + cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE + + dropped=0 + while read line; + do + let dropped=$dropped+$line + done < $TEMP_FILE + + let total=$dropped+$traced + let wanted=$NR_APP_ITER*$NR_ITER + + if [ $wanted -ne $total ]; then + echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " + print_fail + return 1 + else + echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " + print_ok + + # Cleanup only if everything is ok and passes. + rm -rf $TRACE_PATH + rm $TEMP_FILE $TEMP_FILE_2 + + return 0 + fi +} + +function interrupt_cleanup() +{ + echo -en "\n*** Exiting ***\n" + stop_lttng_relayd + stop_lttng_sessiond + reset_bw_limit + exit 1 +} + +# Catch sigint and try to cleanup limits +trap interrupt_cleanup SIGINT + +BW_LIMITS=(3200 1600 800 400 200 100 50 25) +for BW in ${BW_LIMITS[@]}; +do + echo "" + echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits" + set_bw_limit $BW + + start_lttng_sessiond + start_lttng_relayd "-o $TRACE_PATH" + test_high_throughput + result=$? + stop_lttng_relayd + stop_lttng_sessiond + reset_bw_limit + + if [ $result -ne 0 ]; then + exit 1 + fi +done diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel new file mode 100755 index 000000000..f8b813d28 --- /dev/null +++ b/tests/regression/tools/streaming/test_kernel @@ -0,0 +1,119 @@ +#!/bin/bash +# +# Copyright (C) - 2012 David Goulet +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="Streaming - Kernel tracing" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +EVENT_NAME="sched_switch" +PID_RELAYD=0 +SESSION_NAME="" + +TRACE_PATH=$(mktemp -d) + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +if [ "$(id -u)" != "0" ]; then + echo "This test must be running as root. Aborting" + # Exit status 0 so the tests can continue + exit 0 +fi + +# LTTng kernel modules check +out=`ls /lib/modules/$(uname -r)/extra | grep lttng` +if [ -z "$out" ]; then + echo "LTTng modules not detected. Aborting kernel tests!" + echo "" + # Exit status 0 so the tests can continue + exit 0 +fi + +function lttng_create_session_uri +{ + echo -n "Creating session $SESSION_NAME... " + # Create session with default path + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 + if [ $? -eq 1 ]; then + print_fail + return 1 + else + print_ok + fi +} + +function test_kernel_before_start () +{ + echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n" + lttng_create_session_uri + lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + # Give a second + sleep 1 + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # We can not predict _yet_ when the trace is available so we have to do a + # arbitratry sleep to validate the trace. + echo -n "Waiting 3 seconds for the trace to be written on disk " + for i in `seq 1 3`; do + echo -n "." + sleep 1 + done + echo "" +} + +# Deactivated since this feature is not yet available where we can enable +# an event AFTERE tracing has started. +function test_kernel_after_start () +{ + echo -e "\n=== Testing kernel streaming with event enable AFTER start\n" + lttng_create_session_uri + start_lttng_tracing $SESSION_NAME + lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME + # Give a second + sleep 1 + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME +} + +start_lttng_sessiond +start_lttng_relayd "-o $TRACE_PATH" + +tests=( test_kernel_before_start ) + +for fct_test in ${tests[@]}; +do + SESSION_NAME=$(randstring 16 0) + ${fct_test} + + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + else + break + fi +done + +echo "" +stop_lttng_sessiond +stop_lttng_relayd + + +exit $out diff --git a/tests/regression/tools/streaming/test_uri_switch b/tests/regression/tools/streaming/test_uri_switch new file mode 100755 index 000000000..06a3fbcd4 --- /dev/null +++ b/tests/regression/tools/streaming/test_uri_switch @@ -0,0 +1,217 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# David Goulet +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="Streaming - URI switching" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +BIN_NAME="gen-ust-events" +SESSION_NAME="stream" +EVENT_NAME="tp:tptest" +PID_RELAYD=0 + +TRACE_PATH=$(mktemp -d) + +source $TESTDIR/utils/utils.sh + +print_test_banner "$TEST_DESC" + +if [ ! -x "$CURDIR/$BIN_NAME" ]; then + echo -e "No UST nevents binary detected. Skipping." + exit 0 +fi + +function lttng_create_session +{ + URI=$1 + # Create session with custom URI + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $URI $SESSION_NAME >/dev/null 2>&1 +} + +function lttng_enable_consumer +{ + URI=$1 + # Create session with custom URI + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $URI >/dev/null 2>&1 +} + +function run_apps +{ + # Run 5 times with a 1 second delay + COUNT=5 + APP_DELAY=1000000 + ./$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev/null 2>&1 & + +} + +function wait_apps +{ + echo -n "Waiting for applications to end" + while [ -n "$(pidof $BIN_NAME)" ]; do + echo -n "." + sleep 0.5 + done + echo "" +} + +function test_uri_switch_localhost_folder +{ + IPVER=$1 + echo -e "\n=== Testing switch of localhost folder ($IPVER)\n" + + if [ "$IPVER" == "IPv6" ]; then + BASE_URI="net6://localhost" + else + BASE_URI="net://localhost" + fi + + RANDCOUNT=10 + RAND="" + i=1 + + lttng_create_session $BASE_URI + + echo -e "Randomizing output folder on $BASE_URI..." + while [ "$i" -le $RANDCOUNT ] + do + RAND=$(randstring 16 0) + lttng_enable_consumer "$BASE_URI/$RAND" + let "i += 1" + done + + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + run_apps + wait_apps + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND + + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi +} + +function test_uri_switch_file_network +{ + IPVER=$1 + echo "" + echo -e "=== Testing switch file -> network ($IPVER)" + + TMP_PATH=$(mktemp -d) + FILE_URI="file://$TMP_PATH" + + if [ "$IPVER" == "IPv6" ]; then + NETWORK_URIS=("net6://localhost" "net6://[::1]") + else + NETWORK_URIS=("net://localhost" "net://127.0.0.1") + fi + + NET_PATHS=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".") + + for NETWORK_URI in ${NETWORK_URIS[@]}; + do + for NET_PATH in ${NET_PATHS[@]}; + do + SESSION_NAME=$(randstring 16 0) + echo "" + echo "$FILE_URI -> $NETWORK_URI/$NET_PATH" + + lttng_create_session $FILE_URI + lttng_enable_consumer "$NETWORK_URI/$NET_PATH" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + run_apps + wait_apps + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH + + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + else + break + fi + done + done + rm -rf $TMP_PATH +} + +function test_uri_switch_network_file +{ +IPVER=$1 + echo "" + echo -e "=== Testing switch network ($IPVER) -> file" + + if [ "$IPVER" == "IPv6" ]; then + NETWORK_URI="net6://localhost" + else + NETWORK_URI="net://localhost" + fi + + FILE_PATHS=("." "foo/bar" "42") + + for FILE_PATH in ${FILE_PATHS[@]}; + do + TMP_PATH=$(mktemp -d) + FILE_URI="file://$TMP_PATH" + SESSION_NAME=$(randstring 16 0) + + echo "" + echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH" + + lttng_create_session $NETWORK_URI + lttng_enable_consumer "$FILE_URI/$FILE_PATH" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + run_apps + wait_apps + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + validate_trace $EVENT_NAME $TMP_PATH/$FILE_PATH + + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TMP_PATH + else + break + fi + done +} + + +start_lttng_sessiond + +echo "" +echo "=== Testing with IPv4" +start_lttng_relayd "-o $TRACE_PATH" +test_uri_switch_localhost_folder "IPv4" +test_uri_switch_file_network "IPv4" +test_uri_switch_network_file "IPv4" +stop_lttng_relayd + +echo "" +echo "=== Testing with IPv6" +start_lttng_relayd "-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343" +test_uri_switch_localhost_folder "IPv6" +test_uri_switch_file_network "IPv6" +test_uri_switch_network_file "IPv6" +stop_lttng_relayd + +stop_lttng_sessiond diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust new file mode 100755 index 000000000..6e6e5a752 --- /dev/null +++ b/tests/regression/tools/streaming/test_ust @@ -0,0 +1,110 @@ +#!/bin/bash +# +# Copyright (C) - 2012 David Goulet +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="Streaming - User space tracing" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +BIN_NAME="gen-ust-events" +SESSION_NAME="stream" +EVENT_NAME="tp:tptest" +PID_RELAYD=0 + +TRACE_PATH=$(mktemp -d) + +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 +fi + +function lttng_create_session_uri +{ + # Create session with default path + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 +} + +function wait_apps +{ + echo -n "Waiting for applications to end" + while [ -n "$(pidof $BIN_NAME)" ]; do + echo -n "." + sleep 0.5 + done + echo "" +} + +# MUST set TESTDIR before calling those functions + +function test_ust_before_start () +{ + echo -e "\n=== Testing UST streaming BEFORE tracing starts\n" + lttng_create_session_uri + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + + # Run 5 times with a 1 second delay + ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 & + + start_lttng_tracing $SESSION_NAME + + wait_apps + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME +} + +function test_ust_after_start () +{ + echo -e "\n=== Testing UST streaming AFTER tracing starts\n" + lttng_create_session_uri + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 & + + wait_apps + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME +} + +start_lttng_sessiond +start_lttng_relayd "-o $TRACE_PATH" + +tests=( test_ust_before_start test_ust_after_start ) + +for fct_test in ${tests[@]}; +do + SESSION_NAME=$(randstring 16 0) + ${fct_test} + + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + else + break + fi +done + +echo "" +stop_lttng_sessiond +stop_lttng_relayd + +exit $out diff --git a/tests/regression/tools/streaming/uri_switch b/tests/regression/tools/streaming/uri_switch deleted file mode 100755 index 06a3fbcd4..000000000 --- a/tests/regression/tools/streaming/uri_switch +++ /dev/null @@ -1,217 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 Christian Babeux -# David Goulet -# -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -TEST_DESC="Streaming - URI switching" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -BIN_NAME="gen-ust-events" -SESSION_NAME="stream" -EVENT_NAME="tp:tptest" -PID_RELAYD=0 - -TRACE_PATH=$(mktemp -d) - -source $TESTDIR/utils/utils.sh - -print_test_banner "$TEST_DESC" - -if [ ! -x "$CURDIR/$BIN_NAME" ]; then - echo -e "No UST nevents binary detected. Skipping." - exit 0 -fi - -function lttng_create_session -{ - URI=$1 - # Create session with custom URI - $TESTDIR/../src/bin/lttng/$LTTNG_BIN create -U $URI $SESSION_NAME >/dev/null 2>&1 -} - -function lttng_enable_consumer -{ - URI=$1 - # Create session with custom URI - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u $URI >/dev/null 2>&1 -} - -function run_apps -{ - # Run 5 times with a 1 second delay - COUNT=5 - APP_DELAY=1000000 - ./$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev/null 2>&1 & - -} - -function wait_apps -{ - echo -n "Waiting for applications to end" - while [ -n "$(pidof $BIN_NAME)" ]; do - echo -n "." - sleep 0.5 - done - echo "" -} - -function test_uri_switch_localhost_folder -{ - IPVER=$1 - echo -e "\n=== Testing switch of localhost folder ($IPVER)\n" - - if [ "$IPVER" == "IPv6" ]; then - BASE_URI="net6://localhost" - else - BASE_URI="net://localhost" - fi - - RANDCOUNT=10 - RAND="" - i=1 - - lttng_create_session $BASE_URI - - echo -e "Randomizing output folder on $BASE_URI..." - while [ "$i" -le $RANDCOUNT ] - do - RAND=$(randstring 16 0) - lttng_enable_consumer "$BASE_URI/$RAND" - let "i += 1" - done - - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - run_apps - wait_apps - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND - - if [ $? -eq 0 ]; then - # Only delete if successful - rm -rf $TRACE_PATH - fi -} - -function test_uri_switch_file_network -{ - IPVER=$1 - echo "" - echo -e "=== Testing switch file -> network ($IPVER)" - - TMP_PATH=$(mktemp -d) - FILE_URI="file://$TMP_PATH" - - if [ "$IPVER" == "IPv6" ]; then - NETWORK_URIS=("net6://localhost" "net6://[::1]") - else - NETWORK_URIS=("net://localhost" "net://127.0.0.1") - fi - - NET_PATHS=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".") - - for NETWORK_URI in ${NETWORK_URIS[@]}; - do - for NET_PATH in ${NET_PATHS[@]}; - do - SESSION_NAME=$(randstring 16 0) - echo "" - echo "$FILE_URI -> $NETWORK_URI/$NET_PATH" - - lttng_create_session $FILE_URI - lttng_enable_consumer "$NETWORK_URI/$NET_PATH" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - run_apps - wait_apps - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH - - if [ $? -eq 0 ]; then - # Only delete if successful - rm -rf $TRACE_PATH - else - break - fi - done - done - rm -rf $TMP_PATH -} - -function test_uri_switch_network_file -{ -IPVER=$1 - echo "" - echo -e "=== Testing switch network ($IPVER) -> file" - - if [ "$IPVER" == "IPv6" ]; then - NETWORK_URI="net6://localhost" - else - NETWORK_URI="net://localhost" - fi - - FILE_PATHS=("." "foo/bar" "42") - - for FILE_PATH in ${FILE_PATHS[@]}; - do - TMP_PATH=$(mktemp -d) - FILE_URI="file://$TMP_PATH" - SESSION_NAME=$(randstring 16 0) - - echo "" - echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH" - - lttng_create_session $NETWORK_URI - lttng_enable_consumer "$FILE_URI/$FILE_PATH" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME - start_lttng_tracing $SESSION_NAME - run_apps - wait_apps - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - validate_trace $EVENT_NAME $TMP_PATH/$FILE_PATH - - if [ $? -eq 0 ]; then - # Only delete if successful - rm -rf $TMP_PATH - else - break - fi - done -} - - -start_lttng_sessiond - -echo "" -echo "=== Testing with IPv4" -start_lttng_relayd "-o $TRACE_PATH" -test_uri_switch_localhost_folder "IPv4" -test_uri_switch_file_network "IPv4" -test_uri_switch_network_file "IPv4" -stop_lttng_relayd - -echo "" -echo "=== Testing with IPv6" -start_lttng_relayd "-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343" -test_uri_switch_localhost_folder "IPv6" -test_uri_switch_file_network "IPv6" -test_uri_switch_network_file "IPv6" -stop_lttng_relayd - -stop_lttng_sessiond