diff options
author | Ashwin Sekhar T K <asekhar@marvell.com> | 2020-09-18 15:26:01 +0530 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2020-11-19 09:49:08 +0200 |
commit | 3788737479f91d94909344f446e7312f6fd34d40 (patch) | |
tree | c2a1f1c30c2046efe0a39d5dbb720adad682ac1d | |
parent | e2a6e944b2b1e1d924c2c8b7eb2c253e92705079 (diff) |
validation: pool: add vector pool tests
Add tests to validate vector pool functionality.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r-- | test/validation/api/pool/pool.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index 651a00162..70cf4f6ec 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -1,4 +1,6 @@ /* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2020, Marvell + * Copyright (c) 2020, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -10,6 +12,8 @@ #define BUF_SIZE 1500 #define BUF_NUM 1000 #define TMO_NUM 1000 +#define VEC_NUM 1000 +#define VEC_LEN 32 #define PKT_LEN 400 #define PKT_NUM 500 #define MAX_NUM_DEFAULT (10 * 1024 * 1024) @@ -75,6 +79,27 @@ static void pool_test_create_destroy_timeout(void) pool_create_destroy(¶m); } +static void pool_test_create_destroy_vector(void) +{ + odp_pool_param_t param; + odp_pool_capability_t capa; + uint32_t max_num = VEC_NUM; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + + CU_ASSERT_FATAL(capa.vector.max_pools > 0); + + if (capa.vector.max_num && capa.vector.max_num < max_num) + max_num = capa.vector.max_num; + + odp_pool_param_init(¶m); + param.type = ODP_POOL_VECTOR; + param.vector.num = max_num; + param.vector.max_size = capa.vector.max_size < VEC_LEN ? capa.vector.max_size : VEC_LEN; + + pool_create_destroy(¶m); +} + static void pool_test_lookup_info_print(void) { odp_pool_t pool; @@ -156,6 +181,59 @@ static void pool_test_alloc_buffer_max_cache(void) alloc_buffer(global_pool_capa.buf.max_cache_size); } +static void alloc_packet_vector(uint32_t cache_size) +{ + odp_pool_t pool; + odp_pool_param_t param; + odp_pool_capability_t capa; + uint32_t i, num; + odp_packet_vector_t pkt_vec[VEC_NUM]; + uint32_t max_num = VEC_NUM; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + + if (capa.vector.max_num && capa.vector.max_num < max_num) + max_num = capa.vector.max_num; + + odp_pool_param_init(¶m); + param.type = ODP_POOL_VECTOR; + param.vector.num = max_num; + param.vector.max_size = capa.vector.max_size < VEC_LEN ? capa.vector.max_size : VEC_LEN; + param.vector.cache_size = cache_size; + + pool = odp_pool_create(NULL, ¶m); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + num = 0; + for (i = 0; i < max_num; i++) { + pkt_vec[num] = odp_packet_vector_alloc(pool); + CU_ASSERT(pkt_vec[num] != ODP_PACKET_VECTOR_INVALID); + + if (pkt_vec[num] != ODP_PACKET_VECTOR_INVALID) + num++; + } + + for (i = 0; i < num; i++) + odp_packet_vector_free(pkt_vec[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void pool_test_alloc_packet_vector(void) +{ + alloc_packet_vector(default_pool_param.vector.cache_size); +} + +static void pool_test_alloc_packet_vector_min_cache(void) +{ + alloc_packet_vector(global_pool_capa.vector.min_cache_size); +} + +static void pool_test_alloc_packet_vector_max_cache(void) +{ + alloc_packet_vector(global_pool_capa.vector.max_cache_size); +} + static void alloc_packet(uint32_t cache_size) { odp_pool_t pool; @@ -501,6 +579,54 @@ static void pool_test_pkt_max_num(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } +static void pool_test_packet_vector_max_num(void) +{ + odp_pool_t pool; + odp_pool_param_t param; + odp_pool_capability_t capa; + uint32_t num, i; + odp_shm_t shm; + odp_packet_vector_t *pktv; + uint32_t max_num = VEC_NUM; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + + if (capa.vector.max_num) + max_num = capa.vector.max_num; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_VECTOR; + param.vector.num = max_num; + param.vector.max_size = 1; + + pool = odp_pool_create("test_packet_vector_max_num", ¶m); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + shm = odp_shm_reserve("test_max_num_shm", max_num * sizeof(odp_packet_vector_t), + sizeof(odp_packet_vector_t), 0); + CU_ASSERT_FATAL(shm != ODP_SHM_INVALID); + + pktv = odp_shm_addr(shm); + CU_ASSERT_FATAL(pktv != NULL); + + num = 0; + for (i = 0; i < max_num; i++) { + pktv[num] = odp_packet_vector_alloc(pool); + + if (pktv[num] != ODP_PACKET_VECTOR_INVALID) + num++; + } + + CU_ASSERT(num == max_num); + + for (i = 0; i < num; i++) + odp_packet_vector_free(pktv[i]); + + CU_ASSERT(odp_shm_free(shm) == 0); + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + static void pool_test_pkt_seg_len(void) { uint32_t len = 1500; @@ -698,9 +824,13 @@ odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_create_destroy_buffer), ODP_TEST_INFO(pool_test_create_destroy_packet), ODP_TEST_INFO(pool_test_create_destroy_timeout), + ODP_TEST_INFO(pool_test_create_destroy_vector), ODP_TEST_INFO(pool_test_alloc_buffer), ODP_TEST_INFO(pool_test_alloc_buffer_min_cache), ODP_TEST_INFO(pool_test_alloc_buffer_max_cache), + ODP_TEST_INFO(pool_test_alloc_packet_vector), + ODP_TEST_INFO(pool_test_alloc_packet_vector_min_cache), + ODP_TEST_INFO(pool_test_alloc_packet_vector_max_cache), ODP_TEST_INFO(pool_test_alloc_packet), ODP_TEST_INFO(pool_test_alloc_packet_min_cache), ODP_TEST_INFO(pool_test_alloc_packet_max_cache), @@ -713,6 +843,7 @@ odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_info_data_range), ODP_TEST_INFO(pool_test_buf_max_num), ODP_TEST_INFO(pool_test_pkt_max_num), + ODP_TEST_INFO(pool_test_packet_vector_max_num), ODP_TEST_INFO(pool_test_pkt_seg_len), ODP_TEST_INFO(pool_test_tmo_max_num), ODP_TEST_INFO(pool_test_create_after_fork), |