X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=t%2Faxmap.c;h=61e3220729d38da5a4246ab9e611082f5ecbae66;hp=1f8c3e9a90f6855878f37c0fb574217f6363094e;hb=ab3379bcb7748675fd6ef7dac0457f1304516a66;hpb=856b09c838bfd45a9d6d87a1ab03458c9b058d56 diff --git a/t/axmap.c b/t/axmap.c index 1f8c3e9a..61e32207 100644 --- a/t/axmap.c +++ b/t/axmap.c @@ -6,10 +6,7 @@ #include #include "../lib/lfsr.h" - -struct axmap; -void axmap_set(struct axmap *, uint64_t); -struct axmap *axmap_new(uint64_t size); +#include "../lib/axmap.h" void *smalloc(size_t size) { @@ -24,22 +21,45 @@ void sfree(void *ptr) int main(int argc, char *argv[]) { struct fio_lfsr lfsr; - size_t size = (1UL << 28) - 200; + size_t osize, size = (1UL << 28) - 200; struct axmap *map; + uint64_t ff; + int seed = 1; - if (argc > 1) + if (argc > 1) { size = strtoul(argv[1], NULL, 10); + if (argc > 2) + seed = strtoul(argv[2], NULL, 10); + } printf("Using %llu entries\n", (unsigned long long) size); - lfsr_init(&lfsr, size); + lfsr_init(&lfsr, size, seed); map = axmap_new(size); + osize = size; while (size--) { uint64_t val; - lfsr_next(&lfsr, &val); + if (lfsr_next(&lfsr, &val, osize)) { + printf("lfsr: short loop\n"); + break; + } + if (axmap_isset(map, val)) { + printf("bit already set\n"); + break; + } axmap_set(map, val); + if (!axmap_isset(map, val)) { + printf("bit not set\n"); + break; + } + } + + ff = axmap_next_free(map, osize); + if (ff != (uint64_t) -1ULL) { + printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff); + return 1; } return 0;