bug-coreutils
[Top][All Lists]
Advanced

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

fix more tests on cygwin


From: Eric Blake
Subject: fix more tests on cygwin
Date: Tue, 27 Oct 2009 22:12:18 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

In working with PATH problems, I noticed these bugs in the testsuite.  The only 
bad PATH in misc/sort-compress was leftover from when sort attempted to use 
gzip unconditionally.  But since sort now requires --compress, rather than 
assuming gzip is present, that clause of the test was not covering anything 
useful any more; the patch changes the test from fail to pass.

rm/fail-eperm changes from fail to skip when run as an admin user (since 
windows is rather generous with delete rights beyond what the POSIX permissions 
would imply); it will take a bit longer to actually run the test as a non-
admin, but I'm assuming it will now pass in that case.

misc/pwd-long was interesting.  On cygwin 1.5, it is impossible to create a 
directory with more than 256 bytes in the absolute name.  This fix changes from 
a fail to a skip.  On cygwin 1.7, the name length limitation was lifted, so my 
first round of edits improved from outright failure (inability to find 
cygwin1.dll required by pwd) to 50% chance of failure (some runs passed, but 
some failed due to problems converting $actual to a relative name).  After 
quite some time debugging, I finally discovered what appears to be the culprit -
 a bug in cygwin's perl.  It looks like perl was built for 32-bit math, but 
cygwin's ino_t is 64-bit.  Depending on what inode was created for the 
temporary dir, $i==$ino sometimes passes, but sometimes ran into overflow 
issues in converting the stat result from a string into a number, such that the 
numeric comparison failed.  Using eq always succeeds, thus working around that 
problem and making the test reliably pass on cygwin 1.7.

OK to apply?


From: Eric Blake <address@hidden>
Date: Tue, 27 Oct 2009 14:08:14 -0600
Subject: [PATCH] tests: fix PATH problems on cygwin

* tests/misc/sort-compress: Remove non-portable over-restriction
of PATH; besides, commit 3ea177e changed sort to no longer default
to gzip.
* tests/rm/fail-eperm: Untaint, rather than clear, PATH.
* tests/misc/pwd-long: Likewise.  Also skip test if long path
cannot be created.
(normalize_to_cwd_relative): Use eq rather than ==, since cygwin
perl doesn't properly handle 64-bit ino_t numerically.
---
 tests/misc/pwd-long      |   21 +++++++++++++++------
 tests/misc/sort-compress |    6 +-----
 tests/rm/fail-eperm      |    7 ++++++-
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long
index 207e754..c67db02 100755
--- a/tests/misc/pwd-long
+++ b/tests/misc/pwd-long
@@ -48,14 +48,19 @@ sub normalize_to_cwd_relative ($$$)
         and die "$ME: $dir does not contain old CWD\n";
       my $dir_prefix = $slash ? substr ($dir, 0, $slash) : '/';
       my ($d, $i) = (stat $dir_prefix)[0, 1];
-      $d == $dev && $i == $ino
+      $d eq $dev && $i eq $ino
         and return substr $dir, $slash + 1;
     }
 }

 # Set up a safe, well-known environment
-delete @ENV{qw(BASH_ENV CDPATH ENV PATH)};
+delete @ENV{qw(BASH_ENV CDPATH ENV)};
 $ENV{IFS}  = '';
+# PATH is tricky - we can't just clear it, or cygwin will fail.  But we
+# can't use it as-is, or taint checking in `` will stop us.  For this
+# script, it is enough to scrub the incoming $PATH first.
+$ENV{'PATH'} =~ /(.*)/;
+$ENV{'PATH'} = "$1";

 # Save CWD's device and inode numbers.
 my ($dev, $ino) = (stat '.')[0, 1];
@@ -70,9 +75,13 @@ substr ($expected, 0, 1) = '';
 my $i = 0;
 do
   {
-    mkdir $z, 0700
-      or die "$ME: at depth $i: $!\n";
-    chdir $z;
+    if (!mkdir $z, 0700)
+      {
+        warn "$ME: skipping this test; cannot create long directory name "
+          . "at depth $i: $!\n";
+        exit 77;
+      }
+    chdir $z
   }
 until (++$i == $n);

@@ -82,7 +91,7 @@ $abs_top_builddir
 my $build_src_dir = "$abs_top_builddir/src";
 if ($build_src_dir !~ m!^([-+.:/\w]+)$!)
   {
-    warn "$0: skipping this test; odd build source directory name:\n"
+    warn "$ME: skipping this test; odd build source directory name:\n"
       . "$build_src_dir\n";
     exit 77;
   }
diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress
index 487d185..7e319ca 100755
--- a/tests/misc/sort-compress
+++ b/tests/misc/sort-compress
@@ -32,7 +32,7 @@ TMPDIR=.; export TMPDIR

 fail=0

-# This should force the use of temp files compressed with the default gzip
+# This should force the use of temp files
 sort -S 1k in > out || fail=1
 compare exp out || fail=1

@@ -69,8 +69,4 @@ compare exp out || fail=1
 test -f ok || fail=1
 rm -f dzip ok

-# This is to make sure sort functions if it can't find the default gzip
-PATH=. "$SORT" -S 1k in > out || fail=1
-compare exp out || fail=1
-
 Exit $fail
diff --git a/tests/rm/fail-eperm b/tests/rm/fail-eperm
index 9ccb913..36192c2 100755
--- a/tests/rm/fail-eperm
+++ b/tests/rm/fail-eperm
@@ -32,8 +32,13 @@ my $verbose = $ENV{VERBOSE} && $ENV{VERBOSE} eq 'yes';
 $ENV{LC_ALL} = 'C';

 # Set up a safe, well-known environment
-delete @ENV{qw(BASH_ENV CDPATH ENV PATH)};
+delete @ENV{qw(BASH_ENV CDPATH ENV)};
 $ENV{IFS}  = '';
+# PATH is tricky - we can't just clear it, or cygwin will fail.  But we
+# can't use it as-is, or taint checking in `` will stop us.  For this
+# script, it is enough to scrub the incoming $PATH first.
+$ENV{'PATH'} =~ /(.*)/;
+$ENV{'PATH'} = "$1";

 my @dir_list = qw(/tmp /var/tmp /usr/tmp);
 my $rm = "$ENV{abs_top_builddir}/src/rm";
-- 
1.6.4.2







reply via email to

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