bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI, 11 mostly-test-related patches


From: Jim Meyering
Subject: FYI, 11 mostly-test-related patches
Date: Mon, 28 Apr 2008 15:48:42 +0200

[I hesitated to post so many small test-only patches all together,
 but it's better than not posting at all.  Besides, maybe posting
 at all will evoke some review feedback.  So here goes... ]

>From 6bbbd65d895505c506105ea12e44922433e63574 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Apr 2008 12:31:13 +0200
Subject: [PATCH] tests: do define built_programs

* tests/check.mk (built_programs): Define here, where it's used.
This definition was in now-removed tests/misc/Makefile.am.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/check.mk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tests/check.mk b/tests/check.mk
index cb4373a..978313b 100644
--- a/tests/check.mk
+++ b/tests/check.mk
@@ -36,6 +36,9 @@ vc_exe_in_TESTS: Makefile
 check: vc_exe_in_TESTS
 .PHONY: vc_exe_in_TESTS

+built_programs = \
+  (cd $(top_builddir)/src && MAKEFLAGS= $(MAKE) -s built_programs.list)
+
 # Append this, because automake does the same.
 TESTS_ENVIRONMENT =                            \
   abs_top_builddir='$(abs_top_builddir)'       \
--
1.5.5.1.68.gbdcd8


>From cca6a8d7e525edb232160046d074fff16a76bbb5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 27 Apr 2008 21:31:08 +0200
Subject: [PATCH] tweak HACKING advice


Signed-off-by: Jim Meyering <address@hidden>
---
 HACKING |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/HACKING b/HACKING
index d616443..b40ff00 100644
--- a/HACKING
+++ b/HACKING
@@ -26,11 +26,16 @@ That downloads the entire repository, including revision 
control history
 dating back to 1991.  The repository (the part you download, and which
 resides in coreutils/.git) currently weighs in at about 30MB.  So you
 don't want to download it more often than necessary.  Once downloaded,
-you can get incremental updates by running this command from inside
-your new coreutils/ directory:
+you can get incremental updates by running one of these commands from
+inside your new coreutils/ directory:

+If you have made *no* changes:
     git pull

+If you *have* made changes and committed them to "master", do this:
+    git fetch
+    git rebase origin
+

 *Before* you commit changes
 ===========================
--
1.5.5.1.68.gbdcd8


>From 8dc387dba567da10e2e90107fd044baaef580145 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Apr 2008 12:43:20 +0200
Subject: [PATCH] tests: cp/perm (usually not run) was failing on systems with 
SELinux

* tests/cp/perm: Use stat to get the permission string, not ls.
This test was run only when RUN_VERY_EXPENSIVE_TESTS=yes was set
in the environment.  It would fail on SELinux-enable systems
because ls-generated permission strings would not match, e.g.,
"test _-rw-r--r--+ = _-rw-r--r--" would fail.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/cp/perm |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/cp/perm b/tests/cp/perm
index b24221f..b482c17 100755
--- a/tests/cp/perm
+++ b/tests/cp/perm
@@ -41,9 +41,7 @@ for u in 31 37 2; do
          for o_perm in r w x rw wx xr rwx; do
            touch src || exit 1
            chmod u=r,g=rx,o= src || exit 1
-           set _ `ls -l src`
-           shift
-           expected_perms=$1
+           expected_perms=$(stat --format=%A src)
            rm -f dest
            test $existing_dest = yes && {
              touch dest || exit 1
@@ -52,8 +50,7 @@ for u in 31 37 2; do
            $cmd $force src dest || exit 1
            test "$cmd" = mv && test -f src && exit 1
            test "$cmd" = cp && { test -f src || exit 1; }
-           set _ `ls -l dest`
-           shift
+           actual_perms=$(stat --format=%A dest)

            case "$cmd:$force:$existing_dest" in
              cp:*:yes)
@@ -68,7 +65,7 @@ for u in 31 37 2; do
                  expected_perms=`echo $expected_perms|sed 
's/..\(..\).$/--\1-/'`
                ;;
            esac
-           test _$1 = _$expected_perms || exit 1
+           test _$actual_perms = _$expected_perms || exit 1
            # Perform only one iteration when there's no existing destination.
            test $existing_dest = no && break 3
          done
--
1.5.5.1.68.gbdcd8


>From 427f179542e9f7228f77affdd5a4c50a573b4894 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Apr 2008 12:50:24 +0200
Subject: [PATCH] tests: move another file (expensive) into test-lib.sh

