Module Name: src Committed By: rillig Date: Sun Jan 15 23:18:05 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/usr.bin/xlint: Makefile Added Files: src/tests/usr.bin/xlint/xlint: Makefile t_xlint.sh Log Message: tests/lint: add basic tests for lint (not lint1 or lint2) To generate a diff of this commit: cvs rdiff -u -r1.1241 -r1.1242 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.197 -r1.198 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/xlint/Makefile \ src/tests/usr.bin/xlint/xlint/t_xlint.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1241 src/distrib/sets/lists/tests/mi:1.1242 --- src/distrib/sets/lists/tests/mi:1.1241 Sun Jan 15 00:53:19 2023 +++ src/distrib/sets/lists/tests/mi Sun Jan 15 23:18:05 2023 @@ -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 Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.197 src/etc/mtree/NetBSD.dist.tests:1.198 --- src/etc/mtree/NetBSD.dist.tests:1.197 Mon Nov 21 22:01:33 2022 +++ src/etc/mtree/NetBSD.dist.tests Sun Jan 15 23:18:05 2023 @@ -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 Index: src/tests/usr.bin/xlint/Makefile diff -u src/tests/usr.bin/xlint/Makefile:1.2 src/tests/usr.bin/xlint/Makefile:1.3 --- src/tests/usr.bin/xlint/Makefile:1.2 Thu Aug 5 22:36:08 2021 +++ src/tests/usr.bin/xlint/Makefile Sun Jan 15 23:18:05 2023 @@ -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> Added files: Index: src/tests/usr.bin/xlint/xlint/Makefile diff -u /dev/null src/tests/usr.bin/xlint/xlint/Makefile:1.1 --- /dev/null Sun Jan 15 23:18:05 2023 +++ src/tests/usr.bin/xlint/xlint/Makefile Sun Jan 15 23:18:05 2023 @@ -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> Index: src/tests/usr.bin/xlint/xlint/t_xlint.sh diff -u /dev/null src/tests/usr.bin/xlint/xlint/t_xlint.sh:1.1 --- /dev/null Sun Jan 15 23:18:05 2023 +++ src/tests/usr.bin/xlint/xlint/t_xlint.sh Sun Jan 15 23:18:05 2023 @@ -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' +}