Subject: bug#7198: ls-misc failure with Oct 10 snapshot

From: Paul Eggert <[email-masked]>
Date: Wed, 13 Oct 2010 23:45:57 -0700

On 10/13/2010 12:37 AM, Jim Meyering wrote:

> What is the server running?

NetApp 6.5.6.  NFS is configured to be NFSv3, running over TCP.

> First step for that one should be to avoid the warnings from perl,
> e.g., via the patch I suggested.

Yes, thanks, somehow I missed the patch to tests/misc/ls-misc
that you suggested in
<http://lists.gnu.org/archive/html/bug-coreutils/2010-10/msg00038.html>.
I just tried it now, and it does fix the perl warnings.

The problem goes away if I do the build on a local disk, so it does
seem to be specific to NFS.

I reproduced the problem with the standard RHEL tools, i.e., without
using the newer versions of GCC etc. that I normally use.

When I strace the make, the bug goes away.  This indicates that it's
timing-related, and may be hard to debug.

Ooo! Ooo!  The "timing-related" in the previous paragraph made the
light bulb go on in my head.  It's clock skew.  The NFS server's
clock is a tiny bit ahead of the NFS client's clock, and so the output
of "ls -l" contains the date, not the time.

I don't see how clock-skew could also explain the test-rename bug noted in
<http://lists.gnu.org/archive/html/bug-coreutils/2010-10/msg00050.html>,
though.  That part of NFS is not supposed to care about clock skew.

Anyway, the following combined patch fixes the ls-misc failure:

>From 1c1b06cbda069991be012f8171d41a713627b30f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 13 Oct 2010 23:39:50 -0700
Subject: [PATCH] tests: work around portability and clock-skew problems

* tests/misc/ls-misc (push_ls_colors): Don't assume LS_COLORS
is set.  This part of the fix is by Jim Meyering.
(sl-dangle2, sl-dangle3, sl-dangle4, sl-dangle5): Don't assume
that newly-created files will have time stamps in the past.  They
might not, due to clock skew, if the file systems are remote.
---
 tests/misc/ls-misc |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc
index e663a5f..9e38038 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc
@@ -27,7 +27,7 @@ my $saved_ls_colors;
 
 sub push_ls_colors($)
 {
-  $saved_ls_colors = $ENV{LS_COLORS};
+  $saved_ls_colors = $ENV{LS_COLORS} || '';
   $ENV{LS_COLORS} = $_[0];
 }
 
@@ -186,8 +186,8 @@ my @Tests =
      ],
 
      # Test for a bug fixed after coreutils-8.2.
-     ['sl-dangle2', '-o --color=always l',
-      {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+     ['sl-dangle2', '-o --time-style=+:TIME: --color=always l',
+      {OUT_SUBST => 's/.*:TIME: //'},
       {OUT => "l -> nowhere\n"},
       {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
                    push_ls_colors('ln=target')
@@ -195,8 +195,8 @@ my @Tests =
       {POST => sub {unlink 'l' or die "l: $!\n";
                     restore_ls_colors; }},
      ],
-     ['sl-dangle3', '-o --color=always l',
-      {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+     ['sl-dangle3', '-o --time-style=+:TIME: --color=always l',
+      {OUT_SUBST => 's/.*:TIME: //'},
       {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n"},
       {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
                    push_ls_colors('ln=target:or=40:mi=34:')
@@ -204,8 +204,8 @@ my @Tests =
       {POST => sub {unlink 'l' or die "l: $!\n";
                     restore_ls_colors; }},
      ],
-     ['sl-dangle4', '-o --color=always l',
-      {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+     ['sl-dangle4', '-o --time-style=+:TIME: --color=always l',
+      {OUT_SUBST => 's/.*:TIME: //'},
       {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n"},
       {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
                    push_ls_colors('ln=34:mi=35:or=36:')
@@ -213,8 +213,8 @@ my @Tests =
       {POST => sub {unlink 'l' or die "l: $!\n";
                     restore_ls_colors; }},
      ],
-     ['sl-dangle5', '-o --color=always l',
-      {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+     ['sl-dangle5', '-o --time-style=+:TIME: --color=always l',
+      {OUT_SUBST => 's/.*:TIME: //'},
       {OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n"},
       {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
                    push_ls_colors('ln=34:mi=35:')
-- 
1.7.2