diff mbox series

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

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

Commit Message

Github ODP bot Jan. 23, 2018, 9 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: 4508f410a04cf1657d607d24aa2530a42ef011f7
 ** Merge commit sha: 3781732a78e4a3f0347b6b4299e9753da3929a42
 **/
 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 184473aba..7d19e0125 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)