Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: add test for reading the lint1 output



details:   https://anonhg.NetBSD.org/src/rev/1c80f1624d52
branches:  trunk
changeset: 1022797:1c80f1624d52
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 07 21:24:13 2021 +0000

description:
tests/lint: add test for reading the lint1 output

diffstat:

 distrib/sets/lists/tests/mi          |   4 +-
 tests/usr.bin/xlint/lint2/Makefile   |   5 +-
 tests/usr.bin/xlint/lint2/read.exp   |   1 +
 tests/usr.bin/xlint/lint2/read.ln    |  64 ++++++++++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint2/t_lint2.sh |  22 ++++++-----
 5 files changed, 83 insertions(+), 13 deletions(-)

diffs (160 lines):

diff -r ba6f0f661052 -r 1c80f1624d52 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Aug 07 21:23:37 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Aug 07 21:24:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1105 2021/08/06 08:44:31 martin Exp $
+# $NetBSD: mi,v 1.1106 2021/08/07 21:24:13 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7064,6 +7064,8 @@
 ./usr/tests/usr.bin/xlint/lint2/msg_017.ln                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/msg_018.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/msg_018.ln                     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read.exp                       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read.ln                                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/t_lint2                                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/ztest                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/ztest/Atffile                      tests-usr.bin-tests     compattestfile,atf
diff -r ba6f0f661052 -r 1c80f1624d52 tests/usr.bin/xlint/lint2/Makefile
--- a/tests/usr.bin/xlint/lint2/Makefile        Sat Aug 07 21:23:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/Makefile        Sat Aug 07 21:24:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: Makefile,v 1.2 2021/08/07 21:24:14 rillig Exp $
 
 NOMAN=         yes
 
@@ -13,8 +13,9 @@
 .for msg in \
     000 001 002 003 004 005 006 007 008 009 \
     010 011 012 013 014 015 016 017 018
-FILES+=                msg_${msg}.exp msg_${msg}.ln
+FILES+=                msg_${msg}.exp  msg_${msg}.ln
 .endfor
+FILES+=                read.exp        read.ln
 
 # Note: only works for adding tests.
 # To remove a test, the $$mi file must be edited manually.
