X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fexclusion%2Ftest_exclusion;h=6b3a14fd476ffdb33771f470baecf75c188da12b;hb=9f2636716abf0d6cc188fed380ba77a621a370c1;hp=e41925fa5ea7eb5e93d88e84d9166c6fabe3d8c2;hpb=a0e115d5d7da3603a66d1da958ad19f72e2bb5b2;p=lttng-tools.git diff --git a/tests/regression/tools/exclusion/test_exclusion b/tests/regression/tools/exclusion/test_exclusion index e41925fa5..6b3a14fd4 100755 --- a/tests/regression/tools/exclusion/test_exclusion +++ b/tests/regression/tools/exclusion/test_exclusion @@ -9,14 +9,15 @@ TEST_DESC="Event exclusion" CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. -STATS_BIN="$TESTDIR/utils/babelstats.pl" +BT2_PLUGINS_DIR="${TESTDIR}/utils/bt2_plugins" + SESSION_NAME="test-exclusion" TESTAPP_PATH="$TESTDIR/utils/testapp" TESTAPP_NAME="gen-ust-nevents" TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" NR_ITER=100 NR_USEC_WAIT=1 -NUM_TESTS=178 +NUM_TESTS=185 source $TESTDIR/utils/utils.sh @@ -30,7 +31,7 @@ function enable_ust_lttng_all_event_exclusion() function run_apps { - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 + $TESTAPP_BIN --iter $NR_ITER --wait $NR_USEC_WAIT >/dev/null 2>&1 ok $? "Running test application" } @@ -40,7 +41,7 @@ function run_apps # of our test suite to generate events. function dry_run { - trace_path=$(mktemp -d) + local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") # Create session create_lttng_session_ok $SESSION_NAME $trace_path @@ -53,7 +54,7 @@ function dry_run run_apps stop_lttng_tracing_ok $SESSION_NAME - nb_events=$(babeltrace $trace_path | wc -l) + nb_events=$("$BABELTRACE_BIN" $trace_path | wc -l) if [ "$nb_events" -ne "0" ]; then ok 0 "Events were found during the dry run without exclusion" else @@ -68,9 +69,9 @@ function dry_run function test_exclusion { - exclusions="$1" - event_name_expected_to_be_missing="$2" - trace_path=$(mktemp -d) + local exclusions="$1" + local event_name_expected_to_be_missing="$2" + local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") # Create session create_lttng_session_ok $SESSION_NAME $trace_path @@ -86,13 +87,69 @@ function test_exclusion # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null` + stats=$("$BABELTRACE_BIN" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index 2> /dev/null) + if [ ! -z "$stats" ]; then + fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" + else + ok 0 "Validate trace exclusion output" + rm -rf $trace_path + fi +} + +function test_exclusion_tracing_started +{ + local exclusions="$1" + local event_name_expected_to_be_missing="$2" + local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") + local file_wait_before_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_first.XXXXXX") + local file_create_in_main=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_create_in_main.XXXXXX") + + # Create session + create_lttng_session_ok $SESSION_NAME $trace_path + + # Enable a dummy event so that the session is active after we start the + # session. + enable_ust_lttng_event_ok $SESSION_NAME "non-existent-event" + + # Start the tracing + start_lttng_tracing_ok $SESSION_NAME + + # Launch the test app and make it create a sync file once it's in the + # main function. + $TESTAPP_BIN -i 1 -w 10000 \ + --create-in-main ${file_create_in_main} \ + --wait-before-first-event ${file_wait_before_first} 2>&1 & + + while [ ! -f "${file_create_in_main}" ]; do + sleep 0.5 + done + + # Enable an event with an exclusion once the tracing is active in the + # UST app. + enable_ust_lttng_all_event_exclusion $SESSION_NAME "$exclusions" + ok $? "Enable lttng event with event \"$exclusions\" excluded" + + # Create the sync file so that the test app starts generating events. + touch ${file_wait_before_first} + + # Wait for the testapp to finish. + wait + + stop_lttng_tracing_ok $SESSION_NAME + + # Destroy session + destroy_lttng_session_ok $SESSION_NAME + + stats=$("$BABELTRACE_BIN" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index 2> /dev/null) if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else ok 0 "Validate trace exclusion output" rm -rf $trace_path fi + + rm -f $file_wait_before_first + rm -f $file_create_in_main } function test_exclusion_fail @@ -118,6 +175,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond diag "Enable event without exclusion" @@ -147,6 +206,8 @@ test_exclusion '*3' 'tp:tptest3' test_exclusion 'tp*test3,*2' 'tp:tptest2' test_exclusion '**tp*test3,*2' 'tp:tptest3' +test_exclusion_tracing_started 'tp:tptest1' 'tp:tptest1' + diag "Cannot use exclusions with non-globbing event name" test_exclusion_fail "allo" "lol" test_exclusion_fail "allo" "meow,lol"