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: 002dda1fe241b7d56834904f064161bc4f7857af
 **/
 test/validation/api/pool/pool.c | 45 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index 34f973573..3e84cd2d6 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -217,6 +217,50 @@ 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;
+       uintptr_t pkt_data, pool_len;
+
+       odp_pool_param_init(&param);
+
+       param.type     = ODP_POOL_PACKET;
+       param.pkt.num  = PKT_NUM;
+       param.pkt.len  = PKT_LEN;
+
+       pool = odp_pool_create(NULL, &param);
+       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]);
+               CU_ASSERT((pkt_data >= info.min_data_addr) &&
+                         (pkt_data + PKT_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 +269,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,
 };
 

Reply via email to