1
0
mirror of https://git.savannah.gnu.org/git/coreutils.git synced 2025-08-07 07:22:55 +03:00

tests: ensure programs are built before testing

programs may not be built due to missing system dependencies,
or any program can be excluded at configure time with
--enable-no-install-program.  So ensure we're not testing the
system versions in these cases.

* init.cfg (print_ver_): Call require_built_ first.
* tests/misc/tty-eof.pl: Skip programs not built.
* tests/Coreutils.pm (run_tests): Likewise.
* tests/misc/ls-misc.pl: Use 'env test' rather than abs path.
* tests/misc/test-diag.pl: Likewise.
* tests/local.mk: Adjust include order for dependencies.
* tests/misc/arch.sh: Remove redundant calls to require_built_.
* tests/misc/chroot-fail.sh: Likewise.
* tests/misc/groups-dash.sh: Likewise.
* tests/misc/groups-version.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/cp/acl.sh: Remove problematic call to print_ver_ [gs]etfacl.
* tests/mv/acl.sh: Likewise.
* cfg.mk (sc_env_test_dependencies): A new syntax check to enforce
specifying dependencies with print_ver_ for programs
specified through the env command.
* du/bigtime.sh: Add new print_ver_ dependencies.
* du/max-depth.sh: Likewise.
* dd/ascii.sh: Likewise.
* tests/ls/capability.sh: Likewise.
* tests/ls/root-rel-symlink-color.sh: Likewise.
* tests/misc/chroot-fail.sh: Likewise.
* tests/misc/readlink-fp-loop.sh: Likewise.
* tests/misc/sort-debug-keys.sh: Likewise.
* tests/readlink/can-e.sh: Likewise.
* tests/readlink/can-f.sh: Likewise.
* tests/readlink/can-m.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/inotify-race2.sh: Likewise.
* tests/touch/no-create-missing.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.
* tests/misc/printenv.sh: Tweak to avoid syntax check trigger.
* tests/misc/help-version.sh: Likewise.
* tests/misc/yes.sh: Likewise.
* tests/misc/printf-quote.sh: Use previously unused $prog.
* configure.ac (EXTRA_MANS): Add $gl_no_install_prog to the list
so that check-x-vs-1 syntax check is satisfied.
This commit is contained in:
Pádraig Brady
2015-11-10 14:05:50 +00:00
parent dcae88c009
commit f720844207
33 changed files with 55 additions and 37 deletions

14
cfg.mk
View File

@@ -527,6 +527,20 @@ sc_prohibit_verbose_version:
halt='use the print_ver_ function instead...' \ halt='use the print_ver_ function instead...' \
$(_sc_search_regexp) $(_sc_search_regexp)
# Enforce print_ver_ tracking of dependencies
# Each coreutils specific program a test requires
# should be tagged by calling through env(1).
sc_env_test_dependencies:
@cd $(top_srcdir) && GIT_PAGER= git grep -E \
"env ($$(build-aux/gen-lists-of-programs.sh --list-progs | \
grep -vF '[' |paste -d'|' -s))" tests | \
sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
while read test prog; do \
printf '%s' $$test | grep -q '\.pl$$' && continue; \
grep -q "print_ver_.* $$prog" $$test \
|| echo $$test should call: print_ver_ $$prog; \
done | grep . && exit 1 || :
# Use framework_failure_, not the old name without the trailing underscore. # Use framework_failure_, not the old name without the trailing underscore.
sc_prohibit_framework_failure: sc_prohibit_framework_failure:
@prohibit='\<framework_''failure\>' \ @prohibit='\<framework_''failure\>' \

View File

