diff options
| author | Enji Cooper <ngie@FreeBSD.org> | 2026-02-15 01:57:42 +0000 |
|---|---|---|
| committer | Enji Cooper <ngie@FreeBSD.org> | 2026-02-15 02:12:44 +0000 |
| commit | e8dbf2b6df199526a660f81de07d17925cfd8518 (patch) | |
| tree | cd0c09449bea5df56ef67059e797737d70587070 /usr.bin/stat | |
| parent | 56a7ce8416d181a2060d7a428aed9c3c6a431e6d (diff) | |
Diffstat (limited to 'usr.bin/stat')
| -rw-r--r-- | usr.bin/stat/Makefile | 7 | ||||
| -rw-r--r-- | usr.bin/stat/t_stat.sh | 68 |
2 files changed, 75 insertions, 0 deletions
diff --git a/usr.bin/stat/Makefile b/usr.bin/stat/Makefile new file mode 100644 index 000000000000..9118b2434b8f --- /dev/null +++ b/usr.bin/stat/Makefile @@ -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> diff --git a/usr.bin/stat/t_stat.sh b/usr.bin/stat/t_stat.sh new file mode 100644 index 000000000000..b4bc56320d18 --- /dev/null +++ b/usr.bin/stat/t_stat.sh @@ -0,0 +1,68 @@ +# $NetBSD: t_stat.sh,v 1.2 2024/03/14 21:17:54 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' + + atf_check -s exit:1 -o ignore -e 'inline:stat: % SN: bad format\n' \ + stat -f 'string-space <% SN>' 'Ümläute' + + atf_check -s exit:1 -o ignore -e 'inline:stat: %+SN: bad format\n' \ + stat -f 'string-plus <%+SN>' 'Ümläute' + + atf_check -s exit:1 -o ignore -e 'inline:stat: %0SN: bad format\n' \ + stat -f 'string-zero <%0SN>' 'Ü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 +} |
