diff mbox series

[API-NEXT,v2,2/2] validation: test correctness of events subtype implementation

Message ID 20170616091235.2394-3-dmitry.ereminsolenikov@linaro.org
State New
Headers show
Series event subtype implementation | expand

Commit Message

Dmitry Eremin-Solenikov June 16, 2017, 9:12 a.m. UTC
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
 test/common_plat/validation/api/buffer/buffer.c | 37 +++++++++++++++----------
 test/common_plat/validation/api/packet/packet.c |  5 ++++
 test/common_plat/validation/api/timer/timer.c   | 14 ++++++++--
 3 files changed, 39 insertions(+), 17 deletions(-)

-- 
2.11.0
diff mbox series

Patch

diff --git a/test/common_plat/validation/api/buffer/buffer.c b/test/common_plat/validation/api/buffer/buffer.c
index 7c723d4f4df4..8fca8a1f0840 100644
--- a/test/common_plat/validation/api/buffer/buffer.c
+++ b/test/common_plat/validation/api/buffer/buffer.c
@@ -48,7 +48,8 @@  void buffer_test_pool_alloc(void)
 	odp_buffer_t buffer[num];
 	odp_event_t ev;
 	int index;
-	char wrong_type = 0, wrong_size = 0, wrong_align = 0;
+	odp_bool_t wrong_type = false, wrong_subtype = false;
+	odp_bool_t wrong_size = false, wrong_align = false;
 	odp_pool_param_t params;
 
 	odp_pool_param_init(&params);
@@ -71,14 +72,16 @@  void buffer_test_pool_alloc(void)
 
 		ev = odp_buffer_to_event(buffer[index]);
 		if (odp_event_type(ev) != ODP_EVENT_BUFFER)
-			wrong_type = 1;
+			wrong_type = true;
+		if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE)
+			wrong_subtype = true;
 		if (odp_buffer_size(buffer[index]) < BUF_SIZE)
-			wrong_size = 1;
+			wrong_size = true;
 
 		addr = (uintptr_t)odp_buffer_addr(buffer[index]);
 
 		if ((addr % BUF_ALIGN) != 0)
-			wrong_align = 1;
+			wrong_align = true;
 
 		if (wrong_type || wrong_size || wrong_align)
 			odp_buffer_print(buffer[index]);
@@ -90,9 +93,10 @@  void buffer_test_pool_alloc(void)
 	index--;
 
 	/* Check that the pool had correct buffers */
-	CU_ASSERT(wrong_type == 0);
-	CU_ASSERT(wrong_size == 0);
-	CU_ASSERT(wrong_align == 0);
+	CU_ASSERT(!wrong_type);
+	CU_ASSERT(!wrong_subtype);
+	CU_ASSERT(!wrong_size);
+	CU_ASSERT(!wrong_align);
 
 	for (; index >= 0; index--)
 		odp_buffer_free(buffer[index]);
@@ -123,7 +127,8 @@  void buffer_test_pool_alloc_multi(void)
 	odp_buffer_t buffer[num + 1];
 	odp_event_t ev;
 	int index;
-	char wrong_type = 0, wrong_size = 0, wrong_align = 0;
+	odp_bool_t wrong_type = false, wrong_subtype = false;
+	odp_bool_t wrong_size = false, wrong_align = false;
 	odp_pool_param_t params;
 
 	odp_pool_param_init(&params);
@@ -146,14 +151,16 @@  void buffer_test_pool_alloc_multi(void)
 
 		ev = odp_buffer_to_event(buffer[index]);
 		if (odp_event_type(ev) != ODP_EVENT_BUFFER)
-			wrong_type = 1;
+			wrong_type = true;
+		if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE)
+			wrong_subtype = true;
 		if (odp_buffer_size(buffer[index]) < BUF_SIZE)
-			wrong_size = 1;
+			wrong_size = true;
 
 		addr = (uintptr_t)odp_buffer_addr(buffer[index]);
 
 		if ((addr % BUF_ALIGN) != 0)
-			wrong_align = 1;
+			wrong_align = true;
 
 		if (wrong_type || wrong_size || wrong_align)
 			odp_buffer_print(buffer[index]);
