From bf87ea0a1cecef22b232f8182296010c06befd45 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 3 Oct 2025 14:20:56 -0700 Subject: [PATCH] Add option to shuffle test order. The `-R` option will shuffle the order in which tests are executed. The testing order shouldn't affect the outcome of any of the tests, but in practice many of these tests will execute code slightly different based on the history of the filesystem, resources allocated, memory usage etc. of tests that were executed before. Shuffling the order of tests therefore introduces small semi-random variations in the enviroment. The xfstests test is the only one that can't be shuffled yet into the mix, so it is kept at the end. This is because it leaves the filesystems unmounted. At a later point we may want to address this. Signed-off-by: Auke Kok --- tests/run-tests.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index b9917d4f..f8294fca 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -69,6 +69,7 @@ $(basename $0) options: -r | Specify the directory in which to store results of | test runs. The directory will be created if it doesn't | exist. Previous results will be deleted as each test runs. + -R | shuffle the test order randomly using shuf -s | Skip git repo checkouts. -t | Enabled trace events that match the given glob argument. | Multiple options enable multiple globbed events. @@ -164,6 +165,9 @@ while true; do T_RESULTS="$2" shift ;; + -R) + T_SHUF="1" + ;; -s) T_SKIP_CHECKOUT="1" ;; @@ -261,13 +265,26 @@ for e in T_META_DEVICE T_DATA_DEVICE T_EX_META_DEV T_EX_DATA_DEV T_KMOD T_RESULT eval $e=\"$(readlink -f "${!e}")\" done +# permute sequence? +T_SEQUENCE=sequence +if [ -n "$T_SHUF" ]; then + msg "shuffling test order" + shuf sequence -o sequence.shuf + # keep xfstests at the end + if grep -q 'xfstests.sh' sequence.shuf ; then + sed -i '/xfstests.sh/d' sequence.shuf + echo "xfstests.sh" >> sequence.shuf + fi + T_SEQUENCE=sequence.shuf +fi + # include everything by default test -z "$T_INCLUDE" && T_INCLUDE="-e '.*'" # (quickly) exclude nothing by default test -z "$T_EXCLUDE" && T_EXCLUDE="-e '\Zx'" # eval to strip re ticks but not expand -tests=$(grep -v "^#" sequence | +tests=$(grep -v "^#" $T_SEQUENCE | eval grep "$T_INCLUDE" | eval grep -v "$T_EXCLUDE") test -z "$tests" && \ die "no tests found by including $T_INCLUDE and excluding $T_EXCLUDE"