]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
parallel-tests: fix another BSD parallel make issue
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 18 Feb 2012 12:59:26 +0000 (13:59 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 18 Feb 2012 22:12:30 +0000 (23:12 +0100)
When BSD make is run in parallel mode, it apparently strips any
leading directory component from the automatic variable '$*' (of
course, against what POSIX mandates).  This was causing FreeBSD 9.0
make and NetBSD 5.1 make to spuriously fail with automake-generated
test harnesses if subdir tests were present *and* make was being
run in parallel mode.  This issue affected also the Automake own
testsuite.

* lib/am/check2.am (am__set_b): New internal variable.
(%OBJ%, %EXT%.log, %EXT%$(EXEEXT).log): Use it to work around
the described BSD make issue.
* tests/parallel-tests3.test: Enhanced to expose the bug.
* tests/parallel-tests-subdir.test: Enhance a little, since we
are at it.
* NEWS: Update.

NEWS
lib/am/check2.am
tests/parallel-tests-subdir.test
tests/parallel-tests3.test

diff --git a/NEWS b/NEWS
index 252fcf7e6f9b9eb5db4ec4b131fff5af8e89551b..c1de9b2808ed0daad07e5d932051edae889dd6ed 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -154,6 +154,12 @@ Bugs fixed in 1.11a:
   - The AM_COND_IF macro also works if the shell expression for the
     conditional is no longer valid for the condition.
 
+  - The automake-provided parallel testsuite harness does not fail anymore
+    with BSD make used in parallel mode when there are test scripts in a
+    subdirectory, like in:
+
+      TESTS = sub/foo.test sub/bar.test
+
 * Long-standing bugs:
 
   - Automake's own build system finally have a real "installcheck" target.
index a14e775cde70485a18d1f7ae380b3c98c963b139..9847a449f41de74e87afdf49150398cb558e6b14 100644 (file)
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+if %?FIRST%
+## When BSD make is run in parallel mode, it apparently strips any
+## leading directory component from the automatic variable '$*' (of
+## course, against what POSIX mandates).  Try to detect and work
+## around this incompatibility.
+am__set_b = \
+  case '$@' in \
+    */*) \
+      case '$*' in \
+        */*) b='$*';; \
+          *) b=`echo '$@' | sed 's/\.log$$//'`; \
+       esac;; \
+    *) \
+      b='$*';; \
+  esac
+endif %?FIRST%
+
 ## From a test file to a .log and .trs file.
 ?GENERIC?%EXT%.log:
 ?!GENERIC?%OBJ%: %SOURCE%
-       @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \
-       --log-file '%BASE%.log' --trs-file '%BASE%.trs' \
+       @p='%SOURCE%'; \
+## Another hack to support BSD make in parallel mode.
+?!GENERIC?     b='%BASE%'; \
+?GENERIC?      $(am__set_b); \
+       $(am__check_pre) %DRIVER% --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \
        "$$tst" $(AM_TESTS_FD_REDIRECT)
 
 ## conflict with the previous one.
 if %am__EXEEXT%
 ?GENERIC?%EXT%$(EXEEXT).log:
-       @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \
-       --log-file '%BASE%.log' --trs-file '%BASE%.trs' \
+       @p='%SOURCE%'; \
+       ## Another hack to support BSD make in parallel mode.
+?!GENERIC?     b='%BASE%'; \
+?GENERIC?      $(am__set_b); \
+       $(am__check_pre) %DRIVER% --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \
        "$$tst" $(AM_TESTS_FD_REDIRECT)
 endif %am__EXEEXT%
index 81de2f0c8ea737718fbc47b4458f1c302256cbe1..7e7e031a43bd0dd7dfc7ede12f49e83a42251def 100755 (executable)
@@ -44,6 +44,8 @@ $MAKE check
 find . # For debugging.
 test -f test-suite.log
 test -f dir1/foo.log
+test -f dir1/foo.trs
 test -f dir2/dir3/foo.log
+test -f dir2/dir3/foo.trs
 
 :
index 3e6e1897f78b593eee6e9d17cda51379990a1035..f146d0f3410a452bad381da2a8333cc49d99b6f1 100755 (executable)
 # - concurrent parallel execution
 
 am_parallel_tests=yes
-required=GNUmake
 . ./defs || Exit 1
 
 case $MAKE in
   *\ -j*) skip_ "\$MAKE contains \`-j'";;
 esac
 
+using_gmake || echo "all:" | $MAKE -f - -j4 all \
+  || skip_ "can't run make in parallel mode"
+
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
@@ -33,16 +35,25 @@ cat > Makefile.am << 'END'
 TESTS =
 END
 
-for i in 1 2 3 4 5 6 7 8; do
-  echo "TESTS += foo$i.test" >> Makefile.am
-  unindent >foo$i.test <<'END'
-    #! /bin/sh
-    echo "this is $0"
-    # Creative quoting below to please maintainer-check.
-    sleep '1'
-    exit 0
+cat > x <<'END'
+#! /bin/sh
+echo "this is $0"
+# Creative quoting below to please maintainer-check.
+sleep '1'
+exit 0
 END
-  chmod a+x foo$i.test
+chmod a+x ./x
+
+mkdir sub
+for i in 1 2 3; do
+  echo "TESTS += foo$i.test" >> Makefile.am
+  cp x foo$i.test
+  echo "TESTS += zap$i" >> Makefile.am
+  cp x zap$i
+  echo "TESTS += sub/bar$i.test" >> Makefile.am
+  cp x sub/bar$i.test
+  echo "TESTS += sub/mu$i" >> Makefile.am
+  cp x sub/mu$i
 done
 
 $ACLOCAL
@@ -71,7 +82,7 @@ cd ..
 # still be ongoing when the parallel one has terminated.
 kill -0 $!
 cat parallel/stdout
-test `grep -c '^PASS:' parallel/stdout` -eq 8
+test `grep -c '^PASS:' parallel/stdout` -eq 12
 
 # Wait long enough so that there are no open files any more when the
 # post-test cleanup runs.  But exit after we've waited for two minutes