From: Nick Bowler Date: Wed, 25 Jan 2023 02:13:22 +0000 (-0500) Subject: Use libtool to link programs in the testsuite. X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/commitdiff_plain/998925c8d088559a780a9f4fa63f66bad3e3321e Use libtool to link programs in the testsuite. This can help to pick up shared library dependencies automatically and avoid spurious test failures as a result. --- diff --git a/tests/general.at b/tests/general.at index 52c3fca..a9d2def 100644 --- a/tests/general.at +++ b/tests/general.at @@ -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 ]) diff --git a/tests/interface.at b/tests/interface.at index 113c22a..4cc41d9 100644 --- a/tests/interface.at +++ b/tests/interface.at @@ -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 diff --git a/testsuite.at b/testsuite.at index 025e78f..6511c42 100644 --- a/testsuite.at +++ b/testsuite.at @@ -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