aboutsummaryrefslogtreecommitdiffstats
path: root/test/test/test_common.c
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2019-02-26 09:17:37 +0100
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2019-02-26 09:21:27 +0100
commit597cb1874068054d4c0be41f161a72ef37888930 (patch)
tree8899c19634bd8e393a8eac05f33925e4d75bd77d /test/test/test_common.c
parent6e7cbd63706f3435b9d9a2057a37db1da01db9a7 (diff)
New upstream version 17.11.5upstream-17.11-stable
Change-Id: I8d2aa1aee2a9a78614dff5a01008f91e88e810c7 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'test/test/test_common.c')
-rw-r--r--test/test/test_common.c32
1 files changed, 32 insertions, 0 deletions
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
@@ -180,6 +180,37 @@ test_log2(void)
}
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)
{
int ret = 0;
@@ -187,6 +218,7 @@ test_common(void)
ret |= test_macros(0);
ret |= test_misc();
ret |= test_log2();
+ ret |= test_fls();
return ret;
}