7 $standard = "XOPEN2K8";
10 GetOptions
('headers=s' => \
@headers, 'standard=s' => \
$standard,
11 'flags=s' => \
$flags, 'cc=s' => \
$CC, 'tmpdir=s' => \
$tmpdir);
12 @headers = split(/,/,join(',',@headers));
14 # List of the headers we are testing.
16 @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
17 "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "uchar.h",
18 "time.h", "tgmath.h", "termios.h", "tar.h", "sys/wait.h",
19 "sys/utsname.h", "sys/un.h", "sys/uio.h", "sys/types.h",
20 "sys/times.h", "sys/timeb.h", "sys/time.h", "sys/statvfs.h",
21 "sys/stat.h", "sys/socket.h", "sys/shm.h", "sys/sem.h",
22 "sys/select.h", "sys/resource.h", "sys/msg.h", "sys/mman.h",
23 "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", "string.h",
24 "stdnoreturn.h", "stdlib.h", "stdio.h", "stdint.h", "stddef.h",
25 "stdbool.h", "stdarg.h", "stdalign.h", "spawn.h", "signal.h",
26 "setjmp.h", "semaphore.h", "search.h", "sched.h", "regex.h",
27 "pwd.h", "pthread.h", "poll.h", "nl_types.h", "netinet/tcp.h",
28 "netinet/in.h", "net/if.h", "netdb.h", "ndbm.h", "mqueue.h",
29 "monetary.h", "math.h", "locale.h", "libgen.h", "limits.h",
30 "langinfo.h", "iso646.h", "inttypes.h", "iconv.h", "grp.h",
31 "glob.h", "ftw.h", "fnmatch.h", "fmtmsg.h", "float.h", "fenv.h",
32 "fcntl.h", "errno.h", "dlfcn.h", "dirent.h", "ctype.h", "cpio.h",
33 "complex.h", "assert.h", "arpa/inet.h", "aio.h");
36 $CFLAGS_namespace = "$flags -fno-builtin $CFLAGS{$standard} -D_ISOMAC";
37 $CFLAGS = "$CFLAGS_namespace '-D__attribute__(x)='";
39 # Check standard name for validity.
40 die "unknown standard \"$standard\"" if ($CFLAGS{$standard} eq "");
42 # if ($standard ne "XOPEN2K8" && $standard ne "POSIX2008") {
43 # # Some headers need a bit more attention. At least with XPG7
44 # # all headers should be self-contained.
45 # $mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
46 # $mustprepend{'glob.h'} = "#include <sys/types.h>\n";
47 # $mustprepend{'grp.h'} = "#include <sys/types.h>\n";
48 # $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
49 # $mustprepend{'pwd.h'} = "#include <sys/types.h>\n";
50 # $mustprepend{'sched.h'} = "#include <sys/types.h>\n";
51 # $mustprepend{'signal.h'} = "#include <pthread.h>\n#include <sys/types.h>\n";
52 # $mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
53 # $mustprepend{'sys/stat.h'} = "#include <sys/types.h>\n";
54 # $mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
55 # $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
58 # These are the ISO C90 keywords.
59 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
60 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
61 'if', 'int', 'long', 'register', 'return',
62 'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
63 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
64 if ($CFLAGS{$standard} =~ /-std=(c99|c1x)/) {
65 push (@keywords, 'inline', 'restrict');
68 # Make a hash table from this information.
69 while ($#keywords >= 0) {
70 $iskeyword{pop (@keywords)} = 1;
84 printf ("Ignoring this failure.\n");
92 my($pattern, $string) = @_;
93 my($strlen) = length ($string);
96 if (substr ($pattern, 0, 1) eq '*') {
97 my($patlen) = length ($pattern) - 1;
98 $res = ($strlen >= $patlen
99 && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
100 } elsif (substr ($pattern, -1, 1) eq '*') {
101 if (substr ($pattern, -2, 1) eq ']') {
102 my($patlen) = index ($pattern, '[');
103 my($range) = substr ($pattern, $patlen + 1, -2);
104 $res = ($strlen > $patlen
105 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen)
106 && index ($range, substr ($string, $patlen, 1)) != -1);
108 my($patlen) = length ($pattern) - 1;
109 $res = ($strlen >= $patlen
110 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
113 $res = $pattern eq $string;
121 my($fnamebase, $msg, $errmsg, $skip, $optional, $xfail) = @_;
132 $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
134 if ($optional != 0) {
135 printf (" $errmsg\n");
140 printf (" $errmsg Compiler message:\n");
148 if ($verbose > 1 && -s
"$fnamebase.out") {
149 # We print all warnings issued.
153 if ($printlog != 0) {
154 printf (" " . "-" x
71 . "\n");
155 open (MESSAGE
, "< $fnamebase.out");
160 printf (" " . "-" x
71 . "\n");
163 unlink "$fnamebase.c";
164 unlink "$fnamebase.o";
165 unlink "$fnamebase.out";
173 my($fnamebase, $msg, $errmsg, $skip, $xfail) = @_;
184 $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
188 printf (" $errmsg Compiler message:\n");
194 # Now run the program. If the exit code is not zero something is wrong.
195 $result = system "$fnamebase > $fnamebase.out2 2>&1";
198 if ($verbose > 1 && -s
"$fnamebase.out") {
199 # We print all warnings issued.
201 system "cat $fnamebase.out2 >> $fnamebase.out";
207 unlink "$fnamebase.out";
208 rename "$fnamebase.out2", "$fnamebase.out";
211 if ($printlog != 0) {
212 printf (" " . "-" x
71 . "\n");
213 open (MESSAGE
, "< $fnamebase.out");
218 printf (" " . "-" x
71 . "\n");
222 unlink "$fnamebase.c";
223 unlink "$fnamebase.o";
224 unlink "$fnamebase.out";
225 unlink "$fnamebase.out2";
232 my($token, @allow) = @_;
235 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
237 for ($idx = 0; $idx <= $#allow; ++$idx) {
238 return if (poorfnmatch
($allow[$idx], $token));
249 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
251 if (exists $errors{$token}) {
252 undef $errors{$token};
258 my($h, $fnamebase, @allow) = @_;
262 # Generate a program to get the contents of this header.
263 open (TESTFILE
, ">$fnamebase.c");
264 print TESTFILE
"#include <$h>\n";
268 open (CONTENT
, "$CC $CFLAGS_namespace -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
269 loop: while (<CONTENT
>) {
271 if (/^#define (.*)/) {
272 newtoken
($1, @allow);
273 } elsif (/^#undef (.*)/) {
276 # We have to tokenize the line.
279 $str =~ s/"[^"]*"//g;
280 foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
282 newtoken
($token, @allow);
288 unlink "$fnamebase.c";
291 # Sort the output list so it's easier to compare results with diff.
292 foreach $f (sort keys(%errors)) {
293 if ($errors{$f} == 1) {
294 if ($realerror == 0) {
295 printf ("FAIL\n " . "-" x
72 . "\n");
299 printf (" Namespace violation: \"%s\"\n", $f);
302 printf (" " . "-" x
72 . "\n") if ($realerror != 0);
305 if ($realerror == 0) {
311 while ($#headers >= 0) {
312 my($h) = pop (@headers);
315 my($fnamebase) = "$tmpdir/$hf-test";
318 my(@allowheader) = ();
319 my(%seenheader) = ();
320 my($prepend) = $mustprepend{$h};
323 printf ("Testing <$h>\n");
324 printf ("----------" . "-" x
length ($h) . "\n");
326 open (CONTROL
, "$CC -E -D$standard -std=c99 -x c data/$h-data |");
327 control
: while (<CONTROL
>) {
329 next control
if (/^#/);
330 next control
if (/^[ ]*$/);
334 # Generate a program to test for the availability of this header.
335 open (TESTFILE
, ">$fnamebase.c");
336 print TESTFILE
"$prepend";
337 print TESTFILE
"#include <$h>\n";
340 $missing = compiletest
($fnamebase, "Checking whether <$h> is available",
341 "Header <$h> not available", 0, 0, 0);
343 last control
if ($missing);
356 if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
357 my($struct) = "$2$3";
363 # Remember that this name is allowed.
364 push @allow, $member;
366 # Generate a program to test for the availability of this member.
367 open (TESTFILE
, ">$fnamebase.c");
368 print TESTFILE
"$prepend";
369 print TESTFILE
"#include <$h>\n";
370 print TESTFILE
"$struct a;\n";
371 print TESTFILE
"$struct b;\n";
372 print TESTFILE
"extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
373 print TESTFILE
"void foobarbaz (void) {\n";
374 print TESTFILE
" xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
375 print TESTFILE
"}\n";
378 $res = compiletest
($fnamebase, "Testing for member $member",
381 : "Member \"$member\" not available."), $res,
384 if ($res == 0 || $missing != 0 || !$optional) {
385 # Test the types of the members.
386 open (TESTFILE
, ">$fnamebase.c");
387 print TESTFILE
"$prepend";
388 print TESTFILE
"#include <$h>\n";
389 print TESTFILE
"$struct a;\n";
390 print TESTFILE
"extern $type b$rest;\n";
391 print TESTFILE
"extern __typeof__ (a.$member) b;\n";
394 compiletest
($fnamebase, "Testing for type of member $member",
395 "Member \"$member\" does not have the correct type.",
398 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_\\'-]*))?/) {
399 my($symbol_type) = $1;
405 my($mres) = $missing;
406 my($cres) = $missing;
408 # Remember that this name is allowed.
409 push @allow, $symbol;
411 if ($symbol_type =~ /macro/) {
412 # Generate a program to test for availability of this macro.
413 open (TESTFILE
, ">$fnamebase.c");
414 print TESTFILE
"$prepend";
415 print TESTFILE
"#include <$h>\n";
416 print TESTFILE
"#ifndef $symbol\n";
417 print TESTFILE
"# error \"Macro $symbol not defined\"\n";
418 print TESTFILE
"#endif\n";
421 $mres = compiletest
($fnamebase, "Test availability of macro $symbol",
424 : "Macro \"$symbol\" is not available."), $res,
428 if ($symbol_type =~ /constant/) {
429 # Generate a program to test for the availability of this constant.
430 open (TESTFILE
, ">$fnamebase.c");
431 print TESTFILE
"$prepend";
432 print TESTFILE
"#include <$h>\n";
433 print TESTFILE
"__typeof__ ($symbol) a = $symbol;\n";
436 $cres = compiletest
($fnamebase, "Testing for constant $symbol",
439 : "Constant \"$symbol\" not available."), $res,
443 $res = $res || $mres || $cres;
445 if ($symbol_type eq "macro-int-constant" && ($res == 0 || !$optional)) {
446 # Test that the symbol is usable in #if.
447 open (TESTFILE
, ">$fnamebase.c");
448 print TESTFILE
"$prepend";
449 print TESTFILE
"#include <$h>\n";
450 print TESTFILE
"#if $symbol < 0\n";
451 print TESTFILE
"# define conformtest_negative 1\n";
453 for (my $i = 0; $i < 63; $i++) {
454 print TESTFILE
"# if $symbol & (1LL << $i)\n";
455 print TESTFILE
"# define conformtest_bit_$i 0LL\n";
456 print TESTFILE
"# else\n";
457 print TESTFILE
"# define conformtest_bit_$i (1LL << $i)\n";
458 print TESTFILE
"# endif\n";
459 $s .= "|conformtest_bit_$i";
461 print TESTFILE
"# define conformtest_value ~($s)\n";
462 print TESTFILE
"#else\n";
463 print TESTFILE
"# define conformtest_negative 0\n";
465 for (my $i = 0; $i < 64; $i++) {
466 print TESTFILE
"# if $symbol & (1ULL << $i)\n";
467 print TESTFILE
"# define conformtest_bit_$i (1ULL << $i)\n";
468 print TESTFILE
"# else\n";
469 print TESTFILE
"# define conformtest_bit_$i 0ULL\n";
470 print TESTFILE
"# endif\n";
471 $s .= "|conformtest_bit_$i";
473 print TESTFILE
"# define conformtest_value ($s)\n";
474 print TESTFILE
"#endif\n";
475 print TESTFILE
"int main (void) { return !((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value)); }\n";
478 runtest
($fnamebase, "Testing for #if usability of symbol $symbol",
479 "Symbol \"$symbol\" not usable in #if.", $res, $xfail);
482 if (defined ($type) && ($res == 0 || !$optional)) {
483 # Test the type of the symbol.
484 open (TESTFILE
, ">$fnamebase.c");
485 print TESTFILE
"$prepend";
486 print TESTFILE
"#include <$h>\n";
487 if ($type =~ /^promoted:/) {
488 $type =~ s/^promoted://;
489 print TESTFILE
"__typeof__ (($type) 0 + ($type) 0) a;\n";
491 print TESTFILE
"__typeof__ (($type) 0) a;\n";
493 print TESTFILE
"extern __typeof__ ($symbol) a;\n";
496 compiletest
($fnamebase, "Testing for type of symbol $symbol",
497 "Symbol \"$symbol\" does not have the correct type.",
501 if (defined ($op) && ($res == 0 || !$optional)) {
502 # Generate a program to test for the value of this symbol.
503 open (TESTFILE
, ">$fnamebase.c");
504 print TESTFILE
"$prepend";
505 print TESTFILE
"#include <$h>\n";
506 # Negate the value since 0 means ok
507 print TESTFILE
"int main (void) { return !($symbol $op $value); }\n";
510 $res = runtest
($fnamebase, "Testing for value of symbol $symbol",
511 "Symbol \"$symbol\" has not the right value.", $res,
514 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
519 # Remember that this name is allowed.
520 push @allow, $symbol;
522 # Generate a program to test for the availability of this constant.
523 open (TESTFILE
, ">$fnamebase.c");
524 print TESTFILE
"$prepend";
525 print TESTFILE
"#include <$h>\n";
526 print TESTFILE
"void foobarbaz (void) {\n";
527 print TESTFILE
"__typeof__ ($symbol) a = $symbol;\n";
528 print TESTFILE
"}\n";
531 $res = compiletest
($fnamebase, "Testing for symbol $symbol",
532 "Symbol \"$symbol\" not available.", $res, 0, $xfail);
535 # Generate a program to test for the value of this constant.
536 open (TESTFILE
, ">$fnamebase.c");
537 print TESTFILE
"$prepend";
538 print TESTFILE
"#include <$h>\n";
539 print TESTFILE
"int main (void) { return $symbol != $value; }\n";
542 $res = runtest
($fnamebase, "Testing for value of symbol $symbol",
543 "Symbol \"$symbol\" has not the right value.", $res,
546 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
548 my($maybe_opaque) = 0;
550 # Remember that this name is allowed.
551 if ($type =~ /^struct *(.*)/) {
553 } elsif ($type =~ /^union *(.*)/) {
560 # Generate a program to test for the availability of this type.
561 open (TESTFILE
, ">$fnamebase.c");
562 print TESTFILE
"$prepend";
563 print TESTFILE
"#include <$h>\n";
564 if ($maybe_opaque == 1) {
565 print TESTFILE
"$type *a;\n";
567 print TESTFILE
"$type a;\n";
571 compiletest
($fnamebase, "Testing for type $type",
574 : "Type \"$type\" not available."), $missing, $optional,
576 } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) {
579 # Remember that this name is allowed.
580 if ($type =~ /^struct *(.*)/) {
582 } elsif ($type =~ /^union *(.*)/) {
588 # Generate a program to test for the availability of this type.
589 open (TESTFILE
, ">$fnamebase.c");
590 print TESTFILE
"$prepend";
591 print TESTFILE
"#include <$h>\n";
592 print TESTFILE
"$type;\n";
595 compiletest
($fnamebase, "Testing for type $type",
596 "Type \"$type\" not available.", $missing, 0, $xfail);
597 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
598 my($rettype) = "$2$3";
603 # Remember that this name is allowed.
606 # Generate a program to test for availability of this function.
607 open (TESTFILE
, ">$fnamebase.c");
608 print TESTFILE
"$prepend";
609 print TESTFILE
"#include <$h>\n";
610 # print TESTFILE "#undef $fname\n";
611 print TESTFILE
"$rettype (*(*foobarbaz) $args = $fname;\n";
614 $res = compiletest
($fnamebase, "Test availability of function $fname",
617 : "Function \"$fname\" is not available."), $res,
620 if ($res == 0 || $missing == 1 || !$optional) {
621 # Generate a program to test for the type of this function.
622 open (TESTFILE
, ">$fnamebase.c");
623 print TESTFILE
"$prepend";
624 print TESTFILE
"#include <$h>\n";
625 # print TESTFILE "#undef $fname\n";
626 print TESTFILE
"extern $rettype (*(*foobarbaz) $args;\n";
627 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
630 compiletest
($fnamebase, "Test for type of function $fname",
631 "Function \"$fname\" has incorrect type.", $res, 0,
634 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
635 my($rettype) = "$2$3";
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
"$rettype (*foobarbaz) $args = $fname;\n";
651 $res = compiletest
($fnamebase, "Test availability of function $fname",
654 : "Function \"$fname\" is not available."), $res,
657 if ($res == 0 || $missing != 0 || !$optional) {
658 # Generate a program to test for the type of this function.
659 open (TESTFILE
, ">$fnamebase.c");
660 print TESTFILE
"$prepend";
661 print TESTFILE
"#include <$h>\n";
662 # print TESTFILE "#undef $fname\n";
663 print TESTFILE
"extern $rettype (*foobarbaz) $args;\n";
664 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
667 compiletest
($fnamebase, "Test for type of function $fname",
668 "Function \"$fname\" has incorrect type.", $res, 0,
671 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
677 # Remember that this name is allowed.
680 # Generate a program to test for availability of this function.
681 open (TESTFILE
, ">$fnamebase.c");
682 print TESTFILE
"$prepend";
683 print TESTFILE
"#include <$h>\n";
684 # print TESTFILE "#undef $fname\n";
685 print TESTFILE
"typedef $type xyzzy$rest;\n";
686 print TESTFILE
"$xyzzy *foobarbaz = &$vname;\n";
689 $res = compiletest
($fnamebase, "Test availability of variable $vname",
690 "Variable \"$vname\" is not available.", $res, 0,
693 # Generate a program to test for the type of this function.
694 open (TESTFILE
, ">$fnamebase.c");
695 print TESTFILE
"$prepend";
696 print TESTFILE
"#include <$h>\n";
697 # print TESTFILE "#undef $fname\n";
698 print TESTFILE
"extern $type $vname$rest;\n";
701 compiletest
($fnamebase, "Test for type of variable $fname",
702 "Variable \"$vname\" has incorrect type.", $res, 0, $xfail);
703 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
704 my($rettype) = "$2$3";
709 # Remember that this name is allowed.
712 # Generate a program to test for availability of this function.
713 open (TESTFILE
, ">$fnamebase.c");
714 print TESTFILE
"$prepend";
715 print TESTFILE
"#include <$h>\n";
716 print TESTFILE
"#ifndef $fname\n";
717 print TESTFILE
"$rettype (*foobarbaz) $args = $fname;\n";
718 print TESTFILE
"#endif\n";
721 $res = compiletest
($fnamebase, "Test availability of macro $fname",
722 "Function \"$fname\" is not available.", $res, 0,
725 # Generate a program to test for the type of this function.
726 open (TESTFILE
, ">$fnamebase.c");
727 print TESTFILE
"$prepend";
728 print TESTFILE
"#include <$h>\n";
729 print TESTFILE
"#ifndef $fname\n";
730 print TESTFILE
"extern $rettype (*foobarbaz) $args;\n";
731 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
732 print TESTFILE
"#endif\n";
735 compiletest
($fnamebase, "Test for type of macro $fname",
736 "Function \"$fname\" has incorrect type.", $res, 0, $xfail);
737 } elsif (/^macro-str *([^ ]*) *(\".*\")/) {
738 # The above regex doesn't handle a \" in a string.
743 # Remember that this name is allowed.
746 # Generate a program to test for availability of this macro.
747 open (TESTFILE
, ">$fnamebase.c");
748 print TESTFILE
"$prepend";
749 print TESTFILE
"#include <$h>\n";
750 print TESTFILE
"#ifndef $macro\n";
751 print TESTFILE
"# error \"Macro $macro not defined\"\n";
752 print TESTFILE
"#endif\n";
755 compiletest
($fnamebase, "Test availability of macro $macro",
756 "Macro \"$macro\" is not available.", $missing, 0, $xfail);
758 # Generate a program to test for the value of this macro.
759 open (TESTFILE
, ">$fnamebase.c");
760 print TESTFILE
"$prepend";
761 print TESTFILE
"#include <$h>\n";
762 # We can't include <string.h> here.
763 print TESTFILE
"extern int (strcmp)(const char *, const char *);\n";
764 print TESTFILE
"int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
767 $res = runtest
($fnamebase, "Testing for value of macro $macro",
768 "Macro \"$macro\" has not the right value.", $res,
770 } elsif (/^allow-header *(.*)/) {
772 if ($seenheader{$pattern} != 1) {
773 push @allowheader, $pattern;
774 $seenheader{$pattern} = 1;
777 } elsif (/^allow *(.*)/) {
779 push @allow, $pattern;
782 # printf ("line is `%s'\n", $_);
790 # Read the data files for the header files which are allowed to be included.
791 while ($#allowheader >= 0) {
792 my($ah) = pop @allowheader;
794 open (ALLOW
, "$CC -E -D$standard -x c data/$ah-data |");
795 acontrol
: while (<ALLOW
>) {
797 next acontrol
if (/^#/);
798 next acontrol
if (/^[ ]*$/);
802 if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
804 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
806 } elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
809 # Remember that this name is allowed.
810 if ($type =~ /^struct *(.*)/) {
812 } elsif ($type =~ /^union *(.*)/) {
817 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
819 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
821 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
823 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
825 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
827 } elsif (/^allow-header *(.*)/) {
828 if ($seenheader{$1} != 1) {
829 push @allowheader, $1;
832 } elsif (/^allow *(.*)/) {
840 printf (" Not defined\n");
842 # Now check the namespace.
843 printf (" Checking the namespace of \"%s\"... ", $h);
848 checknamespace
($h, $fnamebase, @allow);
855 printf "-" x
76 . "\n";
856 printf (" Total number of tests : %4d\n", $total);
858 printf (" Number of failed tests : %4d (", $errors);
859 $percent = ($errors * 100) / $total;
860 if ($errors > 0 && $percent < 1.0) {
863 printf ("%3d%%)\n", $percent);
866 printf (" Number of xfailed tests : %4d (", $xerrors);
867 $percent = ($xerrors * 100) / $total;
868 if ($xerrors > 0 && $percent < 1.0) {
871 printf ("%3d%%)\n", $percent);
874 printf (" Number of skipped tests : %4d (", $skipped);
875 $percent = ($skipped * 100) / $total;
876 if ($skipped > 0 && $percent < 1.0) {
879 printf ("%3d%%)\n", $percent);
884 # perl-indent-level: 2