diff mbox series

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

Message ID 20170704125403.9212-3-dmitry.ereminsolenikov@linaro.org
State Accepted
Commit 250a492789120f128cb3004a8dacfb7b9d1cf99c
Headers show
Series event subtype implementation | expand

Commit Message

Dmitry Eremin-Solenikov July 4, 2017, 12:54 p.m. UTC
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
 test/common_plat/validation/api/buffer/buffer.c    | 50 ++++++++++++++++------
 .../validation/api/crypto/odp_crypto_test_inp.c    | 14 ++++++
 test/common_plat/validation/api/packet/packet.c    | 21 ++++++++-
 test/common_plat/validation/api/timer/timer.c      | 32 ++++++++++++--
 4 files changed, 99 insertions(+), 18 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..66d00ab71d9a 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);
@@ -63,6 +64,7 @@  void buffer_test_pool_alloc(void)
 	/* Try to allocate num items from the pool */
 	for (index = 0; index < num; index++) {
 		uintptr_t addr;
+		odp_event_subtype_t subtype;
 
 		buffer[index] = odp_buffer_alloc(pool);
 
@@ -71,14 +73,20 @@  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_event_types(ev, &subtype) != ODP_EVENT_BUFFER)
+			wrong_type = true;
+		if (subtype != 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 +98,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 +132,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);
@@ -140,20 +150,27 @@  void buffer_test_pool_alloc_multi(void)
 
 	for (index = 0; index < num; index++) {
 		uintptr_t addr;
+		odp_event_subtype_t subtype;
 
 		if (buffer[index] == ODP_BUFFER_INVALID)
 			break;
 
 		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_event_types(ev, &subtype) != ODP_EVENT_BUFFER)
+			wrong_type = true;
+		if (subtype != 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 +180,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);
 
@@ -244,10 +262,14 @@  void buffer_test_pool_free_multi(void)
 void buffer_test_management_basic(void)
 {
 	odp_event_t ev = odp_buffer_to_event(raw_buffer);
+	odp_event_subtype_t subtype;
 
 	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_event_types(ev, &subtype) == ODP_EVENT_BUFFER);
+	CU_ASSERT(subtype == 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/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index ae600e230118..1d7d49a23c17 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -103,6 +103,7 @@  static void alg_test(odp_crypto_op_t op,
 	odp_crypto_auth_capability_t   auth_capa[MAX_ALG_CAPA];
 	int num, i;
 	int found;
+	odp_event_subtype_t subtype;
 
 	rc = odp_crypto_capability(&capa);
 	CU_ASSERT(!rc);
@@ -263,6 +264,12 @@  static void alg_test(odp_crypto_op_t op,
 			event = odp_queue_deq(suite_context.queue);
 		} while (event == ODP_EVENT_INVALID);
 
+		CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == odp_event_type(event));
+		CU_ASSERT(ODP_EVENT_NO_SUBTYPE == odp_event_subtype(event));
+		CU_ASSERT(ODP_EVENT_CRYPTO_COMPL ==
+			  odp_event_types(event, &subtype));
+		CU_ASSERT(ODP_EVENT_NO_SUBTYPE == subtype);
+
 		compl_event = odp_crypto_compl_from_event(event);
 		CU_ASSERT(odp_crypto_compl_to_u64(compl_event) ==
 			  odp_crypto_compl_to_u64(odp_crypto_compl_from_event(event)));
@@ -272,6 +279,13 @@  static void alg_test(odp_crypto_op_t op,
 
 	CU_ASSERT(result.pkt == pkt);
 	CU_ASSERT(result.ctx == (void *)0xdeadbeef);
+	CU_ASSERT(ODP_EVENT_PACKET ==
+		  odp_event_type(odp_packet_to_event(result.pkt)));
+	CU_ASSERT(ODP_EVENT_PACKET_BASIC ==
+		  odp_event_subtype(odp_packet_to_event(result.pkt)));
+	CU_ASSERT(ODP_EVENT_PACKET ==
+		  odp_event_types(odp_packet_to_event(result.pkt), &subtype));
+	CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype);
 
 	if (should_fail) {
 		CU_ASSERT(!result.ok);
diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c
index 284aaeb5ae56..fa6f4afd9d6d 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -241,6 +241,7 @@  void packet_test_alloc_free(void)
 	odp_packet_t packet;
 	odp_pool_param_t params;
 	odp_pool_capability_t capa;
+	odp_event_subtype_t subtype;
 
 	CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
 
@@ -259,7 +260,12 @@  void packet_test_alloc_free(void)
 	CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID);
 	CU_ASSERT(odp_packet_len(packet) == packet_len);
 	CU_ASSERT(odp_event_type(odp_packet_to_event(packet)) ==
-			ODP_EVENT_PACKET);
+		  ODP_EVENT_PACKET);
+	CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) ==
+		  ODP_EVENT_PACKET_BASIC);
+	CU_ASSERT(odp_event_types(odp_packet_to_event(packet), &subtype) ==
+		  ODP_EVENT_PACKET);
+	CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC);
 	CU_ASSERT(odp_packet_to_u64(packet) !=
 		  odp_packet_to_u64(ODP_PACKET_INVALID));
 
@@ -329,9 +335,17 @@  void packet_test_alloc_free_multi(void)
 	CU_ASSERT_FATAL(ret == num_pkt);
 
 	for (i = 0; i < 2 * num_pkt; ++i) {
+		odp_event_subtype_t subtype;
+
 		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_event_types(odp_packet_to_event(packet[i]),
+					  &subtype) ==
+			  ODP_EVENT_PACKET);
+		CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC);
 		CU_ASSERT(odp_packet_to_u64(packet[i]) !=
 			  odp_packet_to_u64(ODP_PACKET_INVALID));
 	}
@@ -449,10 +463,15 @@  void packet_test_event_conversion(void)
 	odp_packet_t pkt = test_packet;
 	odp_packet_t tmp_pkt;
 	odp_event_t ev;
+	odp_event_subtype_t subtype;
 
 	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);
+	CU_ASSERT(odp_event_types(ev, &subtype) ==
+		  ODP_EVENT_PACKET);
+	CU_ASSERT(subtype == 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..881351602c12 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);
@@ -73,6 +73,8 @@  void timer_test_timeout_pool_alloc(void)
 
 	/* Try to allocate num items from the pool */
 	for (index = 0; index < num; index++) {
+		odp_event_subtype_t subtype;
+
 		tmo[index] = odp_timeout_alloc(pool);
 
 		if (tmo[index] == ODP_TIMEOUT_INVALID)
@@ -80,7 +82,13 @@  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;
+		if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT)
+			wrong_type = true;
+		if (subtype != ODP_EVENT_NO_SUBTYPE)
+			wrong_subtype = true;
 	}
 
 	/* Check that the pool had at least num items */
@@ -89,7 +97,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]);
@@ -219,12 +228,29 @@  void timer_test_odp_timer_cancel(void)
 /* @private Handle a received (timeout) event */
 static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
 {
+	odp_event_subtype_t subtype;
+
 	CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */
 	if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) {
 		/* Not a timeout event */
 		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;
+	}
+	if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT) {
+		/* Not a timeout event */
+		CU_FAIL("Unexpected event type received");
+		return;
+	}
+	if (subtype != 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);