]> git.draconx.ca Git - cdecl99.git/commitdiff
Add a sanity test for randomdecl.
authorNick Bowler <nbowler@draconx.ca>
Sun, 18 Mar 2012 22:10:36 +0000 (18:10 -0400)
committerNick Bowler <nbowler@draconx.ca>
Mon, 19 Mar 2012 01:42:26 +0000 (21:42 -0400)
Makefile.am
tests/randomdecl-sanity.sed [new file with mode: 0644]
tests/randomdecl-sanity.sh [new file with mode: 0755]

index e3b45d2fb12b84ee21058cc111e9e3e6863957e0..296a2224696fb540649d2997109047f405825315 100644 (file)
@@ -74,7 +74,8 @@ TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)'
 TEST_EXTENSIONS = .sh
 SH_LOG_COMPILER = $(SHELL)
 
-TESTS = tests/libcdecl-static-symbols.sh tests/crossparse-c-random.sh
+TESTS = tests/libcdecl-static-symbols.sh tests/randomdecl-sanity.sh \
+       tests/crossparse-c-random.sh
 EXTRA_DIST += $(TESTS)
 
 src/parse.lo: src/scan.h
diff --git a/tests/randomdecl-sanity.sed b/tests/randomdecl-sanity.sed
new file mode 100644 (file)
index 0000000..ad5bfa0
--- /dev/null
@@ -0,0 +1,82 @@
+#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
new file mode 100755 (executable)
index 0000000..52b5534
--- /dev/null
@@ -0,0 +1,36 @@
+#!/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 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