t_lint2.sh revision 1.6 1 1.6 rillig # $NetBSD: t_lint2.sh,v 1.6 2021/08/24 21:30:52 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.2 rillig std_head()
31 1.1 rillig {
32 1.1 rillig atf_set 'require.progs' "$lint2"
33 1.1 rillig }
34 1.1 rillig
35 1.2 rillig std_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.3 rillig # remove comments and whitespace from the .ln file
41 1.3 rillig sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \
42 1.2 rillig < "$srcdir/$1.ln" \
43 1.2 rillig > "$1.ln"
44 1.1 rillig
45 1.2 rillig atf_check -o "file:$srcdir/$1.exp" \
46 1.2 rillig "$lint2" -h -p -x "$1.ln"
47 1.1 rillig }
48 1.1 rillig
49 1.6 rillig std_emit_body()
50 1.6 rillig {
51 1.6 rillig # shellcheck disable=SC2155
52 1.6 rillig local srcdir="$(atf_get_srcdir)"
53 1.6 rillig
54 1.6 rillig # remove comments and whitespace from the .ln files
55 1.6 rillig sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \
56 1.6 rillig < "$srcdir/$1.ln" \
57 1.6 rillig > "$1.ln"
58 1.6 rillig sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \
59 1.6 rillig < "$srcdir/$1.exp-ln" \
60 1.6 rillig > "$1.exp-ln"
61 1.6 rillig
62 1.6 rillig atf_check \
63 1.6 rillig "$lint2" -h -p -x -C "$1" "$1.ln"
64 1.6 rillig
65 1.6 rillig atf_check -o "file:$1.exp-ln" \
66 1.6 rillig cat "llib-l$1.ln"
67 1.6 rillig }
68 1.6 rillig
69 1.6 rillig emit_body()
70 1.6 rillig {
71 1.6 rillig std_emit_body 'emit'
72 1.6 rillig }
73 1.6 rillig
74 1.6 rillig emit_lp64_body()
75 1.6 rillig {
76 1.6 rillig std_emit_body 'emit_lp64'
77 1.6 rillig }
78 1.6 rillig
79 1.1 rillig atf_init_test_cases()
80 1.1 rillig {
81 1.6 rillig local i
82 1.6 rillig
83 1.3 rillig # shellcheck disable=SC2013
84 1.4 rillig for i in $(cd "$(atf_get_srcdir)" && echo *.ln); do
85 1.4 rillig i=${i%.ln}
86 1.5 rillig
87 1.5 rillig case "$i" in
88 1.5 rillig *lp64*)
89 1.5 rillig case "$(uname -p)" in
90 1.5 rillig *64) ;;
91 1.5 rillig *) continue
92 1.5 rillig esac
93 1.5 rillig esac
94 1.5 rillig
95 1.6 rillig type "${i}_head" 1>/dev/null 2>&1 \
96 1.6 rillig || eval "${i}_head() { std_head; }"
97 1.6 rillig type "${i}_body" 1>/dev/null 2>&1 \
98 1.6 rillig || eval "${i}_body() { std_body '$i'; }"
99 1.2 rillig atf_add_test_case "$i"
100 1.1 rillig done
101 1.1 rillig }
102