From ad1f90aa84ba96916d02043958ee416a499f3f25 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 Nov 2012 21:29:14 +0100 Subject: [PATCH 1/1] Add t/axmap tester Signed-off-by: Jens Axboe --- Makefile | 9 +++++++++ t/axmap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 t/axmap.c diff --git a/Makefile b/Makefile index 6384ff01..6a1440c1 100644 --- a/Makefile +++ b/Makefile @@ -90,13 +90,19 @@ T_ZIPF_OBS = t/genzipf.o T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o T_ZIPF_PROGS = t/genzipf +T_AXMAP_OBJS = t/axmap.o +T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o +T_AXMAP_PROGS = t/axmap + T_OBJS = $(T_SMALLOC_OBJS) T_OBJS += $(T_IEEE_OBJS) T_OBJS += $(T_ZIPF_OBJS) +T_OBJS += $(T_AXMAP_OBJS) T_PROGS = $(T_SMALLOC_PROGS) T_PROGS += $(T_IEEE_PROGS) T_PROGS += $(T_ZIPF_PROGS) +T_PROGS += $(T_AXMAP_PROGS) ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V @@ -141,6 +147,9 @@ t/ieee754: $(T_IEEE_OBJS) t/genzipf: $(T_ZIPF_OBJS) $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS) +t/axmap: $(T_AXMAP_OBJS) + $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS) + fio: $(OBJS) $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) diff --git a/t/axmap.c b/t/axmap.c new file mode 100644 index 00000000..1f8c3e9a --- /dev/null +++ b/t/axmap.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include + +#include "../lib/lfsr.h" + +struct axmap; +void axmap_set(struct axmap *, uint64_t); +struct axmap *axmap_new(uint64_t size); + +void *smalloc(size_t size) +{ + return malloc(size); +} + +void sfree(void *ptr) +{ + free(ptr); +} + +int main(int argc, char *argv[]) +{ + struct fio_lfsr lfsr; + size_t size = (1UL << 28) - 200; + struct axmap *map; + + if (argc > 1) + size = strtoul(argv[1], NULL, 10); + + printf("Using %llu entries\n", (unsigned long long) size); + + lfsr_init(&lfsr, size); + map = axmap_new(size); + + while (size--) { + uint64_t val; + + lfsr_next(&lfsr, &val); + axmap_set(map, val); + } + + return 0; +} -- 2.25.1