Author: ngie
Date: Mon Jul 17 21:01:10 2017
New Revision: 321086
URL: https://svnweb.freebsd.org/changeset/base/321086

Log:
  MFC r319834,r319841,r320723,r320724:
  
  r319834:
  
  Write up some basic tests for readlink(1)
  
  The tests exercise -f (f_flag), -n (n_flag), and no arguments (basic).
  
  r319841:
  
  Add initial tests for stat(1)
  
  Testcases for -H, -L, and -f haven't been implemented yet, in part due
  to additional complexity needed to validate the features:
  * -H and -f will require an external "helper" program to display/modify
    the state/permissions for a given path.
  * -L is being covered partially via the -n testcase today.
  
  r320723:
  
  Use %e instead of %d with x_output_date(..)
  
  stat -x doesn't 0-fill days so %d is inappropriate. %e is correct.
  
  MFC with:     r319841
  
  r320724:
  
  :l_flag:: be more aggressive when normalizing whitespace
  
  Save output from ls -ldT and stat -l, then normalize all repeating whitespace 
using
  sed to single column spaces.
  
  This makes the test flexible with single-digit days, etc, similar to r320723. 
This
  approach is just a bit more of a hammer approach because of how the columns 
are
  ordered/spaced in both ls and stat.
  
  MFC with:     r319841

Added:
  stable/11/usr.bin/stat/tests/
     - copied from r319834, head/usr.bin/stat/tests/
  stable/11/usr.bin/stat/tests/stat_test.sh
     - copied, changed from r319841, head/usr.bin/stat/tests/stat_test.sh
Modified:
  stable/11/etc/mtree/BSD.tests.dist
  stable/11/usr.bin/stat/Makefile
  stable/11/usr.bin/stat/stat.1
  stable/11/usr.bin/stat/tests/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/11/etc/mtree/BSD.tests.dist  Mon Jul 17 21:01:07 2017        
(r321085)
+++ stable/11/etc/mtree/BSD.tests.dist  Mon Jul 17 21:01:10 2017        
(r321086)
@@ -650,6 +650,8 @@
         ..
         soelim
         ..
+        stat
+        ..
         tail
         ..
         tar

Modified: stable/11/usr.bin/stat/Makefile
==============================================================================
--- stable/11/usr.bin/stat/Makefile     Mon Jul 17 21:01:07 2017        
(r321085)
+++ stable/11/usr.bin/stat/Makefile     Mon Jul 17 21:01:10 2017        
(r321086)
@@ -1,8 +1,12 @@
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 PROG=  stat
 
 LINKS= ${BINDIR}/stat ${BINDIR}/readlink
 MLINKS=        stat.1 readlink.1
+
+SUBDIR.${MK_TESTS}+=   tests
 
 .include <bsd.prog.mk>

Modified: stable/11/usr.bin/stat/stat.1
==============================================================================
--- stable/11/usr.bin/stat/stat.1       Mon Jul 17 21:01:07 2017        
(r321085)
+++ stable/11/usr.bin/stat/stat.1       Mon Jul 17 21:01:10 2017        
(r321086)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 22, 2012
+.Dd June 22, 2017
 .Dt STAT 1
 .Os
 .Sh NAME

Modified: stable/11/usr.bin/stat/tests/Makefile
==============================================================================
--- head/usr.bin/stat/tests/Makefile    Sun Jun 11 21:13:12 2017        
(r319834)
+++ stable/11/usr.bin/stat/tests/Makefile       Mon Jul 17 21:01:10 2017        
(r321086)
@@ -1,5 +1,6 @@
 # $FreeBSD$
 
 ATF_TESTS_SH+= readlink_test
+ATF_TESTS_SH+= stat_test
 
 .include <bsd.test.mk>

Copied and modified: stable/11/usr.bin/stat/tests/stat_test.sh (from r319841, 
head/usr.bin/stat/tests/stat_test.sh)
==============================================================================
--- head/usr.bin/stat/tests/stat_test.sh        Mon Jun 12 00:21:55 2017        
(r319841, copy source)
+++ stable/11/usr.bin/stat/tests/stat_test.sh   Mon Jul 17 21:01:10 2017        
(r321086)
@@ -60,14 +60,23 @@ l_flag_body()
 
        paths="a b c d"
 
+       ls_out=ls.output
+       stat_out=stat.output
+
        # NOTE:
        # - Even though stat -l claims to be equivalent to `ls -lT`, the
        #   whitespace is a bit more liberal in the `ls -lT` output.
        # - `ls -ldT` is used to not recursively list the contents of
        #   directories.
        for path in $paths; do
-               atf_check -o inline:"$(ls -ldT $path | sed -e 's,  , ,g')\n" \
-                   stat -l $path
+               atf_check -o save:$ls_out ls -ldT $path
+               cat $ls_out
+               atf_check -o save:$stat_out stat -l $path
+               cat $stat_out
+               echo "Comparing normalized whitespace"
+               atf_check sed -i '' -E -e 's/[[:space:]]+/ /g' $ls_out
+               atf_check sed -i '' -E -e 's/[[:space:]]+/ /g' $stat_out
+               atf_check cmp $ls_out $stat_out
        done
 }
 
@@ -165,7 +174,7 @@ t_flag_body()
 
 x_output_date()
 {
-       local date_format='%a %b %d %H:%M:%S %Y'
+       local date_format='%a %b %e %H:%M:%S %Y'
 
        stat -t "$date_format" "$@"
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to