diff mbox series

[v12,2/2] validation: init: remove "library" file

Message ID 1519826413-28417-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v12,1/2] example: generator: move script back to example directory | expand

Commit Message

Github ODP bot Feb. 28, 2018, 2 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Split init.c/init.h files into individual tests, simplifying setup.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 496 (lumag:tests-fix-2)
 ** https://github.com/Linaro/odp/pull/496
 ** Patch: https://github.com/Linaro/odp/pull/496.patch
 ** Base sha: f5e12df388352b27f09787028a0040afb28564f4
 ** Merge commit sha: 15eadb7d8c8d6d10d976c1f7c67d847e9be8301a
 **/
 test/validation/api/init/Makefile.am       |   6 +-
 test/validation/api/init/init.c            | 190 -----------------------------
 test/validation/api/init/init.h            |  32 -----
 test/validation/api/init/init_main_abort.c |  55 ++++++++-
 test/validation/api/init/init_main_log.c   |  75 +++++++++++-
 test/validation/api/init/init_main_ok.c    |  45 ++++++-
 6 files changed, 172 insertions(+), 231 deletions(-)
 delete mode 100644 test/validation/api/init/init.c
 delete mode 100644 test/validation/api/init/init.h
diff mbox series

Patch

diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am
index 2d0661431..5af2e00bc 100644
--- a/test/validation/api/init/Makefile.am
+++ b/test/validation/api/init/Makefile.am
@@ -4,6 +4,6 @@  include ../Makefile.inc
 # following each other: therefore 3 separate binaries are
 # created, each containing its ODP init test.
 test_PROGRAMS = init_main_abort init_main_log init_main_ok
