diff mbox series

[API-NEXT,v2,6/6] validation: packet: test user pointer init to NULL

Message ID 1516021209-8997-7-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v2,1/6] linux-gen: packet: single user ptr field | expand

Commit Message

Github ODP bot Jan. 15, 2018, 1 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Test if user pointer is NULL after alloc and reset.

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

---
/** Email created from pull request 388 (psavol:next-user-ptr-init)
 ** https://github.com/Linaro/odp/pull/388
 ** Patch: https://github.com/Linaro/odp/pull/388.patch
 ** Base sha: 6303c7d0e98fafe0f14c8c4dd9989b3b7633ebf4
 ** Merge commit sha: 76bd874ba5677533132a4c0a39c8e5cf9049a9af
 **/
 test/validation/api/packet/packet.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 75e50d531..e63bd74e5 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -290,6 +290,9 @@  void packet_test_alloc_free(void)
 	CU_ASSERT(odp_packet_to_u64(packet) !=
 		  odp_packet_to_u64(ODP_PACKET_INVALID));
 
+	/* User pointer should be NULL after alloc */
+	CU_ASSERT(odp_packet_user_ptr(packet) == NULL);
+
 	/* Pool should have only one packet */
 	CU_ASSERT_FATAL(odp_packet_alloc(pool, packet_len)
 			== ODP_PACKET_INVALID);
@@ -369,6 +372,9 @@  void packet_test_alloc_free_multi(void)
 		CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC);
 		CU_ASSERT(odp_packet_to_u64(packet[i]) !=
 			  odp_packet_to_u64(ODP_PACKET_INVALID));
+
+		/* User pointer should be NULL after alloc */
+		CU_ASSERT(odp_packet_user_ptr(packet[i]) == NULL);
 	}
 
 	/* Pools should have no more packets */
@@ -648,7 +654,15 @@  void packet_test_context(void)
 	CU_ASSERT(memcmp(udat, &test_packet_udata, sizeof(struct udata_struct))
 		  == 0);
 
+	odp_packet_user_ptr_set(pkt, NULL);
+	CU_ASSERT(odp_packet_user_ptr(pkt) == NULL);
+	odp_packet_user_ptr_set(pkt, (void *)0xdead);
+	CU_ASSERT(odp_packet_user_ptr(pkt) == (void *)0xdead);
+
 	odp_packet_reset(pkt, packet_len);
+
+	/* User pointer should be NULL after reset */
+	CU_ASSERT(odp_packet_user_ptr(pkt) == NULL);
 }
 
 void packet_test_layer_offsets(void)