Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/129609/?format=api
http://patches.dpdk.org/api/patches/129609/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230718024006.2154-5-fengchengwen@huawei.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "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", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20230718024006.2154-5-fengchengwen@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20230718024006.2154-5-fengchengwen@huawei.com", "date": "2023-07-18T02:40:04", "name": "[v17,4/6] test/memarea: support alloc and free API test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "835795c64ce943c115938f4700f7baf6be660e5c", "submitter": { "id": 2146, "url": "http://patches.dpdk.org/api/people/2146/?format=api", "name": "fengchengwen", "email": "fengchengwen@huawei.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230718024006.2154-5-fengchengwen@huawei.com/mbox/", "series": [ { "id": 28961, "url": "http://patches.dpdk.org/api/series/28961/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28961", "date": "2023-07-18T02:40:06", "name": "introduce memarea library", "version": 17, "mbox": "http://patches.dpdk.org/series/28961/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/129609/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/129609/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id F3D8C42EA1;\n\tTue, 18 Jul 2023 04:48:33 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 99F3C42D20;\n\tTue, 18 Jul 2023 04:48:25 +0200 (CEST)", "from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])\n by mails.dpdk.org (Postfix) with ESMTP id 65CC9406B3\n for <dev@dpdk.org>; Tue, 18 Jul 2023 04:48:20 +0200 (CEST)", "from dggpeml100024.china.huawei.com (unknown [172.30.72.53])\n by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R4jzW5QdMzrRnQ;\n Tue, 18 Jul 2023 10:47:35 +0800 (CST)", "from localhost.localdomain (10.50.163.32) by\n dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.27; Tue, 18 Jul 2023 10:48:18 +0800" ], "From": "Chengwen Feng <fengchengwen@huawei.com>", "To": "<thomas@monjalon.net>, <david.marchand@redhat.com>", "CC": "<dev@dpdk.org>, <mb@smartsharesystems.com>, <anatoly.burakov@intel.com>,\n <dmitry.kozliuk@gmail.com>, <jerinjacobk@gmail.com>, <hofors@lysator.liu.se>,\n <stephen@networkplumber.org>", "Subject": "[PATCH v17 4/6] test/memarea: support alloc and free API test", "Date": "Tue, 18 Jul 2023 02:40:04 +0000", "Message-ID": "<20230718024006.2154-5-fengchengwen@huawei.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20230718024006.2154-1-fengchengwen@huawei.com>", "References": "<20220721044648.6817-1-fengchengwen@huawei.com>\n <20230718024006.2154-1-fengchengwen@huawei.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"UTF-8\"", "Content-Transfer-Encoding": "8bit", "X-Originating-IP": "[10.50.163.32]", "X-ClientProxiedBy": "dggems705-chm.china.huawei.com (10.3.19.182) To\n dggpeml100024.china.huawei.com (7.185.36.115)", "X-CFilter-Loop": "Reflected", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "This patch supports rte_memarea_alloc() and rte_memarea_free() API\ntest.\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\nReviewed-by: Dongdong Liu <liudongdong3@huawei.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\nAcked-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n app/test/test_memarea.c | 214 +++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 213 insertions(+), 1 deletion(-)", "diff": "diff --git a/app/test/test_memarea.c b/app/test/test_memarea.c\nindex a2191eb0eb..8a1a0e2e2a 100644\n--- a/app/test/test_memarea.c\n+++ b/app/test/test_memarea.c\n@@ -23,6 +23,12 @@ test_memarea_init_param(struct rte_memarea_param *init)\n \tinit->mt_safe = 1;\n }\n \n+static void\n+test_memarea_fill_region(void *ptr, size_t size)\n+{\n+\tmemset(ptr, 0xff, size);\n+}\n+\n static int\n test_memarea_create_bad_param(void)\n {\n@@ -95,7 +101,7 @@ test_memarea_create_bad_param(void)\n static int\n test_memarea_create_destroy(void)\n {\n-\tstruct rte_memarea *ma;\n+\tstruct rte_memarea *ma, *src_ma;\n \tstruct rte_memarea_param init;\n \n \trte_errno = 0;\n@@ -115,6 +121,207 @@ test_memarea_create_destroy(void)\n \tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n \trte_memarea_destroy(ma);\n \n+\t/* test for create with another memarea */\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tsrc_ma = rte_memarea_create(&init);\n+\tTEST_ASSERT(src_ma != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_MEMAREA;\n+\tinit.total_sz = init.total_sz >> 1;\n+\tinit.ma.src = src_ma;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\trte_memarea_destroy(ma);\n+\trte_memarea_destroy(src_ma);\n+\n+\tTEST_ASSERT(rte_errno == 0, \"Expected ZERO\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_memarea_alloc_bad_param(void)\n+{\n+\tstruct rte_memarea_param init;\n+\tstruct rte_memarea *ma;\n+\tsize_t size;\n+\tvoid *ptr;\n+\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tinit.total_sz = MEMAREA_TEST_DEFAULT_SIZE;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\n+\t/* test for invalid ma */\n+\tptr = rte_memarea_alloc(NULL, 1);\n+\tTEST_ASSERT(ptr == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == EINVAL, \"Expected EINVAL\");\n+\n+\t/* test for invalid size (size = 0) */\n+\tptr = rte_memarea_alloc(ma, 0);\n+\tTEST_ASSERT(ptr == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == EINVAL, \"Expected EINVAL\");\n+\n+\t/* test for invalid size (size rewind) */\n+\tmemset(&size, 0xff, sizeof(size));\n+\tptr = rte_memarea_alloc(ma, size);\n+\tTEST_ASSERT(ptr == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == EINVAL, \"Expected EINVAL\");\n+\n+\trte_memarea_destroy(ma);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_memarea_free_bad_param(void)\n+{\n+\tstruct rte_memarea_param init;\n+\tstruct rte_memarea *ma;\n+\tvoid *ptr;\n+\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tinit.total_sz = MEMAREA_TEST_DEFAULT_SIZE;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\tptr = rte_memarea_alloc(ma, 1);\n+\tTEST_ASSERT(ptr != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_fill_region(ptr, 1);\n+\n+\t/* test for invalid ma */\n+\trte_memarea_free(NULL, ptr);\n+\tTEST_ASSERT(rte_errno == EINVAL, \"Expected EINVAL\");\n+\n+\t/* test for invalid ptr */\n+\trte_memarea_free(ma, NULL);\n+\tTEST_ASSERT(rte_errno == EINVAL, \"Expected EINVAL\");\n+\n+\trte_memarea_destroy(ma);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_memarea_alloc_fail(void)\n+{\n+\tstruct rte_memarea_param init;\n+\tstruct rte_memarea *ma;\n+\tvoid *ptr[2];\n+\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tinit.total_sz = MEMAREA_TEST_DEFAULT_SIZE;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\n+\t/* test alloc fail with big size */\n+\tptr[0] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE);\n+\tTEST_ASSERT(ptr[0] == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == ENOMEM, \"Expected ENOMEM\");\n+\n+\t/* test alloc fail because no memory */\n+\tptr[0] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr[0] != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_fill_region(ptr[0], MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tptr[1] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr[1] == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == ENOMEM, \"Expected ENOMEM\");\n+\trte_memarea_free(ma, ptr[0]);\n+\n+\t/* test alloc fail when second fail */\n+\tptr[0] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr[0] != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_fill_region(ptr[0], MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tptr[1] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr[1] == NULL, \"Expected NULL\");\n+\tTEST_ASSERT(rte_errno == ENOMEM, \"Expected ENOMEM\");\n+\trte_memarea_free(ma, ptr[0]);\n+\tptr[1] = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr[1] != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_fill_region(ptr[1], MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\trte_memarea_free(ma, ptr[1]);\n+\n+\trte_memarea_destroy(ma);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_memarea_free_fail(void)\n+{\n+\tstruct rte_memarea_param init;\n+\tstruct rte_memarea *ma;\n+\tvoid *ptr;\n+\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tinit.total_sz = MEMAREA_TEST_DEFAULT_SIZE;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\n+\t/* test repeat free */\n+\trte_errno = 0;\n+\tptr = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\tTEST_ASSERT(ptr != NULL, \"Expected Non-NULL\");\n+\ttest_memarea_fill_region(ptr, MEMAREA_TEST_DEFAULT_SIZE >> 1);\n+\trte_memarea_free(ma, ptr);\n+\tTEST_ASSERT(rte_errno == 0, \"Expected Zero\");\n+\trte_memarea_free(ma, ptr);\n+\tTEST_ASSERT(rte_errno == EFAULT, \"Expected EFAULT\");\n+\n+\trte_memarea_destroy(ma);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int\n+test_memarea_alloc_free(void)\n+{\n+#define ALLOC_MAX_NUM\t8\n+\tstruct rte_memarea_param init;\n+\tvoid *ptr[ALLOC_MAX_NUM];\n+\tstruct rte_memarea *ma;\n+\tint i;\n+\n+\ttest_memarea_init_param(&init);\n+\tinit.source = RTE_MEMAREA_SOURCE_LIBC;\n+\tinit.total_sz = MEMAREA_TEST_DEFAULT_SIZE;\n+\tma = rte_memarea_create(&init);\n+\tTEST_ASSERT(ma != NULL, \"Expected Non-NULL\");\n+\tmemset(ptr, 0, sizeof(ptr));\n+\n+\trte_errno = 0;\n+\n+\t/* test random alloc and free */\n+\tfor (i = 0; i < ALLOC_MAX_NUM; i++) {\n+\t\tptr[i] = rte_memarea_alloc(ma, 1);\n+\t\tTEST_ASSERT(ptr[i] != NULL, \"Expected Non-NULL\");\n+\t\ttest_memarea_fill_region(ptr[i], 1);\n+\t}\n+\n+\t/* test merge left */\n+\trte_memarea_free(ma, ptr[0]);\n+\trte_memarea_free(ma, ptr[1]);\n+\n+\t/* test merge right */\n+\trte_memarea_free(ma, ptr[7]);\n+\trte_memarea_free(ma, ptr[6]);\n+\n+\t/* test merge left and right */\n+\trte_memarea_free(ma, ptr[3]);\n+\trte_memarea_free(ma, ptr[2]);\n+\n+\t/* test merge remains */\n+\trte_memarea_free(ma, ptr[4]);\n+\trte_memarea_free(ma, ptr[5]);\n+\n+\tTEST_ASSERT(rte_errno == 0, \"Expected Zero\");\n+\n+\trte_memarea_destroy(ma);\n+\n \treturn TEST_SUCCESS;\n }\n \n@@ -125,6 +332,11 @@ static struct unit_test_suite memarea_test_suite = {\n \t.unit_test_cases = {\n \t\tTEST_CASE(test_memarea_create_bad_param),\n \t\tTEST_CASE(test_memarea_create_destroy),\n+\t\tTEST_CASE(test_memarea_alloc_bad_param),\n+\t\tTEST_CASE(test_memarea_free_bad_param),\n+\t\tTEST_CASE(test_memarea_alloc_fail),\n+\t\tTEST_CASE(test_memarea_free_fail),\n+\t\tTEST_CASE(test_memarea_alloc_free),\n \n \t\tTEST_CASES_END() /**< NULL terminate unit test array */\n \t}\n", "prefixes": [ "v17", "4/6" ] }{ "id": 129609, "url": "