From patchwork Tue Sep 20 03:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fengchengwen X-Patchwork-Id: 116462 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id C2BE1A00C3; Tue, 20 Sep 2022 05:53:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B7AA42B79; Tue, 20 Sep 2022 05:53:08 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 626A2410E8 for ; Tue, 20 Sep 2022 05:53:01 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MWncg5p4KzpT3T; Tue, 20 Sep 2022 11:50:11 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 11:52:58 +0800 From: Chengwen Feng To: CC: , , , Subject: [PATCH 8/8] test/memarea: support backup memory test Date: Tue, 20 Sep 2022 03:46:43 +0000 Message-ID: <20220920034643.55476-9-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920034643.55476-1-fengchengwen@huawei.com> References: <20220721044648.6817-1-fengchengwen@huawei.com> <20220920034643.55476-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch supports backup memory mechanism test. Signed-off-by: Chengwen Feng --- app/test/test_memarea.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/app/test/test_memarea.c b/app/test/test_memarea.c index a1214f7080..1f7ab3fb1f 100644 --- a/app/test/test_memarea.c +++ b/app/test/test_memarea.c @@ -282,6 +282,46 @@ test_memarea_dump(void) return 0; } +static int +test_memarea_backup(void) +{ + struct rte_memarea *ma, *bak_ma; + struct rte_memarea_param init; + void *ptr; + + /* prepare env */ + test_memarea_init_def_param(&init); + strcat(init.name, "_backup"); + init.source = RTE_MEMAREA_SOURCE_SYSTEM_API; + init.total_sz = MEMAREA_TEST_DEFAULT_SIZE; + bak_ma = rte_memarea_create(&init); + RTE_TEST_ASSERT(bak_ma != NULL, "Expected Non-NULL"); + test_memarea_init_def_param(&init); + init.source = RTE_MEMAREA_SOURCE_SYSTEM_API; + init.total_sz = MEMAREA_TEST_DEFAULT_SIZE >> 2; + init.bak_memarea = bak_ma; + ma = rte_memarea_create(&init); + RTE_TEST_ASSERT(ma != NULL, "Expected Non-NULL"); + + /* test for backup */ + ptr = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 3, 0); + RTE_TEST_ASSERT(ptr != NULL, "Expected Non-NULL"); + ptr = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1, 0); + RTE_TEST_ASSERT(ptr != NULL, "Expected Non-NULL"); + (void)rte_memarea_dump(ma, stderr, true); + (void)rte_memarea_dump(bak_ma, stderr, true); + rte_memarea_free(ma, ptr); + ptr = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE, 0); + RTE_TEST_ASSERT(ptr == NULL, "Expected NULL"); + (void)rte_memarea_dump(ma, stderr, true); + (void)rte_memarea_dump(bak_ma, stderr, true); + + rte_memarea_destroy(ma); + rte_memarea_destroy(bak_ma); + + return 0; +} + static int test_memarea(void) { @@ -291,6 +331,7 @@ test_memarea(void) MEMAREA_TEST_API_RUN(test_memarea_free_fail); MEMAREA_TEST_API_RUN(test_memarea_alloc_free); MEMAREA_TEST_API_RUN(test_memarea_dump); + MEMAREA_TEST_API_RUN(test_memarea_backup); return 0; }