/pidgin/main: 83e4304811f9: Merged in rw_grim/pidgin (pull reque...

Gary Kramlich grim at reaperworld.com
Wed Mar 30 19:25:28 EDT 2016


Changeset: 83e4304811f9a843c5914183815e63fb766a2ff3
Author:	 Gary Kramlich <grim at reaperworld.com>
Date:	 2016-03-24 21:22 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/83e4304811f9

Description:

Merged in rw_grim/pidgin (pull request #28)

Convert check unit tests to gtester

diffstat:

 .hgignore                                                 |    6 +
 configure.ac                                              |   14 +-
 glib-tap.mk                                               |  135 ++
 libpurple/Makefile.am                                     |    3 +-
 libpurple/glibcompat.h                                    |   41 +
 libpurple/protocols/jabber/Makefile.am                    |    2 +
 libpurple/protocols/jabber/tests/.hgignore                |   10 +
 libpurple/protocols/jabber/tests/Makefile.am              |   37 +
 libpurple/protocols/jabber/tests/test_jabber_caps.c       |   79 +-
 libpurple/protocols/jabber/tests/test_jabber_digest_md5.c |   75 +-
 libpurple/protocols/jabber/tests/test_jabber_jutil.c      |  357 +++--
 libpurple/protocols/jabber/tests/test_jabber_scram.c      |   66 +-
 libpurple/protocols/oscar/Makefile.am                     |    2 +
 libpurple/protocols/oscar/tests/.hgignore                 |    7 +
 libpurple/protocols/oscar/tests/Makefile.am               |   23 +
 libpurple/protocols/oscar/tests/test_oscar_util.c         |   45 +-
 libpurple/protocols/yahoo/Makefile.am                     |    2 +
 libpurple/protocols/yahoo/tests/.hgignore                 |    7 +
 libpurple/protocols/yahoo/tests/Makefile.am               |   23 +
 libpurple/protocols/yahoo/tests/test_yahoo_util.c         |  432 +++---
 libpurple/tests.h                                         |   64 +
 libpurple/tests/.hgignore                                 |   13 +
 libpurple/tests/Makefile.am                               |   89 +-
 libpurple/tests/check_libpurple.c                         |  107 -
 libpurple/tests/test_cipher.c                             |  845 --------------
 libpurple/tests/test_des.c                                |   69 +
 libpurple/tests/test_des3.c                               |  223 +++
 libpurple/tests/test_hmac.c                               |  379 ++++++
 libpurple/tests/test_md4.c                                |   85 +
 libpurple/tests/test_md5.c                                |   85 +
 libpurple/tests/test_sha1.c                               |   79 +
 libpurple/tests/test_sha256.c                             |   79 +
 libpurple/tests/test_trie.c                               |  140 +-
 libpurple/tests/test_util.c                               |  721 ++++++-----
 libpurple/tests/test_xmlnode.c                            |   78 +-
 libpurple/tests/tests.h                                   |   40 -
 libpurple/xmlnode.c                                       |    4 +-
 m4macros/glibtests.m4                                     |   28 +
 tap-driver.sh                                             |  652 ++++++++++
 tap-test                                                  |    5 +
 40 files changed, 3191 insertions(+), 1960 deletions(-)

diffs (truncated from 5911 to 300 lines):

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -149,3 +149,9 @@ po/stamp-it
 stamp-h1
 test-driver
 win32-install-dir(\.release)?
+
+subinclude:libpurple/protocols/jabber/tests/.hgignore
+subinclude:libpurple/protocols/oscar/tests/.hgignore
+subinclude:libpurple/protocols/yahoo/tests/.hgignore
+subinclude:libpurple/tests/.hgignore
+
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)
@@ -2259,15 +2254,18 @@ AC_CONFIG_FILES([Makefile
 		   libpurple/protocols/gg/Makefile
 		   libpurple/protocols/irc/Makefile
 		   libpurple/protocols/jabber/Makefile
+		   libpurple/protocols/jabber/tests/Makefile
 		   libpurple/protocols/msn/Makefile
 		   libpurple/protocols/mxit/Makefile
 		   libpurple/protocols/novell/Makefile
 		   libpurple/protocols/null/Makefile
 		   libpurple/protocols/oscar/Makefile
+		   libpurple/protocols/oscar/tests/Makefile
 		   libpurple/protocols/sametime/Makefile
 		   libpurple/protocols/silc/Makefile
 		   libpurple/protocols/simple/Makefile
 		   libpurple/protocols/yahoo/Makefile
+		   libpurple/protocols/yahoo/tests/Makefile
 		   libpurple/protocols/zephyr/Makefile
 		   libpurple/tests/Makefile
 		   libpurple/purple.h
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]' > $@.tmp; \
+	echo 'Type=session' >> $@.tmp; \
+	echo 'Exec=$(installed_testdir)/$(notdir $<) --tap' >> $@.tmp; \
+	echo 'Output=TAP' >> $@.tmp; \
+	mv $@.tmp $@)
+
+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
@@ -190,6 +190,7 @@ purple_coreheaders = \
 	sound-theme.h \
 	sound-theme-loader.h \
 	sslconn.h \
+	tests.h \
 	theme.h \
 	theme-loader.h \
 	theme-manager.h \
@@ -260,7 +261,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/glibcompat.h b/libpurple/glibcompat.h
--- a/libpurple/glibcompat.h
+++ b/libpurple/glibcompat.h
@@ -94,4 +94,45 @@ purple_g_stat(const gchar *filename, GSt
 
 #endif /* __clang__ */
 
+/******************************************************************************
+ * g_assert_* macros
+ *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2, 38, 0)
+#define g_assert_true(expr)             G_STMT_START { \
+                                             if G_LIKELY (expr) ; else \
+                                               g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                    "'" #expr "' should be TRUE"); \
+                                        } G_STMT_END
+#define g_assert_false(expr)            G_STMT_START { \
+                                             if G_LIKELY (!(expr)) ; else \
+                                               g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                    "'" #expr "' should be FALSE"); \
+                                        } G_STMT_END
+#define g_assert_null(expr)             G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \
+                                               g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                    "'" #expr "' should be NULL"); \
+                                        } G_STMT_END
+#endif
+
+#if !GLIB_CHECK_VERSION(2, 40, 0)
+#define g_assert_nonnull(expr)          G_STMT_START { \
+                                             if G_LIKELY ((expr) != NULL) ; else \
+                                               g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                    "'" #expr "' should not be NULL"); \
+                                        } G_STMT_END
+#endif
+                                        
+#if !GLIB_CHECK_VERSION(2, 46, 0)
+#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
+                                             gconstpointer __m1 = m1, __m2 = m2; \
+                                             int __l1 = l1, __l2 = l2; \
+                                             if (__l1 != __l2) \
+                                               g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                           #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", __l2, 'i'); \
+                                             else if (memcmp (__m1, __m2, __l1) != 0) \
+                                               g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                    "assertion failed (" #m1 " == " #m2 ")"); \
+                                        } G_STMT_END
+#endif
+
 #endif /* _GLIBCOMPAT_H_ */
diff --git a/libpurple/protocols/jabber/Makefile.am b/libpurple/protocols/jabber/Makefile.am
--- a/libpurple/protocols/jabber/Makefile.am
+++ b/libpurple/protocols/jabber/Makefile.am
@@ -137,3 +137,5 @@ AM_CPPFLAGS = \
 	$(LIBXML_CFLAGS) \
 	$(FARSTREAM_CFLAGS) \
 	$(GSTREAMER_CFLAGS)
+
+SUBDIRS = tests
diff --git a/libpurple/protocols/jabber/tests/.hgignore b/libpurple/protocols/jabber/tests/.hgignore
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/jabber/tests/.hgignore
@@ -0,0 +1,10 @@
+syntax: regexp
+^test_jabber_caps$
+^test_jabber_digest_md5$
+^test_jabber_jutil$
+^test_jabber_scram$
+
+syntax: glob
+*.log
+*.trs
+
diff --git a/libpurple/protocols/jabber/tests/Makefile.am b/libpurple/protocols/jabber/tests/Makefile.am
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/jabber/tests/Makefile.am
@@ -0,0 +1,37 @@
+include $(top_srcdir)/glib-tap.mk



More information about the Commits mailing list