Annotation of src/tests/usr.bin/xlint/lint1/t_integration.sh, Revision 1.33
1.33 ! rillig 1: # $NetBSD: t_integration.sh,v 1.32 2021/02/28 22:12:16 rillig Exp $
1.1 jruoho 2: #
3: # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
4: # All rights reserved.
5: #
6: # Redistribution and use in source and binary forms, with or without
7: # modification, are permitted provided that the following conditions
8: # are met:
9: # 1. Redistributions of source code must retain the above copyright
10: # notice, this list of conditions and the following disclaimer.
11: # 2. Redistributions in binary form must reproduce the above copyright
12: # notice, this list of conditions and the following disclaimer in the
13: # documentation and/or other materials provided with the distribution.
14: #
15: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18: # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25: # POSSIBILITY OF SUCH DAMAGE.
26: #
27:
28: LINT1=/usr/libexec/lint1
29:
30: Names=
31:
1.25 rillig 32: extract_flags()
33: {
34: local extract_flags_awk
35:
36: # shellcheck disable=SC2016
37: extract_flags_awk='
38: BEGIN {
39: flags = "-g -S -w"
40: }
41: /^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
42: if ($2 == "lint1-flags:")
43: flags = ""
44: for (i = 3; i < NF; i++)
45: flags = flags " " $i
46: }
47: END {
48: print flags
49: }
50: '
51:
52: awk "$extract_flags_awk" "$@"
53: }
54:
55: # shellcheck disable=SC2155
1.9 rillig 56: check_lint1()
1.1 jruoho 57: {
1.6 rillig 58: local src="$(atf_get_srcdir)/$1"
59: local exp="${src%.c}.exp"
1.25 rillig 60: local flags="$(extract_flags "${src}")"
1.6 rillig 61:
1.9 rillig 62: if [ -f "${exp}" ]; then
1.25 rillig 63: # shellcheck disable=SC2086
1.9 rillig 64: atf_check -s not-exit:0 -o "file:${exp}" -e empty \
1.25 rillig 65: ${LINT1} ${flags} "${src}" /dev/null
1.9 rillig 66: else
1.25 rillig 67: # shellcheck disable=SC2086
1.9 rillig 68: atf_check -s exit:0 \
1.25 rillig 69: ${LINT1} ${flags} "${src}" /dev/null
1.9 rillig 70: fi
1.1 jruoho 71: }
72:
73: test_case()
74: {
75: local name="${1}"; shift
76: local descr="${*}"
77:
78: atf_test_case ${name}
79: eval "${name}_head() {
1.11 rillig 80: if [ \"${descr}\" ]; then
81: atf_set \"descr\" \"${descr}\"
82: fi
1.9 rillig 83: atf_set \"require.progs\" \"${LINT1}\"
1.1 jruoho 84: }"
85: eval "${name}_body() {
1.9 rillig 86: check_lint1 d_${name}.c
1.1 jruoho 87: }"
88:
89: Names="${Names} ${name}"
90: }
91:
1.11 rillig 92: test_case bltinoffsetof
93: test_case c99_anon_struct
94: test_case c99_anon_union
1.22 rillig 95: test_case c99_bool
1.23 rillig 96: test_case c99_bool_strict
1.27 rillig 97: test_case c99_bool_strict_syshdr
1.11 rillig 98: test_case c99_compound_literal_comma
99: test_case c99_decls_after_stmt2
100: test_case c99_flex_array_packed
1.30 rillig 101: test_case c99_init
1.11 rillig 102: test_case c99_nested_struct
103: test_case c99_union_cast
104: test_case c99_union_init4
1.31 rillig 105: test_case c99_union_init5
1.11 rillig 106: test_case cast_fun_array_param
107: test_case cast_typeof
1.13 rillig 108: test_case decl_old_style_arguments
1.15 rillig 109: test_case fold_test
1.11 rillig 110: test_case gcc_extension
1.17 rillig 111: test_case init_pop_member
1.24 rillig 112: test_case lint_assert
1.16 rillig 113: test_case return_type
1.11 rillig 114: test_case type_question_colon
115: test_case typefun
116: test_case typename_as_var
117:
1.12 rillig 118: test_case c99_struct_init
119: test_case c99_union_init1
120: test_case c99_union_init2
121: test_case c99_union_init3
1.14 rillig 122: test_case c99_recursive_init
123: test_case c9x_recursive_init
1.12 rillig 124: test_case nested_structs
125: test_case packed_structs
1.32 rillig 126: test_case pr_22119
1.14 rillig 127: test_case struct_init_nested
1.10 rillig 128:
1.12 rillig 129: test_case cast_init
1.10 rillig 130: test_case cast_init2 "Checks cast initialization as the rhs of a" \
131: "- operand"
132: test_case cast_lhs "Checks whether pointer casts are valid lhs" \
133: "lvalues"
1.1 jruoho 134:
1.10 rillig 135: test_case gcc_func "Checks GCC __FUNCTION__"
136: test_case c99_func "Checks C99 __func__"
1.1 jruoho 137:
1.9 rillig 138: test_case gcc_variable_array_init "Checks GCC variable array initializers"
1.12 rillig 139: test_case c9x_array_init
140: test_case c99_decls_after_stmt
141: test_case c99_decls_after_stmt3
1.10 rillig 142: test_case nolimit_init "Checks no limit initializers"
1.12 rillig 143: test_case zero_sized_arrays
1.9 rillig 144:
1.12 rillig 145: test_case compound_literals1
146: test_case compound_literals2
147: test_case gcc_compound_statements1
1.10 rillig 148: test_case gcc_compound_statements2 "Checks GCC compound statements with" \
149: "non-expressions"
150: test_case gcc_compound_statements3 "Checks GCC compound statements with" \
151: "void type"
1.4 christos 152: # XXX: Because of polymorphic __builtin_isnan and expression has null effect
1.9 rillig 153: # test_case gcc_extension "Checks GCC __extension__ and __typeof__"
1.1 jruoho 154:
1.10 rillig 155: test_case cvt_in_ternary "Checks CVT nodes handling in ?"
156: test_case cvt_constant "Checks constant conversion"
157: test_case ellipsis_in_switch "Checks ellipsis in switch()"
158: test_case c99_complex_num "Checks C99 complex numbers"
159: test_case c99_complex_split "Checks C99 complex access"
1.12 rillig 160: test_case c99_for_loops
1.10 rillig 161: test_case alignof "Checks __alignof__"
162: test_case shift_to_narrower_type "Checks that type shifts that result in" \
163: "narrower types do not produce warnings"
164:
165: test_case constant_conv1 "Checks failing on information-losing" \
166: "constant conversion in argument lists"
167: test_case constant_conv2 "Checks failing on information-losing" \
168: "constant conversion in argument lists"
169:
170: test_case type_conv1 "Checks failing on information-losing" \
171: "type conversion in argument lists"
172: test_case type_conv2 "Checks failing on information-losing" \
173: "type conversion in argument lists"
174: test_case type_conv3 "Checks failing on information-losing" \
175: "type conversion in argument lists"
1.1 jruoho 176:
1.14 rillig 177: test_case incorrect_array_size
1.1 jruoho 178:
1.10 rillig 179: test_case long_double_int "Checks for confusion of 'long double' with" \
180: "'long int'; PR bin/39639"
1.1 jruoho 181:
1.18 rillig 182: test_case all_messages
1.28 rillig 183: all_messages_body()
184: {
1.20 rillig 185: local srcdir ok msg base flags
1.18 rillig 186:
187: srcdir="$(atf_get_srcdir)"
1.20 rillig 188: ok="true"
1.18 rillig 189:
1.33 ! rillig 190: for msg in $(seq 0 340); do
1.18 rillig 191: base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
1.25 rillig 192: flags="$(extract_flags "${base}.c")"
1.18 rillig 193:
1.19 rillig 194: # shellcheck disable=SC2154 disable=SC2086
1.18 rillig 195: ${Atf_Check} -s not-exit:0 -o "file:${base}.exp" -e empty \
1.19 rillig 196: ${LINT1} ${flags} "${base}.c" /dev/null \
1.20 rillig 197: || ok="false"
1.18 rillig 198: done
1.20 rillig 199:
200: atf_check "${ok}"
1.18 rillig 201: }
202:
203:
1.1 jruoho 204: atf_init_test_cases()
205: {
206: for name in ${Names}; do
207: atf_add_test_case ${name}
208: done
209: }
CVSweb <webmaster@jp.NetBSD.org>