* tests/expensive: Remove file.  Move contents into ...
* tests/test-lib.sh (expensive_): ...here.  New function.
* tests/du/fd-leak: Update caller to use the new function.
* tests/mv/leak-fd: Likewise.
* tests/rm/hash: Likewise.
* tests/tail-2/big-4gb: Likewise.
* tests/Makefile.am (EXTRA_DIST): Remove its name.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/Makefile.am    |    1 -
 tests/du/fd-leak     |    5 +++--
 tests/expensive      |   28 ----------------------------
 tests/mv/leak-fd     |    8 ++++----
 tests/rm/hash        |    3 +--
 tests/tail-2/big-4gb |    2 +-
 tests/test-lib.sh    |   13 +++++++++++++
 7 files changed, 22 insertions(+), 38 deletions(-)
 delete mode 100644 tests/expensive

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7dfafac..2a16989 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,7 +12,6 @@ EXTRA_DIST =          \
   README               \
   check.mk             \
   envvar-check         \
-  expensive            \
   group-names          \
   input-tty            \
   lang-default         \
diff --git a/tests/du/fd-leak b/tests/du/fd-leak
index c4080ff..73fe4f8 100755
--- a/tests/du/fd-leak
+++ b/tests/du/fd-leak
@@ -21,10 +21,11 @@ if test "$VERBOSE" = yes; then
   du --version
 fi

+. $top_srcdir/tests/test-lib.sh
+
 # Call this an expensive test.  It's not that expensive, but command line
 # limitations might induce failure on some losing systems.
-. $top_srcdir/tests/expensive
-. $top_srcdir/tests/test-lib.sh
+expensive_

 # Create 1296 (36^2) files.
 # Their names and separating spaces take up 3887 bytes.
diff --git a/tests/expensive b/tests/expensive
deleted file mode 100644
index c365f70..0000000
--- a/tests/expensive
+++ /dev/null
@@ -1,28 +0,0 @@
-# Is a test expensive?
-
-# Copyright (C) 2000, 2004 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/>.
-
-if test "$RUN_EXPENSIVE_TESTS" != yes; then
-  cat <<EOF >&2
-$0: This test is relatively expensive, so it is disabled by default.
-To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
-environment variable set to yes.  E.g.,
-
-  env RUN_EXPENSIVE_TESTS=yes make check
-
-EOF
-  (exit 77); exit 77
-fi
diff --git a/tests/mv/leak-fd b/tests/mv/leak-fd
index 549d256..1ecdb20 100755
--- a/tests/mv/leak-fd
+++ b/tests/mv/leak-fd
@@ -23,15 +23,15 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi

-# This test is relatively expensive, and might well evoke a
-# framework-failure on systems with a smaller command-line length
-. $top_srcdir/tests/expensive
-
 . $top_srcdir/tests/test-lib.sh
 skip_if_root_
 cleanup_() { rm -rf "$other_partition_tmpdir"; }
 . "$abs_top_srcdir/tests/other-fs-tmpdir"

+# This test is relatively expensive, and might well evoke a
+# framework-failure on systems with a smaller command-line length
+expensive_
+
 b="0 1 2 3 4 5 6 7 8 9
 a b c d e f g h i j k l m n o p q r s t u v w x y z
 _A _B _C _D _E _F _G _H _I _J _K _L _M _N _O _P _Q _R _S _T _U _V _W _X _Y _Z"
diff --git a/tests/rm/hash b/tests/rm/hash
index 0b2b6c5..56f96e4 100755
--- a/tests/rm/hash
+++ b/tests/rm/hash
@@ -18,14 +18,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-. $top_srcdir/tests/expensive
-
 if test "$VERBOSE" = yes; then
   set -x
   rm --version
 fi

 . $top_srcdir/tests/test-lib.sh
+expensive_

 # Create a hierarchy with 3*26 leaf directories, each at depth 153.
 echo "$0: creating 78 trees, each of depth 153; this will take a while..." >&2
diff --git a/tests/tail-2/big-4gb b/tests/tail-2/big-4gb
index b7d2528..8b64c6e 100755
--- a/tests/tail-2/big-4gb
+++ b/tests/tail-2/big-4gb
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
   tail --version
 fi

-. $top_srcdir/tests/expensive
 . $top_srcdir/tests/test-lib.sh
