Source-Changes-HG archive

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

[src/trunk]: src tests/lint: test reading of 128-bit integer types and printf



details:   https://anonhg.NetBSD.org/src/rev/a538efcb3cc9
branches:  trunk
changeset: 985090:a538efcb3cc9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 07 23:52:32 2021 +0000

description:
tests/lint: test reading of 128-bit integer types and printf

diffstat:

 distrib/sets/lists/tests/mi              |   7 +++++-
 tests/usr.bin/xlint/lint2/Makefile       |  17 ++++++++++++--
 tests/usr.bin/xlint/lint2/read_lp64.ln   |  10 +++++++++
 tests/usr.bin/xlint/lint2/read_printf.ln |  35 ++++++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint2/t_lint2.sh     |   9 ++++---
 5 files changed, 70 insertions(+), 8 deletions(-)

diffs (137 lines):

diff -r 2e2c420e9120 -r a538efcb3cc9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Aug 07 22:05:26 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Aug 07 23:52:32 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1106 2021/08/07 21:24:13 rillig Exp $
+# $NetBSD: mi,v 1.1107 2021/08/07 23:52:32 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7066,7 +7066,12 @@
 ./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/read_lp64.exp                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_lp64.ln                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_printf.exp                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_printf.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/xlint/lint2/tests                          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
 ./usr/tests/usr.bin/ztest/Kyuafile                     tests-usr.bin-tests     compattestfile,atf,kyua
diff -r 2e2c420e9120 -r a538efcb3cc9 tests/usr.bin/xlint/lint2/Makefile
--- a/tests/usr.bin/xlint/lint2/Makefile        Sat Aug 07 22:05:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/Makefile        Sat Aug 07 23:52:32 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2021/08/07 21:24:14 rillig Exp $
+# $NetBSD: Makefile,v 1.3 2021/08/07 23:52:32 rillig Exp $
 
 NOMAN=         yes
 
@@ -13,9 +13,20 @@
 .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
+TESTS+=                msg_${msg}
 .endfor
-FILES+=                read.exp        read.ln
+TESTS+=                read
+.if ${MACHINE_ARCH:M*64}       # close enough to "is a 64-bit platform"
+TESTS+=                read_lp64
+.endif
+TESTS+=                read_printf
+
+FILES+=                ${TESTS:=.ln} ${TESTS:=.exp}
+FILES+=                tests
+
+realall: tests
+tests:
+       printf '%s\n' ${TESTS} > ${.TARGET}
 
 # Note: only works for adding tests.
 # To remove a test, the $$mi file must be edited manually.
diff -r 2e2c420e9120 -r a538efcb3cc9 tests/usr.bin/xlint/lint2/read_lp64.ln
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/read_lp64.ln    Sat Aug 07 23:52:32 2021 +0000
@@ -0,0 +1,10 @@
+# $NetBSD: read_lp64.ln,v 1.1 2021/08/07 23:52:32 rillig Exp $
+#
+# Cover reading of 128-bit integer types.
+# These types are only available on 64-bit platforms.
+
+0sread_lp64.c
+Sread_lp64.c
+
+115d0.115e4f115F0J             # INT128
+116d0.116e4f116F0uJ            # UINT128
diff -r 2e2c420e9120 -r a538efcb3cc9 tests/usr.bin/xlint/lint2/read_printf.ln
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint2/read_printf.ln  Sat Aug 07 23:52:32 2021 +0000
@@ -0,0 +1,35 @@
+# $NetBSD: read_printf.ln,v 1.1 2021/08/07 23:52:32 rillig Exp $
+#
+# Test reading of declarations and usage of printf-like functions.
+
+# void my_printf(const char *, ...);
+0sprintf-def.c
+Sprintf-def.c
+3d0.3d9my_printfF2PcCEV
+
+0sprintf-use.c
+Sprintf-use.c
+
+# my_printf("string %s", "string %s%%%3d");
+#
+# Argument 1 is converted to 'const char *', due to the function prototype.
+# After that, is it not a string literal anymore, therefore no information
+# about this argument is written to the .ln file.
+#
+# Argument 2 is part of the '...', therefore no conversion to 'const char *'
+# takes place.  Since it is still the address of a string, its value is
+# analyzed for printf format specifiers.  This is unnecessary though since in
+# this example, the format string is already in argument 1, but not 2.
+11c0.11 s2"%s%%%3d" i 9my_printf f2 PcC PC V
+
+# my_printf("int %d", 12345);
+#
+# Argument 2 is a positive integer.
+12c0.12 p2 i 9my_printf f2 PcC I V
+
+# my_printf("%s %d %p", "\t", -6, (const void *)0);
+#
+# Argument 2 is a string without any printf-like format specifiers.
+# Argument 3 is a negative integer.
+# Argument 4 has no further interesting properties.
+13c0.13 s2"" n3 i 9my_printf f4 PcC PC I PcV V
diff -r 2e2c420e9120 -r a538efcb3cc9 tests/usr.bin/xlint/lint2/t_lint2.sh
--- a/tests/usr.bin/xlint/lint2/t_lint2.sh      Sat Aug 07 22:05:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/t_lint2.sh      Sat Aug 07 23:52:32 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.2 2021/08/07 21:24:14 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.3 2021/08/07 23:52:32 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,8 +37,8 @@
        # shellcheck disable=SC2155
        local srcdir="$(atf_get_srcdir)"
 
-       # remove comments and empty lines from the .ln file
-       sed -e '/^#/d' -e '/^$/d' -e 's,[[:space:]]*#.*,,' \
+       # remove comments and whitespace from the .ln file
+       sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \
            < "$srcdir/$1.ln" \
            > "$1.ln"
 
@@ -48,7 +48,8 @@
 
 atf_init_test_cases()
 {
-       for i in $(printf 'msg_%03d\n' $(seq 0 18)) "read"; do
+       # shellcheck disable=SC2013
+       for i in $(cat "$(atf_get_srcdir)/tests"); do
                eval "${i}_head() { std_head; }"
                eval "${i}_body() { std_body '$i'; }"
                atf_add_test_case "$i"



Home | Main Index | Thread Index | Old Index