test/common: fix log2 check
authorDavid Marchand <david.marchand@redhat.com>
Fri, 20 Dec 2019 14:01:49 +0000 (15:01 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 20 Dec 2019 14:05:41 +0000 (15:05 +0100)
commit30a0df64aaed5cbf33fd5d237d5812cee1cc0ef9
tree0f231e5400744412c3a826cc53c930259a4038eb
parentf26c2b39b271cdcd857ba518c5e48c78cb1c30af
test/common: fix log2 check

We recently started to get random failures on the common_autotest ut with
clang on Ubuntu 16.04.6.

Example: https://travis-ci.com/DPDK/dpdk/jobs/263177424

Wrong rte_log2_u64(0) val 0, expected ffffffff
Test Failed

The ut passes 0 to log2() to get an expected value.

Quoting log2 / log(3) manual:
If x is zero, then a pole error occurs, and the functions return
-HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.

rte_log2_uXX helpers handle 0 as a special value and return 0.
Let's have dedicated tests for this case.

Fixes: 05c4345ef5c2 ("test: add unit test for integer log2 function")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
app/test/test_common.c
lib/librte_eal/common/include/rte_common.h