On 7/10/2023 7:49 AM, Chengwen Feng wrote:
This patch supports rte_memarea_alloc() and rte_memarea_free() API
test.

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
Reviewed-by: Dongdong Liu <liudongdo...@huawei.com>
Acked-by: Morten Brørup <m...@smartsharesystems.com>
---

+static int
+test_memarea_free_fail(void)
+{
+       struct rte_memarea_param init;
+       struct rte_memarea *ma;
+       void *ptr;
+
+       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");
+
+       /* test repeat free */
+       rte_errno = 0;
+       ptr = rte_memarea_alloc(ma, MEMAREA_TEST_DEFAULT_SIZE >> 1);
+       TEST_ASSERT(ptr != NULL, "Expected Non-NULL");
+       test_memarea_fill_region(ptr, MEMAREA_TEST_DEFAULT_SIZE >> 1);
+       rte_memarea_free(ma, ptr);
+       TEST_ASSERT(rte_errno == 0, "Expected Zero");
+       rte_memarea_free(ma, ptr);
+       TEST_ASSERT(rte_errno == EFAULT, "Expected EFAULT");
+
+       rte_memarea_destroy(ma);
+
+       return 0;

Same as in other, I think TEST_SUCCESS would be more correct (even though DPDK codebase doesn't always follow that convention).

Acked-by: Anatoly Burakov <anatoly.bura...@intel.com>
--
Thanks,
Anatoly

Reply via email to