Show a patch.

GET /api/patches/44227/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 44227,
    "url": "http://patches.dpdk.org/api/patches/44227/",
    "web_url": "http://patches.dpdk.org/patch/44227/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<5b003e4bf69e6d9f8496916a9e6361d4f8b1a6a1.1536064999.git.anatoly.burakov@intel.com>",
    "date": "2018-09-04T13:11:51",
    "name": "[16/16] test: add unit tests for external memory support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "c8ea2c81ac7215464126d1ef4f1bdad4dce1eb93",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44227/mbox/",
    "series": [
        {
            "id": 1170,
            "url": "http://patches.dpdk.org/api/series/1170/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1170",
            "date": "2018-09-04T13:11:35",
            "name": "Support externally allocated memory in DPDK",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1170/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44227/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44227/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 1.7.0.7",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id CE0104F98;\n\tTue,  4 Sep 2018 15:12:06 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id E96282BA3\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 15:11:59 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 06:11:58 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga002.fm.intel.com with ESMTP; 04 Sep 2018 06:11:55 -0700",
            "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw84DBsks023393; Tue, 4 Sep 2018 14:11:54 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84DBsib024935;\n\tTue, 4 Sep 2018 14:11:54 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84DBseH024919;\n\tTue, 4 Sep 2018 14:11:54 +0100"
        ],
        "References": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<5b003e4bf69e6d9f8496916a9e6361d4f8b1a6a1.1536064999.git.anatoly.burakov@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,329,1531810800\"; d=\"scan'208\";a=\"82876064\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Tue,  4 Sep 2018 14:11:51 +0100",
        "Cc": "laszlo.madarassy@ericsson.com, laszlo.vadkerti@ericsson.com,\n\tandras.kovacs@ericsson.com, winnie.tian@ericsson.com,\n\tdaniel.andrasi@ericsson.com, janos.kobor@ericsson.com,\n\tsrinath.mannam@broadcom.com, scott.branden@broadcom.com,\n\tajit.khaparde@broadcom.com, keith.wiles@intel.com,\n\tbruce.richardson@intel.com, thomas@monjalon.net",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH 16/16] test: add unit tests for external memory\n\tsupport"
    },
    "content": "Add simple unit tests to test external memory support.\nThe tests are pretty basic and mostly consist of checking\nif invalid API calls are handled correctly, plus a simple\nallocation/deallocation test for malloc and memzone.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n test/test/Makefile            |   1 +\n test/test/autotest_data.py    |  14 +-\n test/test/meson.build         |   1 +\n test/test/test_external_mem.c | 384 ++++++++++++++++++++++++++++++++++\n 4 files changed, 396 insertions(+), 4 deletions(-)\n create mode 100644 test/test/test_external_mem.c",
    "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex e6967bab6..074ac6e03 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -71,6 +71,7 @@ SRCS-y += test_bitmap.c\n SRCS-y += test_reciprocal_division.c\n SRCS-y += test_reciprocal_division_perf.c\n SRCS-y += test_fbarray.c\n+SRCS-y += test_external_mem.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\ndiff --git a/test/test/autotest_data.py b/test/test/autotest_data.py\nindex f68d9b111..51f8e1689 100644\n--- a/test/test/autotest_data.py\n+++ b/test/test/autotest_data.py\n@@ -477,10 +477,16 @@\n         \"Report\":  None,\n     },\n     {\n-        \"Name\":    \"Fbarray autotest\",\n-        \"Command\": \"fbarray_autotest\",\n-        \"Func\":    default_autotest,\n-        \"Report\":  None,\n+\t\"Name\":    \"Fbarray autotest\",\n+\t\"Command\": \"fbarray_autotest\",\n+\t\"Func\":    default_autotest,\n+\t\"Report\":  None,\n+    },\n+    {\n+\t\"Name\":    \"External memory autotest\",\n+\t\"Command\": \"external_mem_autotest\",\n+\t\"Func\":    default_autotest,\n+\t\"Report\":  None,\n     },\n     #\n     #Please always keep all dump tests at the end and together!\ndiff --git a/test/test/meson.build b/test/test/meson.build\nindex b1dd6eca2..3abf02b71 100644\n--- a/test/test/meson.build\n+++ b/test/test/meson.build\n@@ -155,6 +155,7 @@ test_names = [\n \t'eventdev_common_autotest',\n \t'eventdev_octeontx_autotest',\n \t'eventdev_sw_autotest',\n+\t'external_mem_autotest',\n \t'func_reentrancy_autotest',\n \t'flow_classify_autotest',\n \t'hash_scaling_autotest',\ndiff --git a/test/test/test_external_mem.c b/test/test/test_external_mem.c\nnew file mode 100644\nindex 000000000..5edb5c348\n--- /dev/null\n+++ b/test/test/test_external_mem.c\n@@ -0,0 +1,384 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include <errno.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <fcntl.h>\n+#include <sys/mman.h>\n+#include <sys/wait.h>\n+\n+#include <rte_common.h>\n+#include <rte_debug.h>\n+#include <rte_eal.h>\n+#include <rte_errno.h>\n+#include <rte_malloc.h>\n+#include <rte_ring.h>\n+#include <rte_string_fns.h>\n+\n+#include \"test.h\"\n+\n+#define EXTERNAL_MEM_SZ (RTE_PGSIZE_4K << 10) /* 4M of data */\n+\n+static int\n+test_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,\n+\t\tint n_pages)\n+{\n+\tstatic const char * const names[] = {\n+\t\tNULL, /* NULL name */\n+\t\t\"\",   /* empty name */\n+\t\t\"this heap name is definitely way too long to be valid\"\n+\t};\n+\tconst char *valid_name = \"valid heap name\";\n+\tunsigned int i;\n+\n+\t/* check invalid name handling */\n+\tfor (i = 0; i < RTE_DIM(names); i++) {\n+\t\tconst char *name = names[i];\n+\n+\t\t/* these calls may fail for other reasons, so check errno */\n+\t\tif (rte_malloc_heap_create(name) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Created heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_destroy(name) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Destroyed heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_get_socket(name) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Found socket for heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_memory_add(name, addr, len,\n+\t\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Added memory to heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (rte_malloc_heap_memory_remove(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Removed memory from heap with invalid name\\n\",\n+\t\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tif (rte_malloc_heap_memory_attach(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Attached memory to heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (rte_malloc_heap_memory_detach(name, addr, len) >= 0 ||\n+\t\t\t\trte_errno != EINVAL) {\n+\t\t\tprintf(\"%s():%i: Detached memory from heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t}\n+\n+\t/* do same as above, but with a valid heap name */\n+\n+\t/* skip create call */\n+\tif (rte_malloc_heap_destroy(valid_name) >= 0 || rte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Destroyed heap with invalid name\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_get_socket(valid_name) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Found socket for heap with invalid name\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* these calls may fail for other reasons, so check errno */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Added memory to non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_remove(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Removed memory from non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Attached memory to non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, addr, len) >= 0 ||\n+\t\t\trte_errno != ENOENT) {\n+\t\tprintf(\"%s():%i: Detached memory from non-existent heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* create a valid heap but test other invalid parameters */\n+\tif (rte_malloc_heap_create(valid_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to create valid heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* zero length */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, 0,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_remove(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Removed memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Attached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, addr, 0) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Detached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* zero address */\n+\tif (rte_malloc_heap_memory_add(valid_name, NULL, len,\n+\t\t\tNULL, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_remove(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Removed memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_malloc_heap_memory_attach(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Attached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_detach(valid_name, NULL, len) >= 0 ||\n+\t\t\trte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Detached memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* wrong page count */\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, 0, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, n_pages - 1, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_memory_add(valid_name, addr, len,\n+\t\t\tiova, n_pages + 1, pgsz) >= 0 || rte_errno != EINVAL) {\n+\t\tprintf(\"%s():%i: Added memory with invalid parameters\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* tests passed, destroy heap */\n+\tif (rte_malloc_heap_destroy(valid_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to destroy valid heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\treturn 0;\n+fail:\n+\trte_malloc_heap_destroy(valid_name);\n+\treturn -1;\n+}\n+\n+static int\n+test_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, int n_pages)\n+{\n+\tconst char *heap_name = \"heap\";\n+\tvoid *ptr = NULL;\n+\tint socket_id, i;\n+\tconst struct rte_memzone *mz = NULL;\n+\n+\t/* create heap */\n+\tif (rte_malloc_heap_create(heap_name) != 0) {\n+\t\tprintf(\"%s():%i: Failed to create malloc heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* get socket ID corresponding to this heap */\n+\tsocket_id = rte_malloc_heap_get_socket(heap_name);\n+\tif (socket_id < 0) {\n+\t\tprintf(\"%s():%i: cannot find socket for external heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* heap is empty, so any allocation should fail */\n+\tptr = rte_malloc_socket(\"EXTMEM\", 64, 0, socket_id);\n+\tif (ptr != NULL) {\n+\t\tprintf(\"%s():%i: Allocated from empty heap\\n\", __func__,\n+\t\t\t__LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* add memory to heap */\n+\tif (rte_malloc_heap_memory_add(heap_name, addr, len,\n+\t\t\tiova, n_pages, pgsz) != 0) {\n+\t\tprintf(\"%s():%i: Failed to add memory to heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* check that we can get this memory from EAL now */\n+\tfor (i = 0; i < n_pages; i++) {\n+\t\tconst struct rte_memseg *ms;\n+\n+\t\tms = rte_mem_virt2memseg(RTE_PTR_ADD(addr, pgsz * i), NULL);\n+\t\tif (ms == NULL) {\n+\t\t\tprintf(\"%s():%i: Failed to retrieve memseg for external mem\\n\",\n+\t\t\t\t__func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t\tif (ms->iova != iova[i]) {\n+\t\t\tprintf(\"%s():%i: IOVA mismatch\\n\", __func__, __LINE__);\n+\t\t\tgoto fail;\n+\t\t}\n+\t}\n+\n+\t/* allocate - this now should succeed */\n+\tptr = rte_malloc_socket(\"EXTMEM\", 64, 0, socket_id);\n+\tif (ptr == NULL) {\n+\t\tprintf(\"%s():%i: Failed to allocate from external heap\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* check if address is in expected range */\n+\tif (ptr < addr || ptr >= RTE_PTR_ADD(addr, len)) {\n+\t\tprintf(\"%s():%i: Allocated from unexpected address space\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* we've allocated something - removing memory should fail */\n+\tif (rte_malloc_heap_memory_remove(heap_name, addr, len) >= 0 ||\n+\t\t\trte_errno != EBUSY) {\n+\t\tprintf(\"%s():%i: Removing memory succeeded when memory is not free\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_destroy(heap_name) >= 0 || rte_errno != EBUSY) {\n+\t\tprintf(\"%s():%i: Destroying heap succeeded when memory is not free\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* try allocating an IOVA-contiguous memzone - this should succeed\n+\t * because we've set up a contiguous IOVA table.\n+\t */\n+\tmz = rte_memzone_reserve(\"heap_test\", pgsz * 2, socket_id,\n+\t\t\tRTE_MEMZONE_IOVA_CONTIG);\n+\tif (mz == NULL) {\n+\t\tprintf(\"%s():%i: Failed to reserve memzone\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\trte_malloc_dump_stats(stdout, NULL);\n+\trte_malloc_dump_heaps(stdout);\n+\n+\t/* free memory - removing it should now succeed */\n+\trte_free(ptr);\n+\tptr = NULL;\n+\n+\trte_memzone_free(mz);\n+\tmz = NULL;\n+\n+\tif (rte_malloc_heap_memory_remove(heap_name, addr, len) != 0) {\n+\t\tprintf(\"%s():%i: Removing memory from heap failed\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\tif (rte_malloc_heap_destroy(heap_name) != 0) {\n+\t\tprintf(\"%s():%i: Destroying heap failed\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\tgoto fail;\n+\t}\n+\n+\treturn 0;\n+fail:\n+\trte_memzone_free(mz);\n+\trte_free(ptr);\n+\t/* even if something failed, attempt to clean up */\n+\trte_malloc_heap_memory_remove(heap_name, addr, len);\n+\trte_malloc_heap_destroy(heap_name);\n+\n+\treturn -1;\n+}\n+\n+/* we need to test attach/detach in secondary processes. */\n+static int\n+test_external_mem(void)\n+{\n+\tsize_t len = EXTERNAL_MEM_SZ;\n+\tsize_t pgsz = RTE_PGSIZE_4K;\n+\trte_iova_t iova[len / pgsz];\n+\tvoid *addr;\n+\tint ret, n_pages;\n+\n+\t/* create external memory area */\n+\tn_pages = RTE_DIM(iova);\n+\taddr = mmap(NULL, len, PROT_WRITE | PROT_READ,\n+\t\t\tMAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tprintf(\"%s():%i: Failed to create dummy memory area\\n\",\n+\t\t\t__func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\tfor (int i = 0; i < n_pages; i++) {\n+\t\t/* arbitrary IOVA */\n+\t\trte_iova_t tmp = 0x100000000 + i * pgsz;\n+\t\tiova[i] = tmp;\n+\t}\n+\n+\tret = test_invalid_param(addr, len, pgsz, iova, n_pages);\n+\tret |= test_basic(addr, len, pgsz, iova, n_pages);\n+\n+\tmunmap(addr, len);\n+\n+\treturn ret;\n+}\n+\n+REGISTER_TEST_COMMAND(external_mem_autotest, test_external_mem);\n",
    "prefixes": [
        "16/16"
    ]
}