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: rework ATF test driver



details:   https://anonhg.NetBSD.org/src/rev/c9481b078eae
branches:  trunk
changeset: 984577:c9481b078eae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 11 22:41:36 2021 +0000

description:
tests/lint: rework ATF test driver

To skip tests that work only on particular platforms, a simple 'eval'
from the shell does not work since it does not exit on failure.  Fix
this by storing the commands in a local variable first.

Remove configuration knobs 'lint1-only-if-arch' and 'lint1-skip-if-arch'
since they are unused.

When skipping a test, actually mark it as skipped in the ATF statistics.

diffstat:

 tests/usr.bin/xlint/lint1/t_integration.sh |  39 ++++++++++-------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diffs (87 lines):

diff -r bdd82121dcac -r c9481b078eae tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Jul 11 22:07:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Jul 11 22:41:36 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.66 2021/06/29 13:58:13 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.67 2021/07/11 22:41:36 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -65,12 +65,12 @@
 
                function platform_has(prop) {
                        if (!match(prop, /^(schar|uchar|ilp32|lp64|int|long|ldbl-64|ldbl-96|ldbl-128)$/)) {
-                               printf("bad property '\''%s'\''\n", prop) > "/dev/stderr";
-                               exit(1);
+                               printf("bad property '\''%s'\''\n", prop) > "/dev/stderr"
+                               exit(1)
                        }
                        if (platform[machine_arch] == "") {
-                               printf("bad machine_arch '\''%s'\''\n", machine_arch) > "/dev/stderr";
-                               exit(1);
+                               printf("bad machine_arch '\''%s'\''\n", machine_arch) > "/dev/stderr"
+                               exit(1)
                        }
                        return match(" " platform[machine_arch] " ", " " prop " ")
                }
@@ -78,9 +78,7 @@
                BEGIN {
                        machine_arch = "'"$machine_arch"'"
                        flags = "-g -S -w"
-                       seen_only_on_arch = 0
-                       match_only_on_arch = 0
-                       skip = 0
+                       skip = "no"
                }
                $1 == "/*" && $2 ~ /^lint1-/ && $NF == "*/" {
                        if ($2 == "lint1-flags:" || $2 == "lint1-extra-flags:") {
@@ -89,29 +87,21 @@
                                for (i = 3; i < NF; i++)
                                        flags = flags " " $i
                        }
-                       if ($2 == "lint1-only-if-arch") {
-                               seen_only_on_arch = 1
-                               if ($3 == machine_arch)
-                                       match_only_on_arch = 1
-                       }
-                       if ($2 == "lint1-skip-if-arch" && $3 == machine_arch)
-                               skip = 1
                        if ($2 == "lint1-only-if" && !platform_has($3))
-                               skip = 1
+                               skip = "yes"
                        if ($2 == "lint1-skip-if" && platform_has($3))
-                               skip = 1
+                               skip = "yes"
                }
 
                END {
-                       if (seen_only_on_arch && !match_only_on_arch)
-                               skip = 1
-
                        printf("flags='\''%s'\''\n", flags)
-                       printf("skip=%s\n", skip ? "yes" : "no")
+                       printf("skip=%s\n", skip)
                }
        '
 
-       eval "$(awk "$awk" "$1")"
+       local config
+       config="$(awk "$awk" "$1")" || exit 1
+       eval "$config"
 }
 
 # shellcheck disable=SC2155
@@ -129,11 +119,10 @@
                wrk_ln='/dev/null'
        fi
 
-       configure_test_case "$src"
+       configure_test_case "$src"      # sets 'skip' and 'flags'
 
        if [ "$skip" = "yes" ]; then
-               atf_check -o 'ignore' echo 'skipped'
-               return
+               atf_skip "unsuitable platform"
        fi
 
        if [ -f "$exp" ]; then



Home | Main Index | Thread Index | Old Index