]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: shuf: ensure randomization doesn't depend solely on ASLR
authoroech3 <79379754+oech3@users.noreply.github.com>
Thu, 26 Feb 2026 12:04:56 +0000 (21:04 +0900)
committerPádraig Brady <P@draigBrady.com>
Thu, 26 Feb 2026 15:55:07 +0000 (15:55 +0000)
* tests/shuf/shuf.sh: Use setarch --addr-no-randomize to disable
ASLR, and show the output is still random.
https://github.com/coreutils/coreutils/pull/198

tests/shuf/shuf.sh

index 12688c631184533a5a622c67c4ba2bb6dfae0d16..662d1a5f2addbf34a4cde8abca495cc06571dd77 100755 (executable)
 print_ver_ shuf
 getlimits_
 
+# ensure randomization doesn't depend solely on ASLR
+# This is a probabilistic test :-)
+# However, the odds of failure are low: 1 in $UINTMAX_MAX (~ 1 in 4B on 32 bit)
+shuf_rand() { setarch -R shuf -i 1-$UINTMAX_MAX -n 1; }
+shuf_rand >out1 && shuf_rand >out2 && compare out1 out2 && fail=1
+
 seq 100 > in || framework_failure_
 
 shuf in >out || fail=1