diff options
| author | David Marchand <[email protected]> | 2024-10-11 17:25:33 +0200 |
|---|---|---|
| committer | David Marchand <[email protected]> | 2024-10-30 09:19:56 +0100 |
| commit | 46ce151ce49d2e44155436adad5e39359db2889e (patch) | |
| tree | 288432034d296575e8c5e4790c12e9eb5c485e51 /app | |
| parent | 892bf8cf7ea1591e71f398657c2d4a29cd316d06 (diff) | |
test/bitops: check worker lcore availability
Coverity is not able to understand that having 2 lcores means that
rte_get_next_lcore(-1, 0, 1) can't return RTE_MAX_LCORE.
Add a check.
Coverity issue: 445382, 445383, 445384, 445387, 445389, 445391
Fixes: 35326b61aecb ("bitops: add atomic bit operations in new API")
Signed-off-by: David Marchand <[email protected]>
Reviewed-by: Morten Brørup <[email protected]>
Acked-by: Jack Bond-Preston <[email protected]>
Diffstat (limited to 'app')
| -rw-r--r-- | app/test/test_bitops.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/test/test_bitops.c b/app/test/test_bitops.c index 681e984037..78a7df6bb1 100644 --- a/app/test/test_bitops.c +++ b/app/test/test_bitops.c @@ -13,6 +13,17 @@ #include <rte_random.h> #include "test.h" +static unsigned int +get_worker_lcore(void) +{ + unsigned int lcore_id = rte_get_next_lcore(-1, 1, 0); + + /* avoid checkers (like Coverity) false positives */ + RTE_VERIFY(lcore_id < RTE_MAX_LCORE); + + return lcore_id; +} + #define GEN_TEST_BIT_ACCESS(test_name, set_fun, clear_fun, assign_fun, flip_fun, test_fun, size, \ mod) \ static int \ @@ -158,7 +169,7 @@ test_bit_atomic_parallel_assign ## size(void) \ printf("Need multiple cores to run parallel test.\n"); \ return TEST_SKIPPED; \ } \ - worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + worker_lcore_id = get_worker_lcore(); \ lmain.bit = rte_rand_max(size); \ do { \ lworker.bit = rte_rand_max(size); \ @@ -217,7 +228,7 @@ test_bit_atomic_parallel_test_and_modify ## size(void) \ printf("Need multiple cores to run parallel test.\n"); \ return TEST_SKIPPED; \ } \ - worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + worker_lcore_id = get_worker_lcore(); \ int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, &lworker, \ worker_lcore_id); \ TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ @@ -266,7 +277,7 @@ test_bit_atomic_parallel_flip ## size(void) \ printf("Need multiple cores to run parallel test.\n"); \ return TEST_SKIPPED; \ } \ - worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + worker_lcore_id = get_worker_lcore(); \ int rc = rte_eal_remote_launch(run_parallel_flip ## size, &lworker, worker_lcore_id); \ TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ run_parallel_flip ## size(&lmain); \ |
