From: David Marchand Date: Fri, 25 Oct 2019 13:56:07 +0000 (+0200) Subject: test/mem: remove dependency on EAL internals X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ab35397e7aea3db87a25249f8506105af4fbcafa;p=dpdk.git test/mem: remove dependency on EAL internals Rather than dereference the mem_config internal structure, we can rely on the rte_memzone_walk API and count memzones. Signed-off-by: David Marchand Acked-by: Thomas Monjalon Acked-by: Anatoly Burakov --- diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c index 7edfd06c4d..4d87444557 100644 --- a/app/test/test_memzone.c +++ b/app/test/test_memzone.c @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include #include "../../lib/librte_eal/common/malloc_elem.h" -#include "../../lib/librte_eal/common/eal_memcfg.h" #include "test.h" @@ -927,6 +927,16 @@ test_memzone_free(void) return 0; } +static int test_memzones_left; +static int memzone_walk_cnt; +static void memzone_walk_clb(const struct rte_memzone *mz, + void *arg __rte_unused) +{ + memzone_walk_cnt++; + if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) + test_memzones_left++; +} + static int test_memzone_basic(void) { @@ -936,8 +946,12 @@ test_memzone_basic(void) const struct rte_memzone *memzone4; const struct rte_memzone *mz; int memzone_cnt_after, memzone_cnt_expected; - int memzone_cnt_before = - rte_eal_get_configuration()->mem_config->memzones.count; + int memzone_cnt_before; + + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_before = memzone_walk_cnt; memzone1 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100, SOCKET_ID_ANY, 0); @@ -960,8 +974,10 @@ test_memzone_basic(void) (memzone1 != NULL) + (memzone2 != NULL) + (memzone3 != NULL) + (memzone4 != NULL); - memzone_cnt_after = - rte_eal_get_configuration()->mem_config->memzones.count; + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_after = memzone_walk_cnt; if (memzone_cnt_after != memzone_cnt_expected) return -1; @@ -1039,30 +1055,26 @@ test_memzone_basic(void) return -1; } - memzone_cnt_after = - rte_eal_get_configuration()->mem_config->memzones.count; + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt_after = memzone_walk_cnt; if (memzone_cnt_after != memzone_cnt_before) return -1; return 0; } -static int test_memzones_left; -static int memzone_walk_cnt; -static void memzone_walk_clb(const struct rte_memzone *mz, - void *arg __rte_unused) -{ - memzone_walk_cnt++; - if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE)) - test_memzones_left++; -} - static int test_memzone(void) { /* take note of how many memzones were allocated before running */ - int memzone_cnt = - rte_eal_get_configuration()->mem_config->memzones.count; + int memzone_cnt; + + memzone_walk_cnt = 0; + test_memzones_left = 0; + rte_memzone_walk(memzone_walk_clb, NULL); + memzone_cnt = memzone_walk_cnt; printf("test basic memzone API\n"); if (test_memzone_basic() < 0)