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

Function test_fls

dpdk/app/test/test_common.c:291–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static int
292test_fls(void)
293{
294 struct fls_test_vector {
295 uint32_t arg;
296 int rc;
297 };
298 int expected, rc;
299 uint32_t i, arg;
300
301 const struct fls_test_vector test[] = {
302 {0x0, 0},
303 {0x1, 1},
304 {0x4000, 15},
305 {0x80000000, 32},
306 };
307
308 for (i = 0; i < RTE_DIM(test); i++) {
309 uint64_t arg64;
310
311 arg = test[i].arg;
312 rc = rte_fls_u32(arg);
313 expected = test[i].rc;
314 if (rc != expected) {
315 printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n",
316 arg, rc, expected);
317 return TEST_FAILED;
318 }
319 /* 64-bit version */
320 arg = test[i].arg;
321 rc = rte_fls_u64(arg);
322 expected = test[i].rc;
323 if (rc != expected) {
324 printf("Wrong rte_fls_u64(0x%x) rc=%d, expected=%d\n",
325 arg, rc, expected);
326 return TEST_FAILED;
327 }
328 /* 64-bit version shifted by 32 bits */
329 arg64 = (uint64_t)test[i].arg << 32;
330 rc = rte_fls_u64(arg64);
331 /* don't shift zero */
332 expected = test[i].rc == 0 ? 0 : test[i].rc + 32;
333 if (rc != expected) {
334 printf("Wrong rte_fls_u64(0x%" PRIx64 ") rc=%d, expected=%d\n",
335 arg64, rc, expected);
336 return TEST_FAILED;
337 }
338 }
339
340 return 0;
341}
342
343static int
344test_common(void)

Callers 1

test_commonFunction · 0.85

Calls 3

rte_fls_u32Function · 0.50
printfFunction · 0.50
rte_fls_u64Function · 0.50

Tested by

no test coverage detected