bookmarkfs/tests/lib_prng.at
CismonX 9da346753d
test: misc refactor
- Repeat simple tests that may fail upon multiple invocations.
- ...
2025-03-28 14:29:18 +08:00

43 lines
1.1 KiB
Text

dnl
dnl Copyright (C) 2025 CismonX <admin@cismon.net>
dnl
dnl Copying and distribution of this file, with or without modification,
dnl are permitted in any medium without royalty,
dnl provided the copyright notice and this notice are preserved.
dnl This file is offered as-is, without any warranty.
dnl
AT_SETUP([util lib: prng])
AT_KEYWORDS([lib prng])
# This test only serves as a basic sanity check.
#
# For reliable testing of PRNGs, see <https://prng.di.unimi.it/#quality>.
ATX_CHECK_LIB([
gen_num() {
check-util-lib prng -s$1 -n$2
}
ATX_RUN_REPEAT([16], [
seed=$(ath_fn_prng_seed)
count=32
echo "prng seed: $seed"
num_1=$(gen_num $seed $count)
num_2=$(gen_num $seed $count)
num_3=$(gen_num $seed $count)
if test "$num_1" != "$num_2" -o "$num_2" != "$num_3"; then
echo 'bad prng: inconsistent number sequence'
exit 1
fi
uniq_count=$(echo "$num_1" | sort | uniq | wc -l)
if test $uniq_count -ne $count; then
echo 'bad prng: getting duplicates too soon'
exit 1
fi
])
])
AT_CLEANUP