[DTrace-devel] [PATCH] Enforce error and drop tag verification for tests.
Kris Van Hees
kris.van.hees at oracle.com
Thu Mar 19 15:16:21 PDT 2020
Various tests exercise error and probe drop conditions and request
that a representative error or drop tag is included in the output.
Tests that are named err.* will be executed with the -xerrtags option
and drp.* tests add the -xdroptags option.
Up until now there was no explicit verification in runtest.sh to
ensure that a test reports the correct tag. This patch adds that
verification.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
runtest.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/runtest.sh b/runtest.sh
index 6ec9f08c..7c0957ce 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -1071,10 +1071,13 @@ for dt in $dtrace; do
raw_dt_flags="$test_incflags"
+ expected_tag=
if [[ $testonly =~ ^err\.D_ ]]; then
raw_dt_flags="$raw_dt_flags -xerrtags"
+ expected_tag="$(echo ''"$testonly" | sed 's,^err\.,,; s,\..*$,,')"
elif [[ $testonly =~ ^drp\. ]]; then
raw_dt_flags="$raw_dt_flags -xdroptags"
+ expected_tag="$(echo ''"$testonly" | sed 's,^drp\.,,; s,\..*$,,')"
fi
dt_flags="$_exit $raw_dt_flags -s $_test"
@@ -1252,6 +1255,14 @@ for dt in $dtrace; do
fi
fi
+ # If we are expecting a specific tag in the error output, make sure
+ # it is present. If found, we clear expected_tag to signal that
+ # all is fine.
+ if [[ -n $expected_tag ]] &&
+ grep -q "\[$expected_tag\]" $testerr; then
+ expected_tag=
+ fi
+
if [[ -n $this_noexec ]]; then
testmsg="no execution"
fi
@@ -1310,6 +1321,12 @@ for dt in $dtrace; do
fail=t
failmsg="core dumped"
+ # Expected tag not found.
+ elif [[ -n $expected_tag ]]; then
+ fail=t
+ failmsg="expected tag $expected_tag"
+ reinvoke_failure=-1
+
# Detect a timeout.
elif [[ $exitcode -eq $TIMEOUTRET ]] && [[ -z $IGNORE_TIMEOUTS ]] &&
[[ "x$(extract_options timeout-success $_test)" = "x" ]]; then
--
2.25.0
More information about the DTrace-devel
mailing list