]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: ensure programs are built before testing
authorPádraig Brady <P@draigBrady.com>
Tue, 10 Nov 2015 14:05:50 +0000 (14:05 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 10 Nov 2015 18:24:18 +0000 (18:24 +0000)
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.

33 files changed:
cfg.mk
configure.ac
init.cfg
tests/Coreutils.pm
tests/cp/acl.sh
tests/dd/ascii.sh
tests/du/bigtime.sh
tests/du/max-depth.sh
tests/local.mk
tests/ls/capability.sh
tests/ls/root-rel-symlink-color.sh
tests/misc/arch.sh
tests/misc/chroot-fail.sh
tests/misc/groups-dash.sh
tests/misc/groups-version.sh
tests/misc/help-version.sh
tests/misc/ls-misc.pl
tests/misc/printenv.sh
tests/misc/printf-quote.sh
tests/misc/readlink-fp-loop.sh
tests/misc/sort-debug-keys.sh
tests/misc/stdbuf.sh
tests/misc/test-diag.pl
tests/misc/tty-eof.pl
tests/misc/yes.sh
tests/mv/acl.sh
tests/readlink/can-e.sh
tests/readlink/can-f.sh
tests/readlink/can-m.sh
tests/tail-2/inotify-race.sh
tests/tail-2/inotify-race2.sh
tests/touch/no-create-missing.sh
tests/touch/no-dereference.sh

diff --git a/cfg.mk b/cfg.mk
index d6c4c9f6182e6c492185aaa3ac3d20336a5aea5c..a2040348cce2f9f9ba98cf84bb34b4ec89d02420 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -527,6 +527,20 @@ sc_prohibit_verbose_version:
        halt='use the print_ver_ function instead...'                   \
          $(_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.
 sc_prohibit_framework_failure:
        @prohibit='\<framework_''failure\>'                             \
index fc1a0526bd68b0a627075303ea01b8bd58561d90..66c8cbe165f720a3fbe1bf0a272c94956fd60b29 100644 (file)
@@ -517,7 +517,9 @@ man1_MANS=`
 
 # Not installed by "make install", but must be built when creating
 # 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.
 single_binary_progs=
index 6f5f80bf300274a3831c2bbae1939a6c534b14c7..e4309ae5397a28dff7c64ab11b2a58ede90c8fcc 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -659,6 +659,7 @@ retry_delay_()
 # sourcing init.sh.
 print_ver_()
 {
+  require_built_ "$@"
   if test "$VERBOSE" = yes; then
     local i
     for i in $*; do
index bd2088f651edf7d6f35d0159450e0b2de4826dab..632960ae0b8646a4e707e58f0e52551b0485f9b8 100644 (file)
@@ -224,6 +224,7 @@ sub run_tests ($$$$$)
   # 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);
   # If it's a ref, invoke it via "env":
+  my $built_prog = ref $prog ? $$prog : $prog;
   my @prog = ref $prog ? (qw(env --), $$prog) : $prog;
 
   # Warn about empty t_spec.
@@ -271,6 +272,9 @@ sub run_tests ($$$$$)
     }
   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
   system (@prog, '--version') if $verbose;
 
index e397ff063dbaa346edf16557c7789f3c10774a70..591479c0bf59dcc45615ef00b5096c53b157e2c9 100755 (executable)
@@ -18,7 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ cp getfacl setfacl
+print_ver_ cp
 
 require_acl_
 
index be6494a0b7e7fbc6276db1714d3fc34460f841a1..5f96a2d3e48d3b0142234a2bed78341478a69cec 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${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.
index 95fa1932daf47522709183c72e8160bc789d7e76..990853ecdbb7db9916a50d90e89533809bdb5cda 100755 (executable)
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ du
 
 export LC_ALL=C
 export TZ=UTC0
index 25ad46896aa9a9c78cdc135ff3b4f596ffc09b9c..3c0b0bc00e37d75fc130a8c94100f6c0e85dca72 100755 (executable)
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ du
 
 mkdir -p a/b/c/d/e || framework_failure_
 printf 'a/b/c\na/b\na\n' > exp || framework_failure_
index f65f7bcc8cdfa281f220b53f3de0ebbceb9e39cb..675607e7ac582237477e0f81fcb4bf7535ee8a88 100644 (file)
@@ -32,7 +32,7 @@ TESTSUITE_PERL = $(SHELL) $(srcdir)/no-perl
 endif
 
 # 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
 # current test script stripped of VPATH components, and is used by the
 # CuTmpdir module to determine the name of the temporary files to be
index bd32be2630801a16b1b55126ec41a4e015a4e6e2..2a85c7c4712044fb01a8203fc4ec8ec2eb7f792e 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ ls
+print_ver_ ls printf
 require_root_
 
 grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \
index 0b977fcb6cbd33e5a81f225d606e2ce0752d5164..41ad34205502cea6be189b9b697ff0658ba99439 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ ls
+print_ver_ ls test
 
 symlink_to_rel=
 for i in /*; do
index d5ae5822899fd98926fe870398f10cb4e8c610db..1c924a0cf4303ed9b9bf3ebe3a4ac4e1ee9713a2 100755 (executable)
@@ -19,8 +19,6 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ arch
 
-require_built_ arch
-
 arch > out || fail=1
 uname -m > exp || fail=1
 
index 14499edd74ab147807d74e057e85ca011926faba..fe4178b1e520bd8b59ba9d292302ca3ec044329d 100755 (executable)
@@ -18,9 +18,7 @@
 
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ chroot
-
-require_built_ chroot
+print_ver_ chroot pwd
 
 # These tests verify exact status of internal failure; since none of
 # them actually run a command, we don't need root privileges
index 8f7ec759024a58dd1ded08ba8a9db359a2693da6..1d967432464e44bbf3fcc143002395e00042914f 100755 (executable)
@@ -18,7 +18,6 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ groups
-require_built_ groups
 
 # Coreutils 6.9 and earlier failed to display information on first argument
 # if later argument was --.
index 4439443529820191bd2e29cf7914259de573aeef..f6de3f2ef1be9c0e2f1d0a998277e1a463863a8c 100755 (executable)
@@ -18,7 +18,6 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ groups
-require_built_ groups
 
 groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1
 id --version | sed '/^$/q' > exp || fail=1
index 29468edbd50321aa110018578db3f4ff57cd2813..1878ae94da0a8d387d1895e90180cbc32fc1cf7c 100755 (executable)
@@ -213,7 +213,8 @@ id_setup () { args=-u; }
 
 # Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
 kill_setup () {
-  env sleep 10m & pid=$!
+  external=env
+  $external sleep 10m & pid=$!
   args=$pid
 }
 
index d3897737e491cc7c4fa297e765fe15127a9d712b..6932e4d0aef0415c806233c52bfab4333e9ca3f8 100755 (executable)
@@ -55,7 +55,7 @@ sub shell_quote($)
 # that cannot be done.
 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 &&
            touch setgid && chmod g+s setgid && $test -g setgid &&
            mkdir sticky && chmod +t sticky  && $test -k sticky &&
index 862b48ba805b0e5112901baea054887f031f8f19..0be97e880b0a16e13d89b7d2406179bef1fcff40 100755 (executable)
@@ -23,7 +23,7 @@ print_ver_ printenv
 # printenv as a builtin, so we must invoke it via "env".
 # But beware of $_, set by many shells to the last command run.
 # Also, filter out LD_PRELOAD, which is set when running under valgrind.
-# Note the apparently redundant "env env": this is to ensure to get
+# Note the apparently redundant "env  env": this is to ensure to get
 # env's output the same way as that of printenv and works around a bug
 # on aarch64 at least where libc's execvp reverses the order of the
 # output.
index 73fc404b845f9aa6b52208ffaef8f9dae8e58c34..e6183007bfb60bb57ab9ee7bd855f082f0e1bd6d 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-prog='env printf'
-
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ printf
 
+prog='env printf'
+
 # 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_
 ''
 ''\'''
@@ -40,11 +40,11 @@ f=$LOCALE_FR_UTF8
 if test "$LOCALE_FR_UTF8" != "none"; then
   (
    #printable multi-byte
-   LC_ALL=$f env printf '%q\n' 'áḃç' > out
+   LC_ALL=$f $prog '%q\n' 'áḃç' > out
    #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
-   LC_ALL=C env printf '%q\n' 'áḃç' >> out
+   LC_ALL=C $prog '%q\n' 'áḃç' >> out
   )
   cat <<\EOF > exp || framework_failure_
 áḃç
index 50ada55e8a17db3840d93229dada55186734ef64..0e18fe72b39d4cf283ae4b0de45e10d3e9f27855 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ readlink
+print_ver_ readlink pwd
 cwd=$(env pwd -P)
 
 # To trigger this bug, we have to construct a name/situation during
index 776fb67cf2979d7f62ae240e50ebbe6505cb3c2e..a0a287401d8f8e038f828659c3a8d85ab8df3f5f 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ sort
+print_ver_ sort printf
 
 number() { cat -n | sed 's/^ *//'; }
 
index 428d4a2f1ee04edf59831141087ce3185cc91d14..66b644bdd2fd2365b8a7ef9ce27c4fa199cc61ed 100755 (executable)
@@ -20,7 +20,6 @@
 print_ver_ stdbuf
 
 getlimits_
-require_built_ stdbuf
 
 # stdbuf fails when the absolute top build dir name contains e.g.,
 # space, TAB, NL
index f498d1a80ed75930f9e703347dd364f64c4ecec7..c120509c7717d8a317d9be93b91714ee74fffc1f 100755 (executable)
@@ -23,7 +23,6 @@ use strict;
 # Turn off localization of executable's output.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
-my $prog = "$ENV{abs_top_builddir}/src/test";
 my @Tests =
     (
      # In coreutils-5.93, this diagnostic lacked the newline.
@@ -34,6 +33,6 @@ my @Tests =
 
 my $save_temps = $ENV{DEBUG};
 my $verbose = $ENV{VERBOSE};
-
-my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+my $prog = 'test';
+my $fail = run_tests ($program_name, \$prog, \@Tests, $save_temps, $verbose);
 exit $fail;
index c1b4b785f1a0f8b248ac2fbc649065ee266e3d90..f7f549207a35a32ce1d345f6696ecf0e2b5b4811 100755 (executable)
@@ -68,6 +68,7 @@ $@
     {
       my $exp = new Expect;
       $exp->log_user(0);
+      $ENV{built_programs} =~ /\b$cmd\b/ || next;
       $exp->spawn("$cmd 2> $stderr")
         or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next;
       # No input for cut -f2.
index 79f8b87c08b727c75cd77601f0524969d36cb346..a5e81776e56174d7d9adce943b4cb05205ef9c1f 100755 (executable)
@@ -31,7 +31,8 @@ done
 
 # Check the many small items case,
 # 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
     seq $i | paste -s -d ' ' | sed p > out.1
     yes $(seq $i) | head -n2 > out.2
index b09125c5ab9afa7f6a1e40c41c685c41b3f3a568..d1471dc22b47fe8fad8b20f4522116a3a74074ea 100755 (executable)
@@ -18,7 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ mv getfacl setfacl
+print_ver_ mv
 
 require_acl_
 
index 05f297b7c21b849cc40d47468ae7afee2187a0cf..eb49bc648afbb6e683cd0e0bfbe9c0a22cb62f95 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ readlink
+print_ver_ readlink pwd
 
 pwd=$(pwd)
 my_pwd=$(env pwd -P)
index 4b25fc63da0079d1d56978ef644dfddb2ddf148b..b157bbf6e59fab8a9df26c7fd1c30efe80668c7d 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ readlink
+print_ver_ readlink pwd
 
 pwd=$(pwd)
 my_pwd=$(env pwd -P)
index 2eb13565a78d5421f21fe89a5edf836913a13944..0bcbd64a7f90cd8f146bab15a845ff37c20c7d25 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ readlink
+print_ver_ readlink pwd
 
 pwd=$(pwd)
 my_pwd=$(env pwd -P)
index 4ce05083ffc6c8398ed46aa10c49425bac241e83..546cb85251d51edb470caf0c41b3dc7dfe0e2629 100755 (executable)
@@ -21,7 +21,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ tail
+print_ver_ tail sleep
 
 # Terminate any background gdb/tail process
 cleanup_() {
index 1e01d5051667cfe0c66c2f8f96f840bfd5ab2b87..78d8b548a67fe20959197416b7404601274f7713 100755 (executable)
@@ -20,7 +20,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ tail
+print_ver_ tail sleep
 
 # Terminate any background gdb/tail process
 cleanup_() {
index 7ad1a3a9aba8468cbecf9eca4ffd1e3950b4cead..90ec6dc69607714547fb69d0f3331b881c5deb83 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ touch
+print_ver_ touch test
 
 
 touch -c no-file > /dev/null 2>&1 || fail=1
index fc0c72378a5a8867b2b091e8d7c8acf7ce1b1f8d..cddcbbeaf87924699f89891e633b02f54d377875 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ touch
+print_ver_ touch test
 
 ln -s nowhere dangling || framework_failure_
 touch file || framework_failure_