[PATCH weston v5 4/6] Enables output in the JUnit XML format.

Pekka Paalanen ppaalanen at gmail.com
Thu Jun 25 06:03:13 PDT 2015


On Sat, 20 Jun 2015 15:47:46 -0700
"Jon A. Cruz" <jonc at osg.samsung.com> wrote:

> Adds basic support fo optionally outputting in the XML format
> commonly used by JUnit compatible tools.
> 
> This format is supported by default by many tools, including
> the Jenkins build system. It also is more detailed and
> captures more information than the more simplistic TAP
> format.
> 
> Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
> ---
>  Makefile.am                           |  10 +
>  configure.ac                          |   6 +
>  tools/zunitc/inc/zunitc/zunitc.h      |  10 +
>  tools/zunitc/src/zuc_junit_reporter.c | 464 ++++++++++++++++++++++++++++++++++
>  tools/zunitc/src/zuc_junit_reporter.h |  38 +++
>  tools/zunitc/src/zunitc_impl.c        |  25 ++
>  6 files changed, 553 insertions(+)
>  create mode 100644 tools/zunitc/src/zuc_junit_reporter.c
>  create mode 100644 tools/zunitc/src/zuc_junit_reporter.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 4b6bb97..f0ed4d2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1031,6 +1031,16 @@ libzunitc_la_CFLAGS = \
>  libzunitc_la_LIBADD = \
>  	libshared.la
>  
> +if HAVE_LIBXML2
> +libzunitc_la_SOURCES += \
> +	tools/zunitc/src/zuc_junit_reporter.c	\
> +	tools/zunitc/src/zuc_junit_reporter.h
> +libzunitc_la_CFLAGS += \
> +	$(LIBXML2_CFLAGS)
> +libzunitc_la_LIBADD += \
> +	$(LIBXML2_LIBS)
> +endif
> +
>  libzunitcmain_la_SOURCES = \
>  	tools/zunitc/src/main.c
>  
> diff --git a/configure.ac b/configure.ac
> index e047fd5..4a89819 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -264,6 +264,11 @@ if test "x$cairo_modules" = "xcairo-glesv2"; then
>  AC_DEFINE([USE_CAIRO_GLESV2], [1], [Use the GLESv2 GL cairo backend])
>  fi
>  
> +PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= 2.6],
> +			   [AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 is available]) have_libxml2=yes],
> +			   have_libxml2=no)
> +AM_CONDITIONAL(HAVE_LIBXML2, [test "x$have_libxml2" = xyes])
> +
>  PKG_CHECK_MODULES(PIXMAN, [pixman-1])
>  PKG_CHECK_MODULES(PNG, [libpng])
>  PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes], [have_webp=no])
> @@ -557,5 +562,6 @@ AC_MSG_RESULT([
>  	LCMS2 Support			${have_lcms}
>  	libwebp Support			${have_webp}
>  	libunwind Support		${have_libunwind}
> +	libxml2 Support			${have_libxml2}

Agreed with Quentin's comments.

Having a --disable-junit-reporter configure option sounds more
understandable, too, since a user probably doesn't care if one uses
libxml2 or not, but he would care whether he gets JUnit output.

>  	VA H.264 encoding Support	${have_libva}
>  ])
> diff --git a/tools/zunitc/inc/zunitc/zunitc.h b/tools/zunitc/inc/zunitc/zunitc.h
> index 559cdd0..bf0077a 100644
> --- a/tools/zunitc/inc/zunitc/zunitc.h
> +++ b/tools/zunitc/inc/zunitc/zunitc.h
> @@ -243,6 +243,16 @@ zuc_set_spawn(bool spawn);
>  void
>  zuc_set_output_tap(bool enable);
>  
> +#if HAVE_LIBXML2
> +/**
> + * Enables output in the JUnit XML format.
> + *
> + * @param enable true to generate JUnit XML output, false to disable.
> + */
> +void
> +zuc_set_output_junit(bool enable);
> +#endif
> +

