1 # Copyright © 2012, 2020, 2022-2024 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 TEST_TAP_SIMPLE([xoshiro256p sanity], [rng-test],
20 [TEST_NEED_PROGRAM([rng-test])])
22 dnl Verify that randomdecl actually produces all keywords and a variety
23 dnl of different declarations.
24 AT_SETUP([randomdecl sanity])
26 TEST_NEED_PROGRAM([randomdecl])
28 m4_define([sanity_tests], [dnl
29 [[^declare], [declaration of an identifier]],
30 [[^type], [type name]],
31 [[inline], [inline function specifier]],
32 [[inline inline], [redundant function specifiers]],
33 [[function [(]@<:@]]RE_ALNUM()_[[@:>@* as], [named function parameter]],
34 [[function [(]void[)]], [empty prototype declaration]],
35 [[function returning], [non-prototype function declaration]],
36 [[\.\.\.], [variadic function]],
37 [[const], [const qualifier]],
38 [[volatile], [volatile qualifier]],
39 [[restrict], [restrict qualifier]],
40 [[const const], [redundant type qualifiers]],
41 [[variable-length array], [variable-length array]],
42 [[static], [static storage-class specifier]],
43 [[extern], [extern storage-class specifier]],
44 [[typedef], [typedef storage-class specifier]],
45 [[auto], [auto storage-class specifier]],
46 [[register], [register storage-class specifier]],
47 [[void], [void type specifier]],
48 [[char], [char type specifier]],
49 [[short], [short type specifier]],
50 [[int], [int type specifier]],
51 [[long], [long type specifier]],
52 [[float], [float type specifier]],
53 [[double], [double type specifier]],
54 [[signed], [signed type specifier]],
55 [[unsigned], [unsigned type specifier]],
56 [[_Bool], [_Bool type specifier]],
57 [[_Complex], [_Complex type specifier]],
58 [[_Imaginary], [_Imaginary type specifier]],
59 [[union], [union type specifier]],
60 [[enum], [enum type specifier]],
61 [[pointer to array], [pointer to an array]],
62 [[pointer to function], [pointer to a function]],
65 m4_define([sanity_awk], [[/$1/ { found["$2"] = 1; }
66 ]])AT_DATA([sanity.awk],
67 [# We don't need any field splitting, so choose a character that does not
68 # appear in C code to avoid tripping over 199-field limit in HP-UX 11 awk.
70 m4_map([sanity_awk], [sanity_tests])dnl
71 END { for (k in found) print "FOUND", k; }
74 m4_define([sanity_exp], [[FOUND $2
76 LC_ALL=C sort >expout <<'EOF'
77 m4_map([sanity_exp], [sanity_tests])dnl
80 AS_ECHO(["Using seed $random_seed"]) >&AS_MESSAGE_LOG_FD
81 AT_CHECK([randomdecl -En 10000 -s "$random_seed" >decls], [0])
82 AT_CHECK([$AWK -f sanity.awk decls | LC_ALL=C sort], [0], [expout])
86 AT_SETUP([random cross-parse])
88 TEST_NEED_PROGRAM([randomdecl])
89 TEST_NEED_PROGRAM([crossparse])
91 AS_ECHO(["Using seed $random_seed"]) >&AS_MESSAGE_LOG_FD
92 AT_CHECK([randomdecl -n "$random_iter" -s "$random_seed"],, [stdout-nolog])
93 AT_CHECK([crossparse -f stdout])