[PATCH v16 4/6] test/memarea: support alloc and free API test
Burakov, Anatoly
anatoly.burakov at intel.com
Mon Jul 17 15:57:38 CEST 2023
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 <fengchengwen at huawei.com>
> Reviewed-by: Dongdong Liu <liudongdong3 at huawei.com>
> Acked-by: Morten Brørup <mb at 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.burakov at intel.com>
--
Thanks,
Anatoly
More information about the dev
mailing list