coreutils/tests/check.mk

100 lines
3.8 KiB
Makefile
Raw Normal View History

# Include this file at the end of each tests/*/Makefile.am.
# Copyright (C) 2007-2011 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 3 of the License, 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/>.
# Ensure that all version-controlled executable files are listed in TESTS.
# Collect test names from the line matching /^TESTS = \\$$/ to the following
# one that does not end in '\'.
_v = TESTS
_w = root_tests
vc_exe_in_TESTS: Makefile
$(AM_V_GEN)rm -f t1 t2; \
if test -d $(top_srcdir)/.git && test $(srcdir) = .; then \
{ sed -n '/^$(_v) =[ ]*\\$$/,/[^\]$$/p' \
$(srcdir)/Makefile.am \
| sed 's/^ *//;/^\$$.*/d;/^$(_v) =/d'; \
sed -n '/^$(_w) =[ ]*\\$$/,/[^\]$$/p' \
$(srcdir)/Makefile.am \
| sed 's/^ *//;/^\$$.*/d;/^$(_w) =/d'; } \
| tr -s '\012\\' ' ' | fmt -1 | sort -u > t1 && \
for f in `cd $(top_srcdir) && build-aux/vc-list-files $(subdir)`; do \
f=`echo $$f|sed 's!^$(subdir)/!!'`; \
test -f "$$f" && test -x "$$f" && echo "$$f"; \
done | sort -u > t2 && \
diff -u t1 t2 || exit 1; \
rm -f t1 t2; \
else :; fi
check: vc_exe_in_TESTS
.PHONY: vc_exe_in_TESTS
CLEANFILES =
CLEANFILES += .built-programs
check-am: .built-programs
.built-programs:
$(AM_V_GEN)(cd $(top_builddir)/src \
&& MAKEFLAGS= $(MAKE) -s built_programs.list) \
> $@-t && mv $@-t $@
## `$f' is set by the Automake-generated test harness to the path of the
## current test script stripped of VPATH components, and is used by the
## shell-or-perl script to determine the name of the temporary files to be
## used. Note that $f is a shell variable, not a make macro, so the use of
## `$$f' below is correct, and not a typo.
LOG_COMPILER = \
$(SHELL) $(srcdir)/shell-or-perl \
--test-name "$$f" --srcdir '$(srcdir)' \
--shell '$(SHELL)' --perl '$(PERL)' --
# Note that the first lines are statements. They ensure that environment
tests: hoist the sourcing of "lang-default" * tests/check.mk (TESTS_ENVIRONMENT): Source lang-default here, ... ... rather than in each of 100+ test scripts. * tests/chgrp/basic: * tests/chgrp/no-x: * tests/chmod/c-option: * tests/chmod/no-x: * tests/chmod/setgid: * tests/chmod/thru-dangling: * tests/chmod/umask-x: * tests/chmod/usage: * tests/chown/basic: * tests/chown/deref: * tests/chown/preserve-root: * tests/cp/abuse: * tests/cp/acl: * tests/cp/backup-is-src: * tests/cp/cp-a-selinux: * tests/cp/cp-i: * tests/cp/cp-mv-backup: * tests/cp/deref-slink: * tests/cp/fail-perm: * tests/cp/into-self: * tests/cp/link-preserve: * tests/cp/preserve-gid: * tests/cp/same-file: * tests/cp/slink-2-slink: * tests/cp/special-f: * tests/cp/symlink-slash: * tests/cp/thru-dangling: * tests/du/basic: * tests/du/hard-link: * tests/du/inacc-dest: * tests/du/long-sloop: * tests/du/no-x: * tests/install/basic-1: * tests/ln/hard-backup: * tests/ln/sf-1: * tests/ls/file-type: * tests/ls/infloop: * tests/ls/nameless-uid: * tests/ls/rt-1: * tests/ls/stat-failed: * tests/ls/symlink-slash: * tests/ls/x-option: * tests/misc/chcon: * tests/misc/chcon-fail: * tests/misc/csplit: * tests/misc/df-P: * tests/misc/groups-dash: * tests/misc/groups-version: * tests/misc/nohup: * tests/misc/printf-surprise: * tests/misc/runcon-no-reorder: * tests/misc/selinux: * tests/misc/split-a: * tests/misc/split-fail: * tests/misc/tac-continue: * tests/misc/wc-files0: * tests/mkdir/p-v: * tests/mkdir/selinux: * tests/mv/acl: * tests/mv/backup-dir: * tests/mv/backup-is-src: * tests/mv/childproof: * tests/mv/diag: * tests/mv/dir2dir: * tests/mv/dup-source: * tests/mv/force: * tests/mv/hard-link-1: * tests/mv/hard-verbose: * tests/mv/i-2: * tests/mv/i-3: * tests/mv/i-4: * tests/mv/i-5: * tests/mv/i-link-no: * tests/mv/into-self: * tests/mv/into-self-2: * tests/mv/into-self-3: * tests/mv/mv-special-1: * tests/mv/part-fail: * tests/mv/part-symlink: * tests/mv/partition-perm: * tests/mv/perm-1: * tests/mv/reply-no: * tests/mv/sticky-to-xpart: * tests/mv/update: * tests/rm/cycle: * tests/rm/dir-no-w: * tests/rm/dir-nonrecur: * tests/rm/fail-2eperm: * tests/rm/fail-eacces: * tests/rm/inaccessible: * tests/rm/interactive-always: * tests/rm/interactive-once: * tests/rm/isatty: * tests/rm/one-file-system: * tests/rm/r-1: * tests/rm/r-2: * tests/rm/rm1: * tests/rm/rm2: * tests/rm/rm3: * tests/rm/rm4: * tests/rm/rm5: * tests/rm/unread2: * tests/rm/v-slash: * tests/touch/fail-diag: * tests/touch/not-owner:
2008-05-03 05:44:59 +08:00
# variables that can perturb tests are unset or set to expected values.
# The rest are envvar settings that propagate build-related Makefile
# variables to test scripts.
TESTS_ENVIRONMENT = \
. $(srcdir)/lang-default; \
tmp__=$${TMPDIR-/tmp}; \
test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.; \
. $(srcdir)/envvar-check; \
tests: remove ugly /bin/sh wrapper around each perl-based test script * tests/check.mk (TESTS_ENVIRONMENT): Save and restore TMPDIR around envvar-check, so that the few scripts that require $TMPDIR don't fail. This is also good to let a user's default TMPDIR setting be used e.g., in the search for an 'other-partition'. FIXME: this is pretty ugly. maybe undo it and find a better way. (TESTS_ENVIRONMENT): Invoke perl scripts with $(PERL), and use -T if the script requires that. Otherwise, use $(SHELL). * tests/misc/md5sum-newline: Create a file whose name contains a newline in Perl (resort to using "system", since open refuses). Fix old brokenness exposed by this change: * tests/du/files0-from: Correct test not to rely on stdin being attached to a non-tty. * tests/misc/sort (3g, 3h, 3i): Likewise: add explicit empty input file. Avoid warnings about using qw()-around-commas. * tests/rm/fail-eperm: Now that this test is run from a temporary subdirectory, adjust the full name of the "rm" program we're going to run. Change #!/bin/sh to #!/usr/bin/perl, and factor out the few lines of boilerplate code to invoke perl. Do not "require 5.00x"; a configure-time Perl test handles that * tests/dd/skip-seek: * tests/misc/base64: * tests/misc/basename: * tests/misc/cut: * tests/misc/date: * tests/misc/dircolors: * tests/misc/dirname: * tests/misc/expand: * tests/misc/expr: * tests/misc/factor: * tests/misc/fmt: * tests/misc/fold: * tests/misc/head: * tests/misc/head-elide-tail: * tests/misc/join: * tests/misc/ls-misc: * tests/misc/md5sum: * tests/misc/md5sum-newline: * tests/misc/mktemp: * tests/misc/od: * tests/misc/paste: * tests/misc/pr: * tests/misc/printf-cov: * tests/misc/seq: * tests/misc/sha1sum: * tests/misc/sha1sum-vec: * tests/misc/sha224sum: * tests/misc/sha256sum: * tests/misc/sha384sum: * tests/misc/sha512sum: * tests/misc/sort-merge: * tests/misc/stat-printf: * tests/misc/sum: * tests/misc/tac: * tests/misc/tail: * tests/misc/test: * tests/misc/test-diag: * tests/misc/tr: * tests/misc/tsort: * tests/misc/tty-eof: * tests/misc/unexpand: * tests/misc/uniq: * tests/misc/wc: * tests/misc/wc-files0-from: * tests/misc/xstrtol: * tests/mv/i-1: * tests/pr/pr-tests: * tests/rm/empty-name: * tests/rm/fail-eperm: * tests/rm/unreadable:
2008-05-14 15:37:02 +08:00
TMPDIR=$$tmp__; export TMPDIR; \
export \
VERSION='$(VERSION)' \
LOCALE_FR='$(LOCALE_FR)' \
LOCALE_FR_UTF8='$(LOCALE_FR_UTF8)' \
abs_top_builddir='$(abs_top_builddir)' \
abs_top_srcdir='$(abs_top_srcdir)' \
abs_srcdir='$(abs_srcdir)' \
built_programs="`cat .built-programs`" \
host_os=$(host_os) \
host_triplet='$(host_triplet)' \
srcdir='$(srcdir)' \
top_srcdir='$(top_srcdir)' \
CONFIG_HEADER='$(abs_top_builddir)/$(CONFIG_INCLUDE)' \
CU_TEST_NAME=`basename '$(abs_srcdir)'`,`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
CC='$(CC)' \
AWK='$(AWK)' \
EGREP='$(EGREP)' \
EXEEXT='$(EXEEXT)' \
MAKE=$(MAKE) \
Port to Solaris 'make' and use a Posixish shell on Solaris. * bootstrap.conf (gnulib_modules): Add gnu-make, posix-shell. * build-aux/check.mk (SHELL): Set to $(PREFERABLY_POSIX_SHELL), so that commands can assume Posix syntax. (ENABLE_HARD_ERRORS, TEST_LOGS): Don't use GNU Make's "?=" syntax. (SH_E_WORKAROUND): New macro. (am__check_pre, $(TEST_SUITE_LOG)): Use it. (am__check_pre): Fail if "mkdir" fails. Use $(SHELL) rather than relying on the "#!/bin/sh" in the file, so that tests can use Posix syntax. (am__check_pre, am__tty_colors): Use $$src rather than $$<, to support the Posix-make $(TEST_LOGS) rule. (%.log: %.test, %.log: %$(EXEEXT)): Remove unused inference rules that rely on a GNU Make extension and cause Solaris 'make' to fail. (SUFFIXES): New macro, so that we can use Posix style inference rules. (%.log: %): Use this rule only if GNU_MAKE. Set $$src so that macros can use $$src rather than $$<. (CHECK-FORCE, DEPENDENCY, $(TEST_LOGS)): New macros and rules, which rely only on Posix 'make' semantics, and are used only with non-GNU 'make' implementations. $(TEST_LOGS) invokes 'make' recursively (and a bit inefficiently) to simulate the GNU 'make' rules. (.log.html): Renamed from "%.html: %.log", so that it relies only on Posix 'make' semantics. (check-clean, .PHONY): Do not depend on check-clean-local, since Solaris 'make' complains about nonexistent rules like that. * src/Makefile.am (SUFFIXES): Remove; no longer needed. (groups): Use a specific rule rather than an inference rule that is only instantiated once. The inference-rule approach does not work with Solaris 'make', which gets confused by the "groups: Makefile" line. It's not clear from the Posix spec that Solaris 'make' is buggy here, so instead of worrying about it, rewrite the makefile so that it clearly conforms to Posix. * tests/check.mk (TESTS_ENVIRONMENT): Export PACKAGE_BUGREPORT. GNU 'make' does this automatically for us, but Solaris 'make' doesn't. 2007-11-15 Paul Eggert <eggert@cs.ucla.edu>
2007-11-16 18:03:03 +08:00
PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
PERL='$(PERL)' \
PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
REPLACE_GETCWD=$(REPLACE_GETCWD) \
; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
; 9>&2
VERBOSE = yes