]> git.draconx.ca Git - cdecl99.git/blob - tests/stress.at
Port random crossparse test to Autotest.
[cdecl99.git] / tests / stress.at
1 # Copyright © 2012, 2020 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 that randomdecl actually produces all keywords and a variety
19 dnl of different declarations.
20 AT_SETUP([randomdecl sanity])
21
22 TEST_NEED_PROGRAM([randomdecl])
23
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]],
59 ])
60
61 m4_define([sanity_sed], [/$1/i\
62 AS_TR_SH([$2])=:])
63 AT_DATA([sanity.sed], [#n
64 m4_map_sep([sanity_sed], [m4_newline], [sanity_tests])
65 ])
66
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
71
72 exec 3<decls.chk
73 while read var <&3; do
74   eval "$var"
75 done
76 exec 3<&-
77
78 m4_define([sanity_check], [AT_CHECK([$AS_TR_SH([$2]) false])])
79 m4_map([sanity_check], [sanity_tests])
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