From: Stefano Lattarini Date: Sun, 6 May 2012 18:59:28 +0000 (+0200) Subject: [ng] built sources: enhance testsuite coverage X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e567cbffd187ccca1dfa119d269d20872dff68b;p=thirdparty%2Fautomake.git [ng] built sources: enhance testsuite coverage This will be useful to better check the correctness of later changes. * t/built-sources.sh: New test, checks basic functionality for BUILT_SOURCES. * t/built-sources.sh: New test, checks basic interaction between BUILT_SOURCES and Automake conditionals. * t/check3.sh: Split this out ... * t/built-sources-check.sh, t/built-sources-install.sh: ... into these tests, to offer more granularity and make the purpose of the tests immediately clear from their names. * t/subdirbuiltsources.sh: Rename this ... * t/built-sources-subdir.sh: ... to this, for consistency. Since we are at it, fix a couple of typos and remove redundant stuff. Signed-off-by: Stefano Lattarini --- diff --git a/t/check3.sh b/t/built-sources-check.sh similarity index 87% rename from t/check3.sh rename to t/built-sources-check.sh index 69b6a674c..8ac82f90f 100755 --- a/t/check3.sh +++ b/t/built-sources-check.sh @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Make sure 'check:' and 'install:' honor $(BUILT_SOURCES). +# Make sure 'check:' honors $(BUILT_SOURCES). # PR/359. # For gen-testsuite-part: ==> try-with-serial-tests <== @@ -68,13 +68,6 @@ grep 'PASS.*echo\.sh' stdout && Exit 1 $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in -$MAKE clean -# Sanity checks -test ! -f command1.inc -test ! -f dir/command2.inc -# Now make sure these two files are rebuilt during make install. -$MAKE install -test -f command1.inc -test -f dir/command2.inc +$MAKE distcheck : diff --git a/t/built-sources-cond.sh b/t/built-sources-cond.sh new file mode 100755 index 000000000..d74ababac --- /dev/null +++ b/t/built-sources-cond.sh @@ -0,0 +1,91 @@ +#! /bin/sh +# Copyright (C) 2003-2012 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 . + +# Interaction of BUILT_SOURCES with conditionals. + +. ./defs || Exit 1 + +cat >> configure.ac <<'END' +AM_CONDITIONAL([COND1], [test $cond1 = yes]) +AM_CONDITIONAL([COND2], [test $cond2 = yes]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +if COND1 +BUILT_SOURCES = a +else +BUILT_SOURCES = b +endif +if COND2 +BUILT_SOURCES += c +endif + +a b c: + echo who cares > $@ +END + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +cleanup () +{ + # Files in $(BUILT_SOURCES) should be automatically removed + # upon maintainer-clean. + $MAKE maintainer-clean + test ! -f a + test ! -f b + test ! -f c +} + +./configure cond1=yes cond2=yes + +$MAKE +test -f a +test ! -f b +test -f c + +cleanup + +./configure cond1=no cond2=yes + +$MAKE +test ! -f a +test -f b +test -f c + +cleanup + +./configure cond1=yes cond2=no + +$MAKE +test -f a +test ! -f b +test ! -f c + +cleanup + +./configure cond1=no cond2=no + +$MAKE +test ! -f a +test -f b +test ! -f c + +cleanup + +: diff --git a/t/built-sources-install.sh b/t/built-sources-install.sh new file mode 100755 index 000000000..307864c34 --- /dev/null +++ b/t/built-sources-install.sh @@ -0,0 +1,69 @@ +#! /bin/sh +# Copyright (C) 2002-2012 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 . + +# Make sure 'install:' honors $(BUILT_SOURCES). +# PR/359. + +. ./defs || Exit 1 + +cat >> configure.ac << 'END' +AC_CONFIG_FILES([dir/Makefile]) +AC_OUTPUT +END + +mkdir dir + +cat > Makefile.am << 'END' +BUILT_SOURCES = built1 +SUBDIRS = dir +built1: + echo ok > $@ +CLEANFILES = built1 +install-data-hook: + $(MKDIR_P) $(DESTDIR)$(prefix)/dir2 + cp built1 $(DESTDIR)$(prefix)/built1 + cp dir/built2 $(DESTDIR)$(prefix)/dir2/built3 +uninstall-hook: + rm -f $(DESTDIR)$(prefix)/built1 + rm -f $(DESTDIR)$(prefix)/dir2/built3 + rmdir $(DESTDIR)$(prefix)/dir2 +installcheck-local: + test -f $(prefix)/built1 + test -f $(prefix)/dir2/built3 +END + +cat > dir/Makefile.am << 'END' +BUILT_SOURCES = built2 +built2: +## The next line ensures that command1.inc has been built before +## recurring into the subdir. + cp ../built1 $@ +CLEANFILES = built2 +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure --prefix "`pwd`/inst" + +# Now make sure these two files are rebuilt during make install. +$MAKE install +test -f built1 +test -f dir/built2 +$MAKE installcheck +$MAKE distcheck + +: diff --git a/t/subdirbuiltsources.sh b/t/built-sources-subdir.sh similarity index 76% rename from t/subdirbuiltsources.sh rename to t/built-sources-subdir.sh index 2f507083e..976b7941a 100755 --- a/t/subdirbuiltsources.sh +++ b/t/built-sources-subdir.sh @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Make sure when using SUBDIR that all BUILT_SOURCES are built. +# Make sure when using SUBDIRS that all BUILT_SOURCES are built. # A bug occurred where subdirs do not have all-recursive or # all-recursive-am which depended on BUILT_SOURCES. @@ -31,14 +31,6 @@ AM_PROG_AR AC_OUTPUT END -# Files required because we are using '--gnu'. -: > INSTALL -: > NEWS -: > README -: > COPYING -: > AUTHORS -: > ChangeLog - cat > Makefile.am << 'END' SUBDIRS = lib END @@ -47,25 +39,22 @@ cat > lib/Makefile.am << 'END' pkgdata_DATA = noinst_LIBRARIES = libfoo.a libfoo_a_SOURCES = foo.c -BUILT_SOURCES=foo.h +BUILT_SOURCES = foo.h foo.h: echo \#define FOO_DEFINE 1 >$@ END cat > lib/foo.c << 'END' #include -int foo () { return !FOO_DEFINE;} +int foo () { return !FOO_DEFINE; } END $ACLOCAL $AUTOCONF -$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu +$AUTOMAKE --copy --add-missing ./configure - -# Remove the comment to get a successful test. -# $MAKE -C lib foo.h $MAKE : diff --git a/t/built-sources.sh b/t/built-sources.sh new file mode 100755 index 000000000..b60a637cc --- /dev/null +++ b/t/built-sources.sh @@ -0,0 +1,66 @@ +#! /bin/sh +# Copyright (C) 2003-2012 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 . + +# Basic test on BUILT_SOURCES. + +required=cc +. ./defs || Exit 1 + +cat >> configure.ac <<'END' +AC_PROG_CC +AC_OUTPUT +END + +cat > Makefile.am << 'END' +BUILT_SOURCES = foo.c +noinst_PROGRAMS = bar baz +foo.c: + rm -f $@ $@-t + echo '#include ' > $@-t + echo 'int main (void)' >> $@-t + echo '{ ' >> $@-t + echo ' printf ("%s\n", FOOMSG);' >> $@-t + echo ' return 0;' >> $@-t + echo '}' >> $@-t + mv -f $@-t $@ +CLEANFILES = foo.c +END + +cat > bar.c <<'END' +#define FOOMSG "Howdy, World" +#include "foo.c" +END + +cat > baz.c <<'END' +#define FOOMSG "Hello, Earth" +#include "foo.c" +END + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE +if cross_compiling; then :; else + ./bar + ./bar | grep 'Howdy, World' + ./baz + ./baz | grep 'Hello, Earth' +fi +$MAKE distcheck + +: