1 # Copyright © 2012, 2020 Nick Bowler
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 AT_BANNER([Randomized tests])
18 dnl Verify that randomdecl actually produces all keywords and a variety
19 dnl of different declarations.
20 AT_SETUP([randomdecl sanity])
22 TEST_NEED_PROGRAM([randomdecl])
24 m4_define([sanity_tests], [dnl
25 [[^declare], [declaration of an identifier]],
26 [[^type], [type name]],
27 [[inline], [inline function specifier]],
28 [[inline inline], [redundant function specifiers]],
29 [[function (@<:@@<:@:alnum:@:>@_@:>@* as], [named function parameter]],
30 [[function (void)], [empty prototype declaration]],
31 [[function returning], [non-prototype function declaration]],
32 [[\.\.\.], [variadic function]],
33 [[const], [const qualifier]],
34 [[volatile], [volatile qualifier]],
35 [[restrict], [restrict qualifier]],
36 [[const const], [redundant type qualifiers]],
37 [[variable-length array], [variable-length array]],
38 [[static], [static storage-class specifier]],
39 [[extern], [extern storage-class specifier]],
40 [[typedef], [typedef storage-class specifier]],
41 [[auto], [auto storage-class specifier]],
42 [[register], [register storage-class specifier]],
43 [[void], [void type specifier]],
44 [[char], [char type specifier]],
45 [[short], [short type specifier]],
46 [[int], [int type specifier]],
47 [[long], [long type specifier]],
48 [[float], [float type specifier]],
49 [[double], [double type specifier]],
50 [[signed], [signed type specifier]],
51 [[unsigned], [unsigned type specifier]],
52 [[_Bool], [_Bool type specifier]],
53 [[_Complex], [_Complex type specifier]],
54 [[_Imaginary], [_Imaginary type specifier]],
55 [[union], [union type specifier]],
56 [[enum], [enum type specifier]],
57 [[pointer to array], [pointer to an array]],
58 [[pointer to function], [pointer to a function]],
61 m4_define([sanity_sed], [/$1/i\
63 AT_DATA([sanity.sed], [#n
64 m4_map_sep([sanity_sed], [m4_newline], [sanity_tests])
67 printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
68 AT_CHECK([randomdecl -En 10000 -s "$random_seed" >decls], [0], [ignore-nolog])
69 AT_CHECK([sed -f sanity.sed decls], [0], [stdout-nolog])
70 sort -u stdout >decls.chk
73 while read var <&3; do
78 m4_define([sanity_check], [AT_CHECK([$AS_TR_SH([$2]) false])])
79 m4_map([sanity_check], [sanity_tests])
83 AT_SETUP([random cross-parse])
85 TEST_NEED_PROGRAM([randomdecl])
86 TEST_NEED_PROGRAM([crossparse])
88 printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
89 AT_CHECK([randomdecl -n "$random_iter" -s "$random_seed"],, [stdout-nolog])
90 AT_CHECK([crossparse -f stdout])