+expensive_

 # Create a file of size exactly 4GB (2^32) with 8 bytes
 # at the beginning and another set of 8 bytes at the end.
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 8f56ab1..78ac97d 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -151,6 +151,19 @@ environment variable set to yes.  E.g.,
   fi
 }

+expensive_()
+{
+  if test "$RUN_EXPENSIVE_TESTS" != yes; then
+    skip_test_ '
+This test is relatively expensive, so it is disabled by default.
+To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
+environment variable set to yes.  E.g.,
+
+  env RUN_EXPENSIVE_TESTS=yes make check
+'
+  fi
+}
+
 require_root_()
 {
   uid_is_privileged_ || skip_test_ "must be run as root"
--
1.5.5.1.68.gbdcd8


>From 53d8a2c412cccd2ee5ee7760f6fcf1890c5e9e3b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 24 Apr 2008 12:58:24 +0200
Subject: [PATCH] tests: put root-only (usually skipped) tests at the end

* tests/Makefile.am (TESTS): Don't list root-only tests explicitly.
Instead, just use $(root_tests).
* tests/check.mk (vc_exe_in_TESTS): Now that root_tests are separate,
parse out the union of $(TESTS) and $(root_tests).

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/Makefile.am |   16 ++--------------
 tests/check.mk    |    8 ++++++--
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2a16989..f340eeb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,7 +88,6 @@ TESTS =                                               \
   rm/empty-inacc                               \
   rm/empty-name                                        \
   rm/f-1                                       \
-  rm/fail-2eperm                               \
   rm/fail-eacces                               \
   rm/fail-eperm                                        \
   rm/hash                                      \
@@ -101,8 +100,6 @@ TESTS =                                             \
   rm/interactive-once                          \
   rm/ir-1                                      \
   rm/isatty                                    \
-  rm/no-give-up                                        \
-  rm/one-file-system                           \
   rm/r-1                                       \
   rm/r-2                                       \
   rm/r-3                                       \
@@ -136,7 +133,6 @@ TESTS =                                             \
   misc/pr                                      \
   misc/df-P                                    \
   misc/pwd-unreadable-parent                   \
-  misc/chcon                                   \
   misc/chcon-fail                              \
   misc/selinux                                 \
   misc/cut                                     \
@@ -218,7 +214,6 @@ TESTS =                                             \
   chmod/thru-dangling                          \
   chmod/umask-x                                        \
   chmod/usage                                  \
-  chown/basic                                  \
   chown/deref                                  \
   chown/preserve-root                          \
   chown/separator                              \
@@ -228,7 +223,6 @@ TESTS =                                             \
   cp/backup-dir                                        \
   cp/backup-is-src                             \
   cp/cp-HL                                     \
-  cp/cp-a-selinux                              \
   cp/cp-deref                                  \
   cp/cp-i                                      \
   cp/cp-mv-backup                              \
@@ -251,13 +245,11 @@ TESTS =                                           \
   cp/parent-perm-race                          \
   cp/perm                                      \
   cp/preserve-2                                        \
-  cp/preserve-gid                              \
   cp/proc-zero-len                             \
   cp/r-vs-symlink                              \
   cp/same-file                                 \
   cp/slink-2-slink                             \
   cp/sparse                                    \
-  cp/special-bits                              \
   cp/special-f                                 \
   cp/src-base-dot                              \
   cp/symlink-slash                             \
@@ -306,7 +298,6 @@ TESTS =                                             \
   ls/infloop                                   \
   ls/inode                                     \
   ls/m-option                                  \
-  ls/nameless-uid                              \
   ls/no-arg                                    \
   ls/proc-selinux-segfault                     \
   ls/recursive                                 \
@@ -328,7 +319,6 @@ TESTS =                                             \
   mkdir/selinux                                        \
   mkdir/special-1                              \
   mkdir/t-slash                                        \
-  mkdir/writable-under-readonly                        \
   mv/acl                                       \
   mv/atomic                                    \
   mv/atomic2                                   \
@@ -365,7 +355,6 @@ TESTS =                                             \
   mv/partition-perm                            \
   mv/perm-1                                    \
   mv/reply-no                                  \
-  mv/sticky-to-xpart                           \
   mv/to-symlink                                        \
   mv/trailing-slash                            \
   mv/update                                    \
@@ -376,7 +365,6 @@ TESTS =                                             \
   rmdir/fail-perm                              \
   rmdir/ignore                                 \
   rmdir/t-slash                                        \
-  tail-2/append-only                           \
   tail-2/assert                                        \
   tail-2/assert-2                              \
   tail-2/big-4gb                               \
@@ -392,9 +380,9 @@ TESTS =                                             \
   touch/no-create-missing                      \
   touch/no-rights                              \
   touch/not-owner                              \
-  touch/now-owned-by-other                     \
   touch/obsolescent                            \
   touch/read-only                              \
-  touch/relative
+  touch/relative                               \
+  $(root_tests)

 include $(top_srcdir)/tests/check.mk
diff --git a/tests/check.mk b/tests/check.mk
index 978313b..f62661c 100644
--- a/tests/check.mk
+++ b/tests/check.mk
@@ -18,12 +18,16 @@
 # 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
        @rm -f t1 t2
        @if test -d $(top_srcdir)/.git && test $(srcdir) = .; then      \
-         sed -n '/^$(_v) =[     ]*\\$$/,/[^\]$$/p'                     \
+         { sed -n '/^$(_v) =[   ]*\\$$/,/[^\]$$/p'                     \
                $(srcdir)/Makefile.am                                   \
-           | sed 's/^  *//;/^\$$.*/d;/^$(_v) =/d'                      \
+           | 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)/!!'`;                         \
--
1.5.5.1.68.gbdcd8


>From dfdb532fd3472304da08fb35859cdfee3caaf5c6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Apr 2008 09:36:54 +0200
Subject: [PATCH] tests: reorder some tests in the long list

* tests/Makefile.am (TESTS): Move some tests that use sleep
"up" in the list so that they don't delay even a little the
completion of "make check".  Also run a chmod test early.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/Makefile.am |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index f340eeb..785e438 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,10 +23,9 @@ EXTRA_DIST =         \
   sparse-file          \
   test-lib.sh

-## N O T E :: Please do not add new tests/ directories.
-## There are too many already.  Put new tests in misc/.
+## N O T E :: Do not add more names to this list.
+## N O T E :: Even these are expected to go away.
 SUBDIRS = cut head join pr sort tac tail test tr uniq wc
-## N O T E :: Please do not add new directories.

 root_tests =                                   \
   chown/basic                                  \
@@ -66,46 +65,52 @@ EXTRA_DIST += $(TESTS)
 # will execute the test script rather than the standard utility.

 # Regarding ordering in SUBDIRS, place early in the list the tools that
-# are most commonly used in test scripts.  Every test script uses rm
-# and chmod, so they have to be very early.
-# Ordering within misc/ should handle the rest.
+# are most commonly used in test scripts.  Nearly every test script uses
+# rm and chmod, so they appear early in the list.

-# Ordering:
+# Notes on the ordering of these tests:
 # help-version comes early because it's a basic sanity test.
 # Put seq early, since lots of other tests use it.
+# Put tests that sleep early, but not all together, so in parallel builds
+# they share time with tests that burn CPU, not with others that sleep.
 # Put head-elide-tail early, because it's long-running.

 TESTS =                                                \
   misc/help-version                            \
-  chgrp/basic                                  \
   rm/cycle                                     \
+  chmod/no-x                                   \
+  chgrp/basic                                  \
   rm/dangling-symlink                          \
+  misc/ls-time                                 \
   rm/deep-1                                    \
   rm/deep-2                                    \
   rm/dir-no-w                                  \
   rm/dir-nonrecur                              \
   rm/dot-rel                                   \
+  rm/isatty                                    \
   rm/empty-inacc                               \
   rm/empty-name                                        \
   rm/f-1                                       \
   rm/fail-eacces                               \
   rm/fail-eperm                                        \
+  tail-2/assert                                        \
   rm/hash                                      \
   rm/i-1                                       \
   rm/i-never                                   \
   rm/i-no-r                                    \
+  tail-2/infloop-1                             \
   rm/ignorable                                 \
   rm/inaccessible                              \
   rm/interactive-always                                \
   rm/interactive-once                          \
   rm/ir-1                                      \
-  rm/isatty                                    \
   rm/r-1                                       \
   rm/r-2                                       \
   rm/r-3                                       \
   rm/r-4                                       \
   rm/readdir-bug                               \
   rm/rm1                                       \
+  touch/empty-file                             \
   rm/rm2                                       \
   rm/rm3                                       \
   rm/rm4                                       \
@@ -122,7 +127,7 @@ TESTS =                                             \
   chgrp/recurse                                        \
   misc/seq                                     \
   misc/head-elide-tail                         \
-  misc/ls-time                                 \
+  tail-2/tail-n0f                              \
   misc/ls-misc                                 \
   misc/date                                    \
   misc/ptx-overrun                             \
@@ -208,7 +213,6 @@ TESTS =                                             \
   chmod/equal-x                                        \
   chmod/equals                                 \
   chmod/inaccessible                           \
-  chmod/no-x                                   \
   chmod/octal                                  \
   chmod/setgid                                 \
   chmod/thru-dangling                          \
@@ -365,16 +369,12 @@ TESTS =                                           \
   rmdir/fail-perm                              \
   rmdir/ignore                                 \
   rmdir/t-slash                                        \
-  tail-2/assert                                        \
   tail-2/assert-2                              \
   tail-2/big-4gb                               \
-  tail-2/infloop-1                             \
   tail-2/proc-ksyms                            \
   tail-2/start-middle                          \
-  tail-2/tail-n0f                              \
   touch/dangling-symlink                       \
   touch/dir-1                                  \
-  touch/empty-file                             \
   touch/fail-diag                              \
   touch/fifo                                   \
   touch/no-create-missing                      \
--
1.5.5.1.68.gbdcd8


>From bbafdc3c8f97cc1df1b4cd0f17280ea5f5295cfa Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Apr 2008 10:41:42 +0200
Subject: [PATCH] tests: improve perl-based tempdir handling

Before, upon interrupt, directories would be left behind.
* tests/CuTmpdir.pm: Remove temporary directory on interrupt.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/CuTmpdir.pm |   65 ++++++++++++++++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/tests/CuTmpdir.pm b/tests/CuTmpdir.pm
index 60eec90..f9d2c00 100644
--- a/tests/CuTmpdir.pm
+++ b/tests/CuTmpdir.pm
@@ -1,7 +1,7 @@
 package CuTmpdir;
 # create, then chdir into a temporary sub-directory

-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007-2008 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
@@ -26,12 +26,44 @@ our $ME = $0 || "<???>";

 my $dir;

-sub skip_test
+sub skip_test($)
 {
-  warn "$ME: skipping test: unsafe working directory name\n";
+  warn "$ME: skipping test: unsafe working directory name: `$_[0]'\n";
   exit 77;
 }

+sub chmod_1
+{
+  my $name = $_;
+
+  # Skip symlinks and non-directories.
+  -l $name || !-d _
+    and return;
+
+  chmod 0700, $name;
+}
+
+sub chmod_tree
+{
+  chdir $dir
+    or warn "$ME: failed to chdir to $dir: $!\n";
+  # Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
+  my $options = {untaint => 1, wanted => \&chmod_1};
+  find ($options, '.');
+}
+
+sub on_sig_remove_tmpdir
+{
+  my ($sig) = @_;
+  if (defined $dir)
+    {
+      chmod_tree;
+      File::Temp::cleanup;
+    }
+  $SIG{$sig} = 'DEFAULT';
+  kill $sig, $$;
+}
+
 sub import {
   my $prefix = $_[1];

@@ -47,35 +79,22 @@ sub import {

   # Untaint for the upcoming mkdir.
   $prefix =~ m!^(address@hidden/]+)$!
-    or skip_test;
+    or skip_test $prefix;
   $prefix = $1;

+  foreach my $sig (qw (INT TERM HUP))
+    {
+      $SIG{$sig} = \&on_sig_remove_tmpdir;
+    }
+
   $dir = File::Temp::tempdir("$prefix.tmp-XXXX", CLEANUP => 1 );
   chdir $dir
     or warn "$ME: failed to chdir to $dir: $!\n";
 }

-sub wanted
-{
-  my $name = $_;
-
-  # Skip symlinks and non-directories.
-  -l $name || !-d _
-    and return;
-
-  chmod 0700, $name;
-}
-
 END {
   my $saved_errno = $?;
-  if (defined $dir)
-    {
-      chdir $dir
-       or warn "$ME: failed to chdir to $dir: $!\n";
-      # Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
-      my $options = {untaint => 1, wanted => \&wanted};
-      find ($options, '.');
-    }
+  chmod_tree;
   $? = $saved_errno;
 }

--
1.5.5.1.68.gbdcd8


>From 816e56a3deff5d95c946b52622a60c17d6d74ee4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Apr 2008 10:59:47 +0200
Subject: [PATCH] tests: ensure at least one failure when $built_programs is 
empty

Before, this test and others would pass with empty $built_programs.
* tests/misc/help-version: Fail if built_programs is empty.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/misc/help-version |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tests/misc/help-version b/tests/misc/help-version
index 6cbf138..da900a5 100755
--- a/tests/misc/help-version
+++ b/tests/misc/help-version
@@ -40,6 +40,9 @@ expected_failure_status_vdir=2

 fail=0

+test "$built_programs" \
+  || { echo "$this_test: no programs built!?!" 1>&2; (exit $fail); exit $fail; 
}
+
 for lang in C fr da; do
   for i in $built_programs; do

--
1.5.5.1.68.gbdcd8


>From 972e2737abf30c522c029051a13354756413ea46 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Apr 2008 14:39:38 +0200
Subject: [PATCH] tests: don't source envvar-check manually, test-lib.sh does it

* tests/cp/abuse: Remove ". $top_srcdir/tests/envvar-check".
* tests/cp/parent-perm: Likewise.
* tests/cp/special-f: Likewise.
* tests/ls/proc-selinux-segfault: Likewise.
* tests/misc/help-version: Likewise.
* tests/mkdir/selinux: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/touch/now-owned-by-other: Likewise.
* tests/sample-test: Remove commented out suggestion.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/cp/abuse                 |    1 -
 tests/cp/parent-perm           |    1 -
 tests/cp/special-f             |    1 -
 tests/ls/proc-selinux-segfault |    1 -
 tests/misc/help-version        |    1 -
 tests/mkdir/selinux            |    1 -
 tests/mv/sticky-to-xpart       |    1 -
 tests/sample-test              |    1 -
 tests/touch/now-owned-by-other |    1 -
 9 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/tests/cp/abuse b/tests/cp/abuse
index f4f215f..737a3eb 100755
--- a/tests/cp/abuse
+++ b/tests/cp/abuse
@@ -21,7 +21,6 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/lang-default
 . $top_srcdir/tests/test-lib.sh

diff --git a/tests/cp/parent-perm b/tests/cp/parent-perm
index d2c2533..77bcf75 100755
--- a/tests/cp/parent-perm
+++ b/tests/cp/parent-perm
@@ -21,7 +21,6 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/test-lib.sh

 working_umask_or_skip_
diff --git a/tests/cp/special-f b/tests/cp/special-f
index cf684e3..a2e67ba 100755
--- a/tests/cp/special-f
+++ b/tests/cp/special-f
@@ -22,7 +22,6 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/lang-default
 . $top_srcdir/tests/test-lib.sh

diff --git a/tests/ls/proc-selinux-segfault b/tests/ls/proc-selinux-segfault
index 60cfe55..79ea523 100755
--- a/tests/ls/proc-selinux-segfault
+++ b/tests/ls/proc-selinux-segfault
@@ -21,7 +21,6 @@ if test "$VERBOSE" = yes; then
   ls --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/test-lib.sh

 f=/proc/sys
diff --git a/tests/misc/help-version b/tests/misc/help-version
index da900a5..25364df 100755
--- a/tests/misc/help-version
+++ b/tests/misc/help-version
@@ -25,7 +25,6 @@ test "$VERBOSE" = yes && set -x
 test "x$SHELL" = x && SHELL=/bin/sh
 export SHELL

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/test-lib.sh

 expected_failure_status_nohup=127
diff --git a/tests/mkdir/selinux b/tests/mkdir/selinux
index c81669d..f0795b1 100755
--- a/tests/mkdir/selinux
+++ b/tests/mkdir/selinux
@@ -27,7 +27,6 @@ fi
 # mcstrans-0.2.8-1.fc9, the following commands may mistakenly exit
 # successfully, in spite of the invalid context string.

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/lang-default
 . $top_srcdir/tests/test-lib.sh

diff --git a/tests/mv/sticky-to-xpart b/tests/mv/sticky-to-xpart
index 1578ae8..940770b 100755
--- a/tests/mv/sticky-to-xpart
+++ b/tests/mv/sticky-to-xpart
@@ -24,7 +24,6 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/lang-default
 . $top_srcdir/tests/test-lib.sh
 require_root_
diff --git a/tests/sample-test b/tests/sample-test
index c081504..e6ef5b6 100644
--- a/tests/sample-test
+++ b/tests/sample-test
@@ -21,7 +21,6 @@ if test "$VERBOSE" = yes; then
   FIXME --version
 fi

-# FIXME: . $top_srcdir/tests/envvar-check
 # FIXME: . $top_srcdir/tests/lang-default
 . $top_srcdir/tests/test-lib.sh
 # FIXME: skip_if_root_
diff --git a/tests/touch/now-owned-by-other b/tests/touch/now-owned-by-other
index 7aaa4f3..2f85850 100755
--- a/tests/touch/now-owned-by-other
+++ b/tests/touch/now-owned-by-other
@@ -21,7 +21,6 @@ if test "$VERBOSE" = yes; then
   touch --version
 fi

-. $top_srcdir/tests/envvar-check
 . $top_srcdir/tests/test-lib.sh
 require_root_

--
1.5.5.1.68.gbdcd8


>From 5a3b0c4805630ab0d509b54987c284cac16d2de5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 25 Apr 2008 15:20:19 +0200
Subject: [PATCH] tests: remove temporary log file upon catchable signal

* check.mk (am__check_pre): Add signal handler to remove address@hidden

Signed-off-by: Jim Meyering <address@hidden>
---
 build-aux/check.mk |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/build-aux/check.mk b/build-aux/check.mk
index be255c4..9d909c6 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -104,6 +104,8 @@ am__check_pre =                                     \
 $(SH_E_WORKAROUND);                            \
 tst=`echo "$$src" | sed 's|^.*/||'`;           \
 rm -f address@hidden;                                  \
+trap 'st=$$?; rm -f '\''$(abs_builddir)/address@hidden'\''; (exit $$st); exit 
$$st' \
+  1 2 13 15;                                   \
 $(mkdir_p) "$$(echo '$@'|$(_dirname))" || exit;        \
 if test -f "./$$src"; then dir=./;             \
 elif test -f "$$src"; then dir=;               \
--
1.5.5.1.68.gbdcd8


>From d6ec836387bc245a17e65f337452c9809bfcdeec Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 26 Apr 2008 23:40:03 +0200
Subject: [PATCH] move wc tests from own subdir into a single script

* configure.ac (AC_CONFIG_FILES): Remove wc/Makefile from the list.
* tests/Makefile.am (SUBDIRS): Remove wc from the list.
(TESTS): Add misc/wc.
* tests/misc/wc: New file, derived from tests/wc/Tests.pm.
* tests/wc/Test.pm: Remove file.

Signed-off-by: Jim Meyering <address@hidden>
---
 configure.ac      |    1 -
 tests/Makefile.am |    3 +-
 tests/misc/wc     |   59 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/wc/Test.pm  |   68 -----------------------------------------------------
 4 files changed, 61 insertions(+), 70 deletions(-)
 create mode 100755 tests/misc/wc
 delete mode 100644 tests/wc/Test.pm

diff --git a/configure.ac b/configure.ac
index adf2903..6a7c5a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,6 +354,5 @@ AC_CONFIG_FILES(
   tests/test/Makefile
   tests/tr/Makefile
   tests/uniq/Makefile
-  tests/wc/Makefile
   )
 AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 785e438..8dde07e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,7 +25,7 @@ EXTRA_DIST =          \

 ## N O T E :: Do not add more names to this list.
 ## N O T E :: Even these are expected to go away.
-SUBDIRS = cut head join pr sort tac tail test tr uniq wc
+SUBDIRS = cut head join pr sort tac tail test tr uniq

 root_tests =                                   \
   chown/basic                                  \
@@ -141,6 +141,7 @@ TESTS =                                             \
   misc/chcon-fail                              \
   misc/selinux                                 \
   misc/cut                                     \
+  misc/wc                                      \
   misc/wc-files0-from                          \
   misc/wc-files0                               \
   misc/cat-proc                                        \
diff --git a/tests/misc/wc b/tests/misc/wc
new file mode 100755
index 0000000..539b1dd
--- /dev/null
+++ b/tests/misc/wc
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Basic tests for "wc".
+
+# Copyright (C) 1997, 2003, 2006, 2008 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/>.
+
+: ${srcdir=.}
+. $top_srcdir/tests/require-perl
+
+me=`echo $0|sed 's,.*/,,'`
+exec $PERL -w -I$top_srcdir/tests -MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF
+require 5.003;
+use strict;
+
+my $prog = 'wc';
+
+# Turn off localisation of executable's ouput.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $degenerate = "d41d8cd98f00b204e9800998ecf8427e";
+
+my @Tests =
+    (
+     ['a0', '-c',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a1', '-l',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a2', '-w',  {IN_PIPE=>''},            {OUT=>"0\n"}],
+     ['a3', '-c',  {IN_PIPE=>'x'},           {OUT=>"1\n"}],
+     ['a4', '-w',  {IN_PIPE=>'x'},           {OUT=>"1\n"}],
+     ['a5', '-w',  {IN_PIPE=>"x y\n"},       {OUT=>"2\n"}],
+     ['a6', '-w',  {IN_PIPE=>"x y\nz"},      {OUT=>"3\n"}],
+     # Remember, -l counts *newline* bytes, not logical lines.
+     ['a7', '-l',  {IN_PIPE=>"x y"},         {OUT=>"0\n"}],
+     ['a8', '-l',  {IN_PIPE=>"x y\n"},       {OUT=>"1\n"}],
+     ['a9', '-l',  {IN_PIPE=>"x\ny\n"},      {OUT=>"2\n"}],
+     ['b0', '',    {IN_PIPE=>""},         {OUT=>"      0       0       0\n"}],
+     ['b1', '',    {IN_PIPE=>"a b\nc\n"}, {OUT=>"      2       3       6\n"}],
+     ['c0', '-L',  {IN_PIPE=>"1\n12\n"},     {OUT=>"2\n"}],
+     ['c1', '-L',  {IN_PIPE=>"1\n123\n1\n"}, {OUT=>"3\n"}],
+     ['c2', '-L',  {IN_PIPE=>"\n123456"},    {OUT=>"6\n"}],
+    );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($prog, $prog, address@hidden, $save_temps, $verbose);
+exit $fail;
+EOF
diff --git a/tests/wc/Test.pm b/tests/wc/Test.pm
deleted file mode 100644
index dae08ff..0000000
--- a/tests/wc/Test.pm
+++ /dev/null
@@ -1,68 +0,0 @@
-# Test "wc".
-
-# Copyright (C) 1997, 2003, 2006 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/>.
-
-package Test;
-require 5.002;
-use strict;
-
-$Test::input_via_stdin = 1;
-
-my @tv = (
-# test flags  input                 expected output        expected return code
-['a0', '-c',  '',                   "0\n",                          0],
-['a1', '-l',  '',                   "0\n",                          0],
-['a2', '-w',  '',                   "0\n",                          0],
-['a3', '-c',  'x',                  "1\n",                          0],
-['a4', '-w',  'x',                  "1\n",                          0],
-['a5', '-w',  "x y\n",              "2\n",                          0],
-['a6', '-w',  "x y\nz",             "3\n",                          0],
-# Remember, -l counts *newline* bytes, not logical lines.
-['a7', '-l',  "x y",                "0\n",                          0],
-['a8', '-l',  "x y\n",              "1\n",                          0],
-['a9', '-l',  "x\ny\n",             "2\n",                          0],
-['b0', '',    "",                   "0 0 0\n",                      0],
-['b1', '',    "a b\nc\n",           "2 3 6\n",                      0],
-['c0', '-L',  "1\n12\n",            "2\n",                          0],
-['c1', '-L',  "1\n123\n1\n",        "3\n",                          0],
-['c2', '-L',  "\n123456",           "6\n",                          0],
-);
-
-sub test_vector
-{
-  my $t;
-  foreach $t (@tv)
-    {
-      my ($test_name, $flags, $in, $exp, $ret) = @$t;
-      # By default, test both stdin-redirection and input from a pipe.
-      $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
-
-      # But if test name ends with `-file', test only with file arg(s).
-      # FIXME: unfortunately, invoking wc like `wc FILE' makes it put
-      # FILE in the ouput -- and FILE is different depending on $srcdir.
-      $Test::input_via{$test_name} = {FILE => 0}
-        if $test_name =~ /-file$/;
-
-      # Now that `wc FILE' (note, with no options) produces results
-      # different from `cat FILE|wc', disable those two `PIPE' tests.
-      $flags eq ''
-       and delete $Test::input_via{$test_name}->{PIPE};
-    }
-
-  return @tv;
-}
-
-1;
--
1.5.5.1.68.gbdcd8




reply via email to

[Prev in Thread] Current Thread [Next in Thread]