[Libosinfo] [libosinfo PATCH] tests: convert from check to the GLib testing framework

Daniel P. Berrange berrange at redhat.com
Thu Oct 19 13:36:28 UTC 2017


On Thu, Oct 19, 2017 at 03:14:24PM +0200, Pino Toscano wrote:
> GLib has shipped a testing framework for many years already, so we can
> make use of it, replacing the external "check".
> 
> The conversion only switches framework without changing the structure of
> the tests, making use of the more appropriate assertion in the various
> places.
> 
> Signed-off-by: Pino Toscano <ptoscano at redhat.com>
> ---
>  configure.ac                |   1 -
>  libosinfo.spec.in           |   1 -
>  tests/Makefile.am           |   3 +-
>  tests/test-db.c             | 165 +++++++++++++++++--------------------
>  tests/test-device.c         |  33 ++------
>  tests/test-devicelist.c     |  77 +++++++----------
>  tests/test-entity.c         | 195 ++++++++++++++++++++------------------------
>  tests/test-filter.c         | 111 +++++++++++--------------
>  tests/test-install-script.c |  92 ++++++++-------------
>  tests/test-isodetect.c      | 138 ++++++++++++++-----------------
>  tests/test-list.c           | 145 +++++++++++++++-----------------
>  tests/test-loader.c         |  33 ++------
>  tests/test-mediauris.c      |  44 ++++------
>  tests/test-os.c             | 122 ++++++++++++---------------
>  tests/test-oslist.c         |  77 +++++++----------
>  tests/test-platform.c       |  61 ++++++--------
>  tests/test-platformlist.c   |  77 +++++++----------
>  tests/test-product.c        | 100 ++++++++++-------------
>  tests/test-productfilter.c  | 143 +++++++++++++++-----------------
>  tests/test-treeuris.c       |  44 ++++------
>  20 files changed, 694 insertions(+), 968 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 99abe94..d834c89 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -57,7 +57,6 @@ AC_ARG_ENABLE([tests],
>  
>  if test "x$enable_tests" != "xno" ; then
>    have_curl=no
> -  PKG_CHECK_MODULES([CHECK], [check])
>    PKG_CHECK_MODULES([CURL], [libcurl], [have_curl=yes], [:])
>    AC_SUBST(CURL_CFLAGS)
>    AC_SUBST(CURL_LIBS)
> diff --git a/libosinfo.spec.in b/libosinfo.spec.in
> index 5a5e6f8..f3e3690 100644
> --- a/libosinfo.spec.in
> +++ b/libosinfo.spec.in
> @@ -11,7 +11,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
>  URL: https://libosinfo.org/
>  BuildRequires: intltool
>  BuildRequires: glib2-devel
> -BuildRequires: check-devel
>  BuildRequires: libxml2-devel >= 2.6.0
>  BuildRequires: libxslt-devel >= 1.0.0
>  BuildRequires: vala
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9315e04..7566d3c 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -30,7 +30,6 @@ COMMON_LDADD = \
>  	$(COVERAGE_LDFLAGS) \
>  	$(GLIB_LIBS) \
>  	$(GOBJECT_LIBS) \
> -	$(CHECK_LIBS) \
>  	../osinfo/libosinfo-1.0.la
>  COMMON_CFLAGS = \
>  	$(WARN_CFLAGS) \
> @@ -40,7 +39,7 @@ COMMON_CFLAGS = \
>  	-I$(top_srcdir) \
>  	-DSRCDIR="\"$(abs_top_srcdir)\"" \
>  	-DBUILDDIR="\"$(abs_top_builddir)\"" \
> -	$(CHECK_CFLAGS)
> +	$(NULL)
>  
>  test_entity_LDADD = $(COMMON_LDADD)
>  test_entity_CFLAGS = $(COMMON_CFLAGS)
> diff --git a/tests/test-isodetect.c b/tests/test-isodetect.c
> index 7214531..97c86c4 100644
> --- a/tests/test-isodetect.c
> +++ b/tests/test-isodetect.c

> -int main(void)
> -{
> -    int number_failed;
> -    Suite *s = list_suite();
> -    SRunner *sr = srunner_create(s);
> +    g_test_init(&argc, &argv, NULL);
> +
> +    g_test_add_func("/isodetect/fedora", test_fedora);
> +    g_test_add_func("/isodetect/rhel", test_rhel);
> +    g_test_add_func("/isodetect/ubuntu", test_ubuntu);
> +    g_test_add_func("/isodetect/debian", test_debian);
> +    g_test_add_func("/isodetect/windows", test_windows);
> +    g_test_add_func("/isodetect/freebsd", test_freebsd);
> +    g_test_add_func("/isodetect/openbsd", test_openbsd);
> +    g_test_add_func("/isodetect/opensuse", test_opensuse);
> +    g_test_add_func("/isodetect/centos", test_centos);
> +    g_test_add_func("/isodetect/gnome", test_gnome);
> +    g_test_add_func("/isodetect/altlinux", test_altlinux);
> +    g_test_add_func("/isodetect/mageia", test_mageia);
> +    g_test_add_func("/isodetect/sles", test_sles);
> +    g_test_add_func("/isodetect/sled", test_sled);

We could wrap all of this in a

   if (g_test_slow()) {
     ....
   }

so that this only executes if people request slow tests via '-m slow' arg

Regardless, fine to push as is

Reviewed-by: Daniel P. Berrange <berrange at redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the Libosinfo mailing list