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