Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jul 2017 21:01:07 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r321085 - in stable/10: etc/mtree usr.bin/stat usr.bin/stat/tests
Message-ID:  <201707172101.v6HL173D050116@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Jul 17 21:01:07 2017
New Revision: 321085
URL: https://svnweb.freebsd.org/changeset/base/321085

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/10/usr.bin/stat/tests/
     - copied from r319834, head/usr.bin/stat/tests/
  stable/10/usr.bin/stat/tests/stat_test.sh
     - copied, changed from r319841, head/usr.bin/stat/tests/stat_test.sh
Modified:
  stable/10/etc/mtree/BSD.tests.dist
  stable/10/usr.bin/stat/Makefile
  stable/10/usr.bin/stat/stat.1
  stable/10/usr.bin/stat/tests/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/10/etc/mtree/BSD.tests.dist	Mon Jul 17 20:57:38 2017	(r321084)
+++ stable/10/etc/mtree/BSD.tests.dist	Mon Jul 17 21:01:07 2017	(r321085)
@@ -622,6 +622,8 @@
             regress.multitest.out
             ..
         ..
+        stat
+        ..
         tail
         ..
         tar

Modified: stable/10/usr.bin/stat/Makefile
==============================================================================
--- stable/10/usr.bin/stat/Makefile	Mon Jul 17 20:57:38 2017	(r321084)
+++ stable/10/usr.bin/stat/Makefile	Mon Jul 17 21:01:07 2017	(r321085)
@@ -1,8 +1,14 @@
 # $FreeBSD$
 
+.include <bsd.own.mk>
+
 PROG=	stat
 
 LINKS=	${BINDIR}/stat ${BINDIR}/readlink
 MLINKS=	stat.1 readlink.1
+
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
 
 .include <bsd.prog.mk>

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

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

Copied and modified: stable/10/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/10/usr.bin/stat/tests/stat_test.sh	Mon Jul 17 21:01:07 2017	(r321085)
@@ -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" "$@"
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707172101.v6HL173D050116>