t_lint2.sh revision 1.3 1 1.3 rillig # $NetBSD: t_lint2.sh,v 1.3 2021/08/07 23:52:32 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.1 rillig atf_init_test_cases()
50 1.1 rillig {
51 1.3 rillig # shellcheck disable=SC2013
52 1.3 rillig for i in $(cat "$(atf_get_srcdir)/tests"); do
53 1.2 rillig eval "${i}_head() { std_head; }"
54 1.2 rillig eval "${i}_body() { std_body '$i'; }"
55 1.2 rillig atf_add_test_case "$i"
56 1.1 rillig done
57 1.1 rillig }
58