diff mbox

[v2,5/5] validation: init: add test for replace abort

Message ID 1422963328-31760-6-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 2ec4dfdf0aaf39d89d0f2d73b0ed2d6aa44f479b
Headers show

Commit Message

Mike Holmes Feb. 3, 2015, 11:35 a.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 test/validation/.gitignore       |  1 +
 test/validation/Makefile.am      |  5 ++--
 test/validation/odp_init_abort.c | 62 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 2 deletions(-)
 create mode 100644 test/validation/odp_init_abort.c
diff mbox

Patch

diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 4a1ccb4..242e576 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -1,6 +1,7 @@ 
 *.log
 *.trs
 odp_init
+odp_init_abort
 odp_queue
 odp_crypto
 odp_classification
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 703d9b6..a57be1a 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,17 +6,18 @@  AM_LDFLAGS += -static
 TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
 
 if test_vald
-TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
+TESTS = odp_init odp_init_abort odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
 endif
 
 dist_bin_SCRIPTS = $(srcdir)/odp_pktio_run
 
-bin_PROGRAMS = odp_init 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_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_timer odp_time odp_synchronizers odp_classification
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
 odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification
 
 dist_odp_init_SOURCES = odp_init.c
+dist_odp_init_abort_SOURCES = odp_init_abort.c
 dist_odp_pktio_SOURCES = odp_pktio.c common/odp_cunit_common.c
 dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
diff --git a/test/validation/odp_init_abort.c b/test/validation/odp_init_abort.c
new file mode 100644
index 0000000..c291146
--- /dev/null
+++ b/test/validation/odp_init_abort.c
@@ -0,0 +1,62 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <stdarg.h>
+#include <odp.h>
+#include <CUnit/Basic.h>
+
+static void odp_init_abort(void) ODP_NORETURN;
+
+static void test_odp_init_global_replace_abort(void)
+{
+	int status;
+	struct odp_init_t init_data;
+
+	memset(&init_data, 0, sizeof(init_data));
+	init_data.abort_fn = &odp_init_abort;
+
+	status = odp_init_global(&init_data, NULL);
+	CU_ASSERT_FATAL(status == 0);
+
+	status = odp_term_global();
+	CU_ASSERT(status == 0);
+}
+
+CU_TestInfo test_odp_init[] = {
+	{"replace abort",  test_odp_init_global_replace_abort},
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+	{"Init", NULL, NULL, NULL, NULL, test_odp_init},
+	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());
+
+	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;
+}
+
+void odp_init_abort(void)
+{
+	abort();
+}