]> git.draconx.ca Git - cdecl99.git/commitdiff
Port randomdecl sanity test to Autotest.
authorNick Bowler <nbowler@draconx.ca>
Thu, 2 Jul 2020 22:58:03 +0000 (18:58 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 3 Jul 2020 03:19:45 +0000 (23:19 -0400)
.gitignore
Makefile.am
configure.ac
tests/randomdecl-sanity.sed [deleted file]
tests/randomdecl-sanity.sh [deleted file]
tests/stress.at [new file with mode: 0644]
testsuite.at

index 911090e8a91553c29224e820d1bbfaf4487d7c31..735368eb75e5701d8e6d67f738d6c22d04761912 100644 (file)
@@ -7,6 +7,7 @@
 /ABOUT-NLS
 /aclocal.m4
 /atconfig
+/atlocal
 /autom4te.cache
 /cdecl99
 /compile
index a9379dbcc0461eae87ba75fb04b78c49ca6fe63e..8ccdc951e945037ff1b95958db7b0a61b58a3e67 100644 (file)
@@ -76,9 +76,9 @@ TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)'
 TEST_EXTENSIONS = .sh
 SH_LOG_COMPILER = $(SHELL)
 
-TESTS = tests/randomdecl-sanity.sh tests/crossparse-c-random.sh
+TESTS = tests/crossparse-c-random.sh
 
-dist_check_SCRIPTS = tests/randomdecl-sanity.sed $(TESTS)
+dist_check_SCRIPTS = $(TESTS)
 
 src/parse.lo: src/scan.h
 src/scan.lo: src/parse.h
@@ -203,6 +203,16 @@ FLEX_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'FLEX    ' $<;
                $(MAKE) $(AM_MAKEFLAGS) $<; \
        fi
 
+atlocal: config.status
+       $(AM_V_GEN) :; { \
+         printf ': "$${%s=%s}"\n' \
+           EXEEXT '$(EXEEXT)' \
+           check_PROGRAMS '$(check_PROGRAMS)' \
+           ; } >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+check_DATA = atlocal
+CLEANFILES += atlocal
+
 include $(top_srcdir)/lib/gnulib.mk
 include $(top_srcdir)/common/snippet/glconfig.mk
 include $(top_srcdir)/common/snippet/autotest.mk
index eed1a1974ef7826944b1c3336d7f781309ee2e05..fa00e02bdd36d98f300bf866aed4d1a52a5752ff 100644 (file)
@@ -71,7 +71,7 @@ AS_CASE([$with_gsl],
        [DX_CHECK_GSL([1.0], [have_gsl=yes], [have_gsl=no])])
 AM_CONDITIONAL([HAVE_GSL], [test x"$have_gsl" = x"yes"])
 
-AC_CONFIG_TESTDIR([.])
+AC_CONFIG_TESTDIR([.], [test:.])
 DX_PROG_AUTOTEST
 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
 
