diff mbox series

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

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

Commit Message

Github ODP bot Jan. 16, 2018, 11 a.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 392 (psavol:next-user-ptr-init-rebase)
 ** https://github.com/Linaro/odp/pull/392
 ** Patch: https://github.com/Linaro/odp/pull/392.patch
 ** Base sha: f6dab2bfa90ef5d3146cb76f86bc8782666f0f3e
 ** Merge commit sha: 7244f46bcf5e4a0fce4048e306f224f31e9a4d2f
 **/
 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)