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 8C33742EBF; Thu, 20 Jul 2023 11:35:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C2FF40E2D; Thu, 20 Jul 2023 11:35:11 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id C8CF540DF5 for ; Thu, 20 Jul 2023 11:35:09 +0200 (CEST) Received: from dggpeml100024.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R66vx0W8lzrRq5; Thu, 20 Jul 2023 17:34:21 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 20 Jul 2023 17:35:06 +0800 Subject: Re: [PATCH v16 6/6] test/memarea: support dump API test To: "Burakov, Anatoly" , , CC: , , , , , References: <20220721044648.6817-1-fengchengwen@huawei.com> <20230710064923.19849-1-fengchengwen@huawei.com> <20230710064923.19849-7-fengchengwen@huawei.com> <00979f82-083a-b5a8-cc77-b4ed87b55930@intel.com> From: fengchengwen Message-ID: Date: Thu, 20 Jul 2023 17:35:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <00979f82-083a-b5a8-cc77-b4ed87b55930@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Anatoly, On 2023/7/19 20:09, Burakov, Anatoly wrote: > On 7/10/2023 7:49 AM, Chengwen Feng wrote: >> This patch supports rte_memarea_dump() API test. >> >> Signed-off-by: Chengwen Feng >> Reviewed-by: Dongdong Liu >> Acked-by: Morten Brørup >> --- >>   app/test/test_memarea.c | 40 ++++++++++++++++++++++++++++++++++++++++ >>   1 file changed, 40 insertions(+) >> >> diff --git a/app/test/test_memarea.c b/app/test/test_memarea.c >> index 4053cdcac9..6511a86699 100644 >> --- a/app/test/test_memarea.c >> +++ b/app/test/test_memarea.c >> @@ -320,6 +320,45 @@ test_memarea_alloc_free(void) >>         TEST_ASSERT(rte_errno == 0, "Expected Zero"); >>   +    fprintf(stderr, "There should have no allocated object.\n"); >> +    rte_memarea_dump(ma, stderr, true); >> + >> +    rte_memarea_destroy(ma); >> + >> +    return 0; >> +} >> + >> +static int >> +test_memarea_dump(void) >> +{ >> +    struct rte_memarea_param init; >> +    struct rte_memarea *ma; >> +    int ret; >> + >> +    test_memarea_init_param(&init); >> +    init.source = RTE_MEMAREA_SOURCE_LIBC; >> +    init.total_sz = MEMAREA_TEST_DEFAULT_SIZE; >> +    ma = rte_memarea_create(&init); >> +    TEST_ASSERT(ma != NULL, "Expected Non-NULL"); > > Here and in other places: I feel it's better to say *why* we expect non-NULL, or make the error message otherwise more meaningful, such as "Memarea creation failed". It already fix in v19. > >> + >> +    /* test for invalid parameters */ >> +    ret = rte_memarea_dump(NULL, stderr, false); >> +    TEST_ASSERT(ret == -1, "Expected -1"); >> +    TEST_ASSERT(rte_errno == EINVAL, "Expected EINVAL"); >> +    ret = rte_memarea_dump(ma, NULL, false); >> +    TEST_ASSERT(ret == -1, "Expected -1"); >> +    TEST_ASSERT(rte_errno == EINVAL, "Expected EINVAL"); >> + >> +    /* test for dump */ >> +    (void)rte_memarea_alloc(ma, 1); >> +    (void)rte_memarea_alloc(ma, 1); >> +    (void)rte_memarea_alloc(ma, 1); >> +    (void)rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE); >> +    (void)rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE); >> +    fprintf(stderr, "There should have three allocated object.\n"); > > I question the value of this printout. I have change the implemention (in v19): so it will depend on the rte_memarea_alloc result. > >> +    ret = rte_memarea_dump(ma, stderr, true); >> +    TEST_ASSERT(ret == 0, "Expected ZERO"); >> + >>       rte_memarea_destroy(ma); >>         return 0; >> @@ -337,6 +376,7 @@ static struct unit_test_suite memarea_test_suite  = { >>           TEST_CASE(test_memarea_alloc_fail), >>           TEST_CASE(test_memarea_free_fail), >>           TEST_CASE(test_memarea_alloc_free), >> +        TEST_CASE(test_memarea_dump), >>             TEST_CASES_END() /**< NULL terminate unit test array */ >>       } > Thanks.