@@ -163,9 +170,10 @@  void buffer_test_pool_alloc_multi(void)
 	CU_ASSERT(index == num);
 
 	/* Check that the pool had correct buffers */
-	CU_ASSERT(wrong_type == 0);
-	CU_ASSERT(wrong_size == 0);
-	CU_ASSERT(wrong_align == 0);
+	CU_ASSERT(!wrong_type);
+	CU_ASSERT(!wrong_subtype);
+	CU_ASSERT(!wrong_size);
+	CU_ASSERT(!wrong_align);
 
 	odp_buffer_free_multi(buffer, num);
 
@@ -248,6 +256,7 @@  void buffer_test_management_basic(void)
 	CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1);
 	CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_POOL_INVALID);
 	CU_ASSERT(odp_event_type(ev) == ODP_EVENT_BUFFER);
+	CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_NO_SUBTYPE);
 	CU_ASSERT(odp_buffer_size(raw_buffer) >= BUF_SIZE);
 	CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL);
 	odp_buffer_print(raw_buffer);
diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c
index 284aaeb5ae56..3d55eff7479f 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -260,6 +260,8 @@  void packet_test_alloc_free(void)
 	CU_ASSERT(odp_packet_len(packet) == packet_len);
 	CU_ASSERT(odp_event_type(odp_packet_to_event(packet)) ==
 			ODP_EVENT_PACKET);
+	CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
+		  ODP_EVENT_PACKET_BASIC);
 	CU_ASSERT(odp_packet_to_u64(packet) !=
 		  odp_packet_to_u64(ODP_PACKET_INVALID));
 
@@ -332,6 +334,8 @@  void packet_test_alloc_free_multi(void)
 		CU_ASSERT(odp_packet_len(packet[i]) == packet_len);
 		CU_ASSERT(odp_event_type(odp_packet_to_event(packet[i])) ==
 			  ODP_EVENT_PACKET);
+		CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet[i])) ==
+			  ODP_EVENT_PACKET_BASIC);
 		CU_ASSERT(odp_packet_to_u64(packet[i]) !=
 			  odp_packet_to_u64(ODP_PACKET_INVALID));
 	}
@@ -453,6 +457,7 @@  void packet_test_event_conversion(void)
 	ev = odp_packet_to_event(pkt);
 	CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID);
 	CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET);
+	CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC);
 
 	tmp_pkt = odp_packet_from_event(ev);
 	CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID);
diff --git a/test/common_plat/validation/api/timer/timer.c b/test/common_plat/validation/api/timer/timer.c
index b7d84c64930e..a09f4d73f09f 100644
--- a/test/common_plat/validation/api/timer/timer.c
+++ b/test/common_plat/validation/api/timer/timer.c
@@ -59,7 +59,7 @@  void timer_test_timeout_pool_alloc(void)
 	odp_timeout_t tmo[num];
 	odp_event_t ev;
 	int index;
-	char wrong_type = 0;
+	odp_bool_t wrong_type = false, wrong_subtype = false;
 	odp_pool_param_t params;
 
 	odp_pool_param_init(&params);
@@ -80,7 +80,9 @@  void timer_test_timeout_pool_alloc(void)
 
 		ev = odp_timeout_to_event(tmo[index]);
 		if (odp_event_type(ev) != ODP_EVENT_TIMEOUT)
-			wrong_type = 1;
+			wrong_type = true;
+		if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE)
+			wrong_subtype = true;
 	}
 
 	/* Check that the pool had at least num items */
@@ -89,7 +91,8 @@  void timer_test_timeout_pool_alloc(void)
 	index--;
 
 	/* Check that the pool had correct buffers */
-	CU_ASSERT(wrong_type == 0);
+	CU_ASSERT(!wrong_type);
+	CU_ASSERT(!wrong_subtype);
 
 	for (; index >= 0; index--)
 		odp_timeout_free(tmo[index]);
@@ -225,6 +228,11 @@  static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
 		CU_FAIL("Unexpected event type received");
 		return;
 	}
+	if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) {
+		/* Not a timeout event */
+		CU_FAIL("Unexpected event subtype received");
+		return;
+	}
 	/* Read the metadata from the timeout */
 	odp_timeout_t tmo = odp_timeout_from_event(ev);
 	odp_timer_t tim = odp_timeout_timer(tmo);