8 #include "../lib/lfsr.h"
9 #include "../lib/axmap.h"
11 static int test_regular(size_t size, int seed)
19 printf("Using %llu entries...", (unsigned long long) size);
22 lfsr_init(&lfsr, size, seed, seed & 0xF);
23 map = axmap_new(size);
30 if (lfsr_next(&lfsr, &val)) {
31 printf("lfsr: short loop\n");
35 if (axmap_isset(map, val)) {
36 printf("bit already set\n");
41 if (!axmap_isset(map, val)) {
42 printf("bit not set\n");
51 ff = axmap_next_free(map, osize);
52 if (ff != (uint64_t) -1ULL) {
53 printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff);
62 static int test_multi(size_t size, unsigned int bit_off)
64 unsigned int map_size = size;
66 uint64_t val = bit_off;
69 printf("Test multi %llu entries %u offset...", (unsigned long long) size, bit_off);
72 map = axmap_new(map_size);
73 while (val + 128 <= map_size) {
75 for (i = val; i < val + 128; i++) {
76 if (axmap_isset(map, val + i)) {
77 printf("bit already set\n");
86 err = axmap_set_nr(map, val, 128);
88 printf("only set %u bits\n", err);
93 for (i = 0; i < 128; i++) {
94 if (!axmap_isset(map, val + i)) {
95 printf("bit not set: %llu\n", (unsigned long long) val + i);
113 int main(int argc, char *argv[])
115 size_t size = (1UL << 23) - 200;
119 size = strtoul(argv[1], NULL, 10);
121 seed = strtoul(argv[2], NULL, 10);
124 if (test_regular(size, seed))
126 if (test_multi(size, 0))
128 if (test_multi(size, 17))