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 lint1: remove redundancy from test...



details:   https://anonhg.NetBSD.org/src/rev/17bc339da0ae
branches:  trunk
changeset: 958191:17bc339da0ae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 28 12:01:24 2020 +0000

description:
lint1: remove redundancy from test definitions

Whether a test is supposed to produce lint warnings is determined by the
corresponding .exp file.  There is no need to encode this information
redundantly in the test driver.

diffstat:

 tests/usr.bin/xlint/lint1/t_integration.sh |  108 ++++++++++++++--------------
 1 files changed, 53 insertions(+), 55 deletions(-)

diffs (166 lines):

diff -r 77ded44bf62f -r 17bc339da0ae tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Mon Dec 28 11:40:54 2020 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Mon Dec 28 12:01:24 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.8 2020/12/28 11:19:01 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.9 2020/12/28 12:01:24 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -29,104 +29,102 @@
 
 Names=
 
-check_valid()
-{
-       atf_check -s exit:0 ${LINT1} -g -S "$(atf_get_srcdir)/$1" /dev/null
-}
-
-check_invalid()
+check_lint1()
 {
        local src="$(atf_get_srcdir)/$1"
        local exp="${src%.c}.exp"
 
-       atf_check -s not-exit:0 -o "file:${exp}" -e empty \
-           ${LINT1} -g -S -w "${src}" /dev/null
+       if [ -f "${exp}" ]; then
+               atf_check -s not-exit:0 -o "file:${exp}" -e empty \
+                   ${LINT1} -g -S -w "${src}" /dev/null
+       else
+               atf_check -s exit:0 \
+                   ${LINT1} -g -S -w "${src}" /dev/null
+       fi
 }
 
 test_case()
 {
-       local result="${1}"; shift
        local name="${1}"; shift
        local descr="${*}"
 
        atf_test_case ${name}
        eval "${name}_head() {
-               atf_set \"descr\" \"${descr}\";
-               atf_set \"require.progs\" \"${LINT1}\";
+               atf_set \"descr\" \"${descr}\"
+               atf_set \"require.progs\" \"${LINT1}\"
        }"
        eval "${name}_body() {
-               ${result} d_${name}.c;
+               check_lint1 d_${name}.c
        }"
 
        Names="${Names} ${name}"
 }
 
-test_case check_valid c99_struct_init "Checks C99 struct initialization"
-test_case check_valid c99_union_init1 "Checks C99 union initialization"
-test_case check_valid c99_union_init2 "Checks C99 union initialization"
-test_case check_valid c99_union_init3 "Checks C99 union initialization"
-test_case check_valid c99_recursive_init "Checks C99 recursive struct/union" \
+test_case c99_struct_init "Checks C99 struct initialization"
+test_case c99_union_init1 "Checks C99 union initialization"
+test_case c99_union_init2 "Checks C99 union initialization"
+test_case c99_union_init3 "Checks C99 union initialization"
+test_case c99_recursive_init "Checks C99 recursive struct/union" \
     "initialization"
-test_case check_valid c9x_recursive_init "Checks C9X struct/union member" \
+test_case c9x_recursive_init "Checks C9X struct/union member" \
     "init, with nested union and trailing member"
-test_case check_valid nested_structs "Checks nested structs"
-test_case check_valid packed_structs "Checks packed structs"
-test_case check_invalid struct_init_nested \
+test_case nested_structs "Checks nested structs"
+test_case packed_structs "Checks packed structs"
+test_case struct_init_nested \
     "Initialization of nested structures"
 
-test_case check_valid cast_init "Checks cast initialization"
-test_case check_valid cast_init2 "Checks cast initialization as the rhs of a" \
+test_case cast_init "Checks cast initialization"
+test_case cast_init2 "Checks cast initialization as the rhs of a" \
     "- operand"
-test_case check_valid cast_lhs "Checks whether pointer casts are valid lhs" \
+test_case cast_lhs "Checks whether pointer casts are valid lhs" \
     "lvalues"
 
-test_case check_valid gcc_func "Checks GCC __FUNCTION__"
-test_case check_valid c99_func "Checks C99 __func__"
+test_case gcc_func "Checks GCC __FUNCTION__"
+test_case c99_func "Checks C99 __func__"
 