-init_main_abort_SOURCES = init_main_abort.c init.c init.h
-init_main_log_SOURCES   = init_main_log.c init.c init.h
-init_main_ok_SOURCES    = init_main_ok.c init.c init.h
+init_main_abort_SOURCES = init_main_abort.c
+init_main_log_SOURCES   = init_main_log.c
+init_main_ok_SOURCES    = init_main_ok.c
diff --git a/test/validation/api/init/init.c b/test/validation/api/init/init.c
deleted file mode 100644
index 39023bd65..000000000
--- a/test/validation/api/init/init.c
+++ /dev/null
@@ -1,190 +0,0 @@ 
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#include "config.h"
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <odp_api.h>
-#include <CUnit/Basic.h>
-#include "init.h"
-
-/* flag set when the replacement logging function is used */
-int replacement_logging_used;
-
-/* replacement abort function: */
-static void odp_init_abort(void) ODP_NORETURN;
-
-/* replacement log function: */
-ODP_PRINTF_FORMAT(2, 3)
-static int odp_init_log(odp_log_level_t level, const char *fmt, ...);
-
-/* test ODP global init, with alternate abort function */
-void init_test_odp_init_global_replace_abort(void)
-{
-	int status;
-	odp_init_t init_data;
-	odp_instance_t instance;
-
-	odp_init_param_init(&init_data);
-	init_data.abort_fn = &odp_init_abort;
-
-	status = odp_init_global(&instance, &init_data, NULL);
-	CU_ASSERT_FATAL(status == 0);
-
-	status = odp_term_global(instance);
-	CU_ASSERT(status == 0);
-}
-
-odp_testinfo_t init_suite_abort[] = {
-	ODP_TEST_INFO(init_test_odp_init_global_replace_abort),
-	ODP_TEST_INFO_NULL,
-};
-
-odp_suiteinfo_t init_suites_abort[] = {
-	{"Init", NULL, NULL, init_suite_abort},
-	ODP_SUITE_INFO_NULL,
-};
-
-static void odp_init_abort(void)
-{
-	abort();
-}
-
-int init_main_abort(int argc, char *argv[])
-{
-	int ret;
-
-	/* parse common options: */
-	if (odp_cunit_parse_options(argc, argv))
-		return -1;
-
-	/* prevent default ODP init: */
-	odp_cunit_register_global_init(NULL);
-	odp_cunit_register_global_term(NULL);
-
-	/* run the tests: */
-	ret = odp_cunit_register(init_suites_abort);
-
-	if (ret == 0)
-		ret = odp_cunit_run();
-
-	return ret;
-}
-
-/* test ODP global init, with alternate log function */
-void init_test_odp_init_global_replace_log(void)
-{
-	int status;
-	odp_init_t init_data;
-	odp_instance_t instance;
-
-	odp_init_param_init(&init_data);
-	init_data.log_fn = &odp_init_log;
-
-	replacement_logging_used = 0;
-
-	status = odp_init_global(&instance, &init_data, NULL);
-	CU_ASSERT_FATAL(status == 0);
-
-	CU_ASSERT_TRUE(replacement_logging_used || ODP_DEBUG_PRINT == 0);
-
-	status = odp_term_global(instance);
-	CU_ASSERT(status == 0);
-}
-
-odp_testinfo_t init_suite_log[] = {
-	ODP_TEST_INFO(init_test_odp_init_global_replace_log),
-	ODP_TEST_INFO_NULL,
-};
-
-odp_suiteinfo_t init_suites_log[] = {
-	{"Init", NULL, NULL, init_suite_log},
-	ODP_SUITE_INFO_NULL,
-};
-
-static int odp_init_log(odp_log_level_t level __attribute__((unused)),
-			const char *fmt, ...)
-{
-	va_list args;
-	int r;
-
-	/* just set a flag to be sure the replacement fn was used */
-	replacement_logging_used = 1;
-
-	va_start(args, fmt);
-	r = vfprintf(stderr, fmt, args);
-	va_end(args);
-
-	return r;
-}
-
-int init_main_log(int argc, char *argv[])
-{
-	int ret;
-
-	/* parse common options: */
-	if (odp_cunit_parse_options(argc, argv))
-		return -1;
-
-	/* prevent default ODP init: */
-	odp_cunit_register_global_init(NULL);
-	odp_cunit_register_global_term(NULL);
-
-	/* register the tests: */
-	ret = odp_cunit_register(init_suites_log);
-
-	/* run the tests: */
-	if (ret == 0)
-		ret = odp_cunit_run();
-
-	return ret;
-}
-
-/* test normal ODP global init */
-void init_test_odp_init_global(void)
-{
-	int status;
-	odp_instance_t instance;
-
-	status = odp_init_global(&instance, NULL, NULL);
-	CU_ASSERT_FATAL(status == 0);
-
-	status = odp_term_global(instance);
-	CU_ASSERT(status == 0);
-}
-
-odp_testinfo_t init_suite_ok[] = {
-	ODP_TEST_INFO(init_test_odp_init_global),
-	ODP_TEST_INFO_NULL,
-};
-
-odp_suiteinfo_t init_suites_ok[] = {
-	{"Init", NULL, NULL, init_suite_ok},
-	ODP_SUITE_INFO_NULL,
-};
-
-int init_main_ok(int argc, char *argv[])
-{
-	int ret;
-
-	/* parse common options: */
-	if (odp_cunit_parse_options(argc, argv))
-		return -1;
-
-	/* prevent default ODP init: */
-	odp_cunit_register_global_init(NULL);
-	odp_cunit_register_global_term(NULL);
-
-	/* register the tests: */
-	ret = odp_cunit_register(init_suites_ok);
-
-	/* run the tests: */
-	if (ret == 0)
-		ret = odp_cunit_run();
-
-	return ret;
-}
diff --git a/test/validation/api/init/init.h b/test/validation/api/init/init.h
deleted file mode 100644
index c5bcf9a23..000000000
--- a/test/validation/api/init/init.h
+++ /dev/null
@@ -1,32 +0,0 @@ 
-/* Copyright (c) 2015-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#ifndef _ODP_TEST_INIT_H_
-#define _ODP_TEST_INIT_H_
-
-#include <odp_cunit_common.h>
-
-/* test functions: */
-void init_test_odp_init_global_replace_abort(void);
-void init_test_odp_init_global_replace_log(void);
-void init_test_odp_init_global(void);
-
-/* test arrays: */
-extern odp_testinfo_t init_suite_abort[];
-extern odp_testinfo_t init_suite_log[];
-extern odp_testinfo_t init_suite_ok[];
-
-/* test registry: */
-extern odp_suiteinfo_t init_suites_abort[];
-extern odp_suiteinfo_t init_suites_log[];
-extern odp_suiteinfo_t init_suites_ok[];
-
-/* main test program: */
-int init_main_abort(int argc, char *argv[]);
-int init_main_log(int argc, char *argv[]);
-int init_main_ok(int argc, char *argv[]);
-
-#endif
diff --git a/test/validation/api/init/init_main_abort.c b/test/validation/api/init/init_main_abort.c
index 8702a0a79..339fba1d0 100644
--- a/test/validation/api/init/init_main_abort.c
+++ b/test/validation/api/init/init_main_abort.c
@@ -6,9 +6,60 @@ 
 
 #include "config.h"
 
