From: Stefano Lattarini Date: Fri, 20 May 2011 21:35:26 +0000 (+0200) Subject: Merge branch 'maint' into java-work X-Git-Tag: ng-0.5a~123^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30f8ffc019653ba9b0ab47deda155d0efe660c8f;p=thirdparty%2Fautomake.git Merge branch 'maint' into java-work * maint: testsuite: avoid re-running few tests with 'parallel-tests' option testsuite: allow tests to avoid the use of 'parallel-tests' option tests/README: update obsoleted advice With extra edits to these files: - tests/java-compile-run-flat.test - tests/java-compile-run-nested.test - ChangeLog - tests/Makefile.in (autogenerated) --- 30f8ffc019653ba9b0ab47deda155d0efe660c8f diff --cc ChangeLog index 33c4c9e01,363112927..b6702cb57 --- a/ChangeLog +++ b/ChangeLog @@@ -1,3 -1,43 +1,48 @@@ + 2011-05-20 Stefano Lattarini + + testsuite: avoid re-running few tests with 'parallel-tests' option + Some tests in our testsuite use the 'simple-tests' driver only + marginally, or simply as a mean to conveniently check unrelated + invariants. It makes little sense to force these tests to also + run with the 'parallel-tests' Automake option active, as doing so + offers no real gain in coverage, while often causing a measurable + overhead in execution time (for an already too-slow testsuite). + * tests/pr401.test (parallel_tests): Define to "no", to prevent + the generation of a sibling test script using the 'parallel-tests' + driver. + * tests/pr401b.test: Likewise. + * tests/pr401c.test: Likewise. ++ * tests/java-flat.test: Likewise, and properly update heading ++ comments. ++ * tests/java-nested.test: Likewise, but defining `parallel_tests' ++ to "yes" instead, for improved coverage in conjunction with the ++ sister test `java-flat.test'. + + 2011-05-20 Stefano Lattarini + + testsuite: allow tests to avoid the use of 'parallel-tests' option + * tests/gen-parallel-tests: Do not generate "siblings" for tests + that explicitly define the `parallel_tests', whether to "yes" or + to any other value. Extend heading comments to give a rationale + for this behaviour. + * tests/README: Update. + + 2011-05-20 Stefano Lattarini + + tests/README: update obsoleted advice + * tests/README (Section "Writing test cases" subsection "Do"): + Do not suggest to use the `*-p.test' pattern for the names of + hand-written tests which use the `parallel-tests' Automake option. + Not only is this not respected by the existing tests, but it is + more likely to cause conflicts with auto-generated tests. + So, suggest to *avoid* using the `*-p.test' pattern in names + of hand-written tests instead. + (Section "Writing test cases" subsection "Do not"): When + suggesting not to override Makefile variables using command + line arguments, do not use the badly outdated variables `U' + and 'ANSI2KNR' in the example; instead, use the more common + and typical `DESTDIR'. + 2011-05-19 Stefano Lattarini test defs: rename requirement 'non-cross' -> 'native' diff --cc tests/java-compile-run-flat.test index 76fde6c69,000000000..0d5651e29 mode 100755,000000..100755 --- a/tests/java-compile-run-flat.test +++ b/tests/java-compile-run-flat.test @@@ -1,238 -1,0 +1,241 @@@ +#! /bin/sh +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test on compilation and execution of Java class files. +# Also meddle with wrapper scripts, as would be probably seen in a real +# "UNIX-style" use case. +# This test uses a "flat" setup for the source tree (i.e., everything in - # the top-level directory); the sister test `java-compile-run-nested.test' - # do similar checks with a more usual, "nested" setup. ++# the top-level directory), and forces the use of the old, non-parallel ++# testsuite driver. The sister test `java-compile-run-nested.test' do ++# similar checks with a more usual, "nested" setup, and using the newer ++# 'parallel-tests' driver. + +required='java javac' ++parallel_tests=no +. ./defs || Exit 1 + +set -e + +echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in + +cat >> configure.in <<'END' +AC_SUBST([JAVA], [java]) +AC_CONFIG_SRCDIR([PkgLocation.jin]) +AC_CONFIG_FILES([PkgLocation.java:PkgLocation.jin]) +AC_OUTPUT +END + +## TOP-LEVEL SETUP AND TARGETS ## + +cat > Makefile.am <<'END' +EXTRA_DIST = # Will be updated later. + +test-built: + ls -l $(srcdir) ;: For debugging. + test $(srcdir) = . || ls -l . ;: Likewise. + test -f $(srcdir)/Main.java + test -f $(srcdir)/HelloStream.java + test -f $(srcdir)/PkgLocation.jin + test -f PkgLocation.java + test -f HelloStream.class + test -f PkgLocation.class + test -f Main.class + test -f classjava.stamp + +test-installed: + ls -l $(javadir) ;: For debugging. + test -f $(javadir)/HelloStream.class + test -f $(javadir)/PkgLocation.class + test -f $(javadir)/Main.class + if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi + +run-installed: + jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check + +check-local: test-built +installcheck-local: test-installed run-installed + +.PHONY: test-built test-installed run-installed +END + +## WRAPPER SCRIPT ## + +cat >> Makefile.am <<'END' +bin_SCRIPTS = jprog + +edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \ + -e 's|[@]javadir@|$(javadir)|g' \ + -e 's|[@]SHELL@|$(SHELL)|g' \ + -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g' + +jprog: jprog.sh + rm -f $@ $@-t + $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t + chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@ + sed 's/^/ | /' $@ ;: for debugging. + +EXTRA_DIST += jprog.sh +CLEANFILES = jprog +END + +cat > jprog.sh <<'END' +#!@SHELL@ +CLASSPATH=${jprog_classpath-'@javadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"} +export CLASSPATH +case $# in + 0) exec @JAVA@ Main;; + *) exec @JAVA@ Main "$@";; +esac +END + +## JAVA SOURCES ## + +cat >> Makefile.am <<'END' +javadir = $(pkgdatadir)/java + +dist_java_JAVA = Main.java HelloStream.java +nodist_java_JAVA = PkgLocation.java +END + +cat > PkgLocation.jin <<'END' +public class PkgLocation { + public static String prefix() { + return new String("@prefix@"); + } +} +END + +cat > Main.java <<'END' +public class Main { + public static void main(String[] args) { + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--print-prefix")) { + System.out.println(PkgLocation.prefix()); + } else if (args[i].equals("--hello-stdout")) { + HelloStream.to(System.out); + } else if (args[i].equals("--hello-stderr")) { + HelloStream.to(System.err); + } else { + System.err.println("jprog: invalid option '" + args[i] + + "'"); + System.exit(2); + } + } + System.exit(0); + } +} +END + +cat > HelloStream.java <<'END' +import java.io.PrintStream; +class HelloStream { + public static void to(PrintStream stream) { + stream.println("Hello, Stream!"); + } +} +END + +## TESTS ## + +cat >> Makefile.am <<'END' +## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available. +TESTS_ENVIRONMENT = \ + if test x"$$jprog_doing_installcheck" != x"yes"; then \ + jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \ + export jprog_classpath; \ + PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + else \ + unset jprog_classpath || :; \ + PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + fi; \ + config_time_prefix='@prefix@'; export config_time_prefix; + +TESTS = \ + simple.test \ + prefix.test \ + stdout.test \ + stderr.test \ + badarg.test + +XFAIL_TESTS = badarg.test + +EXTRA_DIST += $(TESTS) +END + +cat > simple.test <<'END' +#!/bin/sh +jprog +END + +cat > prefix.test <<'END' +#!/bin/sh +jprefix=`jprog --print-prefix` || exit 1 +echo "$0: exp prefix: $config_time_prefix" +echo "$0: got prefix: $jprefix" +test x"$jprefix" = x"$config_time_prefix" +END + +cat > stdout.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' &2 # Likewise. +test -s stdout.err && rc=1 +test "`cat stdout.out`" = 'Hello, Stream!' || rc=1 +rm -f stdout.out stdout.err || rc=1 +exit $rc +END + +cat > stderr.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' &2 # Likewise. +test -s stderr.out && rc=1 +test "`cat stderr.err`" = 'Hello, Stream!' || rc=1 +rm -f stderr.out stderr.err || rc=1 +exit $rc +END + +cat > badarg.test <<'END' +#!/bin/sh +jprog --bad-argument +END + +chmod a+x *.test + +## DO CHECKS ## + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# To have the parallel testsuite more verbose. +VERBOSE=yes; export VERBOSE + +./configure --prefix="`pwd`/_inst" +cat PkgLocation.java # For debugging. +$MAKE check +$MAKE install +$MAKE test-installed +$MAKE run-installed +$MAKE distcheck + +: diff --cc tests/java-compile-run-nested.test index 1a9abfd6d,000000000..ec75c92ce mode 100755,000000..100755 --- a/tests/java-compile-run-nested.test +++ b/tests/java-compile-run-nested.test @@@ -1,251 -1,0 +1,254 @@@ +#! /bin/sh +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test on compilation and execution of Java class files. +# Also meddle with wrapper scripts, as would be probably seen in a real +# "UNIX-style" use case. +# This test uses a typical "nested" source tree setup (i.e., different - # componenets/aspects are separeted into different subdirectories); the - # sister test `java-compile-run-flat.test' do similar checks with a - # "flat" setup (i.e., everything in the top-level directory). ++# components/aspects are separated into different subdirectories), ++# and uses the 'parallel-tests' testsuite driver. The sister test ++# `java-compile-run-flat.test' do similar checks with a "flat" setup ++# (i.e., everything in the top-level directory), and forcing the use ++# of the older non-parallel 'simple-tests' driver. + +required='java javac' ++parallel_tests=yes +. ./defs || Exit 1 + +set -e + +echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.in + +cat >> configure.in <<'END' +AC_SUBST([JAVA], [java]) +AC_CONFIG_SRCDIR([jprog/PkgLocation.jin]) +AC_SUBST([jprogdatadir], ['${pkgdatadir}']) +AC_SUBST([jprogclassdir], ['${jprogdatadir}/jprog']) +AC_CONFIG_FILES([jprog/PkgLocation.java:jprog/PkgLocation.jin]) +AC_CONFIG_FILES([jprog/Makefile bin/Makefile tests/Makefile]) +AC_OUTPUT +END + +## TOP-LEVEL SETUP AND TARGETS ## + +cat > Makefile.am <<'END' +SUBDIRS = bin jprog tests + +test-built: + ls -l $(srcdir)/* ;: For debugging. + test $(srcdir) = . || ls -l * ;: Likewise. + test -f $(srcdir)/jprog/Main.java + test -f $(srcdir)/jprog/HelloStream.java + test -f $(srcdir)/jprog/PkgLocation.jin + test -f jprog/PkgLocation.java + test -f jprog/HelloStream.class + test -f jprog/Main.class + test -f jprog/PkgLocation.class + test -f jprog/classjprogclass.stamp + +test-installed: + ls -l $(jprogclassdir) ;: For debugging. + test -f $(jprogclassdir)/HelloStream.class + test -f $(jprogclassdir)/Main.class + test -f $(jprogclassdir)/PkgLocation.class + if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi + +run-installed: + jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check + +check-local: test-built +installcheck-local: test-installed run-installed + +.PHONY: test-built test-installed run-installed +END + +## WRAPPER SCRIPT ## + +mkdir bin + +cat > bin/Makefile.am <<'END' +bin_SCRIPTS = jprog + +edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \ + -e 's|[@]jprogdatadir@|$(jprogdatadir)|g' \ + -e 's|[@]SHELL@|$(SHELL)|g' \ + -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g' + +jprog: jprog.sh + rm -f $@ $@-t + $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t + chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@ + sed 's/^/ | /' $@ ;: for debugging. + +EXTRA_DIST = jprog.sh +CLEANFILES = jprog +END + +cat > bin/jprog.sh <<'END' +#!@SHELL@ +CLASSPATH=${jprog_classpath-'@jprogdatadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"} +export CLASSPATH +case $# in + 0) exec @JAVA@ jprog.Main;; + *) exec @JAVA@ jprog.Main "$@";; +esac +END + +## JAVA SOURCES ## + +mkdir jprog + +cat > jprog/Makefile.am <<'END' +dist_jprogclass_JAVA = Main.java HelloStream.java +nodist_jprogclass_JAVA = PkgLocation.java +END + +cat > jprog/PkgLocation.jin <<'END' +package jprog; +public class PkgLocation { + public static String prefix() { + return new String("@prefix@"); + } +} +END + +cat > jprog/Main.java <<'END' +package jprog; +import jprog.PkgLocation; +import jprog.HelloStream; +public class Main { + public static void main(String[] args) { + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--print-prefix")) { + System.out.println(PkgLocation.prefix()); + } else if (args[i].equals("--hello-stdout")) { + HelloStream.to(System.out); + } else if (args[i].equals("--hello-stderr")) { + HelloStream.to(System.err); + } else { + System.err.println("jprog: invalid option '" + args[i] + + "'"); + System.exit(2); + } + } + System.exit(0); + } +} +END + +cat > jprog/HelloStream.java <<'END' +package jprog; +import java.io.PrintStream; +class HelloStream { + public static void to(PrintStream stream) { + stream.println("Hello, Stream!"); + } +} +END + +## TESTS ## + +mkdir tests + +cat > tests/Makefile.am <<'END' +## FIXME: Use AM_TESTS_ENVIRONMENT here when it becomes available. +TESTS_ENVIRONMENT = \ + if test x"$$jprog_doing_installcheck" != x"yes"; then \ + jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \ + export jprog_classpath; \ + PATH='$(abs_top_builddir)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + else \ + unset jprog_classpath || :; \ + PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \ + export PATH; \ + fi; \ + config_time_prefix='@prefix@'; export config_time_prefix; + +TESTS = \ + simple.test \ + prefix.test \ + stdout.test \ + stderr.test \ + badarg.test + +XFAIL_TESTS = badarg.test + +EXTRA_DIST = $(TESTS) +END + +cat > tests/simple.test <<'END' +#!/bin/sh +jprog +END + +cat > tests/prefix.test <<'END' +#!/bin/sh +jprefix=`jprog --print-prefix` || exit 1 +echo "$0: exp prefix: $config_time_prefix" +echo "$0: got prefix: $jprefix" +test x"$jprefix" = x"$config_time_prefix" +END + +cat > tests/stdout.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' &2 # Likewise. +test -s stdout.err && rc=1 +test "`cat stdout.out`" = 'Hello, Stream!' || rc=1 +rm -f stdout.out stdout.err || rc=1 +exit $rc +END + +cat > tests/stderr.test <<'END' +#!/bin/sh +rc=0 +jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; } +sed 's/^/out:/' &2 # Likewise. +test -s stderr.out && rc=1 +test "`cat stderr.err`" = 'Hello, Stream!' || rc=1 +rm -f stderr.out stderr.err || rc=1 +exit $rc +END + +cat > tests/badarg.test <<'END' +#!/bin/sh +jprog --bad-argument +END + +chmod a+x tests/*.test + +## DO CHECKS ## + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# To have the parallel testsuite more verbose. +VERBOSE=yes; export VERBOSE + +./configure --prefix="`pwd`/_inst" +cat jprog/PkgLocation.java # For debugging. +$MAKE check +$MAKE install +$MAKE test-installed +$MAKE run-installed +$MAKE distcheck + +: