Debian Codegraph @

tests/all.at

raw
1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
2 # Copyright (C) 2005-2025 Sergey Poznyakoff
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_BANNER([all-functions mode])
18
19 # Default case: in the absense of main, --all is assumed
20 CFLOW_TEST([default],
21 [all all-default all00],
22 [int
23 foo(void)
24 {
25 baz();
26 }
27 int
28 bar(void)
29 {
30 qux();
31 }
32 void
33 qux(void)
34 {
35 boom();
36 }
37 ],
38 [bar() <int bar (void) at prog:7>:
39 qux() <void qux (void) at prog:12>:
40 boom()
41 foo() <int foo (void) at prog:2>:
42 baz()
43 ])
44
45 # Default case: if main is present, only functions directly reachable from it
46 # are displayed.
47 CFLOW_TEST([default (main present)],
48 [all all-default-main all01],
49 [int
50 foo(void)
51 {
52 baz();
53 }
54 int
55 bar(void)
56 {
57 qux();
58 }
59 void
60 qux(void)
61 {
62 boom();
63 }
64 int
65 main(void)
66 {
67 zuuq();
68 }
69 ],
70 [main() <int main (void) at prog:17>:
71 zuuq()
72 ])
73
74 # If --main is supplied, only this function and calls reachable from it are
75 # output.
76 CFLOW_OPT([--main=foo],[
77 CFLOW_TEST([the --main option],
78 [all all--main all02],
79 [int
80 foo(void)
81 {
82 baz();
83 }
84 int
85 bar(void)
86 {
87 qux();
88 }
89 void
90 qux(void)
91 {
92 boom();
93 }
94 ],
95 [foo() <int foo (void) at prog:2>:
96 baz()
97 ])
98 ])
99
100 # Single --all option: print all top-level functions and functions reachable
101 # from them.
102 CFLOW_OPT([--all],[
103 CFLOW_TEST([the --all option],
104 [all all--all all03],
105 [int
106 foo(void)
107 {
108 baz();
109 }
110 int
111 bar(void)
112 {
113 qux();
114 }
115 void
116 qux(void)
117 {
118 boom();
119 }
120 ],
121 [bar() <int bar (void) at prog:7>:
122 qux() <void qux (void) at prog:12>:
123 boom()
124 foo() <int foo (void) at prog:2>:
125 baz()
126 ])
127 ])
128
129 # Double --all options print all global functions, no matter whether reachable
130 # from others.
131 CFLOW_OPT([--all --all],[
132 CFLOW_TEST([the --all --all option],
133 [all all--all--all all04],
134 [int
135 foo(void)
136 {
137 baz();
138 }
139 int
140 bar(void)
141 {
142 qux();
143 }
144 void
145 qux(void)
146 {
147 boom();
148 }
149 ],
150 [bar() <int bar (void) at prog:7>:
151 qux() <void qux (void) at prog:12>:
152 boom()
153 foo() <int foo (void) at prog:2>:
154 baz()
155 qux() <void qux (void) at prog:12>:
156 boom()
157 ])
158 ])
159
160 # The --all option applied to a source with main function: main graph is placed
161 # on top.
162 CFLOW_OPT([--all],[
163 CFLOW_TEST([the --all option with main],
164 [all all--all-main all05],
165 [int
166 foo(void)
167 {
168 baz();
169 }
170 int
171 bar(void)
172 {
173 qux();
174 }
175 void
176 qux(void)
177 {
178 boom();
179 }
180 int
181 main(void)
182 {
183 zuuq();
184 }
185 ],
186 [main() <int main (void) at prog:17>:
187 zuuq()
188 bar() <int bar (void) at prog:7>:
189 qux() <void qux (void) at prog:12>:
190 boom()
191 foo() <int foo (void) at prog:2>:
192 baz()
193 ])
194 ])
195
196 # Double --all option applied to a source with main function: main graph is
197 # placed on top, followed by graphs for all global functions.
198 CFLOW_OPT([--all --all],[
199 CFLOW_TEST([the --all --all option with main],
200 [all all--all--all-main all06],
201 [int
202 foo(void)
203 {
204 baz();
205 }
206 int
207 bar(void)
208 {
209 qux();
210 }
211 void
212 qux(void)
213 {
214 boom();
215 }
216 int
217 main(void)
218 {
219 zuuq();
220 }
221 ],
222 [main() <int main (void) at prog:17>:
223 zuuq()
224 bar() <int bar (void) at prog:7>:
225 qux() <void qux (void) at prog:12>:
226 boom()
227 foo() <int foo (void) at prog:2>:
228 baz()
229 qux() <void qux (void) at prog:12>:
230 boom()
231 ])
232 ])
233
234 # The --no-main option is similar to --all, if the function main() is not
235 # defined.
236 CFLOW_OPT([--no-main],[
237 CFLOW_TEST([the --no-main option],
238 [all all--no-main all07],
239 [int
240 foo(void)
241 {
242 baz();
243 }
244 int
245 bar(void)
246 {
247 qux();
248 }
249 void
250 qux(void)
251 {
252 boom();
253 }
254 ],
255 [bar() <int bar (void) at prog:7>:
256 qux() <void qux (void) at prog:12>:
257 boom()
258 foo() <int foo (void) at prog:2>:
259 baz()
260 ])
261 ])
262
263 # If main() is defined, --no-main has the same effect as --all, except that
264 # the graph for main() is placed according to the global lexicographic
265 # ordering.
266 CFLOW_OPT([--no-main],[
267 CFLOW_TEST([the --no-main option with main],
268 [all all--no-main-main all08],
269 [int
270 foo(void)
271 {
272 baz();
273 }
274 int
275 bar(void)
276 {
277 qux();
278 }
279 void
280 qux(void)
281 {
282 boom();
283 }
284 int
285 main(void)
286 {
287 zuuq();
288 }
289 ],
290 [bar() <int bar (void) at prog:7>:
291 qux() <void qux (void) at prog:12>:
292 boom()
293 foo() <int foo (void) at prog:2>:
294 baz()
295 main() <int main (void) at prog:17>:
296 zuuq()
297 ])
298 ])
299
300