Add validation tests for the new packet reference APIs:
- odp_packet_ref_static()
- odp_packet_ref()
- odp_packet_ref_pkt()
- odp_packet_is_ref()
- odp_packet_unshared_len()

Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org>
---
 test/common_plat/validation/api/packet/packet.c | 368 +++++++++++++++++++++++-
 test/common_plat/validation/api/packet/packet.h |   2 +
 2 files changed, 366 insertions(+), 4 deletions(-)

diff --git a/test/common_plat/validation/api/packet/packet.c 
b/test/common_plat/validation/api/packet/packet.c
index cf11c01..0411d22 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -217,6 +217,7 @@ void packet_test_alloc_free(void)
        params.pkt.num        = 1;
 
        pool = odp_pool_create("packet_pool_alloc", &params);
+       CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
 
        /* Allocate the only buffer from the pool */
        packet = odp_packet_alloc(pool, packet_len);
@@ -1410,7 +1411,7 @@ void packet_test_concat_extend_trunc(void)
        param.pkt.num = 100;
 
        pool = odp_pool_create("packet_pool_concat", &param);
-       CU_ASSERT(packet_pool != ODP_POOL_INVALID);
+       CU_ASSERT_FATAL(packet_pool != ODP_POOL_INVALID);
 
        pkt = odp_packet_alloc(pool, alloc_len);
        CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
@@ -1429,6 +1430,7 @@ void packet_test_concat_extend_trunc(void)
 
                CU_ASSERT(odp_packet_len(pkt) == (cur_len + alloc_len));
                cur_len = odp_packet_len(pkt);
+               CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
        }
 
        ret = odp_packet_extend_tail(&pkt, ext_len, NULL, NULL);
@@ -1436,12 +1438,14 @@ void packet_test_concat_extend_trunc(void)
 
        CU_ASSERT(odp_packet_len(pkt) == (cur_len + ext_len));
        cur_len = odp_packet_len(pkt);
+       CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
 
        ret = odp_packet_extend_head(&pkt, ext_len, NULL, NULL);
        CU_ASSERT(ret >= 0);
 
        CU_ASSERT(odp_packet_len(pkt) == (cur_len + ext_len));
        cur_len = odp_packet_len(pkt);
+       CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
 
        pkt2 = odp_packet_alloc(pool, alloc_len);
        CU_ASSERT_FATAL(pkt2 != ODP_PACKET_INVALID);
@@ -1454,18 +1458,21 @@ void packet_test_concat_extend_trunc(void)
 
        CU_ASSERT(odp_packet_len(pkt) == (cur_len + alloc_len));
        cur_len = odp_packet_len(pkt);
+       CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
 
        ret = odp_packet_trunc_head(&pkt, trunc_len, NULL, NULL);
        CU_ASSERT(ret >= 0);
 
        CU_ASSERT(odp_packet_len(pkt) == (cur_len - trunc_len));
        cur_len = odp_packet_len(pkt);
+       CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
 
        ret = odp_packet_trunc_tail(&pkt, trunc_len, NULL, NULL);
        CU_ASSERT(ret >= 0);
 
        CU_ASSERT(odp_packet_len(pkt) == (cur_len - trunc_len));
        cur_len = odp_packet_len(pkt);
+       CU_ASSERT(cur_len == odp_packet_unshared_len(pkt));
 
        odp_packet_free(pkt);
 
@@ -1497,7 +1504,7 @@ void packet_test_extend_small(void)
        param.pkt.num = 100;
 
        pool = odp_pool_create("packet_pool_extend", &param);
-       CU_ASSERT(packet_pool != ODP_POOL_INVALID);
+       CU_ASSERT_FATAL(packet_pool != ODP_POOL_INVALID);
 
        for (round = 0; round < 2; round++) {
                pkt = odp_packet_alloc(pool, 1);
@@ -1533,6 +1540,7 @@ void packet_test_extend_small(void)
                }
 
                CU_ASSERT(odp_packet_len(pkt) == len);
+               CU_ASSERT(odp_packet_unshared_len(pkt) == len);
 
                len = odp_packet_len(pkt);
 
