X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest_common.c;h=ae3482da7286b8288414c044ec6767f07a6ba0e1;hb=e32cb57973fc311b4b5f60ae5dac37d99e48c94d;hp=6e803f5d357aa5377f36231eda7b840e4d5551b7;hpb=577329e66b9f1e1c227c0f6cb76fe47bb8f8c38c;p=dpdk.git diff --git a/test/test/test_common.c b/test/test/test_common.c index 6e803f5d35..ae3482da72 100644 --- a/test/test/test_common.c +++ b/test/test/test_common.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -159,6 +160,25 @@ test_align(void) return 0; } +static int +test_log2(void) +{ + uint32_t i, base, compare; + const uint32_t max = 0x10000; + const uint32_t step = 1; + + for (i = 0; i < max; i = i + step) { + base = (uint32_t)ceilf(log2((uint32_t)i)); + compare = rte_log2_u32(i); + if (base != compare) { + printf("Wrong rte_log2_u32(%x) val %x, expected %x\n", + i, compare, base); + return TEST_FAILED; + } + } + return 0; +} + static int test_common(void) { @@ -166,6 +186,7 @@ test_common(void) ret |= test_align(); ret |= test_macros(0); ret |= test_misc(); + ret |= test_log2(); return ret; }