> diff --git a/tools/zunitc/src/zunitc_impl.c b/tools/zunitc/src/zunitc_impl.c
> index 7e34aca..3c0b2d7 100644
> --- a/tools/zunitc/src/zunitc_impl.c
> +++ b/tools/zunitc/src/zunitc_impl.c
> @@ -46,6 +46,9 @@
>  #include "zuc_collector.h"
>  #include "zuc_context.h"
>  #include "zuc_event_listener.h"
> +#if HAVE_LIBXML2
> +#include "zuc_junit_reporter.h"
> +#endif
>  #include "zuc_tap_logger.h"
>  
>  #include "shared/config-parser.h"
> @@ -297,6 +300,14 @@ zuc_set_output_tap(bool enable)
>  	g_ctx.output_tap = enable;
>  }
>  
> +#if HAVE_LIBXML2
> +void
> +zuc_set_output_junit(bool enable)
> +{
> +	g_ctx.output_junit = enable;
> +}
> +#endif
> +
>  const char *
>  zuc_get_program_name(void)
>  {
> @@ -320,6 +331,9 @@ zuc_initialize(int *argc, char *argv[], bool *help_flagged)
>  	int opt_random = 0;
>  	int opt_break_on_failure = 0;
>  	int opt_tap = 0;
> +#if HAVE_LIBXML2
> +	int opt_junit = 0;
> +#endif
>  	char *opt_filter = NULL;
>  
>  	char *help_param = NULL;
> @@ -333,6 +347,9 @@ zuc_initialize(int *argc, char *argv[], bool *help_flagged)
>  		{ WESTON_OPTION_BOOLEAN, "zuc-break-on-failure", 0,
>  		  &opt_break_on_failure },
>  		{ WESTON_OPTION_BOOLEAN, "zuc-output-tap", 0, &opt_tap },
> +#if HAVE_LIBXML2
> +		{ WESTON_OPTION_BOOLEAN, "zuc-output-xml", 0, &opt_junit },
> +#endif
>  		{ WESTON_OPTION_STRING, "zuc-filter", 0, &opt_filter },
>  	};
>  
> @@ -422,6 +439,7 @@ zuc_initialize(int *argc, char *argv[], bool *help_flagged)
>  		       "  --zuc-list-tests\n"
>  		       "  --zuc-nofork\n"
>  		       "  --zuc-output-tap\n"
> +		       "  --zuc-output-xml\n"
>  		       "  --zuc-random=N            [0|1|<seed number>]\n"
>  		       "  --zuc-repeat=N\n"
>  		       "  --help\n",
> @@ -438,6 +456,9 @@ zuc_initialize(int *argc, char *argv[], bool *help_flagged)
>  		zuc_set_spawn(!opt_nofork);
>  		zuc_set_break_on_failure(opt_break_on_failure);
>  		zuc_set_output_tap(opt_tap);
> +#if HAVE_LIBXML2
> +		zuc_set_output_junit(opt_junit);
> +#endif
>  		rc = EXIT_SUCCESS;
>  	}
>  
> @@ -972,6 +993,10 @@ zucimpl_run_tests(void)
>  		zuc_add_event_listener(zuc_base_logger_create());
>  		if (g_ctx.output_tap)
>  			zuc_add_event_listener(zuc_tap_logger_create());
> +#if HAVE_LIBXML2
> +		if (g_ctx.output_junit)
> +			zuc_add_event_listener(zuc_junit_reporter_create());
> +#endif
>  	}
>  
>  	if (g_ctx.case_count < 1) {

It's a common convention to reduce the number of #ifdefs by defining
the functions in all cases. If the feature is not available, the
function would just return (a failure).

#ifdeffing the command line option does make sense, though.

I suppose the JUnit XML output is a good idea, thinking about automated
building and testing. Some pointers in a README to tools that make good
use of this output would be nice, e.g. something that formats a nice
report and compares different runs, pointing out regressions etc.


Thanks,
pq


More information about the wayland-devel mailing list