From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 67117A0542;
	Sat,  8 Oct 2022 14:04:16 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3C3874021F;
	Sat,  8 Oct 2022 14:04:15 +0200 (CEST)
Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])
 by mails.dpdk.org (Postfix) with ESMTP id 68C5C42BA0
 for <dev@dpdk.org>; Sat,  8 Oct 2022 14:04:13 +0200 (CEST)
Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.55])
 by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ml3dB3KJMzlXZG;
 Sat,  8 Oct 2022 19:59:42 +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; Sat, 8 Oct 2022 20:04:12 +0800
From: Chengwen Feng <fengchengwen@huawei.com>
To: <david.marchand@redhat.com>, <mb@smartsharesystems.com>,
 <anatoly.burakov@intel.com>, <dmitry.kozliuk@gmail.com>,
 <jerinjacobk@gmail.com>, <hofors@lysator.liu.se>
CC: <thomas@monjalon.net>, <dev@dpdk.org>
Subject: [PATCH v7 06/10] test/memarea: support dump test
Date: Sat, 8 Oct 2022 11:58:29 +0000
Message-ID: <20221008115833.29247-7-fengchengwen@huawei.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20221008115833.29247-1-fengchengwen@huawei.com>
References: <20220721044648.6817-1-fengchengwen@huawei.com>
 <20221008115833.29247-1-fengchengwen@huawei.com>
MIME-Version: 1.0
Content-Type: text/plain
X-Originating-IP: [10.67.165.24]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <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>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

This patch supports rte_memarea_dump() test.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_memarea.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/app/test/test_memarea.c b/app/test/test_memarea.c
index 5ace384b8a..d159e4f2ef 100644
--- a/app/test/test_memarea.c
+++ b/app/test/test_memarea.c
@@ -297,6 +297,38 @@ test_memarea_alloc_free(void)
 	return 0;
 }
 
+static int
+test_memarea_dump(void)
+{
+	struct rte_memarea_param init;
+	struct rte_memarea *ma;
+	int ret;
+
+	/* prepare env */
+	test_memarea_init_def_param(&init);
+	init.source = RTE_MEMAREA_SOURCE_LIBC;
+	init.total_sz = MEMAREA_TEST_DEFAULT_SIZE;
+	ma = rte_memarea_create(&init);
+	RTE_TEST_ASSERT(ma != NULL, "Expected Non-NULL");
+
+	/* test for invalid parameters */
+	ret = rte_memarea_dump(NULL, stderr, false);
+	RTE_TEST_ASSERT(ret == -EINVAL, "Expected EINVAL");
+	ret = rte_memarea_dump(ma, NULL, false);
+	RTE_TEST_ASSERT(ret == -EINVAL, "Expected EINVAL");
+
+	/* test for dump */
+	(void)rte_memarea_alloc(ma, 1, 0);
+	(void)rte_memarea_alloc(ma, 1, 0);
+	(void)rte_memarea_alloc(ma, 1, 0);
+	ret = rte_memarea_dump(ma, stderr, true);
+	RTE_TEST_ASSERT(ret == 0, "Expected ZERO");
+
+	rte_memarea_destroy(ma);
+
+	return 0;
+}
+
 static int
 test_memarea(void)
 {
@@ -307,6 +339,7 @@ test_memarea(void)
 	MEMAREA_TEST_API_RUN(test_memarea_alloc_fail);
 	MEMAREA_TEST_API_RUN(test_memarea_free_fail);
 	MEMAREA_TEST_API_RUN(test_memarea_alloc_free);
+	MEMAREA_TEST_API_RUN(test_memarea_dump);
 
 	return test_memarea_retcode();
 }
-- 
2.17.1