From: Michal Mazur <m...@semihalf.com> Allocate maximum number of packets from pool and verify that packet data are located inside range returned by odp_pool_info.
Signed-off-by: Michal Mazur <m...@semihalf.com> --- /** Email created from pull request 495 (semihalf-mazur-michal:master) ** https://github.com/Linaro/odp/pull/495 ** Patch: https://github.com/Linaro/odp/pull/495.patch ** Base sha: 5a58bbf2bb331fd7dde2ebbc0430634ace6900fb ** Merge commit sha: 0390589df2dbf51cfd601bc4baf1b06b571653bb **/ test/validation/api/pool/pool.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index 34f973573..f6ebb6886 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -217,6 +217,51 @@ static void pool_test_info_packet(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } +static void pool_test_info_data_range(void) +{ + odp_pool_t pool; + odp_pool_info_t info; + odp_pool_param_t param; + odp_packet_t pkt[PKT_NUM]; + uint32_t i, num, seg_len; + uintptr_t pkt_data, pool_len; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET; + param.pkt.num = PKT_NUM; + param.pkt.len = PKT_LEN; + + pool = odp_pool_create(NULL, ¶m); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + CU_ASSERT_FATAL(odp_pool_info(pool, &info) == 0); + + pool_len = info.max_data_addr - info.min_data_addr + 1; + CU_ASSERT(pool_len >= PKT_NUM * PKT_LEN); + + num = 0; + + for (i = 0; i < PKT_NUM; i++) { + pkt[num] = odp_packet_alloc(pool, PKT_LEN); + CU_ASSERT(pkt[num] != ODP_PACKET_INVALID); + + if (pkt[num] != ODP_PACKET_INVALID) + num++; + } + + for (i = 0; i < num; i++) { + pkt_data = (uintptr_t)odp_packet_data(pkt[i]); + seg_len = odp_packet_seg_len(pkt[i]); + CU_ASSERT((pkt_data >= info.min_data_addr) && + (pkt_data + seg_len - 1 <= info.max_data_addr)); + + odp_packet_free(pkt[i]); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_create_destroy_buffer), ODP_TEST_INFO(pool_test_create_destroy_packet), @@ -225,6 +270,7 @@ odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_alloc_packet_subparam), ODP_TEST_INFO(pool_test_info_packet), ODP_TEST_INFO(pool_test_lookup_info_print), + ODP_TEST_INFO(pool_test_info_data_range), ODP_TEST_INFO_NULL, };