test/bitmap: test scan after half cacheline is cleared
Add a test case to test scan operation post clear of half cacheline of slabs. Also fix meson.build to include test_bitmap.c in the compilation. Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
This commit is contained in:
parent
a2a23a794b
commit
5e9647fd5a
@ -13,6 +13,7 @@ test_sources = files('commands.c',
|
|||||||
'test_atomic.c',
|
'test_atomic.c',
|
||||||
'test_barrier.c',
|
'test_barrier.c',
|
||||||
'test_bitops.c',
|
'test_bitops.c',
|
||||||
|
'test_bitmap.c',
|
||||||
'test_bpf.c',
|
'test_bpf.c',
|
||||||
'test_byteorder.c',
|
'test_byteorder.c',
|
||||||
'test_cmdline.c',
|
'test_cmdline.c',
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
static int
|
static int
|
||||||
test_bitmap_scan_operations(struct rte_bitmap *bmp)
|
test_bitmap_scan_operations(struct rte_bitmap *bmp)
|
||||||
{
|
{
|
||||||
uint32_t pos = 0;
|
|
||||||
uint64_t slab1_magic = 0xBADC0FFEEBADF00D;
|
uint64_t slab1_magic = 0xBADC0FFEEBADF00D;
|
||||||
uint64_t slab2_magic = 0xFEEDDEADDEADF00D;
|
uint64_t slab2_magic = 0xFEEDDEADDEADF00D;
|
||||||
|
uint32_t pos = 0, start_pos;
|
||||||
|
int i, nb_clear, nb_set;
|
||||||
uint64_t out_slab = 0;
|
uint64_t out_slab = 0;
|
||||||
|
|
||||||
rte_bitmap_reset(bmp);
|
rte_bitmap_reset(bmp);
|
||||||
@ -70,6 +71,37 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp)
|
|||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test scan when a cline is half full */
|
||||||
|
rte_bitmap_reset(bmp);
|
||||||
|
for (i = 0; i < MAX_BITS; i++)
|
||||||
|
rte_bitmap_set(bmp, i);
|
||||||
|
|
||||||
|
nb_clear = RTE_MIN(RTE_BITMAP_CL_BIT_SIZE / 2, MAX_BITS);
|
||||||
|
for (i = 0; i < nb_clear; i++)
|
||||||
|
rte_bitmap_clear(bmp, i);
|
||||||
|
|
||||||
|
/* Find remaining bits set in bmp */
|
||||||
|
__rte_bitmap_scan_init(bmp);
|
||||||
|
|
||||||
|
if (rte_bitmap_scan(bmp, &pos, &out_slab) != 1) {
|
||||||
|
printf("Initial scan failed with half CL empty.\n");
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_pos = pos;
|
||||||
|
nb_set = 0;
|
||||||
|
do {
|
||||||
|
nb_set += __builtin_popcountll(out_slab);
|
||||||
|
if (!rte_bitmap_scan(bmp, &pos, &out_slab))
|
||||||
|
break;
|
||||||
|
} while (pos != start_pos);
|
||||||
|
|
||||||
|
if ((nb_clear + nb_set) != MAX_BITS) {
|
||||||
|
printf("Scan failed to find all set bits. "
|
||||||
|
"Expected %u, found %u.\n", MAX_BITS - nb_clear, nb_set);
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return TEST_SUCCESS;
|
return TEST_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user