]> git.draconx.ca Git - gob-dx.git/blobdiff - testsuite.at
Replace gnulib patch with new common helper macro.
[gob-dx.git] / testsuite.at
index 97c0253463c51a20370b9b4a8d1d0806711e8ba9..6511c429a5a362e7950fd388e5b5a4f613e5225b 100644 (file)
@@ -1,8 +1,38 @@
-AT_COPYRIGHT([Copyright © 2019 Nick Bowler
+AT_COPYRIGHT([Copyright © 2019-2020, 2023 Nick Bowler
 License GPLv2+: GNU General Public License version 2 or any later version.
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.])
 
+dnl mtime_uptodate file-a file-b: returns success iff file-a's modification
+dnl time is at least as new as file-b's.
+m4_divert_push([PREPARE_TESTS])dnl
+mtime_uptodate () {
+  cat >mtime-uptodate.mk <<EOF
+$1: $2
+       false
+EOF
+  $MAKE -f mtime-uptodate.mk >/dev/null 2>&1 || return 1
+}
+m4_divert_pop([PREPARE_TESTS])
+
+dnl TEST_MTIME_DELAY
+dnl
+dnl Delay script execution such that file modifications done prior to the
+dnl delay will have older timestamps than file modifications performed after
+dnl the delay.
+dnl
+dnl Some filesystems have insufficient timestamp resolution (or maybe
+dnl computers are just too fast) to reliably distinguish between back-to-back
+dnl file modification.
+dnl
+dnl This delay is implemented by repeatingly touching files until a different
+dnl timestamp is produced.
+m4_define([TEST_MTIME_DELAY],
+[touch mtime-delay.old; touch mtime-delay.new
+while mtime_uptodate mtime-delay.old mtime-delay.new; do
+  touch mtime-delay.new
+done])
+
 dnl Compile a C source file with default cflags for libgobject.  The test
 dnl group is skipped if libgobject was not enabled at configure time.  The
 dnl first argument contains extra compiler flags, which must include the
@@ -12,13 +42,69 @@ dnl is the 2nd argument of AT_CHECK -- the expected exit status).
 m4_define([TEST_COMPILE_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
 $CC $CPPFLAGS $CFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
 
+m4_define([TEST_LINK_GOBJECT],
+  [AT_CHECK([$SHELL "$builddir/libtool" --quiet --tag=CC --mode=link \
+    $CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o $1 $2])])
+
 dnl Same as TEST_COMPILE_GOBJECT, except that the C++ compiler is used.
 m4_define([TEST_COMPILEXX_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
 $CXX $CPPFLAGS $CXXFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
 
+dnl TEST_CLASSNAME_REPLACE_SEP(Class:Name, separator)
+dnl
+dnl Convert the components of Class:Name to lower case, and join them
+dnl together with the given separator.  The result is a quoted string.
+m4_define([TEST_CLASSNAME_REPLACE_SEP],
+  [m4_join([$2], m4_unquote(m4_split(m4_tolower([$1]), [:])))])
+
+dnl TEST_TYPE_MODULE(Class:Name)
+dnl Create a GTypeModule (Class:Name:Mod) which registers the dynamic
+dnl type indiciated by Class:Name.
+m4_define([TEST_TYPE_MODULE],
+[TEST_TYPE_MODULE_([$1],
+  TEST_CLASSNAME_REPLACE_SEP([$1], [_]),
+  TEST_CLASSNAME_REPLACE_SEP([$1], [-]))])
+
+m4_define([TEST_TYPE_MODULE_],
+[AT_KEYWORDS([dynamic])dnl
+
+AT_DATA([$3-mod.gob], [[%ctop{
+#include <config.h>
+%}
+%{
+#include "$3.h"
+%}
+class $1:Mod from G:Type:Module
+{
+  override (G:Type:Module) gboolean load(G:Type:Module *m)
+  {
+    $2_register_type(m);
+    return TRUE;
+  }
+}
+]])
+AT_CHECK([gob2 $3-mod.gob])
+TEST_COMPILE_GOBJECT([$3-mod.c], [0], [], [ignore])])
+
 AT_INIT
 AT_COLOR_TESTS
 
 AT_TESTED([gob2])
+m4_divert_push([PREPARE_TESTS])dnl
+CPPFLAGS="-I$builddir $CPPFLAGS"
+:; {
+  AS_ECHO(["AUTOCONF = ${AUTOCONF=autoconf}"])
+  command -v $AUTOCONF 2>&1
+  (set -x; $AUTOCONF --version) 2>&1
+  echo
+  AS_UNSET([MAKEFLAGS])
+  AS_ECHO(["MAKE = ${MAKE=make}"])
+  command -v $MAKE 2>&1
+  (set -x; $MAKE --version) 2>&1
+  echo
+} >&AS_MESSAGE_LOG_FD
+m4_divert_pop([PREPARE_TESTS])
 
 m4_include([tests/general.at])
+m4_include([tests/options.at])
+m4_include([tests/interface.at])