-test_case check_valid gcc_variable_array_init "Checks GCC variable array" \
-    "initializers"
-test_case check_valid c9x_array_init "Checks C9X array initializers"
-test_case check_valid c99_decls_after_stmt "Checks C99 decls after statements"
-test_case check_valid c99_decls_after_stmt3 "Checks C99 decls after statements"
-test_case check_valid nolimit_init "Checks no limit initializers"
-test_case check_valid zero_sized_arrays "Checks zero sized arrays"
+test_case gcc_variable_array_init "Checks GCC variable array initializers"
+test_case c9x_array_init "Checks C9X array initializers"
+test_case c99_decls_after_stmt "Checks C99 decls after statements"
+test_case c99_decls_after_stmt3 "Checks C99 decls after statements"
+test_case nolimit_init "Checks no limit initializers"
+test_case zero_sized_arrays "Checks zero sized arrays"
 
-test_case check_valid compound_literals1 "Checks compound literals"
-test_case check_valid compound_literals2 "Checks compound literals"
-test_case check_valid gcc_compound_statements1 "Checks GCC compound statements"
-test_case check_valid gcc_compound_statements2 "Checks GCC compound" \
+test_case compound_literals1 "Checks compound literals"
+test_case compound_literals2 "Checks compound literals"
+test_case gcc_compound_statements1 "Checks GCC compound statements"
+test_case gcc_compound_statements2 "Checks GCC compound" \
     "statements with non-expressions"
-test_case check_valid gcc_compound_statements3 "Checks GCC compound" \
+test_case gcc_compound_statements3 "Checks GCC compound" \
     "statements with void type"
 # XXX: Because of polymorphic __builtin_isnan and expression has null effect
-# test_case check_valid gcc_extension "Checks GCC __extension__ and __typeof__"
+# test_case gcc_extension "Checks GCC __extension__ and __typeof__"
 
-test_case check_valid cvt_in_ternary "Checks CVT nodes handling in ?"
-test_case check_invalid cvt_constant "Checks constant conversion"
-test_case check_valid ellipsis_in_switch "Checks ellipsis in switch()"
-test_case check_valid c99_complex_num "Checks C99 complex numbers"
-test_case check_valid c99_complex_split "Checks C99 complex access"
-test_case check_valid c99_for_loops "Checks C99 for loops"
-test_case check_valid alignof "Checks __alignof__"
-test_case check_valid shift_to_narrower_type "Checks that type shifts that" \
+test_case cvt_in_ternary "Checks CVT nodes handling in ?"
+test_case cvt_constant "Checks constant conversion"
+test_case ellipsis_in_switch "Checks ellipsis in switch()"
+test_case c99_complex_num "Checks C99 complex numbers"
+test_case c99_complex_split "Checks C99 complex access"
+test_case c99_for_loops "Checks C99 for loops"
+test_case alignof "Checks __alignof__"
+test_case shift_to_narrower_type "Checks that type shifts that" \
     "result in narrower types do not produce warnings"
 
-test_case check_invalid constant_conv1 "Checks failing on information-losing" \
+test_case constant_conv1 "Checks failing on information-losing" \
     "constant conversion in argument lists"
-test_case check_invalid constant_conv2 "Checks failing on information-losing" \
+test_case constant_conv2 "Checks failing on information-losing" \
     "constant conversion in argument lists"
 
-test_case check_invalid type_conv1 "Checks failing on information-losing" \
+test_case type_conv1 "Checks failing on information-losing" \
     "type conversion in argument lists"
-test_case check_invalid type_conv2 "Checks failing on information-losing" \
+test_case type_conv2 "Checks failing on information-losing" \
     "type conversion in argument lists"
-test_case check_invalid type_conv3 "Checks failing on information-losing" \
+test_case type_conv3 "Checks failing on information-losing" \
     "type conversion in argument lists"
 
-test_case check_invalid incorrect_array_size "Checks failing on incorrect" \
+test_case incorrect_array_size "Checks failing on incorrect" \
     "array sizes"
 
-test_case check_invalid long_double_int "Checks for confusion of 'long" \
+test_case long_double_int "Checks for confusion of 'long" \
     "double' with 'long int'; PR bin/39639"
 
 atf_init_test_cases()



Home | Main Index | Thread Index | Old Index