diff mbox series

[v2,4/11] validation: packet: check reference packet content

Message ID 1505221212-27163-5-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v2,1/11] linux-gen: packet: roll back to copy based references | expand

Commit Message

Github ODP bot Sept. 12, 2017, 1 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Check that reference and base packets contain the same data.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 170 (psavol:master-packet-ref-rework)
 ** https://github.com/Linaro/odp/pull/170
 ** Patch: https://github.com/Linaro/odp/pull/170.patch
 ** Base sha: fb3f36cec108ce9c55241d9f0e66d4832a552b8a
 ** Merge commit sha: bab9e010b5432ba0f2ff0651313a85a6a1b563c2
 **/
 test/common_plat/validation/api/packet/packet.c | 99 ++++++++++++++++++++++++-
 1 file changed, 96 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c
index c40dab98..ffcdc3fc 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -2072,14 +2072,107 @@  void packet_test_ref(void)
 {
 	odp_packet_t base_pkt, segmented_base_pkt, hdr_pkt[4],
 		ref_pkt[4], refhdr_pkt[4], hdr_cpy;
+	odp_packet_t pkt, pkt2, pkt3, ref, ref2;
 	uint32_t pkt_len, segmented_pkt_len, hdr_len[4], offset[4], hr[4],
 		base_hr, ref_len[4];
-	int i;
+	int i, ret;
+	odp_pool_t pool;
+
+	/* Create references and compare data */
+	pool = odp_packet_pool(test_packet);
+
+	pkt = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)
+	ref = odp_packet_ref_static(pkt);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	packet_compare_data(pkt, ref);
+	odp_packet_free(ref);
+	odp_packet_free(pkt);
+
+	pkt = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)
+	ref = odp_packet_ref(pkt, 0);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	packet_compare_data(pkt, ref);
+	odp_packet_free(ref);
+	odp_packet_free(pkt);
+
+	pkt  = odp_packet_copy(test_packet, pool);
+	pkt3 = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt  != ODP_PACKET_INVALID)
+	CU_ASSERT_FATAL(pkt3 != ODP_PACKET_INVALID)
+	ret = odp_packet_concat(&pkt3, pkt);
+	CU_ASSERT_FATAL(ret >= 0);
+
+	pkt  = odp_packet_copy(test_packet, pool);
+	pkt2 = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt  != ODP_PACKET_INVALID)
+	CU_ASSERT_FATAL(pkt2 != ODP_PACKET_INVALID)
+	ref = odp_packet_ref_pkt(pkt, 0, pkt2);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	packet_compare_data(pkt3, ref);
+	odp_packet_free(ref);
+	odp_packet_free(pkt);
+	odp_packet_free(pkt3);
+
+	/* Do the same for segmented packets */
+	pool = odp_packet_pool(segmented_test_packet);
+
+	pkt = odp_packet_copy(segmented_test_packet, pool);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)
+	ref = odp_packet_ref_static(pkt);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	packet_compare_data(pkt, ref);
+	odp_packet_free(ref);
+	odp_packet_free(pkt);
+
+	pkt = odp_packet_copy(segmented_test_packet, pool);
+	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)
+	ref = odp_packet_ref(pkt, 0);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	packet_compare_data(pkt, ref);
+	odp_packet_free(ref);
+	odp_packet_free(pkt);
+
+	/* Avoid to create too large packets with concat */
+	pool = odp_packet_pool(test_packet);
+
+	pkt  = odp_packet_copy(test_packet, pool);
+	pkt2 = odp_packet_copy(test_packet, pool);
+	pkt3 = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt  != ODP_PACKET_INVALID)
+	CU_ASSERT_FATAL(pkt2 != ODP_PACKET_INVALID)
+	CU_ASSERT_FATAL(pkt3 != ODP_PACKET_INVALID)
+	ret = odp_packet_concat(&pkt3, pkt2);
+	CU_ASSERT_FATAL(ret >= 0);
+	ret = odp_packet_concat(&pkt3, pkt);
+	CU_ASSERT_FATAL(ret >= 0);
+
+	pkt  = odp_packet_copy(test_packet, pool);
+	pkt2 = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt  != ODP_PACKET_INVALID)
+	CU_ASSERT_FATAL(pkt2 != ODP_PACKET_INVALID)
+	ref = odp_packet_ref_pkt(pkt, 0, pkt2);
+	CU_ASSERT_FATAL(ref != ODP_PACKET_INVALID)
+	pkt2 = odp_packet_copy(test_packet, pool);
+	CU_ASSERT_FATAL(pkt2 != ODP_PACKET_INVALID)
+	ref2 = odp_packet_ref_pkt(ref, 0, pkt2);
+	CU_ASSERT_FATAL(ref2 != ODP_PACKET_INVALID)
+	packet_compare_data(pkt3, ref2);
+
+	/* Try print function on a reference */
+	odp_packet_print(ref2);
+
+	odp_packet_free(ref);
+	odp_packet_free(ref2);
+	odp_packet_free(pkt);
+	odp_packet_free(pkt3);
 
+	/* Test has_ref, unshared_len, lengths, etc */
 	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);
+	base_hr = odp_packet_headroom(base_pkt);
+	pkt_len = odp_packet_len(test_packet);
 
 	segmented_base_pkt =
 		odp_packet_copy(segmented_test_packet,