]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: improve `ccnoco*.test', better cross-compiling support
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 27 May 2011 13:05:40 +0000 (15:05 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 27 May 2011 13:05:40 +0000 (15:05 +0200)
* 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.

ChangeLog
tests/ccnoco.test
tests/ccnoco2.test
tests/ccnoco3.test

index 91f4f99ac2f5b29bdf45a70119ae078bf5fd564f..80b3c500f1d10596d09e43ee22eefffca7e07e22 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-05-27  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       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  <stefano.lattarini@gmail.com>
 
        testsuite: each test case depends on `defs-static'
index fb22ba74fbe891acc897306e0c42b61345e2425c..bcd18fcda936bb44bb421ef7f7e632a87bd10882 100755 (executable)
 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
 
 :
index a724448f2338031ae5649b5e1bc6cd68b9bd4b6c..4c6b22bbb31c851401498020bd4c66f9140726b9 100755 (executable)
@@ -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 <<EOF
@@ -50,4 +50,6 @@ $AUTOMAKE --copy --add-missing
 
 echo 'AUTOMAKE_OPTIONS = subdir-objects' >> 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
+
+:
index 92ccf79b44ddd90fb1173d16185e910a74f8f5d3..2a32f6b1f275a3f4cd2400a26f88e577c7b517a6 100755 (executable)
@@ -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
+: