[v2,3/4] test/extmem: check if memseg list is external

Message ID d5cb333bee4818f3cbb031a711a9eec2ae85c801.1545391716.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series None |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Dec. 21, 2018, 11:29 a.m. UTC
  Extend the extmem autotest to check whether the memseg lists for
externally allocated memory are always marked as external.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_external_mem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Patch

diff --git a/test/test/test_external_mem.c b/test/test/test_external_mem.c
index 06e6ccc1d..b877f8e2e 100644
--- a/test/test/test_external_mem.c
+++ b/test/test/test_external_mem.c
@@ -13,6 +13,7 @@ 
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_eal.h>
+#include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include <rte_ring.h>
@@ -29,11 +30,19 @@  check_mem(void *addr, rte_iova_t *iova, size_t pgsz, int n_pages)
 
 	/* check that we can get this memory from EAL now */
 	for (i = 0; i < n_pages; i++) {
+		const struct rte_memseg_list *msl;
 		const struct rte_memseg *ms;
 		void *cur = RTE_PTR_ADD(addr, pgsz * i);
 		rte_iova_t expected_iova;
 
-		ms = rte_mem_virt2memseg(cur, NULL);
+		msl = rte_mem_virt2memseg_list(cur);
+		if (!msl->external) {
+			printf("%s():%i: Memseg list is not marked as external\n",
+				__func__, __LINE__);
+			return -1;
+		}
+
+		ms = rte_mem_virt2memseg(cur, msl);
 		if (ms == NULL) {
 			printf("%s():%i: Failed to retrieve memseg for external mem\n",
 				__func__, __LINE__);