]> git.draconx.ca Git - cdecl99.git/blob - tests/stress.at
Release 1.3.
[cdecl99.git] / tests / stress.at
1 # Copyright © 2012, 2020, 2022-2024 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([Stress 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_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.
69 BEGIN { FS = "@"; }
70 m4_map([sanity_awk], [sanity_tests])dnl
71 END { for (k in found) print "FOUND", k; }
72 ])
73
74 m4_define([sanity_exp], [[FOUND $2
75 ]])
76 LC_ALL=C sort >expout <<'EOF'
77 m4_map([sanity_exp], [sanity_tests])dnl
78 EOF
79
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])
83
84 AT_CLEANUP
85
86 AT_SETUP([Random crossparse])
87
88 TEST_NEED_PROGRAM([randomdecl])
89 TEST_NEED_PROGRAM([crossparse])
90
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])
94 AT_CLEANUP
95
96 # Check that we can parse declarations with more than 10000 specifiers.
97 AT_SETUP([Excessive specifiers])
98
99 AT_CHECK([gunzip -c "$srcdir/tests/data/manyspec.gz" >test.dat || exit 77
100 cdecl99 -f test.dat], [0],
101 [[type const int
102 type const int
103 const int
104 const int
105 inline int f()
106 ]])
107
108 AT_CLEANUP
109
110 # Check that we can parse declarations with more than 10000 declarators.
111 AT_SETUP([Excessive declarators])
112
113 AT_DATA([check.awk],
114 [[# We don't need any field splitting, so choose a character that does not
115 # appear in C code to avoid tripping over 199-field limit in HP-UX 11 awk.
116 BEGIN { FS = "@"; runstart = 0; }
117 END { finish_run(NR); }
118
119 $0 != lastline {
120   finish_run(NR-1);
121   lastline = $0;
122   runstart = NR;
123   print;
124 }
125
126 function finish_run(nr) {
127   count = nr - runstart;
128   if (count > 0)
129     print "[repeated " count " more times]";
130 }
131 ]])
132
133 AT_CHECK([gunzip -c "$srcdir/tests/data/manydecl.gz" >test.dat || exit 77
134 cdecl99 -f test.dat >test.out; status=$?;
135 tr <test.out ',' '
136 ' | $AWK -f check.awk
137 exit $status], [0],
138 [[declare a as int
139 [repeated 16383 more times]
140 type function (a
141  a
142 [repeated 16381 more times]
143  a) returning int
144 int (a
145  a
146 [repeated 16381 more times]
147  a)
148 ]])
149
150 AT_CLEANUP