Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in C02cont.ztst's -N test



On Apr 29,  8:51pm, Bart Schaefer wrote:
} Subject: Re: Bug in C02cont.ztst's -N test
}
} Is there some magic reason it has to total 60 seconds?

Oh, it's because not all versions of "ls" will show file times down to
the second, so we have to wait a full minute.  But that would mean
waiting one minute between creating and accessing the file, not just
between the runs of "ls".  

So what we need is to first determine whether {mount || /sbin/mount}
is going to return useful mount attribute information, and then do the
60-second sleep only if we can't trust it.

Wild guess without actually attempting to set up mock follows.  This
also handles the case where mount is neither in $PATH nor in /sbin.
Still breaks if "ls" is not in $PATH, but that seems unlikely.


diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index f9fc185..189c233 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -146,7 +146,12 @@
 
 # can't be bothered with -S
 
-  print -u $ZTST_fd 'This test takes two seconds...'
+  if [[ ${mtab::="$({mount || /sbin/mount})"} = *[(]?*[)] ]]; then
+    print -u $ZTST_fd 'This test takes two seconds...'
+  else
+    unmodified_ls="$(ls -lu $unmodified)"
+    print -u $ZTST_fd 'This test takes up to 60 seconds...'
+  fi
   sleep 2
   cat $unmodified
   touch $newnewnew
@@ -154,7 +159,14 @@
     ZTST_skip="[[ -N file ]] not supported on Cygwin"
   elif (( isnfs )); then
     ZTST_skip="[[ -N file ]] not supported with NFS"
-  elif { df -k -- ${$({mount || /sbin/mount} | awk '/noatime/ {print $1,$3}'):-""} | tr -s ' ' | fgrep -- "$(df -k . | tail -1 | tr -s ' ')" } >&/dev/null; then
+  elif { (( ! $+unmodified_ls )) &&
+         { df -k -- ${$(print -r -- "$mtab" |
+                        awk '/noatime/ {print $1,$3}'):-""} | tr -s ' ' |
+           fgrep -- "$(df -k . | tail -1 | tr -s ' ')" } >&/dev/null } ||
+       { (( $+unmodified_ls )) &&
+         ! repeat 30; do ZTST_hashmark; sleep 2
+             [[ $unmodified_ls != "$(ls -lu $unmodified)" ]] && break
+	   done }; then
     ZTST_skip="[[ -N file ]] not supported with noatime file system"
   else
     [[ -N $newnewnew && ! -N $unmodified ]]



Messages sorted by: Reverse Date, Date, Thread, Author