8 GetOptions ('headers=s' => \@headers, 'dialect=s' => \$dialect);
9 @headers = split(/,/,join(',',@headers));
11 # List of the headers we are testing.
13 @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
14 "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h",
15 "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h", "sys/un.h",
16 "sys/uio.h", "sys/types.h", "sys/times.h", "sys/timeb.h",
17 "sys/time.h", "sys/statvfs.h", "sys/stat.h", "sys/socket.h",
18 "sys/shm.h", "sys/sem.h", "sys/resource.h", "sys/msg.h",
19 "sys/mman.h", "sys/ipc.h", "syslog.h", "stropts.h", "strings.h",
20 "string.h", "stdlib.h", "stdio.h", "stdint.h", "stddef.h",
21 "stdarg.h", "spawn.h", "signal.h", "setjmp.h", "semaphore.h",
22 "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h",
23 "poll.h", "nl_types.h", "netinet/tcp.h", "netinet/in.h",
24 "net/if.h", "netdb.h", "ndbm.h", "mqueue.h", "monetary.h",
25 "math.h", "locale.h", "libgen.h", "limits.h", "langinfo.h",
26 "iso646.h", "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h",
27 "fnmatch.h", "fmtmsg.h", "float.h", "fcntl.h", "errno.h",
28 "dlfcn.h", "dirent.h", "ctype.h", "cpio.h", "assert.h",
29 "arpa/inet.h", "aio.h");
32 if ($dialect ne "ISO" && $dialect ne "POSIX" && $dialect ne "XPG3"
33 && $dialect ne "XPG4" && $dialect ne "UNIX98" && $dialect ne "XOPEN2K") {
34 die "unknown dialect \"$dialect\"";
37 $CFLAGS{"ISO"} = "-I. '-D__attribute__(x)=' -ansi";
38 $CFLAGS{"POSIX"} = "-I. '-D__attribute__(x)=' -D_POSIX_C_SOURCE=199912";
39 $CFLAGS{"XPG3"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE";
40 $CFLAGS{"XPG4"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE_EXTENDED";
41 $CFLAGS{"UNIX98"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=500";
42 $CFLAGS{"XOPEN2K"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=600";
45 # These are the ISO C99 keywords.
46 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
47 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
48 'if', 'inline', 'int', 'long', 'register', 'restrict', 'return',
49 'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
50 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
52 # These are symbols which are known to pollute the namespace.
53 @knownproblems = ('unix', 'linux', 'i386');
55 # Some headers need a bit more attention.
56 $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
57 $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
59 # Make a hash table from this information.
60 while ($#keywords >= 0) {
61 $iskeyword{pop (@keywords)} = 1;
64 # Make a hash table from the known problems.
65 while ($#knownproblems >= 0) {
66 $isknown{pop (@knownproblems)} = 1;
79 my($pattern, $string) = @_;
80 my($strlen) = length ($string);
83 if (substr ($pattern, 0, 1) eq '*') {
84 my($patlen) = length ($pattern) - 1;
85 $res = ($strlen >= $patlen
86 && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
87 } elsif (substr ($pattern, -1, 1) eq '*') {
88 my($patlen) = length ($pattern) - 1;
89 $res = ($strlen >= $patlen
90 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
92 $res = $pattern eq $string;
100 my($fnamebase, $msg, $errmsg, $skip, $optional) = @_;
111 $ret = system "$CC $CFLAGS{$dialect} -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
113 if ($optional != 0) {
114 printf (" $errmsg\n");
119 printf (" $errmsg Compiler message:\n");
127 if ($verbose > 1 && -s "$fnamebase.out") {
128 # We print all warnings issued.
132 if ($printlog != 0) {
133 printf (" " . "-" x 71 . "\n");
134 open (MESSAGE, "< $fnamebase.out");
139 printf (" " . "-" x 71 . "\n");
142 unlink "$fnamebase.c";
143 unlink "$fnamebase.o";
144 unlink "$fnamebase.out";
152 my($fnamebase, $msg, $errmsg, $skip) = @_;
163 $ret = system "$CC $CFLAGS{$dialect} -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
167 printf (" $errmsg Compiler message:\n");
173 # Now run the program. If the exit code is not zero something is wrong.
174 $result = system "$fnamebase > $fnamebase.out2 2>&1";
177 if ($verbose > 1 && -s "$fnamebase.out") {
178 # We print all warnings issued.
180 system "cat $fnamebase.out2 >> $fnamebase.out";
186 unlink "$fnamebase.out";
187 rename "$fnamebase.out2", "$fnamebase.out";
190 if ($printlog != 0) {
191 printf (" " . "-" x 71 . "\n");
192 open (MESSAGE, "< $fnamebase.out");
197 printf (" " . "-" x 71 . "\n");
201 unlink "$fnamebase.c";
202 unlink "$fnamebase.o";
203 unlink "$fnamebase.out";
204 unlink "$fnamebase.out2";
211 my($token, @allow) = @_;
214 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
216 for ($idx = 0; $idx <= $#allow; ++$idx) {
217 return if (poorfnmatch ($allow[$idx], $token));
220 if ($isknown{$token}) {
225 printf ("FAIL\n " . "-" x 72 . "\n");
227 printf (" Namespace violation: \"%s\"\n", $token);
233 my($h, $fnamebase, @allow) = @_;
237 # Generate a program to get the contents of this header.
238 open (TESTFILE, ">$fnamebase.c");
239 print TESTFILE "#include <$h>\n";
244 open (CONTENT, "$CC $CFLAGS{$dialect} -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
245 loop: while (<CONTENT>) {
246 next loop if (/^#undef /);
248 if (/^#define (.*)/) {
249 newtoken ($1, @allow);
251 # We have to tokenize the line.
254 my($len) = length ($str);
256 foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
258 newtoken ($token, @allow);
264 unlink "$fnamebase.c";
266 printf (" " . "-" x 72 . "\n");
268 } elsif ($nknown > 0) {
269 printf ("EXPECTED FAILURES\n");
277 while ($#headers >= 0) {
278 my($h) = pop (@headers);
281 my($fnamebase) = "$tmpdir/$hf-test";
284 my(@allowheader) = ();
285 my(%seenheader) = ();
286 my($prepend) = $mustprepend{$h};
288 printf ("Testing <$h>\n");
289 printf ("----------" . "-" x length ($h) . "\n");
291 # Generate a program to test for the availability of this header.
292 open (TESTFILE, ">$fnamebase.c");
293 print TESTFILE "$prepend";
294 print TESTFILE "#include <$h>\n";
297 $missing = compiletest ($fnamebase, "Checking whether <$h> is available",
298 "Header <$h> not available", 0, 0);
302 open (CONTROL, "$CC -E -D$dialect - < data/$h-data |");
303 control: while (<CONTROL>) {
305 next control if (/^#/);
306 next control if (/^[ ]*$/);
308 if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
309 my($struct) = "$2$3";
315 # Remember that this name is allowed.
316 push @allow, $member;
318 # Generate a program to test for the availability of this member.
319 open (TESTFILE, ">$fnamebase.c");
320 print TESTFILE "$prepend";
321 print TESTFILE "#include <$h>\n";
322 print TESTFILE "$struct a;\n";
323 print TESTFILE "$struct b;\n";
324 print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
325 print TESTFILE "void foobarbaz (void) {\n";
326 print TESTFILE " xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
327 print TESTFILE "}\n";
330 $res = compiletest ($fnamebase, "Testing for member $member",
331 "Member \"$member\" not available.", $res, 0);
334 # Test the types of the members.
335 open (TESTFILE, ">$fnamebase.c");
336 print TESTFILE "$prepend";
337 print TESTFILE "#include <$h>\n";
338 print TESTFILE "$struct a;\n";
339 print TESTFILE "extern $type b$rest;\n";
340 print TESTFILE "extern __typeof__ (a.$member) b;\n";
343 compiletest ($fnamebase, "Testing for type of member $member",
344 "Member \"$member\" does not have the correct type.", $res);
345 } elsif (/^optional-constant *([a-zA-Z0-9_]*) ([>=<]+) ([A-Za-z0-9_]*)/) {
351 # Remember that this name is allowed.
354 # Generate a program to test for the availability of this constant.
355 open (TESTFILE, ">$fnamebase.c");
356 print TESTFILE "$prepend";
357 print TESTFILE "#include <$h>\n";
358 print TESTFILE "__typeof__ ($const) a = $const;\n";
361 $res = compiletest ($fnamebase, "Testing for constant $const",
362 "NOT PRESENT", $res, 1);
364 if ($value ne "" && $res == 0) {
365 # Generate a program to test for the value of this constant.
366 open (TESTFILE, ">$fnamebase.c");
367 print TESTFILE "$prepend";
368 print TESTFILE "#include <$h>\n";
369 # Negate the value since 0 means ok
370 print TESTFILE "int main (void) { return !($const $op $value); }\n";
373 $res = runtest ($fnamebase, "Testing for value of constant $const",
374 "Constant \"$const\" has not the right value.", $res);
376 } elsif (/^constant *([a-zA-Z0-9_]*) *([>=<]+) ([A-Za-z0-9_]*)/) {
382 # Remember that this name is allowed.
385 # Generate a program to test for the availability of this constant.
386 open (TESTFILE, ">$fnamebase.c");
387 print TESTFILE "$prepend";
388 print TESTFILE "#include <$h>\n";
389 print TESTFILE "__typeof__ ($const) a = $const;\n";
392 $res = compiletest ($fnamebase, "Testing for constant $const",
393 "Constant \"$const\" not available.", $res, 0);
396 # Generate a program to test for the value of this constant.
397 open (TESTFILE, ">$fnamebase.c");
398 print TESTFILE "$prepend";
399 print TESTFILE "#include <$h>\n";
400 # Negate the value since 0 means ok
401 print TESTFILE "int main (void) { return !($const $op $value); }\n";
404 $res = runtest ($fnamebase, "Testing for value of constant $const",
405 "Constant \"$const\" has not the right value.", $res);
407 } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
413 # Remember that this name is allowed.
416 # Generate a program to test for the availability of this constant.
417 open (TESTFILE, ">$fnamebase.c");
418 print TESTFILE "$prepend";
419 print TESTFILE "#include <$h>\n";
420 print TESTFILE "__typeof__ ($const) a = $const;\n";
423 $res = compiletest ($fnamebase, "Testing for constant $const",
424 "Constant \"$const\" not available.", $res, 0);
426 # Test the types of the members.
427 open (TESTFILE, ">$fnamebase.c");
428 print TESTFILE "$prepend";
429 print TESTFILE "#include <$h>\n";
430 print TESTFILE "__typeof__ (($type) 0) a;\n";
431 print TESTFILE "extern __typeof__ ($const) a;\n";
434 compiletest ($fnamebase, "Testing for type of constant $const",
435 "Constant \"$const\" does not have the correct type.",
439 # Generate a program to test for the value of this constant.
440 open (TESTFILE, ">$fnamebase.c");
441 print TESTFILE "$prepend";
442 print TESTFILE "#include <$h>\n";
443 print TESTFILE "int main (void) { return $const != $value; }\n";
446 $res = runtest ($fnamebase, "Testing for value of constant $const",
447 "Constant \"$const\" has not the right value.", $res);
449 } elsif (/^optional-constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
454 # Remember that this name is allowed.
457 # Generate a program to test for the availability of this constant.
458 open (TESTFILE, ">$fnamebase.c");
459 print TESTFILE "$prepend";
460 print TESTFILE "#include <$h>\n";
461 print TESTFILE "__typeof__ ($const) a = $const;\n";
464 $res = compiletest ($fnamebase, "Testing for constant $const",
465 "NOT PRESENT", $res, 1);
467 if ($value ne "" && $res == 0) {
468 # Generate a program to test for the value of this constant.
469 open (TESTFILE, ">$fnamebase.c");
470 print TESTFILE "$prepend";
471 print TESTFILE "#include <$h>\n";
472 print TESTFILE "int main (void) { return $const != $value; }\n";
475 $res = runtest ($fnamebase, "Testing for value of constant $const",
476 "Constant \"$const\" has not the right value.", $res);
478 } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
483 # Remember that this name is allowed.
486 # Generate a program to test for the availability of this constant.
487 open (TESTFILE, ">$fnamebase.c");
488 print TESTFILE "$prepend";
489 print TESTFILE "#include <$h>\n";
490 print TESTFILE "__typeof__ ($const) a = $const;\n";
493 $res = compiletest ($fnamebase, "Testing for constant $const",
494 "Constant \"$const\" not available.", $res, 0);
497 # Generate a program to test for the value of this constant.
498 open (TESTFILE, ">$fnamebase.c");
499 print TESTFILE "$prepend";
500 print TESTFILE "#include <$h>\n";
501 print TESTFILE "int main (void) { return $const != $value; }\n";
504 $res = runtest ($fnamebase, "Testing for value of constant $const",
505 "Constant \"$const\" has not the right value.", $res);
507 } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
513 # Remember that this name is allowed.
516 # Generate a program to test for the availability of this constant.
517 open (TESTFILE, ">$fnamebase.c");
518 print TESTFILE "$prepend";
519 print TESTFILE "#include <$h>\n";
520 print TESTFILE "__typeof__ ($const) a = $const;\n";
523 $res = compiletest ($fnamebase, "Testing for constant $const",
524 "Constant \"$const\" not available.", $res, 0);
526 # Test the types of the members.
527 open (TESTFILE, ">$fnamebase.c");
528 print TESTFILE "$prepend";
529 print TESTFILE "#include <$h>\n";
530 print TESTFILE "__typeof__ (($type) 0) a;\n";
531 print TESTFILE "extern __typeof__ ($const) a;\n";
534 compiletest ($fnamebase, "Testing for type of constant $const",
535 "Constant \"$const\" does not have the correct type.",
539 # Generate a program to test for the value of this constant.
540 open (TESTFILE, ">$fnamebase.c");
541 print TESTFILE "$prepend";
542 print TESTFILE "#include <$h>\n";
543 print TESTFILE "int main (void) { return $const != $value; }\n";
546 $res = runtest ($fnamebase, "Testing for value of constant $const",
547 "Constant \"$const\" has not the right value.", $res);
549 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
552 # Remember that this name is allowed.
553 if ($type =~ /^struct *(.*)/) {
555 } elsif ($type =~ /^union *(.*)/) {
561 # Remember that this name is allowed.
564 # Generate a program to test for the availability of this constant.
565 open (TESTFILE, ">$fnamebase.c");
566 print TESTFILE "$prepend";
567 print TESTFILE "#include <$h>\n";
568 print TESTFILE "$type *a;\n";
571 compiletest ($fnamebase, "Testing for type $type",
572 "Type \"$type\" not available.", $missing, 0);
573 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
574 my($rettype) = "$2$3";
579 # Remember that this name is allowed.
582 # Generate a program to test for availability of this function.
583 open (TESTFILE, ">$fnamebase.c");
584 print TESTFILE "$prepend";
585 print TESTFILE "#include <$h>\n";
586 # print TESTFILE "#undef $fname\n";
587 print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
590 $res = compiletest ($fnamebase, "Test availability of function $fname",
591 "Function \"$fname\" is not available.", $res, 0);
593 # Generate a program to test for the type of this function.
594 open (TESTFILE, ">$fnamebase.c");
595 print TESTFILE "$prepend";
596 print TESTFILE "#include <$h>\n";
597 # print TESTFILE "#undef $fname\n";
598 print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
599 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
602 compiletest ($fnamebase, "Test for type of function $fname",
603 "Function \"$fname\" has incorrect type.", $res, 0);
604 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
605 my($rettype) = "$2$3";
610 # Remember that this name is allowed.
613 # Generate a program to test for availability of this function.
614 open (TESTFILE, ">$fnamebase.c");
615 print TESTFILE "$prepend";
616 print TESTFILE "#include <$h>\n";
617 # print TESTFILE "#undef $fname\n";
618 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
621 $res = compiletest ($fnamebase, "Test availability of function $fname",
622 "Function \"$fname\" is not available.", $res, 0);
624 # Generate a program to test for the type of this function.
625 open (TESTFILE, ">$fnamebase.c");
626 print TESTFILE "$prepend";
627 print TESTFILE "#include <$h>\n";
628 # print TESTFILE "#undef $fname\n";
629 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
630 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
633 compiletest ($fnamebase, "Test for type of function $fname",
634 "Function \"$fname\" has incorrect type.", $res, 0);
635 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
640 # Remember that this name is allowed.
643 # Generate a program to test for availability of this function.
644 open (TESTFILE, ">$fnamebase.c");
645 print TESTFILE "$prepend";
646 print TESTFILE "#include <$h>\n";
647 # print TESTFILE "#undef $fname\n";
648 print TESTFILE "$type *foobarbaz = &$vname;\n";
651 $res = compiletest ($fnamebase, "Test availability of variable $vname",
652 "Variable \"$vname\" is not available.", $res, 0);
654 # Generate a program to test for the type of this function.
655 open (TESTFILE, ">$fnamebase.c");
656 print TESTFILE "$prepend";
657 print TESTFILE "#include <$h>\n";
658 # print TESTFILE "#undef $fname\n";
659 print TESTFILE "extern $type $vname;\n";
662 compiletest ($fnamebase, "Test for type of variable $fname",
663 "Variable \"$vname\" has incorrect type.", $res, 0);
664 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
665 my($rettype) = "$2$3";
670 # Remember that this name is allowed.
673 # Generate a program to test for availability of this function.
674 open (TESTFILE, ">$fnamebase.c");
675 print TESTFILE "$prepend";
676 print TESTFILE "#include <$h>\n";
677 print TESTFILE "#ifndef $fname\n";
678 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
679 print TESTFILE "#endif\n";
682 $res = compiletest ($fnamebase, "Test availability of function $fname",
683 "Function \"$fname\" is not available.", $res, 0);
685 # Generate a program to test for the type of this function.
686 open (TESTFILE, ">$fnamebase.c");
687 print TESTFILE "$prepend";
688 print TESTFILE "#include <$h>\n";
689 print TESTFILE "#ifndef $fname\n";
690 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
691 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
692 print TESTFILE "#endif\n";
695 compiletest ($fnamebase, "Test for type of function $fname",
696 "Function \"$fname\" has incorrect type.", $res, 0);
697 } elsif (/^macro-str *([^ ]*) *(\".*\")/) {
698 # The above regex doesn't handle a \" in a string.
703 # Remember that this name is allowed.
706 # Generate a program to test for availability of this macro.
707 open (TESTFILE, ">$fnamebase.c");
708 print TESTFILE "$prepend";
709 print TESTFILE "#include <$h>\n";
710 print TESTFILE "#ifndef $macro\n";
711 print TESTFILE "# error \"Macro $macro not defined\"\n";
712 print TESTFILE "#endif\n";
715 compiletest ($fnamebase, "Test availability of macro $macro",
716 "Macro \"$macro\" is not available.", $missing, 0);
718 # Generate a program to test for the value of this macro.
719 open (TESTFILE, ">$fnamebase.c");
720 print TESTFILE "$prepend";
721 print TESTFILE "#include <$h>\n";
722 # We can't include <string.h> here.
723 print TESTFILE "extern int (strcmp)(const char *, const char *);\n";
724 print TESTFILE "int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
727 $res = runtest ($fnamebase, "Testing for value of macro $macro",
728 "Macro \"$macro\" has not the right value.", $res);
729 } elsif (/^optional-macro *([^ ]*)/) {
732 # Remember that this name is allowed.
735 # Generate a program to test for availability of this macro.
736 open (TESTFILE, ">$fnamebase.c");
737 print TESTFILE "$prepend";
738 print TESTFILE "#include <$h>\n";
739 print TESTFILE "#ifndef $macro\n";
740 print TESTFILE "# error \"Macro $macro not defined\"\n";
741 print TESTFILE "#endif\n";
744 compiletest ($fnamebase, "Test availability of macro $macro",
745 "NOT PRESENT", $missing, 1);
746 } elsif (/^macro *([a-zA-Z0-9_]*) *([>=<]+) ([A-Za-z0-9_]*)/) {
752 # Remember that this name is allowed.
755 # Generate a program to test for availability of this macro.
756 open (TESTFILE, ">$fnamebase.c");
757 print TESTFILE "$prepend";
758 print TESTFILE "#include <$h>\n";
759 print TESTFILE "#ifndef $macro\n";
760 print TESTFILE "# error \"Macro $macro not defined\"\n";
761 print TESTFILE "#endif\n";
764 $res = compiletest ($fnamebase, "Test availability of macro $macro",
765 "Macro \"$macro\" is not available.", $res, 0);
768 # Generate a program to test for the value of this constant.
769 open (TESTFILE, ">$fnamebase.c");
770 print TESTFILE "$prepend";
771 print TESTFILE "#include <$h>\n";
772 # Negate the value since 0 means ok
773 print TESTFILE "int main (void) { return !($macro $op $value); }\n";
776 $res = runtest ($fnamebase, "Testing for value of constant $macro",
777 "Macro \"$macro\" has not the right value.", $res);
779 } elsif (/^macro *([^ ]*)/) {
782 # Remember that this name is allowed.
785 # Generate a program to test for availability of this macro.
786 open (TESTFILE, ">$fnamebase.c");
787 print TESTFILE "$prepend";
788 print TESTFILE "#include <$h>\n";
789 print TESTFILE "#ifndef $macro\n";
790 print TESTFILE "# error \"Macro $macro not defined\"\n";
791 print TESTFILE "#endif\n";
794 compiletest ($fnamebase, "Test availability of macro $macro",
795 "Macro \"$macro\" is not available.", $missing, 0);
796 } elsif (/^allow-header *(.*)/) {
798 if ($seenheader{$pattern} != 1) {
799 push @allowheader, $pattern;
800 $seenheader{$pattern} = 1;
803 } elsif (/^allow *(.*)/) {
805 push @allow, $pattern;
808 # printf ("line is `%s'\n", $_);
816 # Read the data files for the header files which are allowed to be included.
817 while ($#allowheader >= 0) {
818 my($ah) = pop @allowheader;
820 open (ALLOW, "$CC -E -D$dialect - < data/$ah-data |");
821 acontrol: while (<ALLOW>) {
822 next acontrol if (/^#/);
823 next acontrol if (/^[ ]*$/);
825 if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
827 } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) {
829 } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
831 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
834 # Remember that this name is allowed.
835 if ($type =~ /^struct *(.*)/) {
837 } elsif ($type =~ /^union *(.*)/) {
842 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
844 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
846 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
848 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
850 } elsif (/^macro *([^ ]*)/) {
852 } elsif (/^allow-header *(.*)/) {
853 if ($seenheader{$1} != 1) {
854 push @allowheader, $1;
857 } elsif (/^allow *(.*)/) {
864 # Now check the namespace.
865 printf (" Checking the namespace of \"%s\"... ", $h);
870 checknamespace ($h, $fnamebase, @allow);
876 printf "-" x 76 . "\n";
877 printf (" Total number of tests : %4d\n", $total);
879 printf (" Number of known failures: %4d (", $known);
880 $percent = ($known * 100) / $total;
881 if ($known > 0 && $percent < 1.0) {
884 printf ("%3d%%)\n", $percent);
887 printf (" Number of failed tests : %4d (", $errors);
888 $percent = ($errors * 100) / $total;
889 if ($errors > 0 && $percent < 1.0) {
892 printf ("%3d%%)\n", $percent);
895 printf (" Number of skipped tests : %4d (", $skipped);
896 $percent = ($skipped * 100) / $total;
897 if ($skipped > 0 && $percent < 1.0) {
900 printf ("%3d%%)\n", $percent);