1275988Sngie/* Copyright (c) 2009 The NetBSD Foundation, Inc. 2240116Smarcel * All rights reserved. 3240116Smarcel * 4240116Smarcel * Redistribution and use in source and binary forms, with or without 5240116Smarcel * modification, are permitted provided that the following conditions 6240116Smarcel * are met: 7240116Smarcel * 1. Redistributions of source code must retain the above copyright 8240116Smarcel * notice, this list of conditions and the following disclaimer. 9240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright 10240116Smarcel * notice, this list of conditions and the following disclaimer in the 11240116Smarcel * documentation and/or other materials provided with the distribution. 12240116Smarcel * 13240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 14240116Smarcel * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 15240116Smarcel * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16240116Smarcel * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17240116Smarcel * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 18240116Smarcel * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19240116Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20240116Smarcel * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21240116Smarcel * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22240116Smarcel * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23240116Smarcel * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24275988Sngie * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 25240116Smarcel 26275988Sngie#if defined(ATF_C_H_BUILD_H) 27240116Smarcel# error "Cannot include h_build.h more than once." 28240116Smarcel#else 29275988Sngie# define ATF_C_H_BUILD_H 30240116Smarcel#endif 31240116Smarcel 32240116Smarcel/* --------------------------------------------------------------------- 33240116Smarcel * Test case data. 34240116Smarcel * --------------------------------------------------------------------- */ 35240116Smarcel 36240116Smarcelstatic struct c_o_test { 37240116Smarcel const char *msg; 38240116Smarcel const char *cc; 39240116Smarcel const char *cflags; 40240116Smarcel const char *cppflags; 41240116Smarcel const char *sfile; 42240116Smarcel const char *ofile; 43240116Smarcel bool hasoptargs; 44240116Smarcel const char *const optargs[16]; 45240116Smarcel const char *const expargv[16]; 46240116Smarcel} c_o_tests[] = { 47240116Smarcel { 48240116Smarcel "No flags", 49240116Smarcel "cc", 50240116Smarcel "", 51240116Smarcel "", 52240116Smarcel "test.c", 53240116Smarcel "test.o", 54240116Smarcel false, 55240116Smarcel { 56240116Smarcel NULL 57240116Smarcel }, 58240116Smarcel { 59240116Smarcel "cc", "-o", "test.o", "-c", "test.c", NULL 60240116Smarcel }, 61240116Smarcel }, 62240116Smarcel 63240116Smarcel { 64240116Smarcel "Multi-word program name", 65240116Smarcel "cc -foo", 66240116Smarcel "", 67240116Smarcel "", 68240116Smarcel "test.c", 69240116Smarcel "test.o", 70240116Smarcel false, 71240116Smarcel { 72240116Smarcel NULL 73240116Smarcel }, 74240116Smarcel { 75240116Smarcel "cc", "-foo", "-o", "test.o", "-c", "test.c", NULL 76240116Smarcel }, 77240116Smarcel }, 78240116Smarcel 79240116Smarcel { 80240116Smarcel "Some cflags", 81240116Smarcel "cc", 82240116Smarcel "-f1 -f2 -f3 -f4-f5", 83240116Smarcel "", 84240116Smarcel "test.c", 85240116Smarcel "test.o", 86240116Smarcel false, 87240116Smarcel { 88240116Smarcel NULL 89240116Smarcel }, 90240116Smarcel { 91240116Smarcel "cc", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o", 92240116Smarcel "-c", "test.c", NULL 93240116Smarcel }, 94240116Smarcel }, 95240116Smarcel 96240116Smarcel { 97240116Smarcel "Some cppflags", 98240116Smarcel "cc", 99240116Smarcel "", 100240116Smarcel "-f1 -f2 -f3 -f4-f5", 101240116Smarcel "test.c", 102240116Smarcel "test.o", 103240116Smarcel false, 104240116Smarcel { 105240116Smarcel NULL 106240116Smarcel }, 107240116Smarcel { 108240116Smarcel "cc", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o", 109240116Smarcel "-c", "test.c", NULL 110240116Smarcel }, 111240116Smarcel }, 112240116Smarcel 113240116Smarcel { 114240116Smarcel "Some cflags and cppflags", 115240116Smarcel "cc", 116240116Smarcel "-f2", 117240116Smarcel "-f1", 118240116Smarcel "test.c", 119240116Smarcel "test.o", 120240116Smarcel false, 121240116Smarcel { 122240116Smarcel NULL 123240116Smarcel }, 124240116Smarcel { 125240116Smarcel "cc", "-f1", "-f2", "-o", "test.o", "-c", "test.c", NULL 126240116Smarcel }, 127240116Smarcel }, 128240116Smarcel 129240116Smarcel { 130240116Smarcel "Some optional arguments", 131240116Smarcel "cc", 132240116Smarcel "", 133240116Smarcel "", 134240116Smarcel "test.c", 135240116Smarcel "test.o", 136240116Smarcel true, 137240116Smarcel { 138240116Smarcel "-o1", "-o2", NULL 139240116Smarcel }, 140240116Smarcel { 141240116Smarcel "cc", "-o1", "-o2", "-o", "test.o", "-c", "test.c", NULL 142240116Smarcel }, 143240116Smarcel }, 144240116Smarcel 145240116Smarcel { 146240116Smarcel "Some cflags, cppflags and optional arguments", 147240116Smarcel "cc", 148240116Smarcel "-f2", 149240116Smarcel "-f1", 150240116Smarcel "test.c", 151240116Smarcel "test.o", 152240116Smarcel true, 153240116Smarcel { 154240116Smarcel "-o1", "-o2", NULL 155240116Smarcel }, 156240116Smarcel { 157240116Smarcel "cc", "-f1", "-f2", "-o1", "-o2", "-o", "test.o", 158240116Smarcel "-c", "test.c", NULL 159240116Smarcel }, 160240116Smarcel }, 161240116Smarcel 162240116Smarcel { 163240116Smarcel NULL, 164240116Smarcel NULL, 165240116Smarcel NULL, 166240116Smarcel NULL, 167240116Smarcel NULL, 168240116Smarcel NULL, 169240116Smarcel false, 170240116Smarcel { NULL }, 171240116Smarcel { NULL }, 172240116Smarcel }, 173240116Smarcel}; 174240116Smarcel 175240116Smarcelstatic struct cpp_test { 176240116Smarcel const char *msg; 177240116Smarcel const char *cpp; 178240116Smarcel const char *cppflags; 179240116Smarcel const char *sfile; 180240116Smarcel const char *ofile; 181240116Smarcel bool hasoptargs; 182240116Smarcel const char *const optargs[16]; 183240116Smarcel const char *const expargv[16]; 184240116Smarcel} cpp_tests[] = { 185240116Smarcel { 186240116Smarcel "No flags", 187240116Smarcel "cpp", 188240116Smarcel "", 189240116Smarcel "test.c", 190240116Smarcel "test.out", 191240116Smarcel false, 192240116Smarcel { 193240116Smarcel NULL 194240116Smarcel }, 195240116Smarcel { 196240116Smarcel "cpp", "-o", "test.out", "test.c", NULL 197240116Smarcel }, 198240116Smarcel }, 199240116Smarcel 200240116Smarcel { 201240116Smarcel "Multi-word program name", 202240116Smarcel "cpp -foo", 203240116Smarcel "", 204240116Smarcel "test.c", 205240116Smarcel "test.out", 206240116Smarcel false, 207240116Smarcel { 208240116Smarcel NULL 209240116Smarcel }, 210240116Smarcel { 211240116Smarcel "cpp", "-foo", "-o", "test.out", "test.c", NULL 212240116Smarcel }, 213240116Smarcel }, 214240116Smarcel 215240116Smarcel { 216240116Smarcel "Some cppflags", 217240116Smarcel "cpp", 218240116Smarcel "-f1 -f2 -f3 -f4-f5", 219240116Smarcel "test.c", 220240116Smarcel "test.out", 221240116Smarcel false, 222240116Smarcel { 223240116Smarcel NULL 224240116Smarcel }, 225240116Smarcel { 226240116Smarcel "cpp", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.out", 227240116Smarcel "test.c", NULL 228240116Smarcel }, 229240116Smarcel }, 230240116Smarcel 231240116Smarcel { 232240116Smarcel "Some optional arguments", 233240116Smarcel "cpp", 234240116Smarcel "", 235240116Smarcel "test.c", 236240116Smarcel "test.out", 237240116Smarcel true, 238240116Smarcel { 239240116Smarcel "-o1", "-o2", NULL 240240116Smarcel }, 241240116Smarcel { 242240116Smarcel "cpp", "-o1", "-o2", "-o", "test.out", "test.c", NULL 243240116Smarcel }, 244240116Smarcel }, 245240116Smarcel 246240116Smarcel { 247240116Smarcel "Some cppflags and optional arguments", 248240116Smarcel "cpp", 249240116Smarcel "-f1", 250240116Smarcel "test.c", 251240116Smarcel "test.out", 252240116Smarcel true, 253240116Smarcel { 254240116Smarcel "-o1", "-o2", NULL 255240116Smarcel }, 256240116Smarcel { 257240116Smarcel "cpp", "-f1", "-o1", "-o2", "-o", "test.out", "test.c", NULL 258240116Smarcel }, 259240116Smarcel }, 260240116Smarcel 261240116Smarcel { 262240116Smarcel NULL, 263240116Smarcel NULL, 264240116Smarcel NULL, 265240116Smarcel NULL, 266240116Smarcel NULL, 267240116Smarcel false, 268240116Smarcel { NULL }, 269240116Smarcel { NULL }, 270240116Smarcel }, 271240116Smarcel}; 272240116Smarcel 273240116Smarcelstatic struct cxx_o_test { 274240116Smarcel const char *msg; 275240116Smarcel const char *cxx; 276240116Smarcel const char *cxxflags; 277240116Smarcel const char *cppflags; 278240116Smarcel const char *sfile; 279240116Smarcel const char *ofile; 280240116Smarcel bool hasoptargs; 281240116Smarcel const char *const optargs[16]; 282240116Smarcel const char *const expargv[16]; 283240116Smarcel} cxx_o_tests[] = { 284240116Smarcel { 285240116Smarcel "No flags", 286240116Smarcel "c++", 287240116Smarcel "", 288240116Smarcel "", 289240116Smarcel "test.c", 290240116Smarcel "test.o", 291240116Smarcel false, 292240116Smarcel { 293240116Smarcel NULL 294240116Smarcel }, 295240116Smarcel { 296240116Smarcel "c++", "-o", "test.o", "-c", "test.c", NULL 297240116Smarcel }, 298240116Smarcel }, 299240116Smarcel 300240116Smarcel { 301240116Smarcel "Multi-word program name", 302240116Smarcel "c++ -foo", 303240116Smarcel "", 304240116Smarcel "", 305240116Smarcel "test.c", 306240116Smarcel "test.o", 307240116Smarcel false, 308240116Smarcel { 309240116Smarcel NULL 310240116Smarcel }, 311240116Smarcel { 312240116Smarcel "c++", "-foo", "-o", "test.o", "-c", "test.c", NULL 313240116Smarcel }, 314240116Smarcel }, 315240116Smarcel 316240116Smarcel { 317240116Smarcel "Some cxxflags", 318240116Smarcel "c++", 319240116Smarcel "-f1 -f2 -f3 -f4-f5", 320240116Smarcel "", 321240116Smarcel "test.c", 322240116Smarcel "test.o", 323240116Smarcel false, 324240116Smarcel { 325240116Smarcel NULL 326240116Smarcel }, 327240116Smarcel { 328240116Smarcel "c++", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o", 329240116Smarcel "-c", "test.c", NULL 330240116Smarcel }, 331240116Smarcel }, 332240116Smarcel 333240116Smarcel { 334240116Smarcel "Some cppflags", 335240116Smarcel "c++", 336240116Smarcel "", 337240116Smarcel "-f1 -f2 -f3 -f4-f5", 338240116Smarcel "test.c", 339240116Smarcel "test.o", 340240116Smarcel false, 341240116Smarcel { 342240116Smarcel NULL 343240116Smarcel }, 344240116Smarcel { 345240116Smarcel "c++", "-f1", "-f2", "-f3", "-f4-f5", "-o", "test.o", 346240116Smarcel "-c", "test.c", NULL 347240116Smarcel }, 348240116Smarcel }, 349240116Smarcel 350240116Smarcel { 351240116Smarcel "Some cxxflags and cppflags", 352240116Smarcel "c++", 353240116Smarcel "-f2", 354240116Smarcel "-f1", 355240116Smarcel "test.c", 356240116Smarcel "test.o", 357240116Smarcel false, 358240116Smarcel { 359240116Smarcel NULL 360240116Smarcel }, 361240116Smarcel { 362240116Smarcel "c++", "-f1", "-f2", "-o", "test.o", "-c", "test.c", NULL 363240116Smarcel }, 364240116Smarcel }, 365240116Smarcel 366240116Smarcel { 367240116Smarcel "Some optional arguments", 368240116Smarcel "c++", 369240116Smarcel "", 370240116Smarcel "", 371240116Smarcel "test.c", 372240116Smarcel "test.o", 373240116Smarcel true, 374240116Smarcel { 375240116Smarcel "-o1", "-o2", NULL 376240116Smarcel }, 377240116Smarcel { 378240116Smarcel "c++", "-o1", "-o2", "-o", "test.o", "-c", "test.c", NULL 379240116Smarcel }, 380240116Smarcel }, 381240116Smarcel 382240116Smarcel { 383240116Smarcel "Some cxxflags, cppflags and optional arguments", 384240116Smarcel "c++", 385240116Smarcel "-f2", 386240116Smarcel "-f1", 387240116Smarcel "test.c", 388240116Smarcel "test.o", 389240116Smarcel true, 390240116Smarcel { 391240116Smarcel "-o1", "-o2", NULL 392240116Smarcel }, 393240116Smarcel { 394240116Smarcel "c++", "-f1", "-f2", "-o1", "-o2", "-o", "test.o", 395240116Smarcel "-c", "test.c", NULL 396240116Smarcel }, 397240116Smarcel }, 398240116Smarcel 399240116Smarcel { 400240116Smarcel NULL, 401240116Smarcel NULL, 402240116Smarcel NULL, 403240116Smarcel NULL, 404240116Smarcel NULL, 405240116Smarcel NULL, 406240116Smarcel false, 407240116Smarcel { NULL }, 408240116Smarcel { NULL }, 409240116Smarcel }, 410240116Smarcel}; 411