From: Simon Marchi Date: Sat, 5 Oct 2024 01:08:40 +0000 (-0400) Subject: tests: factor out discarded packet regex in test-packet-seq-num.sh X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=c755b631564a45aa270ad8c4735dde19dd87544b;p=babeltrace.git tests: factor out discarded packet regex in test-packet-seq-num.sh The regex used in `test_no_lost()` is outdated, which means that if Babeltrace were to emit an unexpected discarded packets message, the test would not catch it. Fix it by factoring the regex used to look for discarded packets messages. At least now, we can have the confidence that we're looking for the right thing, otherwise the `test_lost()` tests wouldn't pass. In general, it's fragile to check for the absence of something, since a typo or change in what to look can easily make the test uneffective. I initially re-wrote this test in Python (the test is in the `cli` directory, but its intent is more to validate the source's behavior than to validate the CLI's behavior), but this simple change seems good enough for now. Change-Id: I9f8c30a567fa6f5036cadcc4691c3bd6f953ca3d Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/13309 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/tests/cli/test-packet-seq-num.sh b/tests/cli/test-packet-seq-num.sh index 47d0c3d7..704746bd 100755 --- a/tests/cli/test-packet-seq-num.sh +++ b/tests/cli/test-packet-seq-num.sh @@ -20,13 +20,15 @@ NUM_TESTS=10 plan_tests $NUM_TESTS +discarded_re="WARNING: Tracer discarded" + test_no_lost() { local trace=$1 bt_cli "/dev/null" "/dev/null" "$trace" ok $? "Trace parses" - bt_cli /dev/null /dev/fd/3 "$trace" 3>&1 | bt_grep "\[warning\] Tracer lost" + bt_cli /dev/null /dev/fd/3 "$trace" 3>&1 | bt_grep "$discarded_re" isnt $? 0 "No events lost" } @@ -41,7 +43,7 @@ test_lost() { # WARNING: Tracer discarded 2 trace packets between .... # WARNING: Tracer discarded 3 trace packets between .... # into "2,3" and make sure it matches the expected result - bt_cli /dev/null /dev/fd/3 "$trace" 3>&1 | bt_grep "WARNING: Tracer discarded" \ + bt_cli /dev/null /dev/fd/3 "$trace" 3>&1 | bt_grep "$discarded_re" \ | cut -d" " -f4 | tr "\n" "," | "${BT_TESTS_SED_BIN}" "s/.$//" | \ bt_grep "$expectedcountstr" >/dev/null ok $? "Lost events string matches $expectedcountstr"