mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
test: misc refactor
- Repeat simple tests that may fail upon multiple invocations. - ...
This commit is contained in:
parent
bdfa812d79
commit
9da346753d
5 changed files with 52 additions and 41 deletions
|
@ -154,19 +154,11 @@ check_watcher (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
char const *path = NULL;
|
if (--argc < 1) {
|
||||||
|
|
||||||
OPT_START(argc, argv, "d:")
|
|
||||||
OPT_OPT('d') {
|
|
||||||
path = optarg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
OPT_END
|
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
log_puts("path not specified");
|
log_puts("path not specified");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
char const *path = *(++argv);
|
||||||
|
|
||||||
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
if (dirfd < 0) {
|
if (dirfd < 0) {
|
||||||
|
|
|
@ -19,23 +19,26 @@ ATX_CHECK_LIB([
|
||||||
echo "$2" | check-util-lib hash -s$1
|
echo "$2" | check-util-lib hash -s$1
|
||||||
}
|
}
|
||||||
|
|
||||||
seed=$(ath_fn_rand_u64_hex)
|
ATX_RUN_REPEAT([16], [
|
||||||
input=$(ath_fn_rand_base64 300)
|
seed=$(ath_fn_rand_u64_hex)
|
||||||
|
input=$(ath_fn_rand_base64 300)
|
||||||
|
echo "hash seed: $seed; input: $input"
|
||||||
|
|
||||||
hash_1=$(calc_digest $seed $input)
|
hash_1=$(calc_digest $seed $input)
|
||||||
hash_2=$(calc_digest $seed $input)
|
hash_2=$(calc_digest $seed $input)
|
||||||
hash_3=$(calc_digest $seed $input)
|
hash_3=$(calc_digest $seed $input)
|
||||||
hash_x=$(calc_digest $seed $input+)
|
hash_x=$(calc_digest $seed $input+)
|
||||||
|
|
||||||
if test "$hash_1" != "$hash_2" -o "$hash_2" != "$hash_3"; then
|
if test "$hash_1" != "$hash_2" -o "$hash_2" != "$hash_3"; then
|
||||||
echo 'bad hash function: inconsistent digest'
|
echo 'bad hash function: inconsistent digest'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$hash_1" = "$hash_x"; then
|
if test "$hash_1" = "$hash_x"; then
|
||||||
echo 'bad hash function: collision'
|
echo 'bad hash function: collision'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
|
@ -18,23 +18,26 @@ ATX_CHECK_LIB([
|
||||||
check-util-lib prng -s$1 -n$2
|
check-util-lib prng -s$1 -n$2
|
||||||
}
|
}
|
||||||
|
|
||||||
seed=$(ath_fn_prng_seed)
|
ATX_RUN_REPEAT([16], [
|
||||||
count=32
|
seed=$(ath_fn_prng_seed)
|
||||||
|
count=32
|
||||||
|
echo "prng seed: $seed"
|
||||||
|
|
||||||
num_1=$(gen_num $seed $count)
|
num_1=$(gen_num $seed $count)
|
||||||
num_2=$(gen_num $seed $count)
|
num_2=$(gen_num $seed $count)
|
||||||
num_3=$(gen_num $seed $count)
|
num_3=$(gen_num $seed $count)
|
||||||
|
|
||||||
if test "$num_1" != "$num_2" -o "$num_2" != "$num_3"; then
|
if test "$num_1" != "$num_2" -o "$num_2" != "$num_3"; then
|
||||||
echo 'bad prng: inconsistent number sequence'
|
echo 'bad prng: inconsistent number sequence'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uniq_count=$(echo "$num_1" | sort | uniq | wc -l)
|
uniq_count=$(echo "$num_1" | sort | uniq | wc -l)
|
||||||
if test $uniq_count -ne $count; then
|
if test $uniq_count -ne $count; then
|
||||||
echo 'bad prng: getting duplicates too soon'
|
echo 'bad prng: getting duplicates too soon'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
|
@ -16,7 +16,7 @@ ATX_CHECK_LIB([
|
||||||
mkdir $tmpdir
|
mkdir $tmpdir
|
||||||
|
|
||||||
ATX_RUN([
|
ATX_RUN([
|
||||||
check-util-lib watcher -d $tmpdir
|
check-util-lib watcher $tmpdir
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,19 @@ m4_define([ATX_FEAT_PREREQ], [
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl ATX_RUN_REPEAT(n, script)
|
||||||
|
dnl
|
||||||
|
dnl Run script n times. Cannot be nested.
|
||||||
|
dnl
|
||||||
|
m4_define([ATX_RUN_REPEAT], [
|
||||||
|
atx_counter_=$1
|
||||||
|
while test $atx_counter_ -gt 0; do
|
||||||
|
$2
|
||||||
|
atx_counter_=$(($atx_counter_ - 1))
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl ATX_RUN_ONE(cmd)
|
dnl ATX_RUN_ONE(cmd)
|
||||||
dnl
|
dnl
|
||||||
|
@ -71,10 +84,10 @@ m4_define([ATX_RUN], [
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl ATX_CHECK_SIMPLE(script)
|
dnl ATX_CHECK_SIMPLE(script, [cleanup])
|
||||||
dnl
|
dnl
|
||||||
m4_define([ATX_CHECK_SIMPLE], [
|
m4_define([ATX_CHECK_SIMPLE], [
|
||||||
AT_CHECK([$1], , [ignore], [ignore])
|
AT_CHECK([$1], , [ignore], [ignore], [$2], [$2])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
|
Loading…
Add table
Reference in a new issue