diff -r ba6f0f661052 -r 1c80f1624d52 tests/usr.bin/xlint/lint2/read.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/read.exp        Sat Aug 07 21:24:13 2021 +0000
@@ -0,0 +1,1 @@
+a125 declared( read.c(125) ), but never used or defined
diff -r ba6f0f661052 -r 1c80f1624d52 tests/usr.bin/xlint/lint2/read.ln
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/read.ln Sat Aug 07 21:24:13 2021 +0000
@@ -0,0 +1,64 @@
+# $NetBSD: read.ln,v 1.1 2021/08/07 21:24:14 rillig Exp $
+#
+# Cover each path of reading declarations, definitions and usages.
+
+0sread.c
+Sread.c
+
+# Cover all tspec_t constants, in declaration order.
+#
+# The line numbers correspond to the constant values of tspec_t,
+# with the 128-bit types included.
+#
+# NOTSPEC      cannot occur in lint1 output.
+# SIGNED       cannot occur in lint1 output.
+# UNSIGN       cannot occur in lint1 output.
+103d0.103e4f103F0B             # BOOL          _Bool           f103(void);
+104d0.104e4f104F0C             # CHAR          char            f104(void);
+105d0.105e4f105F0sC            # SCHAR         signed char     f105(void);
+106d0.106e4f106F0uC            # UCHAR         unsigned char   f106(void);
+107d0.107e4f107F0S             # SHORT         short           f107(void);
+108d0.108e4f108F0uS            # USHORT        unsigned short  f108(void);
+109d0.109e4f109F0I             # INT           int             f109(void);
+110d0.110e4f110F0uI            # UINT          unsigned int    f110(void);
+111d0.111e4f111F0L             # LONG          long            f111(void);
+112d0.112e4f112F0uL            # ULONG         unsigned long   f112(void);
+113d0.113e4f113F0Q             # QUAD          long long       f113(void);
+114d0.114e4f114F0uQ            # UQUAD         unsigned long long f114(void);
+# INT128       works only in 64-bit mode, see read_lp64.
+# UINT128      works only in 64-bit mode, see read_lp64.
+117d0.117e4f117F0sD            # FLOAT         float           f117(void);
+118d0.118e4f118F0D             # DOUBLE        double          f118(void);
+119d0.119e4f119F0lD            # LDOUBLE       long double     f119(void);
+120d0.120e4f120F0V             # VOID          void            f120(void);
+121d0.121e4f121F0sT16tag121    # STRUCT        struct tag121   f121(void);
+122d0.122e4f122F0uT16tag122    # UNION         union tag122    f122(void);
+123d0.123e4f123F0eT16tag123    # ENUM          enum tag123     f123(void);
+124d0.124e4f124FPV             # PTR           void *          f124(void);
+125d0.125e4a125A7D             # ARRAY         extern double   a125[7];
+126d0.126e4f126F0PF1DV         # FUNC          void (*f126(void))(double);
+# COMPLEX      cannot occur in lint1 output.
+127d0.127e4f127F0sX            # FCOMPLEX      float _Complex  f127(void);
+128d0.128e4f128F0X             # COMPLEX       double _Complex f128(void);
+129d0.129e4f129F0lX            # LCOMPLEX      long double _Complex f129(void);
+
+# Tagged types (struct, union, enum) can have tags or typedefs or be
+# anonymous, but anonymous types are not usually used in external
+# declarations.
+#
+# struct s_tag f201(void);
+201d0.201e4f201F0sT15s_tag
+# typedef struct {} s_def;
+# s_def f202(void);
+202d0.202e4f202F0sT25s_def
+# struct { int member; } f203(void);
+203d0.203e4f203F0sT3203.0.0
+
+# Type qualifiers
+#
+# void f301(const int *);
+301d0.301e4f301F1PcIV
+# void f302(volatile int *);
+302d0.302e4f302F1PvIV
+# void f302(const volatile int *);
+303d0.303e4f303F1PcvIV
diff -r ba6f0f661052 -r 1c80f1624d52 tests/usr.bin/xlint/lint2/t_lint2.sh
--- a/tests/usr.bin/xlint/lint2/t_lint2.sh      Sat Aug 07 21:23:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/t_lint2.sh      Sat Aug 07 21:24:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.2 2021/08/07 21:24:14 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -27,28 +27,30 @@
 
 lint2=/usr/libexec/lint2
 
-do_msg_head()
+std_head()
 {
        atf_set 'require.progs' "$lint2"
 }
 
-do_msg_body()
+std_body()
 {
        # shellcheck disable=SC2155
        local srcdir="$(atf_get_srcdir)"
 
        # remove comments and empty lines from the .ln file
-       sed -e '/^#/d' -e '/^$/d' < "$srcdir/msg_$1.ln" > "msg_$1.ln"
+       sed -e '/^#/d' -e '/^$/d' -e 's,[[:space:]]*#.*,,' \
+           < "$srcdir/$1.ln" \
+           > "$1.ln"
 
-       atf_check -o "file:$srcdir/msg_$1.exp" \
-           "$lint2" -h -p -x "msg_$1.ln"
+       atf_check -o "file:$srcdir/$1.exp" \
+           "$lint2" -h -p -x "$1.ln"
 }
 
 atf_init_test_cases()
 {
-       for i in $(printf '%03d\n' $(seq 0 18)); do
-               eval "msg_${i}_head() { do_msg_head; }"
-               eval "msg_${i}_body() { do_msg_body '$i'; }"
-               atf_add_test_case "msg_$i"
+       for i in $(printf 'msg_%03d\n' $(seq 0 18)) "read"; do
+               eval "${i}_head() { std_head; }"
+               eval "${i}_body() { std_body '$i'; }"
+               atf_add_test_case "$i"
        done
 }



Home | Main Index | Thread Index | Old Index