1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-05-24 03:06:46 +02:00

Add support for parallel "make check" (in tests/misc, for now)

This commit is contained in:
Jim Meyering
2007-08-14 10:21:48 +02:00
parent 5c2f8101c5
commit 7a6a30b8a2
13 changed files with 255 additions and 24 deletions
+207
View File
@@ -0,0 +1,207 @@
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2006, 2007 The Vaucanson Group.
##
## 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
## of the License, or (at your option) any later version.
##
## The complete GNU General Public Licence Notice can be found as the
## `COPYING' file in the root directory.
##
## The Vaucanson Group consists of people listed in the `AUTHORS' file.
## Override the definition from Automake to generate a log file with
## failed tests. It also supports parallel make checks.
##
## This file provides special support for "unit tests", that is to
## say, tests that (once run) no longer need to be re-compiled and
## re-run at each "make check", unless their sources changed. To
## enable unit-test supports, define LAZY_TEST_SUITE. In such a
## setting, that heavily relies on correct dependencies, its users may
## prefer to define EXTRA_PROGRAMS instead of check_PROGRAMS, because
## it allows intertwined compilation and execution of the tests.
## Sometimes this helps catching errors earlier (you don't have to
## wait for all the tests to be compiled).
##
## Define TEST_SUITE_LOG to be the name of the global log to create.
## Define TEST_LOGS to the set of logs to include in it. It defaults
## to $(TESTS:.test=.log).
## We use GNU Make extensions (%-rules), and override check-TESTS.
AUTOMAKE_OPTIONS = -Wno-portability -Wno-override
# Restructured Text title and section.
am__rst_title = sed 's/.*/ & /;h;s/./=/g;p;x;p;g;p;s/.*//'
am__rst_section = sed 'p;s/./=/g;p;g'
# Put stdin (possibly several lines separated by ". ") in a box.
am__text_box = $(AWK) '{gsub ("\\. ", "\n"); print $$0; }' | \
$(AWK) ' \
max < length($$0) { \
final= final (final ? "\n" : "") " " $$0; \
max = length($$0); \
} \
END { \
for (i = 0; i < max + 2 ; ++i) \
line = line "="; \
print line; \
print final; \
print line; \
}'
# If stdout is a tty, use colors. If test -t is not supported, then
# this fails; a conservative approach. Of course do not redirect
# stdout here, just stderr...
am__tty_colors = \
if test -t 1 2>/dev/null; then \
red=''; \
grn=''; \
blu=''; \
std=''; \
fi
# To be inserted before the command running the test. Stores in $dir
# the directory containing $<, and passes the TEST_ENVIRONMENT.
am__check_pre = \
if test -f ./$<; then dir=./; \
elif test -f $<; then dir=; \
else dir="$(srcdir)/"; fi; \
$(TESTS_ENVIRONMENT)
# To be appended to the command running the test. Handles the stdout
# and stderr redirection, and catch the exit status.
am__check_post = \
>$@-t 2>&1; \
estatus=$$?; \
$(am__tty_colors); \
case $$estatus:" $(XFAIL_TESTS) " in \
0:*" $$(basename $<) "*) col=$$red; res=XPASS;; \
0:*) col=$$grn; res=PASS ;; \
77:*) col=$$blu; res=SKIP ;; \
*:*" $$(basename $<) "*) col=$$grn; res=XFAIL;; \
*:*) col=$$red; res=FAIL ;; \
esac; \
echo "$${col}$$res$${std}: $$(basename $<)"; \
echo "$$res: $$(basename $<) (exit: $$estatus)" | \
$(am__rst_section) >$@; \
cat $@-t >>$@; \
rm $@-t
# From a test file to a log file.
# Do not use a regular `.test.log:' rule here, since in that case the
# following rule (without incoming extension) will mask this one.
%.log: %.test
@$(am__check_pre) $${dir}$< $(am__check_post)
# The exact same commands, but for programs.
%.log: %$(EXEEXT)
@$(am__check_pre) $${dir}$< $(am__check_post)
TEST_LOGS ?= $(TESTS:.test=.log)
TEST_SUITE_LOG = test-suite.log
$(TEST_SUITE_LOG): $(TEST_LOGS)
@results=$$(for f in $(TEST_LOGS); do sed 1q $$f; done); \
all=$$(echo "$$results" | wc -l | sed -e 's/^[ \t]*//'); \
fail=$$(echo "$$results" | grep -c '^FAIL'); \
pass=$$(echo "$$results" | grep -c '^PASS'); \
skip=$$(echo "$$results" | grep -c '^SKIP'); \
xfail=$$(echo "$$results" | grep -c '^XFAIL'); \
xpass=$$(echo "$$results" | grep -c '^XPASS'); \
case fail=$$fail:xfail=$$xfail:xpass=$$xpass in \
fail=0:xfail=0:xpass=*) \
msg="All $$all tests passed. ";; \
fail=0:xfail=*:xpass=*) \
msg="All $$all tests behaved as expected"; \
msg="$$msg ($$xfail expected failures). ";; \
fail=*:xfail=*:xpass=0) \
msg="$$fail of $$all tests failed. ";; \
fail=*:xfail=*:xpass=*) \
msg="$$fail of $$all tests did not behave as expected"; \
msg="$$msg ($$xpass unexpected passes). ";; \
*) \
echo >&2 "incorrect case"; exit 4;; \
esac; \
if test "$$skip" -ne 0; then \
msg="$$msg($$skip tests were not run). "; \
fi; \
if test "$$fail" -ne 0; then \
{ \
echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
$(am__rst_title); \
echo "$$msg"; \
echo; \
echo ".. contents:: :depth: 2"; \
echo; \
for f in $(TEST_LOGS); \
do \
case $$(sed 1q $$f) in \
SKIP:*|PASS:*|XFAIL:*);; \
*) echo; cat $$f;; \
esac; \
done; \
} >$(TEST_SUITE_LOG).tmp; \
mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG). "; \
if test -n "$(PACKAGE_BUGREPORT)"; then \
msg="$${msg}Please report it to $(PACKAGE_BUGREPORT). "; \
fi; \
fi; \
$(am__tty_colors); \
if test "$$fail" -eq 0; then echo $$grn; else echo $$red; fi; \
echo "$$msg" | $(am__text_box); \
echo $$std; \
if test x"$$VERBOSE" != x && test "$$fail" -ne 0; then \
cat $(TEST_SUITE_LOG); \
fi; \
test "$$fail" -eq 0
# Run all the tests.
check-TESTS:
@if test -z '$(LAZY_TEST_SUITE)'; then \
rm -f $(TEST_SUITE_LOG) $(TEST_LOGS); \
fi
@$(MAKE) $(TEST_SUITE_LOG)
## -------------- ##
## Produce HTML. ##
## -------------- ##
TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
%.html: %.log
@for r2h in $(RST2HTML) $$RST2HTML rst2html rst2html.py; \
do \
if ($$r2h --version) >/dev/null 2>&1; then \
R2H=$$r2h; \
fi; \
done; \
if test -z "$$R2H"; then \
echo >&2 "cannot find rst2html, cannot create $@"; \
exit 2; \
fi; \
$$R2H $< >$@.tmp
mv $@.tmp $@
# Be sure to run check-TESTS first, and then to convert the result.
# Beware of concurrent executions. And expect check-TESTS to fail.
check-html:
@if $(MAKE) $(AM_MAKEFLAGS) check-TESTS; then :; else \
rv=$?; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML); \
exit $$rv; \
fi
.PHONY: check-html
## ------- ##
## Clean. ##
## ------- ##
check-clean: check-clean-local
rm -f $(CHECK_CLEANFILES) $(TEST_SUITE_LOG) $(TEST_SUITE_HTML) $(TEST_LOGS)
.PHONY: check-clean check-clean-local
clean-local: check-clean
+11 -5
View File
@@ -24,6 +24,7 @@ TESTS_ENVIRONMENT = \
built_programs="`$(built_programs)`" \
top_srcdir=$(top_srcdir) \
abs_top_builddir=$(abs_top_builddir) \
abs_top_srcdir=$(abs_top_srcdir) \
srcdir=$(srcdir) \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
PERL="$(PERL)" \
@@ -32,8 +33,7 @@ TESTS_ENVIRONMENT = \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
CONFIG_HEADER=$(CONFIG_HEADER) \
REPLACE_GETCWD=$(REPLACE_GETCWD) \
host_os=$(host_os) \
PROG=`../../src/basename -- "$$tst"`
host_os=$(host_os)
# Do not choose a name that is a shell keyword like 'if', or a
# commonly-used utility like 'cat' or 'test', as the name of a test.
@@ -42,8 +42,10 @@ TESTS_ENVIRONMENT = \
# will execute the test script rather than the standard utility.
TESTS = \
od \
head-elide-tail \
date \
xstrtol \
od \
arch \
pr \
df-P \
@@ -59,7 +61,6 @@ TESTS = \
basename \
close-stdout \
csplit \
date \
date-sec \
df \
dirname \
@@ -68,7 +69,6 @@ TESTS = \
fold \
groups-version \
head-c \
head-elide-tail \
head-pos \
mknod \
nice \
@@ -96,3 +96,9 @@ TESTS = \
tac-continue \
test-diag \
tty-eof
TEST_LOGS = $(TESTS:=.log)
# Parallel replacement of Automake's check-TESTS target.
# Include it last: TEST_LOGS has a default value there.
include $(top_srcdir)/build-aux/check.mk
+2
View File
@@ -20,6 +20,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# -*-perl-*-
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# Copyright (C) 2006-2007 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
@@ -19,6 +19,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -3
View File
@@ -36,10 +36,10 @@ use strict;
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my $prog = 'cut';
my $diag = <<EOF;
my $diag = <<DIAG_EOF;
$prog: fields and positions are numbered from 1
Try \`cut --help' for more information.
EOF
DIAG_EOF
my @Tests =
(
@@ -60,4 +60,4 @@ my $verbose = $ENV{VERBOSE};
my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
FILE_EOF
EOF
+2
View File
@@ -20,6 +20,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -2,7 +2,7 @@
# -*- perl -*-
# Exercise expand.
# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 2004-2007 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
@@ -20,6 +20,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+2
View File
@@ -20,6 +20,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Test "sha224sum".
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005, 2007 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
@@ -19,6 +19,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Test "sha256sum".
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005, 2007 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
@@ -19,6 +19,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Test "sha384sum".
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005, 2007 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
@@ -19,6 +19,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+3 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Test "sha512sum".
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005, 2007 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
@@ -19,6 +19,8 @@
: ${PERL=perl}
: ${srcdir=.}
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
+10 -10
View File
@@ -23,6 +23,8 @@
. $srcdir/../envvar-check
PROG=`echo $0|sed 's,.*/,,'`; export PROG
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
"so can't run this test"
@@ -37,8 +39,7 @@ use strict;
(my $program_name = $0) =~ s|.*/||;
$ENV{PROG} = 'wc';
my $ME = $ENV{PROG};
my $prog = 'wc';
# Turn off localization of executable's ouput.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -47,14 +48,14 @@ my @Tests =
(
# invalid extra command line argument
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
{ERR => "$ME: extra operand `no-such'\n"
{ERR => "$prog: extra operand `no-such'\n"
. "File operands cannot be combined with --files0-from.\n"
. "Try `$ME --help' for more information.\n"}
. "Try `$prog --help' for more information.\n"}
],
# missing input file
['missing', '--files0-from=missing', {EXIT=>1},
{ERR => "$ME: cannot open `missing' for reading: "
{ERR => "$prog: cannot open `missing' for reading: "
. "No such file or directory\n"}],
# empty input
@@ -65,13 +66,13 @@ my @Tests =
# one NUL
['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
{ERR => "$ME: : No such file or directory\n"}],
{ERR => "$prog: : No such file or directory\n"}],
# two NULs
['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
{OUT=>"0 0 0 total\n"},
{ERR => "$ME: : No such file or directory\n"
. "$ME: : No such file or directory\n"}],
{ERR => "$prog: : No such file or directory\n"
. "$prog: : No such file or directory\n"}],
# one file name, no NUL
['1', '--files0-from=-', '<',
@@ -95,13 +96,12 @@ my @Tests =
['zero-len', '--files0-from=-', '<',
{IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
{OUT=>"0 0 0 g\n0 0 0 total\n"},
{ERR => "$ME: : No such file or directory\n"}, {EXIT=>1} ],
{ERR => "$prog: : No such file or directory\n"}, {EXIT=>1} ],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
EOF