MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_bitmap_all_set

Function test_bitmap_all_set

dpdk/app/test/test_bitmap.c:217–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217static int
218test_bitmap_all_set(void)
219{
220 void *mem;
221 uint32_t i;
222 uint64_t slab;
223 uint32_t pos;
224 uint32_t bmp_size;
225 struct rte_bitmap *bmp;
226
227 bmp_size =
228 rte_bitmap_get_memory_footprint(MAX_BITS);
229
230 mem = rte_zmalloc("test_bmap", bmp_size, RTE_CACHE_LINE_SIZE);
231 if (mem == NULL) {
232 printf("Failed to allocate memory for bitmap\n");
233 return TEST_FAILED;
234 }
235
236 bmp = rte_bitmap_init_with_all_set(MAX_BITS, mem, bmp_size);
237 if (bmp == NULL) {
238 printf("Failed to init bitmap\n");
239 return TEST_FAILED;
240 }
241
242 for (i = 0; i < MAX_BITS; i++) {
243 pos = slab = 0;
244 if (!rte_bitmap_scan(bmp, &pos, &slab)) {
245 printf("Failed with init bitmap.\n");
246 return TEST_FAILED;
247 }
248 pos += (slab ? rte_ctz64(slab) : 0);
249 rte_bitmap_clear(bmp, pos);
250 }
251
252 if (rte_bitmap_scan(bmp, &pos, &slab)) {
253 printf("Too much bits set.\n");
254 return TEST_FAILED;
255 }
256
257 rte_bitmap_free(bmp);
258 rte_free(mem);
259
260 return TEST_SUCCESS;
261
262}
263
264static int
265test_bitmap(void)

Callers 1

test_bitmapFunction · 0.85

Calls 9

rte_zmallocFunction · 0.85
rte_bitmap_scanFunction · 0.85
rte_ctz64Function · 0.85
rte_bitmap_clearFunction · 0.85
rte_bitmap_freeFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected