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

Annotation of src/tests/usr.bin/xlint/lint1/accept.sh, Revision 1.9

1.1       rillig      1: #! /bin/sh
1.9     ! rillig      2: # $NetBSD: accept.sh,v 1.8 2021/08/26 19:23:25 rillig Exp $
1.1       rillig      3: #
                      4: # Copyright (c) 2021 The NetBSD Foundation, Inc.
                      5: # All rights reserved.
                      6: #
                      7: # Redistribution and use in source and binary forms, with or without
                      8: # modification, are permitted provided that the following conditions
                      9: # are met:
                     10: # 1. Redistributions of source code must retain the above copyright
                     11: #    notice, this list of conditions and the following disclaimer.
                     12: # 2. Redistributions in binary form must reproduce the above copyright
                     13: #    notice, this list of conditions and the following disclaimer in the
                     14: #    documentation and/or other materials provided with the distribution.
                     15: #
                     16: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     17: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     18: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     19: # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     20: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     21: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     22: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     23: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     24: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     25: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     26: # POSSIBILITY OF SUCH DAMAGE.
                     27: #
                     28:
                     29: # usage: accept.sh <pattern>...
                     30: #
                     31: #      Accept the actual output from running the lint tests and save them
                     32: #      back into the .exp files.
                     33:
                     34: set -eu
                     35:
1.9     ! rillig     36: : "${archsubdir:=$(make -v ARCHSUBDIR)}"
        !            37: . './t_integration.sh'         # for configure_test_case
1.1       rillig     38:
                     39: for pattern in "$@"; do
1.5       rillig     40:        # shellcheck disable=SC2231
1.1       rillig     41:        for test in *$pattern*.c; do
                     42:                base=${test%.*}
                     43:                cfile="$base.c"
                     44:                expfile="$base.exp"
                     45:                tmpfile="$base.exp.tmp"
1.4       rillig     46:                ln_file="$base.exp-ln"
1.1       rillig     47:
                     48:                configure_test_case "$cfile"
1.2       rillig     49:                # shellcheck disable=SC2154
1.5       rillig     50:                if [ "$skip" = yes ]; then
1.1       rillig     51:                        continue
                     52:                fi
                     53:
                     54:                if [ ! -f "$ln_file" ]; then
                     55:                        ln_file='/dev/null'
                     56:                fi
                     57:
1.2       rillig     58:                # shellcheck disable=SC2154
                     59:                # shellcheck disable=SC2086
1.1       rillig     60:                if "$lint1" $flags "$base.c" "$ln_file" > "$tmpfile"; then
                     61:                        if [ -s "$tmpfile" ]; then
                     62:                                echo "$base produces output but exits successfully"
                     63:                                sed 's,^,| ,' "$tmpfile"
                     64:                        fi
                     65:                        rm -f "$expfile" "$tmpfile"
1.3       rillig     66:                elif [ $? -ge 128 ]; then
                     67:                        echo "$base crashed"
                     68:                        continue
1.1       rillig     69:                else
                     70:                        if [ -f "$tmpfile" ] && cmp -s "$tmpfile" "$expfile"; then
                     71:                                rm "$tmpfile"
                     72:                        else
                     73:                                echo "replacing $base"
                     74:                                mv "$tmpfile" "$expfile"
                     75:                        fi
                     76:                fi
                     77:
                     78:                case "$base" in (msg_*)
1.8       rillig     79:                        if grep 'This message is not used\.' "$cfile" >/dev/null; then
                     80:                                : 'Skip further checks.'
                     81:                        elif [ ! -f "$expfile" ]; then
1.1       rillig     82:                                echo "$base should produce warnings"
                     83:                        elif grep '^TODO: "Add example code' "$base.c" >/dev/null; then
                     84:                                : 'ok, this test is not yet written'
                     85:                        else
                     86:                                msgid=${base}
                     87:                                msgid=${msgid#msg_00}
                     88:                                msgid=${msgid#msg_0}
                     89:                                msgid=${msgid#msg_}
1.6       rillig     90:                                msgid=${msgid%%_*}
1.1       rillig     91:                                if ! grep "\\[$msgid\\]" "$expfile" >/dev/null; then
                     92:                                        echo "$base should trigger the message '$msgid'"
                     93:                                fi
                     94:                        fi
                     95:                esac
                     96:        done
                     97: done
                     98:
1.5       rillig     99: # shellcheck disable=SC2035
1.1       rillig    100: lua '../check-expect.lua' *.c

CVSweb <webmaster@jp.NetBSD.org>