@@ -1583,7 +1591,7 @@ void packet_test_extend_large(void)
        param.pkt.num = 100;
 
        pool = odp_pool_create("packet_pool_extend", &param);
-       CU_ASSERT(packet_pool != ODP_POOL_INVALID);
+       CU_ASSERT_FATAL(packet_pool != ODP_POOL_INVALID);
 
        for (round = 0; round < 2 * num_div; round++) {
                ext_len = len / div;
@@ -1694,7 +1702,7 @@ void packet_test_extend_mix(void)
        param.pkt.num = 100;
 
        pool = odp_pool_create("packet_pool_extend", &param);
-       CU_ASSERT(packet_pool != ODP_POOL_INVALID);
+       CU_ASSERT_FATAL(packet_pool != ODP_POOL_INVALID);
 
        for (round = 0; round < 2; round++) {
                small_count = 30;
@@ -1774,6 +1782,90 @@ void packet_test_extend_mix(void)
        CU_ASSERT(odp_pool_destroy(pool) == 0);
 }
 
+void packet_test_extend_ref(void)
+{
+       odp_packet_t max_pkt, ref;
+       uint32_t hr, tr, max_len;
+
+       max_pkt = odp_packet_copy(segmented_test_packet,
+                                 odp_packet_pool(segmented_test_packet));
+       CU_ASSERT_FATAL(max_pkt != ODP_PACKET_INVALID);
+       max_len = odp_packet_len(max_pkt);
+
+       /* Maximize the max pkt */
+       hr = odp_packet_headroom(max_pkt);
+       tr = odp_packet_tailroom(max_pkt);
+       odp_packet_push_head(max_pkt, hr);
+       odp_packet_push_tail(max_pkt, tr);
+
+       /* Max packet should not be extendable at either end */
+       CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
+       CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
+
+       /* See if we can trunc and extend anyway */
+       CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
+                                       NULL, NULL) >= 0);
+       CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) >= 0);
+       CU_ASSERT(odp_packet_len(max_pkt) == max_len);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == max_len);
+
+       /* Now try with a reference in place */
+       CU_ASSERT(odp_packet_trunc_tail(&max_pkt, 100, NULL, NULL) >= 0);
+       ref = odp_packet_ref(max_pkt, 100);
+
+       /* Verify ref lengths */
+       CU_ASSERT(ref != ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_len(ref) == max_len - 200);
+       CU_ASSERT(odp_packet_unshared_len(ref) == 0);
+
+       /* And ref's affect on max_pkt */
+       CU_ASSERT(odp_packet_is_ref(max_pkt) == 1);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == 100);
+
+       /* Now extend max_pkt and verify effect */
+       CU_ASSERT(odp_packet_extend_head(&max_pkt, 10, NULL, NULL) >= 0);
+       CU_ASSERT(odp_packet_len(max_pkt) == max_len - 90);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110);
+       CU_ASSERT(odp_packet_is_ref(max_pkt) == 1);
+
+       /* Extend on max_pkt should not affect ref */
+       CU_ASSERT(odp_packet_is_ref(ref) == 1);
+       CU_ASSERT(odp_packet_len(ref) == max_len - 200);
+       CU_ASSERT(odp_packet_unshared_len(ref) == 0);
+
+       /* Now extend ref and verify effect*/
+       CU_ASSERT(odp_packet_extend_head(&ref, 20, NULL, NULL) >= 0);
+       CU_ASSERT(odp_packet_len(ref) == max_len - 180);
+       CU_ASSERT(odp_packet_unshared_len(ref) == 20);
+
+       /* Extend on ref should not affect max_pkt */
+       CU_ASSERT(odp_packet_len(max_pkt) == max_len - 90);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110);
+       CU_ASSERT(odp_packet_is_ref(max_pkt) == 1);
+
+       /* Trunc max_pkt of all unshared len */
+       CU_ASSERT(odp_packet_trunc_head(&max_pkt,
+                                       odp_packet_unshared_len(max_pkt),
+                                       NULL, NULL) >= 0);
+
+       /* Verify effect on max_pkt */
+       CU_ASSERT(odp_packet_len(max_pkt) == max_len - 200);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == 0);
+       CU_ASSERT(odp_packet_is_ref(max_pkt) == 1);
+
+       /* Verify that ref is unchanged */
+       CU_ASSERT(odp_packet_len(ref) == max_len - 180);
+       CU_ASSERT(odp_packet_unshared_len(ref) == 20);
+
+       /* Free ref and verify that max_pkt is back to being unreferenced */
+       odp_packet_free(ref);
+       CU_ASSERT(odp_packet_is_ref(max_pkt) == 0);
+       CU_ASSERT(odp_packet_len(max_pkt) == max_len - 200);
+       CU_ASSERT(odp_packet_unshared_len(max_pkt) == max_len - 200);
+
+       odp_packet_free(max_pkt);
+}
+
 void packet_test_align(void)
 {
        odp_packet_t pkt;
@@ -1878,6 +1970,272 @@ void packet_test_offset(void)
        CU_ASSERT_PTR_NOT_NULL(ptr);
 }
 
