]> git.draconx.ca Git - gob-dx.git/commitdiff
Use libtool to link programs in the testsuite.
authorNick Bowler <nbowler@draconx.ca>
Wed, 25 Jan 2023 02:13:22 +0000 (21:13 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 25 Jan 2023 02:13:22 +0000 (21:13 -0500)
This can help to pick up shared library dependencies automatically
and avoid spurious test failures as a result.

tests/general.at
tests/interface.at
testsuite.at

index 52c3fcac43209cfb096fdf8da35c3047a39e1049..a9d2def55164919beb56d118a84a502838cc7a10 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2019-2022 Nick Bowler
+dnl Copyright © 2019-2023 Nick Bowler
 dnl License GPLv2+: GNU General Public License version 2 or any later version.
 dnl This is free software: you are free to change and redistribute it.
 dnl There is NO WARRANTY, to the extent permitted by law.
@@ -77,7 +77,7 @@ TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr])
 mv stderr str_stderr
 TEST_COMPILE_GOBJECT([main.c], [0], [], [stderr])
 mv stderr main_stderr
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main str.o main.o])
+TEST_LINK_GOBJECT([main], [str.o main.o])
 
 AT_DATA([str.awk],
 [[/want a string/ { lines[NR] = 1; }
@@ -141,8 +141,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main test.o main.o])
+TEST_LINK_GOBJECT([main], [test.o main.o])
 
 AT_CLEANUP
 
@@ -207,9 +206,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test.o test-mod.o main.o])
+TEST_LINK_GOBJECT([main], [test.o test-mod.o main.o])
 AT_CHECK([./main], [0], [Hello, World
 ])
 
@@ -294,9 +291,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test.o main.o])
+TEST_LINK_GOBJECT([main], [test.o main.o])
 AT_CHECK([./main], [0], [42
 123
 ])
@@ -342,9 +337,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test.o test-mod.o main.o])
+TEST_LINK_GOBJECT([main], [test.o test-mod.o main.o])
 AT_CHECK([./main], [0], [54
 123
 ])
index 113c22a60e19ac7b6beb9e3e331f7224bc14eade..4cc41d9bb02846f72a1d39e474a15c4e343026df 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2020 Nick Bowler
+dnl Copyright © 2020, 2022-2023 Nick Bowler
 dnl License GPLv2+: GNU General Public License version 2 or any later version.
 dnl This is free software: you are free to change and redistribute it.
 dnl There is NO WARRANTY, to the extent permitted by law.
@@ -80,9 +80,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-fooable.o main.o])
+TEST_LINK_GOBJECT([main], [test-a.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [42
 ])
 
@@ -118,9 +116,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-a-mod.o test-fooable.o main.o])
+TEST_LINK_GOBJECT([main], [test-a.o test-a-mod.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [54
 ])
 
@@ -164,9 +160,7 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-b.o test-fooable.o main.o])
+TEST_LINK_GOBJECT([main], [test-a.o test-b.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [Test:A foo called
 42
 Test:B foo called
@@ -216,10 +210,8 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-b.o test-b-mod.o test-fooable.o main.o])
-
+TEST_LINK_GOBJECT([main],
+  [test-a.o test-b.o test-b-mod.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [Test:A foo called
 42
 Test:B foo called
@@ -271,10 +263,8 @@ int main(void)
 }
 ]])
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-a-mod.o test-b.o test-b-mod.o test-fooable.o main.o])
-
+TEST_LINK_GOBJECT([main],
+  [test-a.o test-a-mod.o test-b.o test-b-mod.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [Test:A foo called
 42
 Test:B foo called
@@ -318,9 +308,7 @@ int main(void)
 ]])
 
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-b.o test-c.o test-fooable.o main.o])
+TEST_LINK_GOBJECT([main], [test-a.o test-b.o test-c.o test-fooable.o main.o])
 AT_CHECK([./main], [0], [Test:C foo called
 Test:B foo called
 Test:A foo called
@@ -371,10 +359,9 @@ int main(void)
 ]])
 
 TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
-  test-a.o test-a-mod.o test-b.o test-b-mod.o test-c.o test-c-mod.o \
-  test-fooable.o main.o])
+TEST_LINK_GOBJECT([main], m4_join([ ],
+  [test-a.o test-a-mod.o test-b.o test-b-mod.o test-c.o test-c-mod.o],
+  [test-fooable.o main.o]))
 AT_CHECK([./main], [0], [Test:C foo called
 Test:B foo called
 Test:A foo called
index 025e78f000f542fdf5853dd897edf1edf8d022ab..6511c429a5a362e7950fd388e5b5a4f613e5225b 100644 (file)
@@ -1,4 +1,4 @@
-AT_COPYRIGHT([Copyright © 2019-2020 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.])
@@ -42,6 +42,10 @@ 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($@))])
@@ -90,12 +94,12 @@ m4_divert_push([PREPARE_TESTS])dnl
 CPPFLAGS="-I$builddir $CPPFLAGS"
 :; {
   AS_ECHO(["AUTOCONF = ${AUTOCONF=autoconf}"])
-  command -v $AUTOCONF
+  command -v $AUTOCONF 2>&1
   (set -x; $AUTOCONF --version) 2>&1
   echo
   AS_UNSET([MAKEFLAGS])
   AS_ECHO(["MAKE = ${MAKE=make}"])
-  command -v $MAKE
+  command -v $MAKE 2>&1
   (set -x; $MAKE --version) 2>&1
   echo
 } >&AS_MESSAGE_LOG_FD