From: Stefano Lattarini Date: Fri, 27 May 2011 13:05:40 +0000 (+0200) Subject: tests: improve `ccnoco*.test', better cross-compiling support X-Git-Tag: ng-0.5a~89^2~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e12798cb90f9d603285c77ee79f5f9ae658abde;p=thirdparty%2Fautomake.git tests: improve `ccnoco*.test', better cross-compiling support * tests/ccnoco3.test (Mycomp): Use the `$CC' chosen by `tests/defs' instead of forcing `gcc' unconditionally. This ensures better coverage in case of cross-compiling, when GCC can be named e.g., `i586-mingw32msvc-gcc', instead of simply `gcc'. * tests/ccnoco.test: Likewise. Remove redundant checks. Modernize the created `configure.in'. Run tests both in-tree and in VPATH. Export `CC' to the overridden value only once. * tests/ccnoco2.test: Slightly stricter grepping of automake stderr. Add trailing `:' command. --- diff --git a/ChangeLog b/ChangeLog index 91f4f99ac..80b3c500f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-05-27 Stefano Lattarini + + tests: improve `ccnoco*.test', better cross-compiling support + * tests/ccnoco3.test (Mycomp): Use the `$CC' chosen by `tests/defs' + instead of forcing `gcc' unconditionally. This ensures better + coverage in case of cross-compiling, when GCC can be named e.g., + `i586-mingw32msvc-gcc', instead of simply `gcc'. + * tests/ccnoco.test: Likewise. Remove redundant checks. Modernize + the created `configure.in'. Run tests both in-tree and in VPATH. + Export `CC' to the overridden value only once. + * tests/ccnoco2.test: Slightly stricter grepping of automake + stderr. Add trailing `:' command. + 2011-05-27 Stefano Lattarini testsuite: each test case depends on `defs-static' diff --git a/tests/ccnoco.test b/tests/ccnoco.test index fb22ba74f..bcd18fcda 100755 --- a/tests/ccnoco.test +++ b/tests/ccnoco.test @@ -20,22 +20,12 @@ required=gcc . ./defs || Exit 1 -cat > configure.1 << 'END' -AC_INIT(a.c) -AM_INIT_AUTOMAKE(nonesuch, 0.23) +cat >> configure.in << 'END' AC_PROG_CC AM_PROG_CC_C_O -AC_OUTPUT(Makefile) -END - -# This one makes sure that $CC can be used after AM_PROG_CC_C_O. -cat > configure.3 << 'END' -AC_INIT(a.c) -AM_INIT_AUTOMAKE(nonesuch, 0.23) -AC_PROG_CC -AM_PROG_CC_C_O -$CC -v > Hi 2>&1 || exit 1 -AC_OUTPUT(Makefile) +# Make sure that $CC can be used after AM_PROG_CC_C_O. +$CC -v || exit 1 +AC_OUTPUT END cat > Makefile.am << 'END' @@ -54,16 +44,17 @@ int main () } END -cat > Mycomp << 'END' +cat > Mycomp << END #!/bin/sh -case " "$* in +case " \$* " in *\ -c*\ -o* | *\ -o*\ -c*) exit 1 ;; esac -exec gcc "$@" +# Use '$CC', not 'gcc', to honour the compiler chosen by 'tests/defs'. +exec $CC "\$@" END chmod +x Mycomp @@ -72,25 +63,25 @@ chmod +x Mycomp CFLAGS= export CFLAGS -for conf in configure.1 configure.3; do - cp $conf configure.in - - $ACLOCAL - $AUTOCONF - $AUTOMAKE --copy --add-missing - - rm -rf build - mkdir build - cd build - - # Make sure the compiler doesn't understand `-c -o' - CC=`pwd`/../Mycomp - export CC - - ../configure - $MAKE - - cd .. +# Make sure the compiler doesn't understand `-c -o' +CC=`pwd`/Mycomp +export CC + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --copy --add-missing + +for vpath in : false; do + if $vpath; then + srcdir=.. + mkdir build + cd build + else + srcdir=. + fi + $srcdir/configure + $MAKE + cd $srcdir done : diff --git a/tests/ccnoco2.test b/tests/ccnoco2.test index a724448f2..4c6b22bbb 100755 --- a/tests/ccnoco2.test +++ b/tests/ccnoco2.test @@ -35,7 +35,7 @@ touch a.c $ACLOCAL $AUTOCONF AUTOMAKE_fails --copy --add-missing -grep 'Makefile.am:2:.*per-target.*AM_PROG_CC_C_O' stderr +grep '^Makefile\.am:2:.*per-target.*AM_PROG_CC_C_O' stderr cat >Makefile.am <> Makefile.am AUTOMAKE_fails --copy --add-missing -grep 'Makefile.am:2:.*subdir.*AM_PROG_CC_C_O' stderr +grep '^Makefile\.am:2:.*subdir.*AM_PROG_CC_C_O' stderr + +: diff --git a/tests/ccnoco3.test b/tests/ccnoco3.test index 92ccf79b4..2a32f6b1f 100755 --- a/tests/ccnoco3.test +++ b/tests/ccnoco3.test @@ -23,6 +23,7 @@ required=gcc cat >> configure.in << 'END' AC_PROG_CC AM_PROG_CC_C_O +$CC --version; $CC -v; # For debugging. AC_OUTPUT END @@ -43,16 +44,17 @@ int main () } END -cat > Mycomp << 'END' +cat > Mycomp << END #!/bin/sh -case " "$* in +case " \$* " in *\ -c*\ -o* | *\ -o*\ -c*) exit 1 ;; esac -exec gcc "$@" +# Use '$CC', not 'gcc', to honour the compiler chosen by 'tests/defs'. +exec $CC "\$@" END chmod +x Mycomp @@ -77,4 +79,4 @@ $MAKE 2>stderr || { cat stderr >&2; Exit 1; } cat stderr >&2 grep 'mv.*the same file' stderr && Exit 1 -Exit 0 +: