Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: add basic tests for lint (not lint1 or lint2)
details: https://anonhg.NetBSD.org/src/rev/7333d9acb4b3
branches: trunk
changeset: 373072:7333d9acb4b3
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 15 23:18:05 2023 +0000
description:
tests/lint: add basic tests for lint (not lint1 or lint2)
diffstat:
distrib/sets/lists/tests/mi | 4 +-
etc/mtree/NetBSD.dist.tests | 3 +-
tests/usr.bin/xlint/Makefile | 4 +-
tests/usr.bin/xlint/xlint/Makefile | 8 ++
tests/usr.bin/xlint/xlint/t_xlint.sh | 120 +++++++++++++++++++++++++++++++++++
5 files changed, 135 insertions(+), 4 deletions(-)
diffs (186 lines):
diff -r 74ac6ef61891 -r 7333d9acb4b3 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jan 15 23:10:52 2023 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jan 15 23:18:05 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1241 2023/01/15 00:53:19 rillig Exp $
+# $NetBSD: mi,v 1.1242 2023/01/15 23:18:05 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -7424,6 +7424,8 @@
./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/xlint/Atffile tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/xlint/t_xlint 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 74ac6ef61891 -r 7333d9acb4b3 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests Sun Jan 15 23:10:52 2023 +0000
+++ b/etc/mtree/NetBSD.dist.tests Sun Jan 15 23:18:05 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.dist.tests,v 1.197 2022/11/21 22:01:33 christos Exp $
+# $NetBSD: NetBSD.dist.tests,v 1.198 2023/01/15 23:18:05 rillig Exp $
./usr/libdata/debug/usr/tests
./usr/libdata/debug/usr/tests/atf
@@ -479,6 +479,7 @@
./usr/tests/usr.bin/xlint
./usr/tests/usr.bin/xlint/lint1
./usr/tests/usr.bin/xlint/lint2
+./usr/tests/usr.bin/xlint/xlint
./usr/tests/usr.bin/ztest
./usr/tests/usr.sbin
./usr/tests/usr.sbin/cpuctl
diff -r 74ac6ef61891 -r 7333d9acb4b3 tests/usr.bin/xlint/Makefile
--- a/tests/usr.bin/xlint/Makefile Sun Jan 15 23:10:52 2023 +0000
+++ b/tests/usr.bin/xlint/Makefile Sun Jan 15 23:18:05 2023 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.2 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: Makefile,v 1.3 2023/01/15 23:18:05 rillig Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/xlint
-TESTS_SUBDIRS= lint1 lint2
+TESTS_SUBDIRS= lint1 lint2 xlint
.include <bsd.test.mk>
diff -r 74ac6ef61891 -r 7333d9acb4b3 tests/usr.bin/xlint/xlint/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/xlint/Makefile Sun Jan 15 23:18:05 2023 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2023/01/15 23:18:05 rillig Exp $
+
+NOMAN= yes
+TESTSDIR= ${TESTSBASE}/usr.bin/xlint/xlint
+TESTS_SH= t_xlint
+FILESDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff -r 74ac6ef61891 -r 7333d9acb4b3 tests/usr.bin/xlint/xlint/t_xlint.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/xlint/t_xlint.sh Sun Jan 15 23:18:05 2023 +0000
@@ -0,0 +1,120 @@
+# $NetBSD: t_xlint.sh,v 1.1 2023/01/15 23:18:05 rillig Exp $
+#
+# Copyright (c) 2023 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.
+#
+
+: ${lint:='/usr/bin/lint'}
+
+run_lint1_error_head()
+{
+ :
+}
+
+run_lint1_error_body()
+{
+ cat <<-EOF >input.c || atf_fail 'prepare input.c'
+ #include <stdbool.h>
+
+ bool
+ return_true(void)
+ {
+ return 1;
+ }
+ EOF
+
+ atf_check \
+ -s 'exit:1' \
+ -o "inline:input.c(6): error: function has return type '_Bool' but returns 'int' [211]\n" \
+ "$lint" -aabceghiprSTxz input.c
+
+ # In case of an error, no output file is written.
+ atf_check \
+ -s 'exit:1' \
+ test -f input.ln
+}
+
+
+run_lint1_warning_head()
+{
+ :
+}
+
+run_lint1_warning_body()
+{
+ cat <<-EOF >input.c || atf_fail 'prepare input.c'
+ static int number;
+
+ const void *
+ function(int a, const char *s)
+ {
+ return s + a;
+ }
+ EOF
+ cat <<-EOF >input.exp || atf_fail 'prepare input.exp'
+ 0sinput.c
+ Sinput.c
+ 1s<built-in>
+ 2s<command-line>
+ 4d0.4dr8functionF2IPcCPcV
+ EOF
+
+ atf_check \
+ -o "inline:input.c(1): warning: static variable 'number' unused [226]\n" \
+ "$lint" -aabceghiprSTxz input.c
+ atf_check \
+ -o 'file:input.exp' \
+ cat input.ln
+}
+
+run_lint2_head()
+{
+ :
+}
+
+run_lint2_body()
+{
+ cat <<-EOF >input.ln || atf_fail 'prepare input.ln'
+ 0sinput.c
+ Sinput.c
+ 1s<built-in>
+ 2s<command-line>
+ 4d0.4dr8functionF2IPcCPcV
+ EOF
+
+ # Most of the command line options are not relevant for lint2,
+ # so they are effectively ignored. The option '-i' is absent.
+ atf_check \
+ -o 'inline:function defined( input.c(4) ), but never used\n' \
+ -e 'inline:lint: cannot find llib-lc.ln\n' \
+ "$lint" -aabceghprSTxz input.ln
+}
+
+
+atf_init_test_cases()
+{
+ atf_add_test_case 'run_lint1_error'
+ atf_add_test_case 'run_lint1_warning'
+ atf_add_test_case 'run_lint2'
+}
Home |
Main Index |
Thread Index |
Old Index