+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'
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'
}
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
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
:
$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
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
+
+:
cat >> configure.in << 'END'
AC_PROG_CC
AM_PROG_CC_C_O
+$CC --version; $CC -v; # For debugging.
AC_OUTPUT
END
}
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
cat stderr >&2
grep 'mv.*the same file' stderr && Exit 1
-Exit 0
+: