Home | History | Annotate | Line # | Download | only in lint2
t_lint2.sh revision 1.1
      1  1.1  rillig # $NetBSD: t_lint2.sh,v 1.1 2021/08/05 22:36:08 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Copyright (c) 2021 The NetBSD Foundation, Inc.
      4  1.1  rillig # All rights reserved.
      5  1.1  rillig #
      6  1.1  rillig # Redistribution and use in source and binary forms, with or without
      7  1.1  rillig # modification, are permitted provided that the following conditions
      8  1.1  rillig # are met:
      9  1.1  rillig # 1. Redistributions of source code must retain the above copyright
     10  1.1  rillig #    notice, this list of conditions and the following disclaimer.
     11  1.1  rillig # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  rillig #    notice, this list of conditions and the following disclaimer in the
     13  1.1  rillig #    documentation and/or other materials provided with the distribution.
     14  1.1  rillig #
     15  1.1  rillig # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  rillig # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  rillig # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  rillig # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  rillig # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  rillig # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  rillig # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  rillig # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  rillig # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  rillig # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  rillig # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  rillig #
     27  1.1  rillig 
     28  1.1  rillig lint2=/usr/libexec/lint2
     29  1.1  rillig 
     30  1.1  rillig do_msg_head()
     31  1.1  rillig {
     32  1.1  rillig 	atf_set 'require.progs' "$lint2"
     33  1.1  rillig }
     34  1.1  rillig 
     35  1.1  rillig do_msg_body()
     36  1.1  rillig {
     37  1.1  rillig 	# shellcheck disable=SC2155
     38  1.1  rillig 	local srcdir="$(atf_get_srcdir)"
     39  1.1  rillig 
     40  1.1  rillig 	# remove comments and empty lines from the .ln file
     41  1.1  rillig 	sed -e '/^#/d' -e '/^$/d' < "$srcdir/msg_$1.ln" > "msg_$1.ln"
     42  1.1  rillig 
     43  1.1  rillig 	atf_check -o "file:$srcdir/msg_$1.exp" \
     44  1.1  rillig 	    "$lint2" -h -p -x "msg_$1.ln"
     45  1.1  rillig }
     46  1.1  rillig 
     47  1.1  rillig atf_init_test_cases()
     48  1.1  rillig {
     49  1.1  rillig 	for i in $(printf '%03d\n' $(seq 0 18)); do
     50  1.1  rillig 		eval "msg_${i}_head() { do_msg_head; }"
     51  1.1  rillig 		eval "msg_${i}_body() { do_msg_body '$i'; }"
     52  1.1  rillig 		atf_add_test_case "msg_$i"
     53  1.1  rillig 	done
     54  1.1  rillig }
     55