diff --git a/tests/randomdecl-sanity.sed b/tests/randomdecl-sanity.sed
deleted file mode 100644 (file)
index ad5bfa0..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#n
-# Checks for key bits in English declarations.  This file is itself parsed
-# to determine the things checked for: lines containing "=yes" are assumed
-# to be variables to be tested, and must be followed by a # and a comment
-# stating the feature being tested.
-#
-# Copyright © 2012 Nick Bowler
-#
-# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-# This is free software: you are free to do what the fuck you want to.
-# There is NO WARRANTY, to the extent permitted by law.
-10000q
-/^declare/i\
-declaration=yes # declaration of an identifier
-/^type/i\
-abstract=yes # type name
-/inline/i\
-inline=yes # inline function
-/inline inline/i\
-redundant_funcspec=yes # redundant function specifiers
-/function ([[:alnum:]_]* as/i\
-named_parameter=yes # named function parameter
-/function (void)/i\
-empty_prototype=yes # empty prototype declaration
-/function returning/i\
-non_prototype=yes # non-prototype function declaration.
-/\.\.\.)/i\
-variadic=yes # variadic function
-/const/i\
-const=yes # const qualifier
-/volatile/i\
-volatile=yes # volatile qualifier
-/restrict/i\
-restrict=yes # restrict qualifier
-/const const/i\
-redundant_qualifier=yes # redundant type qualifiers
-/variable-length array/i\
-vla=yes # variable-length array
-/static/i\
-static=yes # static storage-class specifier
-/extern/i\
-extern=yes # extern storage-class specifier
-/typedef/i\
-typedef=yes # typedef storage-class specifier
-/auto/i\
-auto=yes # auto storage-class specifier
-/register/i\
-register=yes # register storage-class specifier
-/void/i\
-void=yes # void type specifier
-/char/i\
-char=yes # char type specifier
-/short/i\
-short=yes # short type specifier
-/int/i\
-int=yes # int type specifier
-/long/i\
-long=yes # long type specifier
-/float/i\
-float=yes # float type specifier
-/double/i\
-double=yes # double type specifier
-/signed/i\
-signed=yes # signed type specifier
-/unsigned/i\
-unsigned=yes # unsigned type specifier
-/_Bool/i\
-bool=yes # _Bool type specifier
-/_Complex/i\
-complex=yes # _Complex type specifier
-/_Imaginary/i\
-imaginary=yes # _Imaginary type specifier
-/struct/i\
-struct=yes # struct type specifier
-/union/i\
-union=yes # union type specifier
-/enum/i\
-enum=yes # enum type specifier
-/pointer to array/i\
-pointer_to_array=yes # pointer to an array
-/pointer to function/i\
-pointer_to_function=yes # pointer to a function
diff --git a/tests/randomdecl-sanity.sh b/tests/randomdecl-sanity.sh
deleted file mode 100755 (executable)
index fad6d5a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-#
-# Copyright © 2012 Nick Bowler
-#
-# Check randomdecl's output to make sure it actually generates a variety
-# of declarations.
-#
-# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-# This is free software: you are free to do what the fuck you want to.
-# There is NO WARRANTY, to the extent permitted by law.
-
-randomdecl=test/randomdecl$EXEEXT
-test -x $randomdecl || exit 77
-
-proc() {
-       sed -f "$srcdir/tests/randomdecl-sanity.sed" \
-               || { echo "result=fail"; return 1; }
-}
-
-printf '%s: randomized test using RANDOMSEED=%d\n' "$0" "$RANDOMSEED"
-
-result=pass
-eval_cmd=`exec 3>&1
-       { $randomdecl -E -s "$RANDOMSEED" 3>&-
-               echo gen_status=$? >&3
-       } | proc >&3`
-eval "$eval_cmd"
-
-eval_cmd=`sed -ne 's/^\(.*\)=yes #\(.*\)$/\
-       test x"$\1" = x"yes" || { echo no \2; result=fail; }/p' \
-       tests/randomdecl-sanity.sed`
-eval "$eval_cmd"
-
-if test x"$result" != x"pass"; then
-       printf '%s: test failed\n' "$0"
-       exit 1
-fi
diff --git a/tests/stress.at b/tests/stress.at
new file mode 100644 (file)
index 0000000..9b45cea
--- /dev/null
@@ -0,0 +1,81 @@
+# Copyright © 2012, 2020 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+AT_BANNER([Randomized tests])
+
+dnl Verify that randomdecl actually produces all keywords and a variety
+dnl of different declarations.
+AT_SETUP([randomdecl sanity])
+
+TEST_NEED_PROGRAM([randomdecl])
+
+m4_define([sanity_tests], [dnl
+  [[^declare], [declaration of an identifier]],
+  [[^type], [type name]],
+  [[inline], [inline function specifier]],
+  [[inline inline], [redundant function specifiers]],
+  [[function (@<:@@<:@:alnum:@:>@_@:>@* as], [named function parameter]],
+  [[function (void)], [empty prototype declaration]],
+  [[function returning], [non-prototype function declaration]],
+  [[\.\.\.], [variadic function]],
+  [[const], [const qualifier]],
+  [[volatile], [volatile qualifier]],
+  [[restrict], [restrict qualifier]],
+  [[const const], [redundant type qualifiers]],
+  [[variable-length array], [variable-length array]],
+  [[static], [static storage-class specifier]],
+  [[extern], [extern storage-class specifier]],
+  [[typedef], [typedef storage-class specifier]],
+  [[auto], [auto storage-class specifier]],
+  [[register], [register storage-class specifier]],
+  [[void], [void type specifier]],
+  [[char], [char type specifier]],
+  [[short], [short type specifier]],
+  [[int], [int type specifier]],
+  [[long], [long type specifier]],
+  [[float], [float type specifier]],
+  [[double], [double type specifier]],
+  [[signed], [signed type specifier]],
+  [[unsigned], [unsigned type specifier]],
+  [[_Bool], [_Bool type specifier]],
+  [[_Complex], [_Complex type specifier]],
+  [[_Imaginary], [_Imaginary type specifier]],
+  [[union], [union type specifier]],
+  [[enum], [enum type specifier]],
+  [[pointer to array], [pointer to an array]],
+  [[pointer to function], [pointer to a function]],
+])
+
+m4_define([sanity_sed], [/$1/i\
+AS_TR_SH([$2])=:])
+AT_DATA([sanity.sed], [#n
+m4_map_sep([sanity_sed], [m4_newline], [sanity_tests])
+])
+
+printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
+AT_CHECK([randomdecl -En 10000 -s "$random_seed" >decls], [0], [ignore-nolog])
+AT_CHECK([sed -f sanity.sed decls], [0], [stdout-nolog])
+sort -u stdout >decls.chk
+
+exec 3<decls.chk
+while read var <&3; do
+  eval "$var"
+done
+exec 3<&-
+
+m4_define([sanity_check], [AT_CHECK([$AS_TR_SH([$2]) false])])
+m4_map([sanity_check], [sanity_tests])
+
+AT_CLEANUP
index dc1678319484636689074175b3b7146ebd9eccb3..930ff2ceaf4102d11b72d3deaf36b4a63cdbf0a8 100644 (file)
@@ -18,10 +18,24 @@ AT_COLOR_TESTS
 
 AT_TESTED([cdecl99])
 
+AT_ARG_OPTION_ARG([random-seed],
+  [AS_HELP_STRING([--random-seed=ARG],
+    [Integer seed for randomized testing (default: auto)])],
+  [random_seed=$at_optarg], [random_seed=$RANDOM$$])
+
 m4_divert_push([PREPARE_TESTS])dnl
 : ${LIBTOOL="$SHELL $builddir/libtool"}
+random_seed=`printf '%s' "$random_seed" | tr -cd '@<:@:digit:@:>@'`
+random_seed=${random_seed:-0}
 m4_divert_pop([PREPARE_TESTS])
 
+m4_define([TEST_NEED_PROGRAM], [AT_KEYWORDS([$1])dnl
+AT_CHECK([for arg in $check_PROGRAMS; do
+test x"${arg##*/}" != x"$1$EXEEXT" || exit 0
+done
+exit 77])])
+
 m4_include([tests/general.at])
 m4_include([tests/decl-good.at])
 m4_include([tests/decl-bad.at])
+m4_include([tests/stress.at])