/pidgin/main: 17c34d87c5b3: Initial conversion to gtester
Gary Kramlich <[email protected]>
| Newsgroups | gmane.comp.gnome.gaim.cvs |
|---|---|
| Message-ID | <[email protected]> |
Changeset: 17c34d87c5b3af3418ba5a21f211bc0ee542e586 Author: Gary Kramlich <[email protected]> Date: 2016-03-08 23:45 -0600 Branch: default URL: https://hg.pidgin.im/pidgin/main/rev/17c34d87c5b3 Description: Initial conversion to gtester diffstat: .hgignore | 2 + configure.ac | 11 +- glib-tap.mk | 135 ++++++++ libpurple/Makefile.am | 2 +- libpurple/tests/Makefile.am | 56 +-- libpurple/tests/test_md5hash.c | 85 +++++ m4macros/glibtests.m4 | 28 + tap-driver.sh | 652 +++++++++++++++++++++++++++++++++++++++++ tap-test | 5 + 9 files changed, 929 insertions(+), 47 deletions(-) diffs (truncated from 1047 to 300 lines): diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -3,6 +3,8 @@ syntax: glob clang_output_* pidgin-* .dirstamp +*.log +*.trs syntax: regexp (.*/)?TAGS$ diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -497,6 +497,9 @@ AC_SUBST(GLIB_GENMARSHAL) GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` AC_SUBST(GLIB_MKENUMS) +AC_PATH_PROG(GTESTER, gtester) +GLIB_TESTS + AC_ARG_WITH([extraversion], AS_HELP_STRING([--with-extraversion=STRING], [extra version number to be displayed in Help->About and --help (for packagers)]), @@ -2167,14 +2170,6 @@ if test "x$ac_cv_va_val_copy" = "xno"; t fi dnl ####################################################################### -dnl # Check for check -dnl ####################################################################### -PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], , [AC_MSG_RESULT([no, testing is disabled])]) -AM_CONDITIONAL(HAVE_CHECK, [test "x$CHECK_LIBS" != "x"]) -AC_SUBST(CHECK_CFLAGS) -AC_SUBST(CHECK_LIBS) - -dnl ####################################################################### dnl # Disable pixmap installation dnl ####################################################################### AC_ARG_ENABLE(pixmaps-install, AS_HELP_STRING([--disable-pixmaps-install], [disable installation of pixmap files - Pidgin still needs them!]), enable_pixmaps="$enableval", enable_pixmaps=yes) diff --git a/glib-tap.mk b/glib-tap.mk new file mode 100644 --- /dev/null +++ b/glib-tap.mk @@ -0,0 +1,135 @@ +# GLIB - Library of useful C routines + +TESTS_ENVIRONMENT= \ + G_TEST_SRCDIR="$(abs_srcdir)" \ + G_TEST_BUILDDIR="$(abs_builddir)" \ + G_DEBUG=gc-friendly \ + MALLOC_CHECK_=2 \ + MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh +LOG_COMPILER = $(top_srcdir)/tap-test + +NULL = + +# initialize variables for unconditional += appending +BUILT_SOURCES = +BUILT_EXTRA_DIST = +CLEANFILES = *.log *.trs +DISTCLEANFILES = +MAINTAINERCLEANFILES = +EXTRA_DIST = +TESTS = + +installed_test_LTLIBRARIES = +installed_test_PROGRAMS = +installed_test_SCRIPTS = +nobase_installed_test_DATA = + +noinst_LTLIBRARIES = +noinst_PROGRAMS = +noinst_SCRIPTS = +noinst_DATA = + +check_LTLIBRARIES = +check_PROGRAMS = +check_SCRIPTS = +check_DATA = + +# We support a fairly large range of possible variables. It is expected that all types of files in a test suite +# will belong in exactly one of the following variables. +# +# First, we support the usual automake suffixes, but in lowercase, with the customary meaning: +# +# test_programs, test_scripts, test_data, test_ltlibraries +# +# The above are used to list files that are involved in both uninstalled and installed testing. The +# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite. +# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is +# installed in the same way as it appears in the package layout. +# +# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled', +# like so: +# +# installed_test_programs, uninstalled_test_programs +# installed_test_scripts, uninstalled_test_scripts +# installed_test_data, uninstalled_test_data +# installed_test_ltlibraries, uninstalled_test_ltlibraries +# +# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts +# that should not themselves be run as testcases (but exist to be used from other testcases): +# +# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs +# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts +# +# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data +# file automatically end up in the tarball. +# +# dist_test_scripts, dist_test_data, dist_test_extra_scripts +# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts +# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts +# +# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the +# standard automake convention of not disting programs scripts or data by default. +# +# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted +# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under +# gtester. That's a bit strange for scripts, but it's possible. + +TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \ + $(dist_test_scripts) $(dist_uninstalled_test_scripts) + +# Note: build even the installed-only targets during 'make check' to ensure that they still work. +# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to +# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were +# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'. +all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \ + $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs) +all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \ + $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts) +all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \ + $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts) +all_test_scripts += $(all_dist_test_scripts) +EXTRA_DIST += $(all_dist_test_scripts) +all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data) +all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data) +all_test_data += $(all_dist_test_data) +EXTRA_DIST += $(all_dist_test_data) +all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries) + +if ENABLE_ALWAYS_BUILD_TESTS +noinst_LTLIBRARIES += $(all_test_ltlibs) +noinst_PROGRAMS += $(all_test_programs) +noinst_SCRIPTS += $(all_test_scripts) +noinst_DATA += $(all_test_data) +else +check_LTLIBRARIES += $(all_test_ltlibs) +check_PROGRAMS += $(all_test_programs) +check_SCRIPTS += $(all_test_scripts) +check_DATA += $(all_test_data) +endif + +if ENABLE_INSTALLED_TESTS +installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \ + $(test_extra_programs) $(installed_test_extra_programs) +installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \ + $(test_extra_scripts) $(test_installed_extra_scripts) +installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \ + $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts) +nobase_installed_test_DATA += $(test_data) $(installed_test_data) +nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data) +installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries) +installed_testcases = $(test_programs) $(installed_test_programs) \ + $(test_scripts) $(installed_test_scripts) \ + $(dist_test_scripts) $(dist_installed_test_scripts) + +installed_test_meta_DATA = $(installed_testcases:=.test) + +%.test: %$(EXEEXT) Makefile + $(AM_V_GEN) (echo '[Test]' > [email protected]; \ + echo 'Type=session' >> [email protected]; \ + echo 'Exec=$(installed_testdir)/$(notdir $<) --tap' >> [email protected]; \ + echo 'Output=TAP' >> [email protected]; \ + mv [email protected] $@) + +CLEANFILES += $(installed_test_meta_DATA) +endif \ No newline at end of file diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am --- a/libpurple/Makefile.am +++ b/libpurple/Makefile.am @@ -260,7 +260,7 @@ purple_enumheaders = \ $(srcdir)/protocols.h \ $(srcdir)/roomlist.h \ $(srcdir)/status.h \ - ${srcdir}/sound.h \ + $(srcdir)/sound.h \ $(srcdir)/xfer.h \ $(srcdir)/xmlnode.h diff --git a/libpurple/tests/Makefile.am b/libpurple/tests/Makefile.am --- a/libpurple/tests/Makefile.am +++ b/libpurple/tests/Makefile.am @@ -1,42 +1,22 @@ -if HAVE_CHECK -TESTS=check_libpurple +include $(top_srcdir)/glib-tap.mk -clean-local: - -rm -rf libpurple.. +COMMON_LIBS=\ + $(top_builddir)/libpurple/libpurple.la \ + $(GLIB_LIBS) \ + $(GPLUGIN_LIBS) -check_PROGRAMS=check_libpurple +test_programs=\ + test_md5hash -check_libpurple_SOURCES=\ - check_libpurple.c \ - tests.h \ - test_cipher.c \ - test_jabber_caps.c \ - test_jabber_digest_md5.c \ - test_jabber_jutil.c \ - test_jabber_scram.c \ - test_oscar_util.c \ - test_trie.c \ - test_yahoo_util.c \ - test_util.c \ - test_xmlnode.c \ - $(top_builddir)/libpurple/util.h +test_md5hash_SOURCES=test_md5hash.c +test_md5hash_LDADD=$(COMMON_LIBS) -check_libpurple_CFLAGS=\ - @CHECK_CFLAGS@ \ - $(GLIB_CFLAGS) \ - $(GPLUGIN_CFLAGS) \ - $(DEBUG_CFLAGS) \ - $(LIBXML_CFLAGS) \ - -I.. \ - -I$(top_srcdir)/libpurple - -check_libpurple_LDADD=\ - $(top_builddir)/libpurple/protocols/jabber/libjabber.la \ - $(top_builddir)/libpurple/protocols/oscar/liboscar.la \ - $(top_builddir)/libpurple/protocols/yahoo/libyahoo.la \ - $(top_builddir)/libpurple/libpurple.la \ - @CHECK_LIBS@ \ - $(GLIB_LIBS) \ - $(GPLUGIN_LIBS) - -endif +AM_CPPFLAGS = \ + -I$(top_srcdir)/libpurple \ + -I$(top_builddir)/libpurple \ + $(DEBUG_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GPLUGIN_CFLAGS) \ + $(PLUGIN_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(NSS_CFLAGS) diff --git a/libpurple/tests/test_md5hash.c b/libpurple/tests/test_md5hash.c new file mode 100644 --- /dev/null +++ b/libpurple/tests/test_md5hash.c @@ -0,0 +1,85 @@ +#include <glib.h> + +#include <purple.h> + +#include "ciphers/md5hash.h" + +static void +test_md5hash(gchar *data, gchar *digest) { + PurpleHash *hash = NULL; + gchar cdigest[33]; + gboolean ret = FALSE; + + hash = purple_md5_hash_new(); + + purple_hash_append(hash, (guchar *)data, strlen(data)); + + ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest)); + + g_assert(ret); + g_assert_cmpstr(digest, ==, cdigest); +} + +static void +test_md5hash_empty_string(void) { + test_md5hash("", + "d41d8cd98f00b204e9800998ecf8427e"); +} + +static void +test_md5hash_a(void) { + test_md5hash("a", + "0cc175b9c0f1b6a831c399e269772661"); +} + +static void +test_md5hash_abc(void) { + test_md5hash("abc", + "900150983cd24fb0d6963f7d28e17f72"); _______________________________________________ Commits mailing list [email protected] https://pidgin.im/cgi-bin/mailman/listinfo/commits