]> git.draconx.ca Git - cdecl99.git/blob - tests/stress.at
tests: Better output filter in randomdecl sanity test.
[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_awk], [[/$1/ { found["$2"] = 1; }
66 ]])AT_DATA([sanity.awk],
67 [m4_map([sanity_awk], [sanity_tests])dnl
68 END { for (k in found) print "FOUND", k; }
69 ])
70
71 m4_define([sanity_exp], [[FOUND $2
72 ]])
73 LC_ALL=C sort >expout <<'EOF'
74 m4_map([sanity_exp], [sanity_tests])dnl
75 EOF
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([$AWK -f sanity.awk decls | LC_ALL=C sort], [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