X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest%2Ftest_common.c;h=da2ff75b4a611160b38fed5e35bf466479603794;hb=refs%2Fheads%2Fupstream-17.11-stable;hp=ae3482da7286b8288414c044ec6767f07a6ba0e1;hpb=6e7cbd63706f3435b9d9a2057a37db1da01db9a7;p=deb_dpdk.git diff --git a/test/test/test_common.c b/test/test/test_common.c index ae3482da..da2ff75b 100644 --- a/test/test/test_common.c +++ b/test/test/test_common.c @@ -179,6 +179,37 @@ test_log2(void) return 0; } +static int +test_fls(void) +{ + struct fls_test_vector { + uint32_t arg; + int rc; + }; + int expected, rc; + uint32_t i, arg; + + const struct fls_test_vector test[] = { + {0x0, 0}, + {0x1, 1}, + {0x4000, 15}, + {0x80000000, 32}, + }; + + for (i = 0; i < RTE_DIM(test); i++) { + arg = test[i].arg; + rc = rte_fls_u32(arg); + expected = test[i].rc; + if (rc != expected) { + printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n", + arg, rc, expected); + return TEST_FAILED; + } + } + + return 0; +} + static int test_common(void) { @@ -187,6 +218,7 @@ test_common(void) ret |= test_macros(0); ret |= test_misc(); ret |= test_log2(); + ret |= test_fls(); return ret; }