]> git.draconx.ca Git - cdecl99.git/blob - tests/stress.at
Avoid POSIX character classes in the test suite.
[cdecl99.git] / tests / stress.at
1 # Copyright © 2012, 2020, 2022-2023 Nick Bowler
2 #
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.
7 #
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.
12 #
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/>.
15
16 AT_BANNER([Randomized tests])
17
18 dnl Verify the RNG implementation
19 AT_SETUP([xoshiro256p sanity])
20
21 TEST_NEED_PROGRAM([rng-test])
22 AT_CHECK([rng-test >out
23 grep -v '^ok' out], [0], [1..200
24 ])
25
26 AT_CLEANUP
27
28 dnl Verify that randomdecl actually produces all keywords and a variety
29 dnl of different declarations.
30 AT_SETUP([randomdecl sanity])
31
32 TEST_NEED_PROGRAM([randomdecl])
33
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]],
69 ])
70
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])
74 ])
75 sed -n '/^FOUND/p' sanity.sed | LC_ALL=C sort -u >expout
76
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])
80
81 AT_CLEANUP
82
83 AT_SETUP([random cross-parse])
84
85 TEST_NEED_PROGRAM([randomdecl])
86 TEST_NEED_PROGRAM([crossparse])
87
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])
91 AT_CLEANUP