diff mbox series

[v8,1/5] test: build: enable cunit output to xml

Message ID 1513022420-22227-2-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v8,1/5] test: build: enable cunit output to xml | expand

Commit Message

Github ODP bot Dec. 11, 2017, 8 p.m. UTC
From: Maxim Uvarov <maxim.uvarov@linaro.org>


Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 309 (muvarov:devel/master_shippable2)
 ** https://github.com/Linaro/odp/pull/309
 ** Patch: https://github.com/Linaro/odp/pull/309.patch
 ** Base sha: 6881620135a179911a5839d4be97423a8d80e5ab
 ** Merge commit sha: 9af6bae56adfa7e06e06d13bb60a5964fcf40977
 **/
 .gitignore                     |  3 +++
 configure.ac                   |  1 +
 doc/.gitignore                 |  1 +
 test/common/odp_cunit_common.c |  9 +++++++++
 test/common/odp_cunit_common.h |  3 +++
 test/m4/validation.m4          | 11 +++++++++++
 6 files changed, 28 insertions(+)
 create mode 100644 doc/.gitignore
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index 93ab63a31..4653f8976 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,13 +2,16 @@ 
 *.gcda
 *.gcno
 *.gcov
+*.trs
 *.la
 *.lo
+*.log
 *.o
 *.orig
 *.patch
 *.rej
 *.swp
+*.xml
 *~
 .deps/
 .dirstamp
diff --git a/configure.ac b/configure.ac
index 95e316026..c4ce56e20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -383,6 +383,7 @@  AC_MSG_RESULT([
 	Deprecated APIs:	${deprecated}
 	debug:			${enable_debug}
 	cunit:			${cunit_support}
+	cunit xml output:	${cunit_out_xml}
 	test_vald:		${test_vald}
 	test_perf:		${test_perf}
 	test_perf_proc:		${test_perf_proc}
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 000000000..d7ec32eaf
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1 @@ 
+!*.xml
diff --git a/test/common/odp_cunit_common.c b/test/common/odp_cunit_common.c
index 08bf1f264..7ed343745 100644
--- a/test/common/odp_cunit_common.c
+++ b/test/common/odp_cunit_common.c
@@ -1,3 +1,4 @@ 
+
 /* Copyright (c) 2014, Linaro Limited
  * All rights reserved.
  *
@@ -7,12 +8,14 @@ 
 #include "config.h"
 
 #include <string.h>
+#include <unistd.h>
 #include <odp_api.h>
 #include "odp_cunit_common.h"
 #include <odp/helper/odph_api.h>
 /* Globals */
 static odph_odpthread_t thread_tbl[MAX_WORKERS];
 static odp_instance_t instance;
+static char *progname;
 
 /*
  * global init/term functions which may be registered
@@ -296,8 +299,13 @@  int odp_cunit_run(void)
 	printf("\tODP implementation name:    %s\n", odp_version_impl_name());
 	printf("\tODP implementation version: %s\n", odp_version_impl_str());
 
+#if TEST_CUNIT_XML
+	CU_set_output_filename(progname);
+	CU_automated_run_tests();
+#else
 	CU_basic_set_mode(CU_BRM_VERBOSE);
 	CU_basic_run_tests();
+#endif
 
 	ret = CU_get_number_of_failure_records();
 
@@ -371,5 +379,6 @@  int odp_cunit_register(odp_suiteinfo_t testsuites[])
  */
 int odp_cunit_parse_options(int argc, char *argv[])
 {
+	progname = argv[0];
 	return odph_parse_options(argc, argv, NULL, NULL);
 }
diff --git a/test/common/odp_cunit_common.h b/test/common/odp_cunit_common.h
index 486a5ec51..1497a33c7 100644
--- a/test/common/odp_cunit_common.h
+++ b/test/common/odp_cunit_common.h
@@ -17,6 +17,9 @@ 
 #include <inttypes.h>
 #include "CUnit/Basic.h"
 #include "CUnit/TestDB.h"
+#if TEST_CUNIT_XML
+#include <CUnit/Automated.h>
+#endif
 #include <odp_api.h>
 
 #define MAX_WORKERS 32 /**< Maximum number of work threads */
diff --git a/test/m4/validation.m4 b/test/m4/validation.m4
index 65ba2aa2e..216510a76 100644
--- a/test/m4/validation.m4
+++ b/test/m4/validation.m4
@@ -31,3 +31,14 @@  AM_CONDITIONAL([test_vald], [test "x$test_vald" = "xyes"])
 
 AC_SUBST([CUNIT_CFLAGS])
 AC_SUBST([CUNIT_LIBS])
+
+AC_ARG_ENABLE([cunit_out_xml],
+    [AS_HELP_STRING([--enable-cunit_out_xml],
+		    [output to xml]
+		    [(output test results to xml instead of plain text)])],
+		    cunit_out_xml=yes, cunit_out_xml=no)
+AS_IF([test "x$cunit_out_xml" == "xyes"], [TEST_CUNIT_XML=1],
+      [TEST_CUNIT_XML=0])
+AC_DEFINE_UNQUOTED([TEST_CUNIT_XML], [$TEST_CUNIT_XML],
+		   [Define to 1 to output to xml])
+AM_CONDITIONAL([cunit_out_xml], [test "x$cunit_out_xml" = "xyes"])