From a9b6cf1675cfa98b65452608aa5b66bd0af3ef61 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 15 Feb 2024 13:50:31 -0500 Subject: [PATCH] Add 'atf-sh' detection to configure The configure script now checks for the 'atf-sh' binary when the test suite is enabled. The binary found is then used in the test script shebang. As an added bonus, the test script generation is now done by AC_CONFIG_FILES instead of the Makefile copy custom rules. Signed-off-by: Michael Jeanson --- Makefile.am | 34 ++++++------------- configure.ac | 14 ++++++++ ...unctional-tests.sh => functional-tests.in} | 2 +- tests/{mlmmj-bounce.sh => mlmmj-bounce.in} | 2 +- tests/{mlmmj-list.sh => mlmmj-list.in} | 2 +- tests/{mlmmj-maintd.sh => mlmmj-maintd.in} | 2 +- tests/{mlmmj-process.sh => mlmmj-process.in} | 2 +- tests/{mlmmj-receive.sh => mlmmj-receive.in} | 2 +- tests/{mlmmj-send.sh => mlmmj-send.in} | 2 +- tests/{mlmmj-sub.sh => mlmmj-sub.in} | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) rename tests/{functional-tests.sh => functional-tests.in} (98%) rename tests/{mlmmj-bounce.sh => mlmmj-bounce.in} (99%) rename tests/{mlmmj-list.sh => mlmmj-list.in} (99%) mode change 100755 => 100644 rename tests/{mlmmj-maintd.sh => mlmmj-maintd.in} (99%) mode change 100755 => 100644 rename tests/{mlmmj-process.sh => mlmmj-process.in} (98%) rename tests/{mlmmj-receive.sh => mlmmj-receive.in} (97%) mode change 100755 => 100644 rename tests/{mlmmj-send.sh => mlmmj-send.in} (98%) rename tests/{mlmmj-sub.sh => mlmmj-sub.in} (98%) mode change 100755 => 100644 diff --git a/Makefile.am b/Makefile.am index 3d0c917d..91673afd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,32 +35,18 @@ tests_mlmmj_LDADD = \ tests_fakesmtpd_SOURCES = \ tests/fakesmtpd.c -EXTRA_DIST += \ - tests/*.sh - -CLEANFILES += \ - $(test_scripts:.sh=) - test_scripts = \ - tests/mlmmj-send.sh \ - tests/functional-tests.sh \ - tests/mlmmj-maintd.sh \ - tests/mlmmj-sub.sh \ - tests/mlmmj-bounce.sh \ - tests/mlmmj-list.sh \ - tests/mlmmj-process.sh \ - tests/mlmmj-receive.sh - -check_SCRIPTS = \ - $(test_scripts:.sh=) - -# Copy the test scripts striped of the '.sh' extension in the build directory -SUFFIXES = .sh -.sh: - install -m 755 $< $@ + tests/mlmmj-send \ + tests/functional-tests \ + tests/mlmmj-maintd \ + tests/mlmmj-sub \ + tests/mlmmj-bounce \ + tests/mlmmj-list \ + tests/mlmmj-process \ + tests/mlmmj-receive # Run the Kyua test suite when the 'check' target is invoked -check-local: $(check_SCRIPTS) $(check_PROGRAMS) +check-local: $(check_PROGRAMS) $(test_scripts) failed=no; \ $(KYUA) --config='$(top_builddir)/kyua.conf' test \ --kyuafile='$(top_srcdir)/Kyuafile' --build-root='$(top_builddir)' \ @@ -72,6 +58,6 @@ check-local: $(check_SCRIPTS) $(check_PROGRAMS) fi # Build the test programs when the 'all' target is invoked -all-local: $(check_PROGRAMS) $(check_SCRIPTS) +all-local: $(check_PROGRAMS) endif diff --git a/configure.ac b/configure.ac index e2b8ee0f..b066d8f6 100644 --- a/configure.ac +++ b/configure.ac @@ -79,11 +79,16 @@ AC_CHECK_FUNCS([arc4random_uniform copy_file_range]) AS_IF([test x"$enable_tests" = xyes], [ PKG_CHECK_MODULES([ATF], [atf-c]) + AC_PATH_PROG([ATFSH], [atf-sh]) AC_PATH_PROG([KYUA], [kyua]) AS_IF([test "x$KYUA" == "x"], [ AC_MSG_ERROR([A 'kyua' binary is required when the tests are enabled. Set the PATH or use the KYUA environment variable to specify its location.]) ]) + + AS_IF([test "x$ATFSH" == "x"], [ + AC_MSG_ERROR([An 'atf-sh' binary is required when the tests are enabled. Set the PATH or use the ATFSH environment variable to specify its location.]) + ]) ]) AM_CONDITIONAL([WANT_TESTS], [test x"$enable_tests" = xyes]) @@ -104,4 +109,13 @@ AC_CONFIG_FILES([listtexts/Makefile]) AC_CONFIG_FILES([contrib/Makefile]) AC_CONFIG_FILES([contrib/receivestrip/Makefile]) AC_CONFIG_FILES([tests/test_env.sh]) +AC_CONFIG_FILES([tests/functional-tests],[chmod +x tests/functional-tests]) +AC_CONFIG_FILES([tests/mlmmj-bounce],[chmod +x tests/mlmmj-bounce]) +AC_CONFIG_FILES([tests/mlmmj-list],[chmod +x tests/mlmmj-list]) +AC_CONFIG_FILES([tests/mlmmj-maintd],[chmod +x tests/mlmmj-maintd]) +AC_CONFIG_FILES([tests/mlmmj-process],[chmod +x tests/mlmmj-process]) +AC_CONFIG_FILES([tests/mlmmj-receive],[chmod +x tests/mlmmj-receive]) +AC_CONFIG_FILES([tests/mlmmj-send],[chmod +x tests/mlmmj-send]) +AC_CONFIG_FILES([tests/mlmmj-sub],[chmod +x tests/mlmmj-sub]) + AC_OUTPUT diff --git a/tests/functional-tests.sh b/tests/functional-tests.in similarity index 98% rename from tests/functional-tests.sh rename to tests/functional-tests.in index 787a4d0f..a655259e 100644 --- a/tests/functional-tests.sh +++ b/tests/functional-tests.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-bounce.sh b/tests/mlmmj-bounce.in similarity index 99% rename from tests/mlmmj-bounce.sh rename to tests/mlmmj-bounce.in index a4492007..73776e00 100644 --- a/tests/mlmmj-bounce.sh +++ b/tests/mlmmj-bounce.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-list.sh b/tests/mlmmj-list.in old mode 100755 new mode 100644 similarity index 99% rename from tests/mlmmj-list.sh rename to tests/mlmmj-list.in index cb83bf3a..3b75a191 --- a/tests/mlmmj-list.sh +++ b/tests/mlmmj-list.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-maintd.sh b/tests/mlmmj-maintd.in old mode 100755 new mode 100644 similarity index 99% rename from tests/mlmmj-maintd.sh rename to tests/mlmmj-maintd.in index b3552121..34152bca --- a/tests/mlmmj-maintd.sh +++ b/tests/mlmmj-maintd.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-process.sh b/tests/mlmmj-process.in similarity index 98% rename from tests/mlmmj-process.sh rename to tests/mlmmj-process.in index d7320b65..1741cd3d 100644 --- a/tests/mlmmj-process.sh +++ b/tests/mlmmj-process.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-receive.sh b/tests/mlmmj-receive.in old mode 100755 new mode 100644 similarity index 97% rename from tests/mlmmj-receive.sh rename to tests/mlmmj-receive.in index a4cce297..5d824f96 --- a/tests/mlmmj-receive.sh +++ b/tests/mlmmj-receive.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-send.sh b/tests/mlmmj-send.in similarity index 98% rename from tests/mlmmj-send.sh rename to tests/mlmmj-send.in index 8623bbc9..e92f2ae6 100644 --- a/tests/mlmmj-send.sh +++ b/tests/mlmmj-send.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh diff --git a/tests/mlmmj-sub.sh b/tests/mlmmj-sub.in old mode 100755 new mode 100644 similarity index 98% rename from tests/mlmmj-sub.sh rename to tests/mlmmj-sub.in index 3df33b52..b2dfe13a --- a/tests/mlmmj-sub.sh +++ b/tests/mlmmj-sub.in @@ -1,4 +1,4 @@ -#!/usr/bin/env atf-sh +#!@ATFSH@ . $(atf_get_srcdir)/test_env.sh -- 2.47.2