[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] autotest: add a simple test suite that runs a C program
From: |
Paolo Bonzini |
Subject: |
[PATCH 2/3] autotest: add a simple test suite that runs a C program |
Date: |
Sun, 16 Dec 2012 15:34:59 +0100 |
* tests/autotest.at (C unit tests): New testcase.
* NEWS: Document change.
Signed-off-by: Paolo Bonzini <address@hidden>
---
NEWS | 3 ++
lib/autoconf/autotest.m4 | 6 ++-
lib/autoconf/lang.m4 | 2 +-
tests/autotest.at | 112 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 121 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index d0a38a3..6fa116a 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,9 @@ GNU Autoconf NEWS - User visible changes.
but processing variable substitutions, command substitutions and
backslashes in the contents argument.
+- AC_CONFIG_TESTDIR will automatically pass EXEEXT to a testsuite (via
+ the atconfig file).
+
* Noteworthy changes in release 2.69 (2012-04-24) [stable]
diff --git a/lib/autoconf/autotest.m4 b/lib/autoconf/autotest.m4
index 64e3d56..fd8c36a 100644
--- a/lib/autoconf/autotest.m4
+++ b/lib/autoconf/autotest.m4
@@ -59,6 +59,9 @@ abs_top_builddir='$ac_abs_top_builddir'
# Backward compatibility with Autotest <= 2.59b:
at_top_builddir=\$at_top_build_prefix
+m4_provide_if([_AC_COMPILER_EXEEXT], [
+EXEEXT='$ac_cv_exeext'
+])dnl
AUTOTEST_PATH='m4_default([$2], [$1])'
SHELL=\${CONFIG_SHELL-'$SHELL'}
@@ -71,7 +74,8 @@ ERLCFLAGS='$ERLCFLAGS'
])dnl
ATEOF
],
-[m4_provide_if([AC_ERLANG_PATH_ERL], [ERL="$ERL"
+[m4_provide_if([_AC_COMPILER_EXEEXT], [ac_cv_exeext="$ac_cv_exeext"
+])m4_provide_if([AC_ERLANG_PATH_ERL], [ERL="$ERL"
])m4_provide_if([AC_ERLANG_PATH_ERLC], [ERLC="$ERLC"
ERLCFLAGS="$ERLCFLAGS"
])])])# AC_CONFIG_TESTDIR
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index 19852b8..fdaf4a1 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -656,7 +656,7 @@ AC_MSG_RESULT([$ac_cv_exeext])
# by checking whether `_AC_COMPILER_EXEEXT' has been expanded.
#
# See _AC_COMPILER_EXEEXT_CROSS for why we need _AC_LANG_IO_PROGRAM.
-m4_define([_AC_COMPILER_EXEEXT],
+AC_DEFUN([_AC_COMPILER_EXEEXT],
[AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
diff --git a/tests/autotest.at b/tests/autotest.at
index 82084b5..78e8c6b 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -1886,6 +1886,118 @@ AT_CHECK([grep 'two spaces' suite.log], [1])
AT_CLEANUP
+## --------------- ##
+## C executables. ##
+## --------------- ##
+
+AT_SETUP([C unit tests])
+AT_KEYWORDS([AC_@&address@hidden)
+
+mkdir t
+AT_DATA([configure.ac], [[AC_INIT
+AC_PROG_CC
+AC_CONFIG_TESTDIR([t], [.])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+# Test file
+AT_DATA([testprog.c],
+[[int main(int argc) { return argc == 2 ? 0 : 1; }
+]])
+
+# Testsuite
+AT_DATA([Makefile.in],
address@hidden@
address@hidden@
+
address@hidden@: testprog.o
+testprog.o: testprog.c
+.SUFFIXES: .c .o @EXEEXT@
+
+.c.o:
+ $(CC) -c $<
address@hidden@:
+ $(CC) -o $@ $^
+]])
+
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check C programs])
+AT_SETUP([my only test])
+AT_CHECK([testprog$EXEEXT foo], [0])
+AT_CHECK([testprog$EXEEXT], [1])
+AT_CLEANUP
+]], [], [], [], [t])
+
+rm t/atconfig
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([grep '^EXEEXT='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([make], [], [ignore])
+AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
+AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
+AT_CLEANUP
+
+
+## -------------------------------------- ##
+## C executables (force .exe extension). ##
+## -------------------------------------- ##
+
+AT_SETUP([C unit tests (EXEEXT)])
+AT_KEYWORDS([AC_@&address@hidden)
+
+mkdir t
+AT_DATA([configure.ac], [[AC_INIT
+AC_PROG_CC
+case $ac_cv_exeext in
+ '' | .exe) ;;
+ *) exit 77 ;;
+esac
+ac_cv_exeext=.exe
+AC_SUBST([EXEEXT], [$ac_cv_exeext])
+AC_CONFIG_TESTDIR([t], [.])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+# Test file
+AT_DATA([testprog.c],
+[[int main(int argc) { return argc == 2 ? 0 : 1; }
+]])
+
+# Testsuite
+AT_DATA([Makefile.in],
address@hidden@
address@hidden@
+
address@hidden@: testprog.o
+testprog.o: testprog.c
+.SUFFIXES: .c .o @EXEEXT@
+
+.c.o:
+ $(CC) -c $<
address@hidden@:
+ $(CC) -o $@ $^
+]])
+
+AT_CHECK_AT_PREP([suite],
+[[AT_INIT([suite to check C programs])
+AT_SETUP([my only test])
+AT_CHECK([testprog$EXEEXT foo], [0])
+AT_CHECK([testprog$EXEEXT], [1])
+AT_CLEANUP
+]], [], [], [], [t])
+
+rm t/atconfig
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([grep '^EXEEXT='\''.*'\' t/atconfig], [], [ignore])
+AT_CHECK([make], [], [ignore])
+AT_CHECK([cd t && $CONFIG_SHELL ./suite], [], [ignore])
+AT_CHECK([grep 1.*successful t/suite.log], [], [ignore])
+AT_CLEANUP
+
+
## ------------------------- ##
## Erlang EUnit unit tests. ##
## ------------------------- ##
--
1.8.0.1