From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80DF6A0542; Wed, 5 Oct 2022 05:39:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A39FC42B71; Wed, 5 Oct 2022 05:39:11 +0200 (CEST) Received: from out162-62-58-216.mail.qq.com (out162-62-58-216.mail.qq.com [162.62.58.216]) by mails.dpdk.org (Postfix) with ESMTP id 42E9342B71 for ; Wed, 5 Oct 2022 05:39:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1664941146; bh=1K/8Rt7vdqUS1PyVSUzU7CnydL6bqe3VgI77Oh1k5Ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w7AXvg3sk5JONLeDWI4S8Q45OQvcaDcmZkVHvaBKcbiZFD4u7xRYDU5xt6a3Viad2 5I6/AzuZ/YtBUqgzqBnfGRHWvvGhZjPiD0ZxQFL1M2mduCWXV4Fp6p56SXew9RFefN 8R5+JeGOmtK0lZyp9XhXqU3gDxXaprzLAM391UzE= Received: from qq.com ([120.229.93.179]) by newxmesmtplogicsvrszc13.qq.com (NewEsmtp) with SMTP id 9B40FA58; Wed, 05 Oct 2022 11:38:52 +0800 X-QQ-mid: xmsmtpt1664941144tavswky21 Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjnm+d5BBD381LObK556byYN4qdTU1Xd4DUSNAH0DEX3ulw6cVUE u7Xd58EdRXS5nt5aHUmV7lmiPjQO77JX3KoGRQuPeut6R0UMoCdjkeCpTiaDlBRx9w0kivD2hDxv ws7iC58vCkyrk2mdTVXkxav6AerPoR8sZih5OYWpC6gObwxZAwmrjyNj0vs7MZjXGKxQXGZJJpSH KCQGGkn7YWZEJ0n64hYXVm/5Nom2tkVYb7Bk/D9Jal4tZlpsrXH+uqe6LrpLNdFDZ0RtabRElo9Q gsNDXg30gFCSNRwIXFCSUfakk1+W0jHyVKeUZCUUOUaQX4VRkIjHE82ELDUFRkqvk9sAMqRrQnBU aKTpLDXR4csQ/bXB28nj5t7J/7TE9ql60S01NZR2xQe+ZzsyOCbqbLLtJIqHLdkASevsrgCD8bFk Af5QNOeW/mY+00Ob7rxuWkEwH1jeDi1ISu9NaQgmSbFNtpWRmQqNMGlvLFu1L+253QE6eEG7HXNI bGwN5AWDMEWscpekGanzU5B2BMLsitxR0NjP8vKOzbMWlNbWm3xBisEBLJybbdycJYQI58rka1h/ LdozID/CqcgTpKVTykDx3wkoeUDdveA7YVwOWrqDzEcb5QvBkGwx3vIGHVFud05TdMLCDOBdvGMX Cj04IyDpTtrWb6eZuBXbVZKPrs5XrDSoHGK8795BkkbBRpogcMjpfbMi9b5a7QglSLEItMR9uX9x p6hJqPsGS8GW18fBvK2PohWumyclr9qQA5OibcHMqYeLL7e7617GdGEy6iEuMPxqX9RfX7thTId8 DWDOabm365quE9mAtYI5SqXU37SgQYBBvgF9a9mFQgdEZ7F8zf6Ym5EaGOGWQepSZuJuYXmq4V1l swTlKwIgWkT5e0ss8eMsNTvE+7sq22KauXGx9syQqlxgB4FuKfHr2YyYIxtRcAalKdCvg7MRonYf 4A4q/6rd0RIti4Yl6L10DuJb1rwUfg From: datshan To: david.marchand@redhat.com, mb@smartsharesystems.com, anatoly.burakov@intel.com, dmitry.kozliuk@gmail.com, jerinjacobk@gmail.com Cc: thomas@monjalon.net, dev@dpdk.org, Chengwen Feng Subject: [PATCH v4 08/10] test/memarea: support backup memory test Date: Wed, 5 Oct 2022 11:38:46 +0800 X-OQ-MSGID: <20221005033848.2241-9-datshan@qq.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005033848.2241-1-datshan@qq.com> References: <20220721044648.6817-1-fengchengwen@huawei.com> <20221005033848.2241-1-datshan@qq.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Chengwen Feng 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 ab360f0265..ec3475c354 100644 --- a/app/test/test_memarea.c +++ b/app/test/test_memarea.c @@ -313,6 +313,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) { @@ -322,6 +362,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; } -- 2.34.1