tests/lint: add test skeletons for messages from lint2

This commit is contained in:
rillig 2021-08-05 22:36:07 +00:00
parent 2e6662efc3
commit 2e1c5b53fe
43 changed files with 286 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1103 2021/08/05 06:34:42 rillig Exp $
# $NetBSD: mi,v 1.1104 2021/08/05 22:36:07 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -7023,6 +7023,48 @@
./usr/tests/usr.bin/xlint/lint1/stmt_if.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_if.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2 tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/Atffile tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua
./usr/tests/usr.bin/xlint/lint2/msg_000.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_000.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_001.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_001.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_002.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_002.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_003.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_003.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_004.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_004.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_005.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_005.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_006.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_006.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_007.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_007.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_008.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_008.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_009.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_009.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_010.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_010.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_011.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_011.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_012.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_012.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_013.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_013.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_014.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_014.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_015.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_015.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_016.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_016.ln tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint2/msg_017.exp tests-usr.bin-tests compattestfile,atf
./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/lint1/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
./usr/tests/usr.bin/ztest/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua

View File

@ -1,4 +1,4 @@
# $NetBSD: NetBSD.dist.tests,v 1.185 2021/07/14 03:22:33 ozaki-r Exp $
# $NetBSD: NetBSD.dist.tests,v 1.186 2021/08/05 22:36:07 rillig Exp $
./usr/libdata/debug/usr/tests
./usr/libdata/debug/usr/tests/atf
@ -462,6 +462,7 @@
./usr/tests/usr.bin/vmstat
./usr/tests/usr.bin/xlint
./usr/tests/usr.bin/xlint/lint1
./usr/tests/usr.bin/xlint/lint2
./usr/tests/usr.bin/ztest
./usr/tests/usr.sbin
./usr/tests/usr.sbin/cpuctl

View File

@ -1,9 +1,9 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:15 jruoho Exp $
# $NetBSD: Makefile,v 1.2 2021/08/05 22:36:08 rillig Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/xlint
TESTS_SUBDIRS= lint1
TESTS_SUBDIRS= lint1 lint2
.include <bsd.test.mk>

View File

@ -0,0 +1,33 @@
# $NetBSD: Makefile,v 1.1 2021/08/05 22:36:08 rillig Exp $
NOMAN= yes
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint2
TESTS_SH= t_lint2
FILESDIR= ${TESTSDIR}
.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
.endfor
# Note: only works for adding tests.
# To remove a test, the $$mi file must be edited manually.
sync-mi: .PHONY
@set -eu; \
cd "${MAKEFILE:tA:H}/../../../.."; \
mi="distrib/sets/lists/tests/mi"; \
cvs update "$$mi"; \
fmt="./usr/tests/usr.bin/xlint/lint2/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \
cat "$$mi" > "$$mi.tmp"; \
printf "$$fmt" ${FILES} >> "$$mi.tmp"; \
distrib/sets/fmt-list "$$mi.tmp"; \
mv "$$mi.tmp" "$$mi"; \
cvs diff "$$mi" || true
.include <bsd.test.mk>

View File

@ -0,0 +1,2 @@
defined_not_used defined( msg_000.c(2) ), but never used
used_not_defined used( msg_000.c(3) ), but not defined

View File

@ -0,0 +1,42 @@
# $NetBSD: msg_000.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 0 of lint2:
# %s used( %s ), but not defined
#
# Define file number 0.
0smsg_000.c
# Define the main file of the translation unit.
Smsg_000.c
# Have a function that is used but not defined, and a function that is defined
# but not used, generated by this code:
# 1: # 2 "msg_000.c"
# 2: defined_not_used() {
# 3: used_not_defined(1, 0.0);
# 4: }
#
# The function call in line 3 generates this entry:
# '3' logical line 3 in the main .c source
# 'c' function call
# '0.3' file 0, logical line 3 in the currently included file
# 'p1' the first argument is a positive constant
# 'i' the return value of the function call is ignored
# '16...' the name of the called function
# 'f2' it's a function with 2 arguments
# 'I' the first argument has type 'int'
# 'D' the first argument has type 'double'
# 'I' the return type of the function is (implicitly) 'int'
3c0.3p1i16used_not_definedf2IDI
#
# The function definition in line 2 generates this entry:
# '2' logical line 2 in the main .c source
# 'd' function definition
# '0.2' file 0, logical line 2 in the currently included file
# 'd' function definition
# 'o' old-style function definition
# '16...' the name of the defined function
# 'f0' it's a function with 0 arguments
# 'I' the return type of the function is (implicitly) 'int'
2d0.2do16defined_not_usedf0I

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_001.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 1 of lint2:
# %s defined( %s ), but never used
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_002.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 2 of lint2:
# %s declared( %s ), but never used or defined
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_003.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 3 of lint2:
# %s multiply defined %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_004.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 4 of lint2:
# %s value used inconsistently %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_005.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 5 of lint2:
# %s value declared inconsistently (%s != %s) %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_006.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 6 of lint2:
# %s, arg %d used inconsistently %s[%s] :: %s[%s]
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_007.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 7 of lint2:
# %s: variable # of args %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_008.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 8 of lint2:
# %s returns value which is always ignored
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_009.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 9 of lint2:
# %s returns value which is sometimes ignored
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_010.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 10 of lint2:
# %s value is used( %s ), but none returned
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_011.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 11 of lint2:
# %s, arg %d declared inconsistently (%s != %s) %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_012.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 12 of lint2:
# %s: variable # of args declared %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_013.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 13 of lint2:
# %s: malformed format string %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_014.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 14 of lint2:
# %s, arg %d inconsistent with format %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_015.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 15 of lint2:
# %s: too few args for format %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_016.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 16 of lint2:
# s: too many args for format %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_017.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 17 of lint2:
# %s function value must be declared before use %s :: %s
#
# TODO: add actual test data

View File

View File

@ -0,0 +1,6 @@
# $NetBSD: msg_018.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Test data for message 18:
# %s renamed multiple times %s :: %s
#
# TODO: add actual test data

View File

@ -0,0 +1,54 @@
# $NetBSD: t_lint2.sh,v 1.1 2021/08/05 22:36:08 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
lint2=/usr/libexec/lint2
do_msg_head()
{
atf_set 'require.progs' "$lint2"
}
do_msg_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"
atf_check -o "file:$srcdir/msg_$1.exp" \
"$lint2" -h -p -x "msg_$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"
done
}