1/*
2 * Automated Testing Framework (atf)
3 *
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#if defined(TESTS_ATF_ATF_C_H_BUILD_H)
31#   error "Cannot include h_build.h more than once."
32#else
33#   define TESTS_ATF_ATF_C_H_BUILD_H
34#endif
35
36/* ---------------------------------------------------------------------
37 * Test case data.
38 * --------------------------------------------------------------------- */
39
40static struct c_o_test {
41    const char *msg;
42    const char *cc;
43    const char *cflags;
44    const char *cppflags;
45    const char *sfile;
46    const char *ofile;
47    bool hasoptargs;
48    const char *const optargs[16];
49    const char *const expargv[16];
50} c_o_tests[] = {
51    {
52        "No flags",
53        "cc",
54        "",
55        "",
56        "test.c",
57        "test.o",
58        false,
59        {
60            NULL
61        },
62        {
63            "cc", "-o", "test.o", "-c", "test.c", NULL
64        },
65    },
66
67    {
68        "Multi-word program name",
69        "cc -foo",
70        "",
71        "",
72        "test.c",
73        "test.o",
74        false,
75        {
76            NULL
77        },
78        {
79            "cc", "-foo", "-o", "test.o", "-c", "test.c", NULL
80        },
81    },
82
83    {
84        "Some cflags",
85        "cc",
86        "-f1 -f2    -f3 -f4-f5",
87        "",
88        "test.c",
89        "test.o",
90        false,
91        {
92            NULL
93        },
94        {
95            "cc", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o",
96            "-c", "test.c", NULL
97        },
98    },
99
100    {
101        "Some cppflags",
102        "cc",
103        "",
104        "-f1 -f2    -f3 -f4-f5",
105        "test.c",
106        "test.o",
107        false,
108        {
109            NULL
110        },
111        {
112            "cc", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o",
113            "-c", "test.c", NULL
114        },
115    },
116
117    {
118        "Some cflags and cppflags",
119        "cc",
120        "-f2",
121        "-f1",
122        "test.c",
123        "test.o",
124        false,
125        {
126            NULL
127        },
128        {
129            "cc", "-f1", "-f2", "-o", "test.o", "-c", "test.c", NULL
130        },
131    },
132
133    {
134        "Some optional arguments",
135        "cc",
136        "",
137        "",
138        "test.c",
139        "test.o",
140        true,
141        {
142            "-o1", "-o2", NULL
143        },
144        {
145            "cc", "-o1", "-o2", "-o", "test.o", "-c", "test.c", NULL
146        },
147    },
148
149    {
150        "Some cflags, cppflags and optional arguments",
151        "cc",
152        "-f2",
153        "-f1",
154        "test.c",
155        "test.o",
156        true,
157        {
158            "-o1", "-o2", NULL
159        },
160        {
161            "cc", "-f1", "-f2", "-o1", "-o2", "-o", "test.o",
162            "-c", "test.c", NULL
163        },
164    },
165
166    {
167        NULL,
168        NULL,
169        NULL,
170        NULL,
171        NULL,
172        NULL,
173        false,
174        { NULL },
175        { NULL },
176    },
177};
178
179static struct cpp_test {
180    const char *msg;
181    const char *cpp;
182    const char *cppflags;
183    const char *sfile;
184    const char *ofile;
185    bool hasoptargs;
186    const char *const optargs[16];
187    const char *const expargv[16];
188} cpp_tests[] = {
189    {
190        "No flags",
191        "cpp",
192        "",
193        "test.c",
194        "test.out",
195        false,
196        {
197            NULL
198        },
199        {
200            "cpp", "-o", "test.out", "test.c", NULL
201        },
202    },
203
204    {
205        "Multi-word program name",
206        "cpp -foo",
207        "",
208        "test.c",
209        "test.out",
210        false,
211        {
212            NULL
213        },
214        {
215            "cpp", "-foo", "-o", "test.out", "test.c", NULL
216        },
217    },
218
219    {
220        "Some cppflags",
221        "cpp",
222        "-f1 -f2    -f3 -f4-f5",
223        "test.c",
224        "test.out",
225        false,
226        {
227            NULL
228        },
229        {
230            "cpp", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.out",
231            "test.c", NULL
232        },
233    },
234
235    {
236        "Some optional arguments",
237        "cpp",
238        "",
239        "test.c",
240        "test.out",
241        true,
242        {
243            "-o1", "-o2", NULL
244        },
245        {
246            "cpp", "-o1", "-o2", "-o", "test.out", "test.c", NULL
247        },
248    },
249
250    {
251        "Some cppflags and optional arguments",
252        "cpp",
253        "-f1",
254        "test.c",
255        "test.out",
256        true,
257        {
258            "-o1", "-o2", NULL
259        },
260        {
261            "cpp", "-f1", "-o1", "-o2", "-o", "test.out", "test.c", NULL
262        },
263    },
264
265    {
266        NULL,
267        NULL,
268        NULL,
269        NULL,
270        NULL,
271        false,
272        { NULL },
273        { NULL },
274    },
275};
276
277static struct cxx_o_test {
278    const char *msg;
279    const char *cxx;
280    const char *cxxflags;
281    const char *cppflags;
282    const char *sfile;
283    const char *ofile;
284    bool hasoptargs;
285    const char *const optargs[16];
286    const char *const expargv[16];
287} cxx_o_tests[] = {
288    {
289        "No flags",
290        "c++",
291        "",
292        "",
293        "test.c",
294        "test.o",
295        false,
296        {
297            NULL
298        },
299        {
300            "c++", "-o", "test.o", "-c", "test.c", NULL
301        },
302    },
303
304    {
305        "Multi-word program name",
306        "c++ -foo",
307        "",
308        "",
309        "test.c",
310        "test.o",
311        false,
312        {
313            NULL
314        },
315        {
316            "c++", "-foo", "-o", "test.o", "-c", "test.c", NULL
317        },
318    },
319
320    {
321        "Some cxxflags",
322        "c++",
323        "-f1 -f2    -f3 -f4-f5",
324        "",
325        "test.c",
326        "test.o",
327        false,
328        {
329            NULL
330        },
331        {
332            "c++", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o",
333            "-c", "test.c", NULL
334        },
335    },
336
337    {
338        "Some cppflags",
339        "c++",
340        "",
341        "-f1 -f2    -f3 -f4-f5",
342        "test.c",
343        "test.o",
344        false,
345        {
346            NULL
347        },
348        {
349            "c++", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o",
350            "-c", "test.c", NULL
351        },
352    },
353
354    {
355        "Some cxxflags and cppflags",
356        "c++",
357        "-f2",
358        "-f1",
359        "test.c",
360        "test.o",
361        false,
362        {
363            NULL
364        },
365        {
366            "c++", "-f1", "-f2", "-o", "test.o", "-c", "test.c", NULL
367        },
368    },
369
370    {
371        "Some optional arguments",
372        "c++",
373        "",
374        "",
375        "test.c",
376        "test.o",
377        true,
378        {
379            "-o1", "-o2", NULL
380        },
381        {
382            "c++", "-o1", "-o2", "-o", "test.o", "-c", "test.c", NULL
383        },
384    },
385
386    {
387        "Some cxxflags, cppflags and optional arguments",
388        "c++",
389        "-f2",
390        "-f1",
391        "test.c",
392        "test.o",
393        true,
394        {
395            "-o1", "-o2", NULL
396        },
397        {
398            "c++", "-f1", "-f2", "-o1", "-o2", "-o", "test.o",
399            "-c", "test.c", NULL
400        },
401    },
402
403    {
404        NULL,
405        NULL,
406        NULL,
407        NULL,
408        NULL,
409        NULL,
410        false,
411        { NULL },
412        { NULL },
413    },
414};
415