Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: allow skipping individ...
details: https://anonhg.NetBSD.org/src/rev/d76ecde0ad5a
branches: trunk
changeset: 984194:d76ecde0ad5a
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jun 27 10:14:43 2021 +0000
description:
tests/lint: allow skipping individual tests
Depending on the platform, some tests do not make sense or produce
platform-dependent results. Allow these tests to be marked as such.
For example, the test lex_integer.c only works on 64-bit platforms.
Therefore it is disabled on i386 for now since it prints different
warnings there. Even better would be a "lint1-only-on-lpi32" toggle,
but that would need detection of 'sizeof(int)' at runtime.
diffstat:
tests/usr.bin/xlint/lint1/lex_integer.c | 4 ++-
tests/usr.bin/xlint/lint1/lex_integer.exp | 10 ++++----
tests/usr.bin/xlint/lint1/t_integration.sh | 34 ++++++++++++++++++++++-------
3 files changed, 34 insertions(+), 14 deletions(-)
diffs (118 lines):
diff -r 552299ab43ef -r d76ecde0ad5a tests/usr.bin/xlint/lint1/lex_integer.c
--- a/tests/usr.bin/xlint/lint1/lex_integer.c Sun Jun 27 09:22:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_integer.c Sun Jun 27 10:14:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_integer.c,v 1.1 2021/06/19 08:30:08 rillig Exp $ */
+/* $NetBSD: lex_integer.c,v 1.2 2021/06/27 10:14:43 rillig Exp $ */
# 3 "lex_integer.c"
/*
@@ -7,6 +7,8 @@
* C99 6.4.4.1 "Integer constants"
*/
+/* lint1-not-on-arch: i386 (has 32-bit long) */
+
void sinki(int);
void sinku(unsigned int);
diff -r 552299ab43ef -r d76ecde0ad5a tests/usr.bin/xlint/lint1/lex_integer.exp
--- a/tests/usr.bin/xlint/lint1/lex_integer.exp Sun Jun 27 09:22:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_integer.exp Sun Jun 27 10:14:43 2021 +0000
@@ -1,5 +1,5 @@
-lex_integer.c(25): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
-lex_integer.c(25): warning: conversion of 'long' to 'int' is out of range, arg #1 [295]
-lex_integer.c(30): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
-lex_integer.c(42): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]
-lex_integer.c(42): warning: conversion of 'unsigned long' to 'unsigned int' is out of range, arg #1 [295]
+lex_integer.c(27): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+lex_integer.c(27): warning: conversion of 'long' to 'int' is out of range, arg #1 [295]
+lex_integer.c(32): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+lex_integer.c(44): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]
+lex_integer.c(44): warning: conversion of 'unsigned long' to 'unsigned int' is out of range, arg #1 [295]
diff -r 552299ab43ef -r d76ecde0ad5a tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 27 09:22:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 27 10:14:43 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.58 2021/06/27 09:22:31 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.59 2021/06/27 10:14:43 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -28,16 +28,19 @@
lint1=/usr/libexec/lint1
test_case_names=
+machine_arch="$(sysctl -n hw.machine_arch)"
-extract_flags()
+configure_test_case()
{
- local extract_flags_awk
+ local awk
# shellcheck disable=SC2016
- extract_flags_awk='
+ awk='
BEGIN {
+ machine_arch = "'"$machine_arch"'"
flags = "-g -S -w"
+ skip = 0
}
/^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
if ($2 == "lint1-flags:")
@@ -45,12 +48,19 @@
for (i = 3; i < NF; i++)
flags = flags " " $i
}
+ /^\/\* lint1-only-on-arch: .* \*\/$/ && $3 != machine_arch {
+ skip = 1
+ }
+ /^\/\* lint1-not-on-arch: .* \*\/$/ && $3 == machine_arch {
+ skip = 1
+ }
END {
- print flags
+ printf("flags='\''%s'\''\n", flags)
+ printf("skip=%s\n", skip ? "yes" : "no")
}
'
- awk "$extract_flags_awk" "$@"
+ eval "$(awk "$awk" "$1")"
}
# shellcheck disable=SC2155
@@ -60,13 +70,21 @@
local exp="${src%.c}.exp"
local exp_ln="${src%.c}.ln"
local wrk_ln="${1%.c}.ln"
- local flags="$(extract_flags "$src")"
+ local flags=""
+ local skip=""
if [ ! -f "$exp_ln" ]; then
exp_ln='/dev/null'
wrk_ln='/dev/null'
fi
+ configure_test_case "$src"
+
+ if [ "$skip" = "yes" ]; then
+ atf_check -o 'ignore' echo 'skipped'
+ return
+ fi
+
if [ -f "$exp" ]; then
# shellcheck disable=SC2086
atf_check -s not-exit:0 -o "file:$exp" -e empty \
@@ -77,7 +95,7 @@
"$lint1" $flags "$src" "$wrk_ln"
fi
- if [ "$src_ln" != '/dev/null' ]; then
+ if [ "$exp_ln" != '/dev/null' ]; then
atf_check -o "file:$exp_ln" cat "$wrk_ln"
fi
}
Home |
Main Index |
Thread Index |
Old Index