mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-07-16 14:18:54 +00:00
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.
This commit is contained in:
parent
14b5a79147
commit
303c934894
14 changed files with 38 additions and 63 deletions
|
@ -31,13 +31,13 @@ if BOOKMARKFS_MOUNT
|
||||||
|
|
||||||
check_fs_CPPFLAGS = -I$(top_srcdir)/src
|
check_fs_CPPFLAGS = -I$(top_srcdir)/src
|
||||||
check_fs_LDADD =
|
check_fs_LDADD =
|
||||||
check_fs_SOURCES = check_fs.c
|
check_fs_SOURCES = check_fs.c check_fs_dents.c check_fs_regrw.c \
|
||||||
|
check_fs_times.c check_util.c
|
||||||
|
|
||||||
if BOOKMARKFS_UTIL
|
if BOOKMARKFS_UTIL
|
||||||
check_fs_CPPFLAGS += -DHAVE_BOOKMARKFS_UTIL
|
check_fs_LDADD += $(top_builddir)/src/libbookmarkfs_util.la
|
||||||
check_fs_LDADD += $(top_builddir)/src/libbookmarkfs_util.la
|
else
|
||||||
check_fs_SOURCES += check_fs_regrw.c check_fs_dents.c check_util.c \
|
check_fs_LDADD += $(BOOKMARKFS_UTIL_LIBS)
|
||||||
check_fs_times.c
|
|
||||||
endif # BOOKMARKFS_UTIL
|
endif # BOOKMARKFS_UTIL
|
||||||
endif # BOOKMARKFS_MOUNT
|
endif # BOOKMARKFS_MOUNT
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,10 @@ dispatch_subcmds (
|
||||||
status = subcmd_ismount(argc, argv);
|
status = subcmd_ismount(argc, argv);
|
||||||
} else if (0 == strcmp("sleep", cmd)) {
|
} else if (0 == strcmp("sleep", cmd)) {
|
||||||
status = subcmd_sleep(argc, argv);
|
status = subcmd_sleep(argc, argv);
|
||||||
#ifdef HAVE_BOOKMARKFS_UTIL
|
|
||||||
} else if (0 == strcmp("regrw", cmd)) {
|
} else if (0 == strcmp("regrw", cmd)) {
|
||||||
status = check_fs_regrw(argc, argv);
|
status = check_fs_regrw(argc, argv);
|
||||||
} else if (0 == strcmp("dents", cmd)) {
|
} else if (0 == strcmp("dents", cmd)) {
|
||||||
status = check_fs_dents(argc, argv);
|
status = check_fs_dents(argc, argv);
|
||||||
#endif
|
|
||||||
} else if (0 == strcmp("times", cmd)) {
|
} else if (0 == strcmp("times", cmd)) {
|
||||||
status = check_fs_times(argc, argv);
|
status = check_fs_times(argc, argv);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -241,7 +241,7 @@ check_fs_dents (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
uint64_t seed_buf[4], *seed = NULL;
|
char const *seed = NULL;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
|
|
||||||
OPT_START(argc, argv, "n:s:")
|
OPT_START(argc, argv, "n:s:")
|
||||||
|
@ -250,10 +250,7 @@ check_fs_dents (
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_OPT('s') {
|
OPT_OPT('s') {
|
||||||
if (0 != prng_seed_from_hex(seed_buf, optarg)) {
|
seed = optarg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
seed = seed_buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_END
|
OPT_END
|
||||||
|
@ -268,7 +265,7 @@ check_fs_dents (
|
||||||
}
|
}
|
||||||
char const *path = argv[0];
|
char const *path = argv[0];
|
||||||
|
|
||||||
if (0 != prng_seed(seed)) {
|
if (0 != prng_seed_from_hex(seed)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
|
|
|
@ -167,7 +167,7 @@ check_fs_regrw (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
uint64_t seed_buf[4], *seed = NULL;
|
char const *seed = NULL;
|
||||||
int file_max = -1;
|
int file_max = -1;
|
||||||
|
|
||||||
OPT_START(argc, argv, "n:s:")
|
OPT_START(argc, argv, "n:s:")
|
||||||
|
@ -176,10 +176,7 @@ check_fs_regrw (
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_OPT('s') {
|
OPT_OPT('s') {
|
||||||
if (0 != prng_seed_from_hex(seed_buf, optarg)) {
|
seed = optarg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
seed = seed_buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_END
|
OPT_END
|
||||||
|
@ -194,7 +191,7 @@ check_fs_regrw (
|
||||||
}
|
}
|
||||||
char const *path = argv[0];
|
char const *path = argv[0];
|
||||||
|
|
||||||
if (0 != prng_seed(seed)) {
|
if (0 != prng_seed_from_hex(seed)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return do_check_fs_regrw(path, file_max);
|
return do_check_fs_regrw(path, file_max);
|
||||||
|
|
|
@ -153,7 +153,7 @@ check_fs_times (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
uint64_t seed_buf[4], *seed = NULL;
|
char const *seed = NULL;
|
||||||
int rounds = -1;
|
int rounds = -1;
|
||||||
|
|
||||||
OPT_START(argc, argv, "r:s:")
|
OPT_START(argc, argv, "r:s:")
|
||||||
|
@ -162,10 +162,7 @@ check_fs_times (
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_OPT('s') {
|
OPT_OPT('s') {
|
||||||
if (0 != prng_seed_from_hex(seed_buf, optarg)) {
|
seed = optarg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
seed = seed_buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_END
|
OPT_END
|
||||||
|
@ -180,7 +177,7 @@ check_fs_times (
|
||||||
}
|
}
|
||||||
char const *path = argv[0];
|
char const *path = argv[0];
|
||||||
|
|
||||||
if (0 != prng_seed(seed)) {
|
if (0 != prng_seed_from_hex(seed)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
int dirfd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
|
|
|
@ -168,16 +168,13 @@ check_hashmap (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
uint64_t seed_buf[4], *seed = NULL;
|
char const *seed = NULL;
|
||||||
int size_exp = -1;
|
int size_exp = -1;
|
||||||
int rounds = -1;
|
int rounds = -1;
|
||||||
|
|
||||||
OPT_START(argc, argv, "s:n:r:")
|
OPT_START(argc, argv, "s:n:r:")
|
||||||
OPT_OPT('s') {
|
OPT_OPT('s') {
|
||||||
if (0 != prng_seed_from_hex(seed_buf, optarg)) {
|
seed = optarg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
seed = seed_buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_OPT('n') {
|
OPT_OPT('n') {
|
||||||
|
@ -199,7 +196,7 @@ check_hashmap (
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != prng_seed(seed)) {
|
if (0 != prng_seed_from_hex(seed)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return do_check_hashmap(1u << size_exp, rounds);
|
return do_check_hashmap(1u << size_exp, rounds);
|
||||||
|
|
|
@ -104,15 +104,12 @@ subcmd_prng (
|
||||||
int argc,
|
int argc,
|
||||||
char *argv[]
|
char *argv[]
|
||||||
) {
|
) {
|
||||||
uint64_t seed_buf[4], *seed = NULL;
|
char const *seed = NULL;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
OPT_START(argc, argv, "s:n:")
|
OPT_START(argc, argv, "s:n:")
|
||||||
OPT_OPT('s') {
|
OPT_OPT('s') {
|
||||||
if (0 != prng_seed_from_hex(seed_buf, optarg)) {
|
seed = optarg;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
seed = seed_buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OPT_OPT('n') {
|
OPT_OPT('n') {
|
||||||
|
@ -121,7 +118,7 @@ subcmd_prng (
|
||||||
}
|
}
|
||||||
OPT_END
|
OPT_END
|
||||||
|
|
||||||
if (0 != prng_seed(seed)) {
|
if (0 != prng_seed_from_hex(seed)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (; n > 0; --n) {
|
for (; n > 0; --n) {
|
||||||
|
|
|
@ -27,17 +27,24 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "prng.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
prng_seed_from_hex (
|
prng_seed_from_hex (
|
||||||
uint64_t *buf,
|
|
||||||
char const *str
|
char const *str
|
||||||
) {
|
) {
|
||||||
int cnt = sscanf(str,
|
uint64_t buf[4], *seed = NULL;
|
||||||
"%16" SCNx64 "%16" SCNx64 "%16" SCNx64 "%16" SCNx64,
|
|
||||||
&buf[0], &buf[1], &buf[2], &buf[3]);
|
if (str != NULL) {
|
||||||
if (cnt != 4) {
|
int cnt = sscanf(str,
|
||||||
log_printf("bad seed '%s'", str);
|
"%16" SCNx64 "%16" SCNx64 "%16" SCNx64 "%16" SCNx64,
|
||||||
return -1;
|
&buf[0], &buf[1], &buf[2], &buf[3]);
|
||||||
|
if (cnt != 4) {
|
||||||
|
log_puts("bad prng seed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
seed = buf;
|
||||||
|
log_printf("prng seed: '%s'", str);
|
||||||
}
|
}
|
||||||
return 0;
|
return prng_seed(seed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ check_watcher (
|
||||||
|
|
||||||
int
|
int
|
||||||
prng_seed_from_hex (
|
prng_seed_from_hex (
|
||||||
uint64_t *buf,
|
|
||||||
char const *str
|
char const *str
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,10 @@ dnl
|
||||||
AT_SETUP([fs: directory entries])
|
AT_SETUP([fs: directory entries])
|
||||||
AT_KEYWORDS([fs dents])
|
AT_KEYWORDS([fs dents])
|
||||||
|
|
||||||
ATX_CHECK_FS_NEW_ANY(, [
|
ATX_CHECK_FS_NEW_ANY(, , [
|
||||||
# requires PRNG
|
|
||||||
ATX_FEAT_PREREQ([bookmarkfs-util])
|
|
||||||
], [
|
|
||||||
ATX_RUN_REPEAT([8], [
|
ATX_RUN_REPEAT([8], [
|
||||||
name=$(ath_fn_rand_u64_hex)
|
name=$(ath_fn_rand_u64_hex)
|
||||||
seed=$(ath_fn_prng_seed)
|
seed=$(ath_fn_prng_seed)
|
||||||
echo "prng seed: $seed"
|
|
||||||
|
|
||||||
mkdir $name
|
mkdir $name
|
||||||
ATX_RUN([
|
ATX_RUN([
|
||||||
|
|
|
@ -10,13 +10,9 @@ dnl
|
||||||
AT_SETUP([fs: regular file read/write])
|
AT_SETUP([fs: regular file read/write])
|
||||||
AT_KEYWORDS([fs regrw])
|
AT_KEYWORDS([fs regrw])
|
||||||
|
|
||||||
ATX_CHECK_FS_NEW_ANY([file_max=524288], [
|
ATX_CHECK_FS_NEW_ANY([file_max=524288], , [
|
||||||
# requires PRNG
|
|
||||||
ATX_FEAT_PREREQ([bookmarkfs-util])
|
|
||||||
], [
|
|
||||||
name=$(ath_fn_rand_u64_hex)
|
name=$(ath_fn_rand_u64_hex)
|
||||||
seed=$(ath_fn_prng_seed)
|
seed=$(ath_fn_prng_seed)
|
||||||
echo "prng seed: $seed"
|
|
||||||
|
|
||||||
ATX_RUN([
|
ATX_RUN([
|
||||||
check-fs regrw -n 524288 -s "$seed" $name
|
check-fs regrw -n 524288 -s "$seed" $name
|
||||||
|
|
|
@ -10,13 +10,9 @@ dnl
|
||||||
AT_SETUP([fs: last access/modification times])
|
AT_SETUP([fs: last access/modification times])
|
||||||
AT_KEYWORDS([fs times])
|
AT_KEYWORDS([fs times])
|
||||||
|
|
||||||
ATX_CHECK_FS_NEW_ANY(, [
|
ATX_CHECK_FS_NEW_ANY(, , [
|
||||||
# requires PRNG
|
|
||||||
ATX_FEAT_PREREQ([bookmarkfs-util])
|
|
||||||
], [
|
|
||||||
name=$(ath_fn_rand_u64_hex)
|
name=$(ath_fn_rand_u64_hex)
|
||||||
seed=$(ath_fn_prng_seed)
|
seed=$(ath_fn_prng_seed)
|
||||||
echo "prng seed: $seed"
|
|
||||||
|
|
||||||
mkdir $name
|
mkdir $name
|
||||||
ATX_RUN([
|
ATX_RUN([
|
||||||
|
|
|
@ -15,7 +15,6 @@ ATX_CHECK_LIB([
|
||||||
if test -z "$seed"; then
|
if test -z "$seed"; then
|
||||||
seed=$(ath_fn_prng_seed)
|
seed=$(ath_fn_prng_seed)
|
||||||
fi
|
fi
|
||||||
echo "prng seed: $seed"
|
|
||||||
|
|
||||||
size="${CHECK_HASHMAP_DATA_SIZE}"
|
size="${CHECK_HASHMAP_DATA_SIZE}"
|
||||||
if test -z "$size"; then
|
if test -z "$size"; then
|
||||||
|
|
|
@ -21,7 +21,6 @@ ATX_CHECK_LIB([
|
||||||
ATX_RUN_REPEAT([16], [
|
ATX_RUN_REPEAT([16], [
|
||||||
seed=$(ath_fn_prng_seed)
|
seed=$(ath_fn_prng_seed)
|
||||||
count=32
|
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue