Module Name:    src
Committed By:   rillig
Date:           Thu Mar 14 21:00:33 UTC 2024

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/etc/mtree: NetBSD.dist.tests
        src/tests/usr.bin: Makefile
Added Files:
        src/tests/usr.bin/stat: Makefile t_stat.sh

Log Message:
tests/stat: test the left-aligned and right-aligned 'S' format


To generate a diff of this commit:
cvs rdiff -u -r1.1309 -r1.1310 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.202 -r1.203 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.39 -r1.40 src/tests/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/stat/Makefile \
    src/tests/usr.bin/stat/t_stat.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1309 src/distrib/sets/lists/tests/mi:1.1310
--- src/distrib/sets/lists/tests/mi:1.1309	Sun Mar  3 00:50:41 2024
+++ src/distrib/sets/lists/tests/mi	Thu Mar 14 21:00:33 2024
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1309 2024/03/03 00:50:41 rillig Exp $
+# $NetBSD: mi,v 1.1310 2024/03/14 21:00:33 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6473,6 +6473,10 @@
 ./usr/tests/usr.bin/sort/d_any_char_iflag_out.txt	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/sort/d_any_char_in.txt		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/sort/t_sort				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/stat				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/stat/Atffile			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/stat/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua
+./usr/tests/usr.bin/stat/t_stat				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/tar					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/tar/Atffile					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/tar/Kyuafile				tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.202 src/etc/mtree/NetBSD.dist.tests:1.203
--- src/etc/mtree/NetBSD.dist.tests:1.202	Thu Jan 25 00:30:57 2024
+++ src/etc/mtree/NetBSD.dist.tests	Thu Mar 14 21:00:32 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.202 2024/01/25 00:30:57 riastradh Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.203 2024/03/14 21:00:32 rillig Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -476,6 +476,7 @@
 ./usr/tests/usr.bin/sed
 ./usr/tests/usr.bin/shmif_dumpbus
 ./usr/tests/usr.bin/sort
+./usr/tests/usr.bin/stat
 ./usr/tests/usr.bin/tar
 ./usr/tests/usr.bin/tmux
 ./usr/tests/usr.bin/tr

Index: src/tests/usr.bin/Makefile
diff -u src/tests/usr.bin/Makefile:1.39 src/tests/usr.bin/Makefile:1.40
--- src/tests/usr.bin/Makefile:1.39	Thu Jan 25 00:30:57 2024
+++ src/tests/usr.bin/Makefile	Thu Mar 14 21:00:33 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.39 2024/01/25 00:30:57 riastradh Exp $
+#	$NetBSD: Makefile,v 1.40 2024/03/14 21:00:33 rillig Exp $
 #
 
 .include <bsd.own.mk>
@@ -9,7 +9,7 @@ TESTS_SUBDIRS=	awk basename bzip2 cc cmp
 		diff dirname error find fstat gdb grep gzip id indent \
 		infocmp jot ld locale m4 make mixerctl mkdep mtree nbperf \
 		netpgpverify patch pkill pr printf pwhash realpath rump_server \
-		shmif_dumpbus sdiff sed sort tar tmux tr unifdef uniq \
+		shmif_dumpbus sdiff sed sort stat tar tmux tr unifdef uniq \
 		vmstat xlint ztest
 
 .if ${MKCXX} != "no"

Added files:

Index: src/tests/usr.bin/stat/Makefile
diff -u /dev/null src/tests/usr.bin/stat/Makefile:1.1
--- /dev/null	Thu Mar 14 21:00:33 2024
+++ src/tests/usr.bin/stat/Makefile	Thu Mar 14 21:00:33 2024
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1 2024/03/14 21:00:33 rillig Exp $
+
+TESTSDIR=	${TESTSBASE}/usr.bin/stat
+
+TESTS_SH=	t_stat
+
+.include <bsd.test.mk>
Index: src/tests/usr.bin/stat/t_stat.sh
diff -u /dev/null src/tests/usr.bin/stat/t_stat.sh:1.1
--- /dev/null	Thu Mar 14 21:00:33 2024
+++ src/tests/usr.bin/stat/t_stat.sh	Thu Mar 14 21:00:33 2024
@@ -0,0 +1,63 @@
+# $NetBSD: t_stat.sh,v 1.1 2024/03/14 21:00:33 rillig Exp $
+#
+# Copyright (c) 2024 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Roland Illig.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+atf_test_case string_format
+string_format_head() {
+	atf_set "descr" "Tests the string output format 'S'"
+}
+string_format_body() {
+	echo 'äöü' > './Ümläute'
+
+	atf_check -o 'inline:plain <Ümläute>\n' \
+	    stat -f 'plain <%SN>' 'Ümläute'
+
+	atf_check -o 'inline:right-aligned <           Ümläute>\n' \
+	    stat -f 'right-aligned <%20SN>' 'Ümläute'
+
+	atf_check -o 'inline:left-aligned <Ümläute           >\n' \
+	    stat -f 'left-aligned <%-20SN>' 'Ümläute'
+
+	# FIXME: invokes undefined behavior in snprintf "%+s"
+	atf_check -o 'inline:string-plus <Ümläute>\n' \
+	    stat -f 'string-plus <%+SN>' 'Ümläute'
+
+	atf_check -o 'inline:vis <\303\234ml\303\244ute>\n' \
+	    stat -f 'vis <%#SN>' 'Ümläute'
+
+	atf_check -o 'inline:vis left-aligned <\303\234ml\303\244ute         >\n' \
+	    stat -f 'vis left-aligned <%#-30SN>' 'Ümläute'
+
+	atf_check -o 'inline:vis right-aligned <         \303\234ml\303\244ute>\n' \
+	    stat -f 'vis right-aligned <%#30SN>' 'Ümläute'
+}
+
+atf_init_test_cases() {
+	atf_add_test_case string_format
+}

Reply via email to