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

Message ID 1515772811-30441-6-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series
  • User pointer init to NULL
Related show

Commit Message

Github ODP bot Jan. 12, 2018, 4 p.m.
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: 9eaabe631329dd5cc41960f7cfb5592d60ff0499
 **/
 test/validation/api/packet/packet.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch

diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 75e50d531..3b80e9919 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,12 @@  void packet_test_context(void)
 	CU_ASSERT(memcmp(udat, &test_packet_udata, sizeof(struct udata_struct))
 		  == 0);
 
+	odp_packet_user_ptr_set(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)