-#include "init.h"
+#include <stdlib.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+/* replacement abort function: */
+static void ODP_NORETURN odp_init_abort(void)
+{
+	abort();
+}
+
+/* test ODP global init, with alternate abort function */
+static void init_test_odp_init_global_replace_abort(void)
+{
+	int status;
+	odp_init_t init_data;
+	odp_instance_t instance;
+
+	odp_init_param_init(&init_data);
+	init_data.abort_fn = &odp_init_abort;
+
+	status = odp_init_global(&instance, &init_data, NULL);
+	CU_ASSERT_FATAL(status == 0);
+
+	status = odp_term_global(instance);
+	CU_ASSERT(status == 0);
+}
+
+odp_testinfo_t init_suite_abort[] = {
+	ODP_TEST_INFO(init_test_odp_init_global_replace_abort),
+	ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t init_suites_abort[] = {
+	{"Init", NULL, NULL, init_suite_abort},
+	ODP_SUITE_INFO_NULL,
+};
 
 int main(int argc, char *argv[])
 {
-	return init_main_abort(argc, argv);
+	int ret;
+
+	/* parse common options: */
+	if (odp_cunit_parse_options(argc, argv))
+		return -1;
+
+	/* prevent default ODP init: */
+	odp_cunit_register_global_init(NULL);
+	odp_cunit_register_global_term(NULL);
+
+	/* run the tests: */
+	ret = odp_cunit_register(init_suites_abort);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/api/init/init_main_log.c b/test/validation/api/init/init_main_log.c
index 9dc6cba0b..9ada02289 100644
--- a/test/validation/api/init/init_main_log.c
+++ b/test/validation/api/init/init_main_log.c
@@ -6,9 +6,80 @@ 
 
 #include "config.h"
 
-#include "init.h"
+#include <stdarg.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+/* flag set when the replacement logging function is used */
+int replacement_logging_used;
+
+/* replacement log function: */
+ODP_PRINTF_FORMAT(2, 3)
+static int odp_init_log(odp_log_level_t level __attribute__((unused)),
+			const char *fmt, ...)
+{
+	va_list args;
+	int r;
+
+	/* just set a flag to be sure the replacement fn was used */
+	replacement_logging_used = 1;
+
+	va_start(args, fmt);
+	r = vfprintf(stderr, fmt, args);
+	va_end(args);
+
+	return r;
+}
+
+/* test ODP global init, with alternate log function */
+static void init_test_odp_init_global_replace_log(void)
+{
+	int status;
+	odp_init_t init_data;
+	odp_instance_t instance;
+
+	odp_init_param_init(&init_data);
+	init_data.log_fn = &odp_init_log;
+
+	replacement_logging_used = 0;
+
+	status = odp_init_global(&instance, &init_data, NULL);
+	CU_ASSERT_FATAL(status == 0);
+
+	CU_ASSERT_TRUE(replacement_logging_used || ODP_DEBUG_PRINT == 0);
+
+	status = odp_term_global(instance);
+	CU_ASSERT(status == 0);
+}
+
+odp_testinfo_t init_suite_log[] = {
+	ODP_TEST_INFO(init_test_odp_init_global_replace_log),
+	ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t init_suites_log[] = {
+	{"Init", NULL, NULL, init_suite_log},
+	ODP_SUITE_INFO_NULL,
+};
 
 int main(int argc, char *argv[])
 {
-	return init_main_log(argc, argv);
+	int ret;
+
+	/* parse common options: */
+	if (odp_cunit_parse_options(argc, argv))
+		return -1;
+
+	/* prevent default ODP init: */
+	odp_cunit_register_global_init(NULL);
+	odp_cunit_register_global_term(NULL);
+
+	/* register the tests: */
+	ret = odp_cunit_register(init_suites_log);
+
+	/* run the tests: */
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }
diff --git a/test/validation/api/init/init_main_ok.c b/test/validation/api/init/init_main_ok.c
index 3512fca80..a97db8e79 100644
--- a/test/validation/api/init/init_main_ok.c
+++ b/test/validation/api/init/init_main_ok.c
@@ -6,9 +6,50 @@ 
 
 #include "config.h"
 
-#include "init.h"
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+/* test normal ODP global init */
+static void init_test_odp_init_global(void)
+{
+	int status;
+	odp_instance_t instance;
+
+	status = odp_init_global(&instance, NULL, NULL);
+	CU_ASSERT_FATAL(status == 0);
+
+	status = odp_term_global(instance);
+	CU_ASSERT(status == 0);
+}
+
+odp_testinfo_t init_suite_ok[] = {
+	ODP_TEST_INFO(init_test_odp_init_global),
+	ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t init_suites_ok[] = {
+	{"Init", NULL, NULL, init_suite_ok},
+	ODP_SUITE_INFO_NULL,
+};
 
 int main(int argc, char *argv[])
 {
-	return init_main_ok(argc, argv);
+	int ret;
+
+	/* parse common options: */
+	if (odp_cunit_parse_options(argc, argv))
+		return -1;
+
+	/* prevent default ODP init: */
+	odp_cunit_register_global_init(NULL);
+	odp_cunit_register_global_term(NULL);
+
+	/* register the tests: */
+	ret = odp_cunit_register(init_suites_ok);
+
+	/* run the tests: */
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
 }