Home | History | Annotate | Line # | Download | only in stat
t_stat.sh revision 1.1
      1  1.1  rillig # $NetBSD: t_stat.sh,v 1.1 2024/03/14 21:00:33 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Copyright (c) 2024 The NetBSD Foundation, Inc.
      4  1.1  rillig # All rights reserved.
      5  1.1  rillig #
      6  1.1  rillig # This code is derived from software contributed to The NetBSD Foundation
      7  1.1  rillig # by Roland Illig.
      8  1.1  rillig #
      9  1.1  rillig # Redistribution and use in source and binary forms, with or without
     10  1.1  rillig # modification, are permitted provided that the following conditions
     11  1.1  rillig # are met:
     12  1.1  rillig # 1. Redistributions of source code must retain the above copyright
     13  1.1  rillig #    notice, this list of conditions and the following disclaimer.
     14  1.1  rillig # 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  rillig #    notice, this list of conditions and the following disclaimer in the
     16  1.1  rillig #    documentation and/or other materials provided with the distribution.
     17  1.1  rillig #
     18  1.1  rillig # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  1.1  rillig # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  1.1  rillig # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  1.1  rillig # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  1.1  rillig # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  1.1  rillig # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  1.1  rillig # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  1.1  rillig # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  1.1  rillig # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  1.1  rillig # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  1.1  rillig # POSSIBILITY OF SUCH DAMAGE.
     29  1.1  rillig #
     30  1.1  rillig 
     31  1.1  rillig atf_test_case string_format
     32  1.1  rillig string_format_head() {
     33  1.1  rillig 	atf_set "descr" "Tests the string output format 'S'"
     34  1.1  rillig }
     35  1.1  rillig string_format_body() {
     36  1.1  rillig 	echo '' > './mlute'
     37  1.1  rillig 
     38  1.1  rillig 	atf_check -o 'inline:plain <mlute>\n' \
     39  1.1  rillig 	    stat -f 'plain <%SN>' 'mlute'
     40  1.1  rillig 
     41  1.1  rillig 	atf_check -o 'inline:right-aligned <           mlute>\n' \
     42  1.1  rillig 	    stat -f 'right-aligned <%20SN>' 'mlute'
     43  1.1  rillig 
     44  1.1  rillig 	atf_check -o 'inline:left-aligned <mlute           >\n' \
     45  1.1  rillig 	    stat -f 'left-aligned <%-20SN>' 'mlute'
     46  1.1  rillig 
     47  1.1  rillig 	# FIXME: invokes undefined behavior in snprintf "%+s"
     48  1.1  rillig 	atf_check -o 'inline:string-plus <mlute>\n' \
     49  1.1  rillig 	    stat -f 'string-plus <%+SN>' 'mlute'
     50  1.1  rillig 
     51  1.1  rillig 	atf_check -o 'inline:vis <\303\234ml\303\244ute>\n' \
     52  1.1  rillig 	    stat -f 'vis <%#SN>' 'mlute'
     53  1.1  rillig 
     54  1.1  rillig 	atf_check -o 'inline:vis left-aligned <\303\234ml\303\244ute         >\n' \
     55  1.1  rillig 	    stat -f 'vis left-aligned <%#-30SN>' 'mlute'
     56  1.1  rillig 
     57  1.1  rillig 	atf_check -o 'inline:vis right-aligned <         \303\234ml\303\244ute>\n' \
     58  1.1  rillig 	    stat -f 'vis right-aligned <%#30SN>' 'mlute'
     59  1.1  rillig }
     60  1.1  rillig 
     61  1.1  rillig atf_init_test_cases() {
     62  1.1  rillig 	atf_add_test_case string_format
     63  1.1  rillig }
     64