[BACK]Return to t_integration.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1

Annotation of src/tests/usr.bin/xlint/lint1/t_integration.sh, Revision 1.47

1.47    ! rillig      1: # $NetBSD: t_integration.sh,v 1.46 2021/05/02 20:44:46 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.43      rillig     60:        local src_ln="${src%.c}.ln"
                     61:        local wrk_ln="${1%.c}.ln"
1.25      rillig     62:        local flags="$(extract_flags "${src}")"
1.6       rillig     63:
1.43      rillig     64:        if [ ! -f "${src_ln}" ]; then
                     65:                src_ln="/dev/null"
                     66:                wrk_ln="/dev/null"
                     67:        fi
                     68:
1.9       rillig     69:        if [ -f "${exp}" ]; then
1.25      rillig     70:                # shellcheck disable=SC2086
1.9       rillig     71:                atf_check -s not-exit:0 -o "file:${exp}" -e empty \
1.43      rillig     72:                    ${LINT1} ${flags} "${src}" "${wrk_ln}"
1.9       rillig     73:        else
1.25      rillig     74:                # shellcheck disable=SC2086
1.9       rillig     75:                atf_check -s exit:0 \
1.43      rillig     76:                    ${LINT1} ${flags} "${src}" "${wrk_ln}"
                     77:        fi
                     78:
                     79:        if [ "${src_ln}" != "/dev/null" ]; then
                     80:                atf_check -o "file:${src_ln}" cat "${wrk_ln}"
1.9       rillig     81:        fi
1.1       jruoho     82: }
                     83:
                     84: test_case()
                     85: {
                     86:        local name="${1}"; shift
                     87:        local descr="${*}"
                     88:
                     89:        atf_test_case ${name}
                     90:        eval "${name}_head() {
1.11      rillig     91:                if [ \"${descr}\" ]; then
                     92:                        atf_set \"descr\" \"${descr}\"
                     93:                fi
1.9       rillig     94:                atf_set \"require.progs\" \"${LINT1}\"
1.1       jruoho     95:        }"
                     96:        eval "${name}_body() {
1.35      rillig     97:                check_lint1 ${name}.c
1.1       jruoho     98:        }"
                     99:
                    100:        Names="${Names} ${name}"
                    101: }
                    102:
1.35      rillig    103: test_case d_bltinoffsetof
                    104: test_case d_c99_anon_struct
                    105: test_case d_c99_anon_union
                    106: test_case d_c99_bool
                    107: test_case d_c99_bool_strict
                    108: test_case d_c99_bool_strict_syshdr
                    109: test_case d_c99_compound_literal_comma
                    110: test_case d_c99_decls_after_stmt2
                    111: test_case d_c99_flex_array_packed
                    112: test_case d_c99_init
                    113: test_case d_c99_nested_struct
                    114: test_case d_c99_union_cast
                    115: test_case d_c99_union_init4
                    116: test_case d_c99_union_init5
                    117: test_case d_cast_fun_array_param
                    118: test_case d_cast_typeof
                    119: test_case d_decl_old_style_arguments
                    120: test_case d_fold_test
                    121: test_case d_gcc_extension
                    122: test_case d_init_array_using_string
                    123: test_case d_init_pop_member
                    124: test_case d_lint_assert
                    125: test_case d_return_type
                    126: test_case d_type_question_colon
                    127: test_case d_typefun
                    128: test_case d_typename_as_var
                    129:
                    130: test_case d_c99_struct_init
                    131: test_case d_c99_union_init1
                    132: test_case d_c99_union_init2
                    133: test_case d_c99_union_init3
                    134: test_case d_c99_recursive_init
                    135: test_case d_c9x_recursive_init
                    136: test_case d_nested_structs
                    137: test_case d_packed_structs
                    138: test_case d_pr_22119
                    139: test_case d_struct_init_nested
1.10      rillig    140:
1.35      rillig    141: test_case d_cast_init
1.36      rillig    142: test_case d_cast_init2
                    143: test_case d_cast_lhs
1.1       jruoho    144:
1.36      rillig    145: test_case d_gcc_func
                    146: test_case d_c99_func
1.1       jruoho    147:
1.36      rillig    148: test_case d_gcc_variable_array_init
1.35      rillig    149: test_case d_c9x_array_init
                    150: test_case d_c99_decls_after_stmt
                    151: test_case d_c99_decls_after_stmt3
1.36      rillig    152: test_case d_nolimit_init
1.35      rillig    153: test_case d_zero_sized_arrays
                    154:
                    155: test_case d_compound_literals1
                    156: test_case d_compound_literals2
                    157: test_case d_gcc_compound_statements1
1.36      rillig    158: test_case d_gcc_compound_statements2
                    159: test_case d_gcc_compound_statements3
                    160:
1.4       christos  161: # XXX: Because of polymorphic __builtin_isnan and expression has null effect
1.9       rillig    162: # test_case gcc_extension "Checks GCC __extension__ and __typeof__"
1.1       jruoho    163:
1.36      rillig    164: test_case d_cvt_in_ternary
                    165: test_case d_cvt_constant
                    166: test_case d_ellipsis_in_switch
                    167: test_case d_c99_complex_num
                    168: test_case d_c99_complex_split
1.35      rillig    169: test_case d_c99_for_loops
1.36      rillig    170: test_case d_alignof
                    171: test_case d_shift_to_narrower_type
                    172: test_case d_constant_conv1
                    173: test_case d_constant_conv2
                    174: test_case d_type_conv1
                    175: test_case d_type_conv2
                    176: test_case d_type_conv3
1.35      rillig    177: test_case d_incorrect_array_size
1.36      rillig    178: test_case d_long_double_int
1.1       jruoho    179:
1.43      rillig    180: test_case emit
                    181:
1.45      rillig    182: test_case gcc_attribute
1.46      rillig    183: test_case gcc_attribute_aligned
1.47    ! rillig    184: test_case gcc_bit_field_types
1.42      rillig    185: test_case gcc_init_compound_literal
1.44      rillig    186: test_case gcc_typeof_after_statement
1.42      rillig    187:
1.38      rillig    188: test_case op_colon
                    189:
1.40      rillig    190: test_case feat_stacktrace
                    191:
1.18      rillig    192: test_case all_messages
1.28      rillig    193: all_messages_body()
                    194: {
1.37      rillig    195:        local failed msg
1.18      rillig    196:
1.37      rillig    197:        failed=""
1.18      rillig    198:
1.41      rillig    199:        for msg in $(seq 0 343); do
1.37      rillig    200:                name="$(printf 'msg_%03d.c' "${msg}")"
                    201:                check_lint1 "${name}" \
                    202:                || failed="$failed${failed:+ }$name"
1.18      rillig    203:        done
1.20      rillig    204:
1.37      rillig    205:        if [ "$failed" != "" ]; then
                    206:                atf_check "false" "$failed"
                    207:        fi
1.18      rillig    208: }
                    209:
                    210:
1.1       jruoho    211: atf_init_test_cases()
                    212: {
                    213:        for name in ${Names}; do
                    214:                atf_add_test_case ${name}
                    215:        done
                    216: }

CVSweb <webmaster@jp.NetBSD.org>