diff mbox

validation: strongtypes: add unit tests for strong type display functions

Message ID 1423267633-15604-1-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Feb. 7, 2015, 12:07 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---

Intial version tests all display functions except odp_crypto_compl_to_u64()
as there does not appear to an architected way to create one of these
objects.

 test/validation/.gitignore    |   1 +
 test/validation/Makefile.am   |   3 +-
 test/validation/strongtypes.c | 110 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 test/validation/strongtypes.c
diff mbox

Patch

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 197b094..62000e1 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -13,4 +13,5 @@  odp_pktio
 odp_buffer
 odp_timer
 odp_time
+odp_strongtypes
 odp_synchronizers
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index f9d7d7a..5e6a44e 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -11,7 +11,7 @@  endif
 
 dist_bin_SCRIPTS = $(srcdir)/odp_pktio_run
 
-bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
+bin_PROGRAMS = odp_init odp_init_abort odp_init_log odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification odp_strongtypes
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
 odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification
@@ -38,3 +38,4 @@  dist_odp_synchronizers_SOURCES = odp_synchronizers.c \
 dist_odp_classification_SOURCES = classification/odp_classification_tests.c \
 				classification/odp_classification_basic.c \
 				odp_classification.c common/odp_cunit_common.c
+dist_odp_strongtypes_SOURCES = strongtypes.c
diff --git a/test/validation/strongtypes.c b/test/validation/strongtypes.c
new file mode 100644
index 0000000..6dc3976
--- /dev/null
+++ b/test/validation/strongtypes.c
@@ -0,0 +1,110 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <CUnit/Basic.h>
+
+static void test_odp_strong_types(void)
+{
+	odp_buffer_t buf = ODP_BUFFER_INVALID;
+	odp_cos_t cos = ODP_COS_INVALID;
+	odp_pmr_t pmr = ODP_PMR_INVAL;
+	odp_pmr_set_t pmrset = ODP_PMR_SET_INVAL;
+	odp_crypto_session_t csession = ODP_CRYPTO_SESSION_INVALID;
+	/* odp_crypto_compl_t ccompl; */
+	odp_event_t evt = ODP_EVENT_INVALID;
+	odp_pktio_t pktio = ODP_PKTIO_INVALID;
+	odp_packet_t pkt = ODP_PACKET_INVALID;
+	odp_packet_seg_t pktseg = ODP_PACKET_SEG_INVALID;
+	odp_pool_t pool = ODP_POOL_INVALID;
+	odp_queue_t queue = ODP_QUEUE_INVALID;
+	odp_shm_t shm = ODP_SHM_INVALID;
+
+       /*
+	* Note: These type conversion functions have no defined return values
+	* since they produce implementation-defined values for display
+	* purposes. This test simply verifies that they exist and can be
+	* invoked.
+	*/
+
+	CU_ASSERT(odp_buffer_to_u64(buf) ==
+		  odp_buffer_to_u64(ODP_BUFFER_INVALID));
+
+	CU_ASSERT(odp_cos_to_u64(cos) ==
+		  odp_cos_to_u64(ODP_COS_INVALID));
+
+	CU_ASSERT(odp_pmr_to_u64(pmr) ==
+		  odp_pmr_to_u64(ODP_PMR_INVAL));
+
+	CU_ASSERT(odp_pmr_set_to_u64(pmrset) ==
+		  odp_pmr_set_to_u64(ODP_PMR_SET_INVAL));
+
+	CU_ASSERT(odp_crypto_session_to_u64(csession) ==
+		  odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID));
+
+	/*
+	CU_ASSERT(odp_crypto_compl_to_u64(ccompl) ==
+		  odp_crypto_compl_to_u64(ccompl));
+	*/
+
+	CU_ASSERT(odp_event_to_u64(evt) ==
+		  odp_event_to_u64(ODP_EVENT_INVALID));
+
+	CU_ASSERT(odp_pktio_to_u64(pktio) ==
+		  odp_pktio_to_u64(ODP_PKTIO_INVALID));
+
+	CU_ASSERT(odp_packet_to_u64(pkt) ==
+		  odp_packet_to_u64(ODP_PACKET_INVALID));
+
+	CU_ASSERT(odp_packet_seg_to_u64(pktseg) ==
+		  odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
+
+	CU_ASSERT(odp_pool_to_u64(pool) ==
+		  odp_pool_to_u64(ODP_POOL_INVALID));
+
+	CU_ASSERT(odp_queue_to_u64(queue) ==
+		  odp_queue_to_u64(ODP_QUEUE_INVALID));
+
+	CU_ASSERT(odp_shm_to_u64(shm) ==
+		  odp_shm_to_u64(ODP_SHM_INVALID));
+}
+
+CU_TestInfo test_odp_type_display[] = {
+	{"ODP abstract type diplay test", test_odp_strong_types},
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+	{ "ODP abstract type display functions",
+	  NULL, NULL, NULL, NULL,
+	  test_odp_type_display,
+	},
+	CU_SUITE_INFO_NULL,
+};
+
+int main(void)
+{
+	int ret;
+
+	printf("\tODP API version: %s\n", odp_version_api_str());
+	printf("\tODP implementation version: %s\n", odp_version_impl_str());
+
+	/* odp_init_global(NULL, NULL); */
+	/* odp_init_local(); */
+
+	CU_set_error_action(CUEA_ABORT);
+
+	CU_initialize_registry();
+	CU_register_suites(odp_testsuites);
+	CU_basic_set_mode(CU_BRM_VERBOSE);
+	CU_basic_run_tests();
+
+	ret = CU_get_number_of_failure_records();
+
+	CU_cleanup_registry();
+
+	return ret;
+}