From: Nick Bowler Date: Thu, 2 Jul 2020 22:58:03 +0000 (-0400) Subject: Port randomdecl sanity test to Autotest. X-Git-Tag: v1~20 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/0be9665d13739d12085ef2f5c2d4a47215d7612d Port randomdecl sanity test to Autotest. --- diff --git a/.gitignore b/.gitignore index 911090e..735368e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /ABOUT-NLS /aclocal.m4 /atconfig +/atlocal /autom4te.cache /cdecl99 /compile diff --git a/Makefile.am b/Makefile.am index a9379db..8ccdc95 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index eed1a19..fa00e02 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index ad5bfa0..0000000 --- a/tests/randomdecl-sanity.sed +++ /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 index fad6d5a..0000000 --- a/tests/randomdecl-sanity.sh +++ /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 index 0000000..9b45cea --- /dev/null +++ b/tests/stress.at @@ -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 . + +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@'` +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])