]> git.draconx.ca Git - cdecl99.git/blob - tests/stress.at
b71836950db3d98de82f85b0140e2f489bf4cd20
[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 TEST_TAP_SIMPLE([xoshiro256p sanity], [rng-test],
20   [TEST_NEED_PROGRAM([rng-test])])
21
22 dnl Verify that randomdecl actually produces all keywords and a variety
23 dnl of different declarations.
24 AT_SETUP([randomdecl sanity])
25
26 TEST_NEED_PROGRAM([randomdecl])
27
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]],
63 ])
64
65 m4_define([sanity_sed], [/$1/i\
66 FOUND $2])AT_DATA([sanity.sed], [#n
67 m4_map_sep([sanity_sed], [m4_newline], [sanity_tests])
68 ])
69 sed -n '/^FOUND/p' sanity.sed | LC_ALL=C sort -u >expout
70
71 printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
72 AT_CHECK([randomdecl -En 10000 -s "$random_seed" >decls], [0])
73 AT_CHECK([sed -f sanity.sed decls | LC_ALL=C sort -u], [0], [expout])
74
75 AT_CLEANUP
76
77 AT_SETUP([random cross-parse])
78
79 TEST_NEED_PROGRAM([randomdecl])
80 TEST_NEED_PROGRAM([crossparse])
81
82 printf 'Using seed %d\n' "$random_seed" >&AS_MESSAGE_LOG_FD
83 AT_CHECK([randomdecl -n "$random_iter" -s "$random_seed"],, [stdout-nolog])
84 AT_CHECK([crossparse -f stdout])
85 AT_CLEANUP