[DTrace-devel] [PATCH 2/3] test: Add support for a @@nosort tag

eugene.loh at oracle.com eugene.loh at oracle.com
Thu Sep 1 17:32:35 UTC 2022


From: Eugene Loh <eugene.loh at oracle.com>

By default, we sort test results before comparing with a .r results
file, since test results often do not have a well-defined order.
For example, probes firing on different CPUs emit output in varying
order.

Some tests, however, check for particular ordering.

Add a tag to suppress the default sort behavior.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 runtest.sh | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/runtest.sh b/runtest.sh
index 0fe1cdb0..6996087f 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -837,6 +837,12 @@ for dt in $dtrace; do
         # @@link: A library to link .c programs against (see below).  -ldtrace
         #         by default.
         #
+        # @@nosort: If present, this means do not sort before comparing results
+        #           with a .r file.  Results are sorted by default, since many
+        #           test results do not have a well-defined order -- notably,
+        #           when generated on different CPUs.  Some tests, however,
+        #           care about strict ordering.
+        #
         # Certain filenames of test .d script are treated specially:
         #
         # tst.*.d: These are assumed to have /* @@trigger: none */ by default.
@@ -1310,12 +1316,20 @@ for dt in $dtrace; do
             want_all_output=
             failmsg=
 
+            # By default, sort before comparing since test results often
+            # have indeterminate order (generated on different CPUs, etc.).
+            if exist_options nosort $_test; then
+                sortcmd=cat
+            else
+                sortcmd=sort
+            fi
+
             # Compare results, if available, and log the diff.
             rfile=$base.$arch.r
             [[ -e $rfile ]] || rfile=$base.r
 
             if [[ -e $rfile ]] && [[ -n $COMPARISON ]] &&
-               ! diff -u <(sort $rfile) <(sort $tmpdir/test.out) >/dev/null; then
+               ! diff -u <($sortcmd $rfile) <($sortcmd $tmpdir/test.out) >/dev/null; then
 
                 fail=t
                 failmsg="expected results differ"
-- 
2.18.4




More information about the DTrace-devel mailing list