bookmarkfs/tests/lib_prng.at
CismonX 303c934894
test: misc refactor
- If the utility library is not built, link to the existing library
  when building helper programs for filesystem tests.
- Refactor PRNG seeding in tests.
2025-06-11 20:45:16 +08:00

42 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
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