1 # Copyright © 2012, 2020, 2022-2023 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 the RNG implementation
19 AT_SETUP([xoshiro256p sanity])
21 TEST_NEED_PROGRAM([rng-test])
22 AT_CHECK([rng-test >out
23 grep -v '^ok' out], [0], [1..200
28 dnl Verify that randomdecl actually produces all keywords and a variety
29 dnl of different declarations.
30 AT_SETUP([randomdecl sanity])
32 TEST_NEED_PROGRAM([randomdecl])
34 m4_define([sanity_tests], [dnl
35 [[^declare], [declaration of an identifier]],
36 [[^type], [type name]],
37 [[inline], [inline function specifier]],
38 [[inline inline], [redundant function specifiers]],
39 [[function (@<:@RE_ALNUM()_@:>@* as], [named function parameter]],
40 [[function (void)], [empty prototype declaration]],
41 [[function returning], [non-prototype function declaration]],
42 [[\.\.\.], [variadic function]],
43 [[const], [const qualifier]],
44 [[volatile], [volatile qualifier]],
45 [[restrict], [restrict qualifier]],
46 [[const const], [redundant type qualifiers]],
47 [[variable-length array], [variable-length array]],
48 [[static], [static storage-class specifier]],
49 [[extern], [extern storage-class specifier]],
50 [[typedef], [typedef storage-class specifier]],
51 [[auto], [auto storage-class specifier]],
52 [[register], [register storage-class specifier]],
53 [[void], [void type specifier]],
54 [[char], [char type specifier]],
55 [[short], [short type specifier]],
56 [[int], [int type specifier]],
57 [[long], [long type specifier]],
58 [[float], [float type specifier]],
59 [[double], [double type specifier]],
60 [[signed], [signed type specifier]],
61 [[unsigned], [unsigned type specifier]],
62 [[_Bool], [_Bool type specifier]],
63 [[_Complex], [_Complex type specifier]],
64 [[_Imaginary], [_Imaginary type specifier]],
65 [[union], [union type specifier]],
66 [[enum], [enum type specifier]],
67 [[pointer to array], [pointer to an array]],
68 [[pointer to function], [pointer to a function]],
71 m4_define([sanity_sed], [/$1/i\
72 FOUND $2])AT_DATA([sanity.sed], [#n
73 m4_map_sep([sanity_sed], [m4_newline], [sanity_tests])
75 sed -n '/^FOUND/p' sanity.sed | LC_ALL=C sort -u >expout
77 printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
78 AT_CHECK([randomdecl -En 10000 -s "$random_seed" >decls], [0])
79 AT_CHECK([sed -f sanity.sed decls | LC_ALL=C sort -u], [0], [expout])
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])