--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
+
+# Make sure that Automake can handle "funny chars" in TEST_EXTENSIONS,
+# as long as they can be used in GNU make variable names.
+
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+echo AC_OUTPUT >> configure.ac
+
+cat >> Makefile.am <<'END'
+TEST_EXTENSIONS = .@ .f-o-o .l!Nu.x
+TESTS = foo.@ bar.f-o-o zardoz.l!Nu.x
+XFAIL_TESTS = zardoz.l!Nu.x
+@_LOG_COMPILER = $(SHELL)
+F-O-O_LOG_DRIVER = $(srcdir)/tap-driver
+L!NU.X_LOG_COMPILER = false
+EXTRA_DIST = $(TESTS) tap-driver
+END
+
+touch foo.@ bar.f-o-o zardoz.l!Nu.x \
+ || skip_ "your file system doesn't support funny characters"
+
+# Try to ensure this file fails if executed directly.
+cat > foo.@ << 'END'
+#! /bin/false
+echo @K @K @K
+exit 0
+END
+chmod a-x foo.@ # We don't want it to be executable, either.
+
+cat > bar.f-o-o << 'END'
+#! /bin/sh
+echo 1..4
+echo "ok - good"
+echo "ok 2 # SKIP"
+echo "not ok 3 # TODO"
+echo ok
+END
+chmod a+x bar.f-o-o
+
+cat > zardoz.l!Nu.x << 'END'
+#! /bin/sh
+echo Hello Zardoz
+exit 0
+END
+chmod a+x zardoz.l!Nu.x
+
+count_all ()
+{
+ count_test_results total=6 pass=3 fail=0 skip=1 xfail=2 xpass=0 error=0
+ grep '^PASS: foo\.@$' stdout
+ grep '^XFAIL: zardoz.l!Nu\.x$' stdout
+ grep '^PASS: bar\.f-o-o 1 - good' stdout
+ grep '^SKIP: bar\.f-o-o 2 # SKIP' stdout
+ grep '^XFAIL: bar\.f-o-o 3 # TODO' stdout
+ grep '^PASS: bar\.f-o-o 4$' stdout
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+st=0; $MAKE check >stdout || st=$?
+cat stdout
+ls -l
+cat test-suite.log
+cat foo.log
+grep '@K @K @K' foo.log
+cat bar.log
+cat zardoz.log
+grep 'Hello Zardoz' zardoz.log && Exit 1
+test $st -eq 0 || Exit 1
+count_all
+
+$MAKE clean
+test ! -f test-suite.log
+test ! -f foo.log
+test ! -f bar.log
+test ! -f zardoz.log
+
+st=0
+$MAKE check TESTS=zardoz L!NU.X_LOG_COMPILER=/bin/sh >stdout || st=$?
+cat stdout
+count_test_results total=1 pass=0 fail=0 skip=0 xfail=0 xpass=1 error=0
+cat test-suite.log
+test ! -f foo.log
+test ! -f bar.log
+cat zardoz.log
+grep 'Hello Zardoz' zardoz.log
+test $st -gt 0 || Exit 1
+
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=1 pass=0 fail=0 skip=0 xfail=1 xpass=0 error=0
+grep '^XFAIL: zardoz.l!Nu\.x$' stdout
+
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=0 pass=0 fail=0 skip=0 xfail=0 xpass=0 error=0
+
+$MAKE distcheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_all
+
+: