]> git.draconx.ca Git - gob-dx.git/blob - testsuite.at
Replace gnulib patch with new common helper macro.
[gob-dx.git] / testsuite.at
1 AT_COPYRIGHT([Copyright © 2019-2020, 2023 Nick Bowler
2 License GPLv2+: GNU General Public License version 2 or any later version.
3 This is free software: you are free to change and redistribute it.
4 There is NO WARRANTY, to the extent permitted by law.])
5
6 dnl mtime_uptodate file-a file-b: returns success iff file-a's modification
7 dnl time is at least as new as file-b's.
8 m4_divert_push([PREPARE_TESTS])dnl
9 mtime_uptodate () {
10   cat >mtime-uptodate.mk <<EOF
11 $1: $2
12         false
13 EOF
14   $MAKE -f mtime-uptodate.mk >/dev/null 2>&1 || return 1
15 }
16 m4_divert_pop([PREPARE_TESTS])
17
18 dnl TEST_MTIME_DELAY
19 dnl
20 dnl Delay script execution such that file modifications done prior to the
21 dnl delay will have older timestamps than file modifications performed after
22 dnl the delay.
23 dnl
24 dnl Some filesystems have insufficient timestamp resolution (or maybe
25 dnl computers are just too fast) to reliably distinguish between back-to-back
26 dnl file modification.
27 dnl
28 dnl This delay is implemented by repeatingly touching files until a different
29 dnl timestamp is produced.
30 m4_define([TEST_MTIME_DELAY],
31 [touch mtime-delay.old; touch mtime-delay.new
32 while mtime_uptodate mtime-delay.old mtime-delay.new; do
33   touch mtime-delay.new
34 done])
35
36 dnl Compile a C source file with default cflags for libgobject.  The test
37 dnl group is skipped if libgobject was not enabled at configure time.  The
38 dnl first argument contains extra compiler flags, which must include the
39 dnl source file name.  The remaining arguments correspond to the remaining
40 dnl arguments of AT_CHECK (e.g., the 2nd argument to TEST_COMPILE_GOBJECT
41 dnl is the 2nd argument of AT_CHECK -- the expected exit status).
42 m4_define([TEST_COMPILE_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
43 $CC $CPPFLAGS $CFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
44
45 m4_define([TEST_LINK_GOBJECT],
46   [AT_CHECK([$SHELL "$builddir/libtool" --quiet --tag=CC --mode=link \
47     $CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o $1 $2])])
48
49 dnl Same as TEST_COMPILE_GOBJECT, except that the C++ compiler is used.
50 m4_define([TEST_COMPILEXX_GOBJECT], [AT_CHECK([$HAVE_GOBJECT || exit 77
51 $CXX $CPPFLAGS $CXXFLAGS $LIBGOBJECT_CFLAGS -c $1], m4_shift($@))])
52
53 dnl TEST_CLASSNAME_REPLACE_SEP(Class:Name, separator)
54 dnl
55 dnl Convert the components of Class:Name to lower case, and join them
56 dnl together with the given separator.  The result is a quoted string.
57 m4_define([TEST_CLASSNAME_REPLACE_SEP],
58   [m4_join([$2], m4_unquote(m4_split(m4_tolower([$1]), [:])))])
59
60 dnl TEST_TYPE_MODULE(Class:Name)
61 dnl Create a GTypeModule (Class:Name:Mod) which registers the dynamic
62 dnl type indiciated by Class:Name.
63 m4_define([TEST_TYPE_MODULE],
64 [TEST_TYPE_MODULE_([$1],
65   TEST_CLASSNAME_REPLACE_SEP([$1], [_]),
66   TEST_CLASSNAME_REPLACE_SEP([$1], [-]))])
67
68 m4_define([TEST_TYPE_MODULE_],
69 [AT_KEYWORDS([dynamic])dnl
70
71 AT_DATA([$3-mod.gob], [[%ctop{
72 #include <config.h>
73 %}
74 %{
75 #include "$3.h"
76 %}
77 class $1:Mod from G:Type:Module
78 {
79   override (G:Type:Module) gboolean load(G:Type:Module *m)
80   {
81     $2_register_type(m);
82     return TRUE;
83   }
84 }
85 ]])
86 AT_CHECK([gob2 $3-mod.gob])
87 TEST_COMPILE_GOBJECT([$3-mod.c], [0], [], [ignore])])
88
89 AT_INIT
90 AT_COLOR_TESTS
91
92 AT_TESTED([gob2])
93 m4_divert_push([PREPARE_TESTS])dnl
94 CPPFLAGS="-I$builddir $CPPFLAGS"
95 :; {
96   AS_ECHO(["AUTOCONF = ${AUTOCONF=autoconf}"])
97   command -v $AUTOCONF 2>&1
98   (set -x; $AUTOCONF --version) 2>&1
99   echo
100   AS_UNSET([MAKEFLAGS])
101   AS_ECHO(["MAKE = ${MAKE=make}"])
102   command -v $MAKE 2>&1
103   (set -x; $MAKE --version) 2>&1
104   echo
105 } >&AS_MESSAGE_LOG_FD
106 m4_divert_pop([PREPARE_TESTS])
107
108 m4_include([tests/general.at])
109 m4_include([tests/options.at])
110 m4_include([tests/interface.at])