Skip to content

Commit

Permalink
test: Add support for a @@Nosort tag
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Sep 8, 2022
1 parent f256db8 commit 79112e2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,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.
Expand Down Expand Up @@ -1313,12 +1319,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"
Expand Down

0 comments on commit 79112e2

Please sign in to comment.