+void packet_test_ref(void)
+{
+       odp_packet_t base_pkt, segmented_base_pkt, hdr_pkt[4],
+               ref_pkt[4], refhdr_pkt[4], hdr_cpy;
+       uint32_t pkt_len, segmented_pkt_len, hdr_len[4], offset[4], hr[4],
+               base_hr, ref_len[4];
+       int i;
+
+       base_pkt = odp_packet_copy(test_packet, odp_packet_pool(test_packet));
+       base_hr = odp_packet_headroom(base_pkt);
+       pkt_len  = odp_packet_len(test_packet);
+       CU_ASSERT_FATAL(base_pkt != ODP_PACKET_INVALID);
+
+       segmented_base_pkt =
+               odp_packet_copy(segmented_test_packet,
+                               odp_packet_pool(segmented_test_packet));
+       segmented_pkt_len = odp_packet_len(segmented_test_packet);
+       CU_ASSERT_FATAL(segmented_base_pkt != ODP_PACKET_INVALID);
+
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 0);
+
+       hdr_pkt[0] =
+               odp_packet_copy_part(segmented_test_packet, 0,
+                                    odp_packet_len(segmented_test_packet) / 4,
+                                    odp_packet_pool(segmented_test_packet));
+       CU_ASSERT_FATAL(hdr_pkt[0] != ODP_PACKET_INVALID);
+       hdr_len[0] = odp_packet_len(hdr_pkt[0]);
+       offset[0]  = 0;
+
+       hdr_pkt[1] =
+               odp_packet_copy_part(segmented_test_packet, 10,
+                                    odp_packet_len(segmented_test_packet) / 8,
+                                    odp_packet_pool(segmented_test_packet));
+       CU_ASSERT_FATAL(hdr_pkt[1] != ODP_PACKET_INVALID);
+       hdr_len[1] = odp_packet_len(hdr_pkt[1]);
+       offset[1]  = 5;
+
+       hdr_pkt[2] = odp_packet_copy_part(test_packet, 0,
+                                         odp_packet_len(test_packet) / 4,
+                                         odp_packet_pool(test_packet));
+       CU_ASSERT_FATAL(hdr_pkt[2] != ODP_PACKET_INVALID);
+       hdr_len[2] = odp_packet_len(hdr_pkt[2]);
+       offset[2]  = 64;
+
+       hdr_pkt[3] = odp_packet_copy_part(test_packet, 0,
+                                         odp_packet_len(test_packet) / 4,
+                                         odp_packet_pool(test_packet));
+       CU_ASSERT_FATAL(hdr_pkt[3] != ODP_PACKET_INVALID);
+       hdr_len[3] = odp_packet_len(hdr_pkt[3]);
+       offset[3]  = 64;
+
+       /* Nothing is a ref or has a ref before we start */
+       for (i = 0; i < 4; i++) {
+               CU_ASSERT(odp_packet_is_ref(hdr_pkt[i]) == 0);
+               CU_ASSERT(odp_packet_len(hdr_pkt[i]) ==
+                         odp_packet_unshared_len(hdr_pkt[i]));
+       }
+
+       /* Attempt an invalid ref */
+       refhdr_pkt[0] = odp_packet_ref_pkt(base_pkt, pkt_len, hdr_pkt[0]);
+       CU_ASSERT(refhdr_pkt[0] == ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_is_ref(hdr_pkt[0]) == 0);
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 0);
+
+       /* We can't ref to ourselves */
+       refhdr_pkt[0] = odp_packet_ref_pkt(hdr_pkt[0], 0, hdr_pkt[0]);
+       CU_ASSERT(refhdr_pkt[0] == ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_is_ref(hdr_pkt[0]) == 0);
+
+       /* Now create a couple of valid refs */
+       refhdr_pkt[0] = odp_packet_ref_pkt(base_pkt, offset[0], hdr_pkt[0]);
+       refhdr_pkt[1] = odp_packet_ref_pkt(base_pkt, offset[1], hdr_pkt[1]);
+
+       CU_ASSERT(refhdr_pkt[0] != ODP_PACKET_INVALID);
+       CU_ASSERT(refhdr_pkt[1] != ODP_PACKET_INVALID);
+
+       CU_ASSERT(odp_packet_is_ref(refhdr_pkt[0]) == 1);
+       CU_ASSERT(odp_packet_is_ref(refhdr_pkt[1]) == 1);
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 1);
+
+       /* Verify ref lengths and contents */
+       CU_ASSERT(odp_packet_unshared_len(base_pkt) == 0);
+
+       CU_ASSERT(odp_packet_len(refhdr_pkt[0]) ==
+                 hdr_len[0] + pkt_len - offset[0]);
+       CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == hdr_len[0]);
+       CU_ASSERT(odp_packet_len(refhdr_pkt[1]) ==
+                 hdr_len[1] + pkt_len - offset[1]);
+       CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[1]) == hdr_len[1]);
+
+       _packet_compare_offset(refhdr_pkt[0], hdr_len[0],
+                              base_pkt, offset[0],
+                              pkt_len - offset[0]);
+
+       _packet_compare_offset(refhdr_pkt[1], hdr_len[1],
+                              base_pkt, offset[1],
+                              pkt_len - offset[1]);
+
+       /* See if compound references are supported and if so that they
+        * operate properly */
+       hdr_cpy = odp_packet_copy(hdr_pkt[2], odp_packet_pool(hdr_pkt[2]));
+       CU_ASSERT_FATAL(hdr_cpy != ODP_PACKET_INVALID);
+
+       refhdr_pkt[2] = odp_packet_ref_pkt(refhdr_pkt[0], 2, hdr_cpy);
+       CU_ASSERT(refhdr_pkt[2] != ODP_PACKET_INVALID);
+
+       if (refhdr_pkt[2] != ODP_PACKET_INVALID) {
+               CU_ASSERT(odp_packet_is_ref(base_pkt) == 1);
+               CU_ASSERT(odp_packet_is_ref(refhdr_pkt[2]) == 1);
+               CU_ASSERT(odp_packet_is_ref(refhdr_pkt[0]) == 1);
+               CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[2]) == hdr_len[2]);
+               CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == 2);
+
+               /* Free the compound ref and verify we're back to simple ref */
+               odp_packet_free(refhdr_pkt[2]);
+               CU_ASSERT(odp_packet_is_ref(base_pkt) == 1);
+               CU_ASSERT(odp_packet_is_ref(refhdr_pkt[0]) == 1);
+               CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == hdr_len[0]);
+       }
+
+       /* Delete the refs */
+       odp_packet_free(refhdr_pkt[0]);
+       odp_packet_free(refhdr_pkt[1]);
+
+       /* Verify that base_pkt no longer has a ref */
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 0);
+
+       /* Now create a two more shared refs */
+       refhdr_pkt[2] = odp_packet_ref_pkt(base_pkt, offset[2], hdr_pkt[2]);
+       refhdr_pkt[3] = odp_packet_ref_pkt(base_pkt, offset[3], hdr_pkt[3]);
+
+       CU_ASSERT(hdr_pkt[2] != ODP_PACKET_INVALID);
+       CU_ASSERT(hdr_pkt[3] != ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_is_ref(refhdr_pkt[2]) == 1);
+       CU_ASSERT(odp_packet_is_ref(refhdr_pkt[3]) == 1);
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 1);
+
+       CU_ASSERT(odp_packet_len(refhdr_pkt[2]) ==
+                 odp_packet_len(refhdr_pkt[3]));
+
+       _packet_compare_offset(refhdr_pkt[2], 0,
+                              refhdr_pkt[3], 0,
+                              odp_packet_len(hdr_pkt[2]));
+
+       /* Delete the headers */
+       odp_packet_free(refhdr_pkt[2]);
+       odp_packet_free(refhdr_pkt[3]);
+
+       /* Verify that base_pkt is no longer ref'd */
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 0);
+
+       /* Create a static reference */
+       ref_pkt[0] = odp_packet_ref_static(base_pkt);
+       CU_ASSERT(ref_pkt[0] != ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 1);
+       CU_ASSERT(odp_packet_len(ref_pkt[0]) == odp_packet_len(base_pkt));
+       _packet_compare_offset(ref_pkt[0], 0, base_pkt, 0,
+                              odp_packet_len(base_pkt));
+
+       /* Now delete it */
+       odp_packet_free(ref_pkt[0]);
+       CU_ASSERT(odp_packet_is_ref(base_pkt) == 0);
+
+       /* Create an invalid basic reference */
+       ref_pkt[0] = odp_packet_ref(segmented_base_pkt, segmented_pkt_len);
+       CU_ASSERT(ref_pkt[0] == ODP_PACKET_INVALID);
+       CU_ASSERT(odp_packet_is_ref(segmented_base_pkt) == 0);
+
+       /* Now create valid references */
+       ref_pkt[0] = odp_packet_ref(segmented_base_pkt, offset[0]);
+       CU_ASSERT(odp_packet_is_ref(ref_pkt[0]) == 1);
+       CU_ASSERT(odp_packet_is_ref(segmented_base_pkt) == 1);
+
+       ref_pkt[1] = odp_packet_ref(segmented_base_pkt, offset[1]);
+       CU_ASSERT(odp_packet_is_ref(ref_pkt[1]) == 1);
+       CU_ASSERT(odp_packet_is_ref(segmented_base_pkt) == 1);
+
+       /* Verify reference lengths */
+       CU_ASSERT(odp_packet_len(ref_pkt[0]) == segmented_pkt_len - offset[0]);
+       CU_ASSERT(odp_packet_len(ref_pkt[1]) == segmented_pkt_len - offset[1]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0);
+
+       /* Free the base pkts -- references should still be valid */
+       odp_packet_free(base_pkt);
+       odp_packet_free(segmented_base_pkt);
+
+       CU_ASSERT(odp_packet_is_ref(ref_pkt[0]) == 1);
+       CU_ASSERT(odp_packet_is_ref(ref_pkt[1]) == 1);
+
+       _packet_compare_offset(ref_pkt[0], 0,
+                              segmented_test_packet, offset[0],
+                              segmented_pkt_len - offset[0]);
+       _packet_compare_offset(ref_pkt[1], 0,
+                              segmented_test_packet, offset[1],
+                              segmented_pkt_len - offset[1]);
+
+       /* Verify we can modify the refs */
+       hr[0] = odp_packet_headroom(ref_pkt[0]);
+       hr[1] = odp_packet_headroom(ref_pkt[1]);
+
+       CU_ASSERT(odp_packet_push_head(ref_pkt[0], hr[0]) != NULL);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]);
+       CU_ASSERT(odp_packet_len(ref_pkt[0]) ==
+                 hr[0] + segmented_pkt_len - offset[0]);
+
+       CU_ASSERT(odp_packet_pull_head(ref_pkt[0], hr[0] / 2) != NULL);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0] - (hr[0] / 2));
+
+       if (hr[1] > 0) {
+               CU_ASSERT(odp_packet_push_head(ref_pkt[1], 1) != NULL);
+               CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 1);
+               CU_ASSERT(odp_packet_len(ref_pkt[1]) ==
+                         1 + segmented_pkt_len - offset[1]);
+               CU_ASSERT(odp_packet_pull_head(ref_pkt[1], 1) != NULL);
+               CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0);
+               CU_ASSERT(odp_packet_len(ref_pkt[1]) ==
+                         segmented_pkt_len - offset[1]);
+       }
+
+       odp_packet_free(ref_pkt[0]);
+       odp_packet_free(ref_pkt[1]);
+
+       /* Verify we can modify base packet after reference is created */
+       base_pkt = odp_packet_copy(test_packet, odp_packet_pool(test_packet));
+
+       ref_pkt[1] = odp_packet_ref(base_pkt, offset[1]);
+       CU_ASSERT_FATAL(ref_pkt[1] != ODP_PACKET_INVALID);
+       ref_len[1] = odp_packet_len(ref_pkt[1]);
+       CU_ASSERT(ref_len[1] == odp_packet_len(base_pkt) - offset[1]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0);
+
+       CU_ASSERT(odp_packet_push_head(base_pkt, base_hr / 2) != NULL);
+       CU_ASSERT(odp_packet_unshared_len(base_pkt) == base_hr / 2 + offset[1]);
+       CU_ASSERT(odp_packet_len(ref_pkt[1]) == ref_len[1]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0);
+
+       ref_pkt[0] = odp_packet_ref(base_pkt, offset[0]);
+       CU_ASSERT_FATAL(ref_pkt[0] != ODP_PACKET_INVALID);
+       ref_len[0] = odp_packet_len(ref_pkt[0]);
+       CU_ASSERT(ref_len[0] = odp_packet_len(base_pkt) - offset[0]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0);
+
+       CU_ASSERT(odp_packet_push_head(base_pkt,
+                                      base_hr - base_hr / 2) != NULL);
+       CU_ASSERT(odp_packet_unshared_len(base_pkt) ==
+                 base_hr - base_hr / 2 + offset[0]);
+       CU_ASSERT(odp_packet_len(ref_pkt[1]) == ref_len[1]);
+       CU_ASSERT(odp_packet_len(ref_pkt[0]) == ref_len[0]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0);
+
+       hr[0] = odp_packet_headroom(ref_pkt[0]);
+       hr[1] = odp_packet_headroom(ref_pkt[1]);
+       CU_ASSERT(odp_packet_push_head(ref_pkt[0], hr[0]) != NULL);
+       CU_ASSERT(odp_packet_push_head(ref_pkt[1], hr[1]) != NULL);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]);
+       CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == hr[1]);
+       CU_ASSERT(odp_packet_unshared_len(base_pkt) ==
+                 base_hr - base_hr / 2 + offset[0]);
+
+       odp_packet_free(base_pkt);
+       odp_packet_free(ref_pkt[0]);
+       odp_packet_free(ref_pkt[1]);
+}
+
 odp_testinfo_t packet_suite[] = {
        ODP_TEST_INFO(packet_test_alloc_free),
        ODP_TEST_INFO(packet_test_alloc_free_multi),
@@ -1904,8 +2262,10 @@ odp_testinfo_t packet_suite[] = {
        ODP_TEST_INFO(packet_test_extend_small),
        ODP_TEST_INFO(packet_test_extend_large),
        ODP_TEST_INFO(packet_test_extend_mix),
+       ODP_TEST_INFO(packet_test_extend_ref),
        ODP_TEST_INFO(packet_test_align),
        ODP_TEST_INFO(packet_test_offset),
+       ODP_TEST_INFO(packet_test_ref),
        ODP_TEST_INFO_NULL,
 };
 
diff --git a/test/common_plat/validation/api/packet/packet.h 
b/test/common_plat/validation/api/packet/packet.h
index 9bc3d63..783b7a1 100644
--- a/test/common_plat/validation/api/packet/packet.h
+++ b/test/common_plat/validation/api/packet/packet.h
@@ -35,8 +35,10 @@ void packet_test_concat_extend_trunc(void);
 void packet_test_extend_small(void);
 void packet_test_extend_large(void);
 void packet_test_extend_mix(void);
+void packet_test_extend_ref(void);
 void packet_test_align(void);
 void packet_test_offset(void);
+void packet_test_ref(void);
 
 /* test arrays: */
 extern odp_testinfo_t packet_suite[];
-- 
2.7.4

Reply via email to