@@ -517,7 +517,9 @@ man1_MANS=`
# Not installed by "make install", but must be built when creating # Not installed by "make install", but must be built when creating
# a distribution tarball. # a distribution tarball.
EXTRA_MANS=`for p in $no_install_progs_default; do echo man/$p.1; done` EXTRA_MANS=`for p in $no_install_progs_default $gl_no_install_prog; do
echo man/$p.1
done`
# Replace all the programs by the single binary and symlinks if specified. # Replace all the programs by the single binary and symlinks if specified.
single_binary_progs= single_binary_progs=

View File

@@ -659,6 +659,7 @@ retry_delay_()
# sourcing init.sh. # sourcing init.sh.
print_ver_() print_ver_()
{ {
require_built_ "$@"
if test "$VERBOSE" = yes; then if test "$VERBOSE" = yes; then
local i local i
for i in $*; do for i in $*; do

View File

@@ -224,6 +224,7 @@ sub run_tests ($$$$$)
# To indicate that $prog is a shell built-in, you'd make it a string 'ref'. # To indicate that $prog is a shell built-in, you'd make it a string 'ref'.
# E.g., call run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); # E.g., call run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose);
# If it's a ref, invoke it via "env": # If it's a ref, invoke it via "env":
my $built_prog = ref $prog ? $$prog : $prog;
my @prog = ref $prog ? (qw(env --), $$prog) : $prog; my @prog = ref $prog ? (qw(env --), $$prog) : $prog;
# Warn about empty t_spec. # Warn about empty t_spec.
@@ -271,6 +272,9 @@ sub run_tests ($$$$$)
} }
return 1 if $bad_test_name; return 1 if $bad_test_name;
$ENV{built_programs} =~ /\b$built_prog\b/ ||
CuSkip::skip "required program(s) not built [$built_prog]\n";
# FIXME check exit status # FIXME check exit status
system (@prog, '--version') if $verbose; system (@prog, '--version') if $verbose;

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp getfacl setfacl print_ver_ cp
require_acl_ require_acl_

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ dd print_ver_ dd printf
{ {
# Two lines, EBCDIC " A A" and " A ", followed by all the bytes in order. # Two lines, EBCDIC " A A" and " A ", followed by all the bytes in order.

View File

@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ du
export LC_ALL=C export LC_ALL=C
export TZ=UTC0 export TZ=UTC0

View File

@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ du
mkdir -p a/b/c/d/e || framework_failure_ mkdir -p a/b/c/d/e || framework_failure_
printf 'a/b/c\na/b\na\n' > exp || framework_failure_ printf 'a/b/c\na/b\na\n' > exp || framework_failure_

View File

@@ -32,7 +32,7 @@ TESTSUITE_PERL = $(SHELL) $(srcdir)/no-perl
endif endif
# Options passed to the perl invocations running the perl test scripts. # Options passed to the perl invocations running the perl test scripts.
TESTSUITE_PERL_OPTIONS = -w -I$(srcdir)/tests -MCoreutils -MCuSkip TESTSUITE_PERL_OPTIONS = -w -I$(srcdir)/tests -MCuSkip -MCoreutils
# '$f' is set by the Automake-generated test harness to the path of the # '$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 # current test script stripped of VPATH components, and is used by the
# CuTmpdir module to determine the name of the temporary files to be # CuTmpdir module to determine the name of the temporary files to be

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ls print_ver_ ls printf
require_root_ require_root_
grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \ grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ ls print_ver_ ls test
symlink_to_rel= symlink_to_rel=
for i in /*; do for i in /*; do

View File

@@ -19,8 +19,6 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ arch print_ver_ arch
require_built_ arch
arch > out || fail=1 arch > out || fail=1
uname -m > exp || fail=1 uname -m > exp || fail=1

View File

@@ -18,9 +18,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ chroot print_ver_ chroot pwd
require_built_ chroot
# These tests verify exact status of internal failure; since none of # These tests verify exact status of internal failure; since none of
# them actually run a command, we don't need root privileges # them actually run a command, we don't need root privileges

View File

@@ -18,7 +18,6 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ groups print_ver_ groups
require_built_ groups
# Coreutils 6.9 and earlier failed to display information on first argument # Coreutils 6.9 and earlier failed to display information on first argument
# if later argument was --. # if later argument was --.

View File

@@ -18,7 +18,6 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ groups print_ver_ groups
require_built_ groups
groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1 groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1
id --version | sed '/^$/q' > exp || fail=1 id --version | sed '/^$/q' > exp || fail=1

View File

@@ -213,7 +213,8 @@ id_setup () { args=-u; }
# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh. # Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
kill_setup () { kill_setup () {
env sleep 10m & pid=$! external=env
$external sleep 10m & pid=$!
args=$pid args=$pid
} }

View File

@@ -55,7 +55,7 @@ sub shell_quote($)
# that cannot be done. # that cannot be done.
sub setuid_setup() sub setuid_setup()
{ {
my $test = shell_quote "$ENV{abs_top_builddir}/src/test"; my $test = 'env test';
system (qq(touch setuid && chmod u+s setuid && $test -u setuid && system (qq(touch setuid && chmod u+s setuid && $test -u setuid &&
touch setgid && chmod g+s setgid && $test -g setgid && touch setgid && chmod g+s setgid && $test -g setgid &&
mkdir sticky && chmod +t sticky && $test -k sticky && mkdir sticky && chmod +t sticky && $test -k sticky &&

View File

@@ -16,13 +16,13 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
prog='env printf'
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ printf print_ver_ printf
prog='env printf'
# Equivalent output to ls --quoting=shell-escape # Equivalent output to ls --quoting=shell-escape
env printf '%q\n' '' "'" a 'a b' '~a' 'a~' "$(env printf %b 'a\r')" > out $prog '%q\n' '' "'" a 'a b' '~a' 'a~' "$($prog %b 'a\r')" > out
cat <<\EOF > exp || framework_failure_ cat <<\EOF > exp || framework_failure_
'' ''
''\''' ''\'''
@@ -40,11 +40,11 @@ f=$LOCALE_FR_UTF8
if test "$LOCALE_FR_UTF8" != "none"; then if test "$LOCALE_FR_UTF8" != "none"; then
( (
#printable multi-byte #printable multi-byte
LC_ALL=$f env printf '%q\n' 'áḃç' > out LC_ALL=$f $prog '%q\n' 'áḃç' > out
#non-printable multi-byte #non-printable multi-byte
LC_ALL=$f env printf '%q\n' "$(LC_ALL=$f env printf '\u0378')" >> out LC_ALL=$f $prog '%q\n' "$(LC_ALL=$f $prog '\u0378')" >> out
#printable multi-byte in C locale #printable multi-byte in C locale
LC_ALL=C env printf '%q\n' 'áḃç' >> out LC_ALL=C $prog '%q\n' 'áḃç' >> out
) )
cat <<\EOF > exp || framework_failure_ cat <<\EOF > exp || framework_failure_
áḃç áḃç

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink print_ver_ readlink pwd
cwd=$(env pwd -P) cwd=$(env pwd -P)
# To trigger this bug, we have to construct a name/situation during # To trigger this bug, we have to construct a name/situation during

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ sort print_ver_ sort printf
number() { cat -n | sed 's/^ *//'; } number() { cat -n | sed 's/^ *//'; }

View File

@@ -20,7 +20,6 @@
print_ver_ stdbuf print_ver_ stdbuf
getlimits_ getlimits_
require_built_ stdbuf
# stdbuf fails when the absolute top build dir name contains e.g., # stdbuf fails when the absolute top build dir name contains e.g.,
# space, TAB, NL # space, TAB, NL

View File

@@ -23,7 +23,6 @@ use strict;
# Turn off localization of executable's output. # Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my $prog = "$ENV{abs_top_builddir}/src/test";
my @Tests = my @Tests =
( (
# In coreutils-5.93, this diagnostic lacked the newline. # In coreutils-5.93, this diagnostic lacked the newline.
@@ -34,6 +33,6 @@ my @Tests =
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
my $prog = 'test';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); my $fail = run_tests ($program_name, \$prog, \@Tests, $save_temps, $verbose);
exit $fail; exit $fail;

View File

@@ -68,6 +68,7 @@ $@
{ {
my $exp = new Expect; my $exp = new Expect;
$exp->log_user(0); $exp->log_user(0);
$ENV{built_programs} =~ /\b$cmd\b/ || next;
$exp->spawn("$cmd 2> $stderr") $exp->spawn("$cmd 2> $stderr")
or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next; or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next;
# No input for cut -f2. # No input for cut -f2.

View File

@@ -31,7 +31,8 @@ done
# Check the many small items case, # Check the many small items case,
# both fitting and overflowing the internal buffer # both fitting and overflowing the internal buffer
if env true $(seq 4000); then external=env
if external true $(seq 4000); then
for i in 100 4000; do for i in 100 4000; do
seq $i | paste -s -d ' ' | sed p > out.1 seq $i | paste -s -d ' ' | sed p > out.1
yes $(seq $i) | head -n2 > out.2 yes $(seq $i) | head -n2 > out.2

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ mv getfacl setfacl print_ver_ mv
require_acl_ require_acl_

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink print_ver_ readlink pwd
pwd=$(pwd) pwd=$(pwd)
my_pwd=$(env pwd -P) my_pwd=$(env pwd -P)

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink print_ver_ readlink pwd
pwd=$(pwd) pwd=$(pwd)
my_pwd=$(env pwd -P) my_pwd=$(env pwd -P)

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ readlink print_ver_ readlink pwd
pwd=$(pwd) pwd=$(pwd)
my_pwd=$(env pwd -P) my_pwd=$(env pwd -P)

View File

@@ -21,7 +21,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail print_ver_ tail sleep
# Terminate any background gdb/tail process # Terminate any background gdb/tail process
cleanup_() { cleanup_() {

View File

@@ -20,7 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail print_ver_ tail sleep
# Terminate any background gdb/tail process # Terminate any background gdb/tail process
cleanup_() { cleanup_() {

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ touch print_ver_ touch test
touch -c no-file > /dev/null 2>&1 || fail=1 touch -c no-file > /dev/null 2>&1 || fail=1

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ touch print_ver_ touch test
ln -s nowhere dangling || framework_failure_ ln -s nowhere dangling || framework_failure_
touch file || framework_failure_ touch file || framework_failure_