From afa7d3f1c0fae5ab6acb5e2fff3eaaa5558d6743 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 11 Feb 2020 18:27:35 -0500 Subject: [PATCH] Fix: Tests: `test_exclusion` passing for the wrong reason MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue ===== The following commit added `-i` and `-w` flags to the test app arguments of the `test_exclusion` tests: commit 6c4a91d639747f260ab46decebc50998ef063712 Author: Mathieu Desnoyers Date: Mon Aug 26 14:22:06 2019 -0400 tests: gen-ust-events: use options instead of arguments Remove argument dependency and ease usage of features individually. The `gen-ust-nevents` was not modified to support those flags. I suspect this mistake was caused by the name similarity of the `gen-ust-nevents` and the `gen-ust-events` test applications. We ended up calling the following command: ./gen-ust-nevents -i 100 -w -1 When called with such arguments the `gen-ust-nevents` parsed the first argument (`-i`) using `atoi()` which retuned 0. This was interpreted as the number of iterations requested by the user so the app immediately exited without generating any events. So, the test was not seeing any of the excluded events in the trace which was then considered as a successful result but no events were ever excluded because none were generated in the first place. Solution ======== Remove the use of `-i` and `-w` flags. I also added a `dry_run` test to confirm that we do indeed get events when exclusions are not used to prevent this error from happening in the future. Notes ===== - I changed the wildcard used in the enable-event command so to only enable events from the testapp and not the `lttng_ust_statedump:` events as those are generated even if we didnt' ask for them. - I add a stderr redirection to `/dev/null` in the trace reading pipeline because we now end up with traces with no events. This has changed because we now only enable events from the application (see previous note). - In a future commit, I will change the `gen-ust-nevents` application to take those `-i` and `-w` flags. Signed-off-by: Francis Deslauriers Change-Id: Id37dcd59a18b3401d97439bce1191a8c5cac87d5 Signed-off-by: Jérémie Galarneau --- .../regression/tools/exclusion/test_exclusion | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/tests/regression/tools/exclusion/test_exclusion b/tests/regression/tools/exclusion/test_exclusion index 6cd808c6d..d29553582 100755 --- a/tests/regression/tools/exclusion/test_exclusion +++ b/tests/regression/tools/exclusion/test_exclusion @@ -16,7 +16,7 @@ TESTAPP_NAME="gen-ust-nevents" TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" NR_ITER=100 NR_USEC_WAIT=1 -NUM_TESTS=149 +NUM_TESTS=178 source $TESTDIR/utils/utils.sh @@ -25,12 +25,45 @@ function enable_ust_lttng_all_event_exclusion() sess_name="$1" exclusion="$2" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -u "tp:*" -s $sess_name -x "$exclusion" } function run_apps { - $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1 + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 + ok $? "Running test application" +} + +# Testing for the absence of an event when testing exclusion is tricky. An +# event could be absent because our exclusion mechanism works but also because +# the event was not generate in the first place. This function test the ability +# of our test suite to generate events. +function dry_run +{ + trace_path=$(mktemp -d) + + # Create session + create_lttng_session_ok $SESSION_NAME $trace_path + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -u "tp:*" -s $SESSION_NAME > /dev/null + ok $? "Enabling events without exclusion" + + # Trace apps + start_lttng_tracing_ok $SESSION_NAME + run_apps + stop_lttng_tracing_ok $SESSION_NAME + + nb_events=$(babeltrace $trace_path | wc -l) + if [ "$nb_events" -ne "0" ]; then + ok 0 "Events were found during the dry run without exclusion" + else + fail "No events were found during the dry run without exclusion" + fi + + rm -rf $trace_path + + # Destroy session + destroy_lttng_session_ok $SESSION_NAME } function test_exclusion @@ -53,7 +86,7 @@ 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` + stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null` if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else @@ -87,6 +120,8 @@ print_test_banner $TEST_DESC start_lttng_sessiond +dry_run + test_exclusion 'tp:tptest2' 'tp:tptest2' test_exclusion 'tp:tptest3' 'tp:tptest3' test_exclusion 'tp:tptest*' 'tp:tptest1' -- 2.34.1