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