7 $standard = "XOPEN2K8";
12 GetOptions
('headers=s' => \
@headers, 'standard=s' => \
$standard,
13 'flags=s' => \
$flags, 'cc=s' => \
$CC, 'tmpdir=s' => \
$tmpdir,
14 'cross' => \
$cross, 'xfail=s' => \
$xfail_str);
15 @headers = split(/,/,join(',',@headers));
17 # List of the headers we are testing.
19 @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
20 "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "uchar.h",
21 "time.h", "tgmath.h", "termios.h", "tar.h", "sys/wait.h",
22 "sys/utsname.h", "sys/un.h", "sys/uio.h", "sys/types.h",
23 "sys/times.h", "sys/timeb.h", "sys/time.h", "sys/statvfs.h",
24 "sys/stat.h", "sys/socket.h", "sys/shm.h", "sys/sem.h",
25 "sys/select.h", "sys/resource.h", "sys/msg.h", "sys/mman.h",
26 "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", "string.h",
27 "stdnoreturn.h", "stdlib.h", "stdio.h", "stdint.h", "stddef.h",
28 "stdbool.h", "stdarg.h", "stdalign.h", "spawn.h", "signal.h",
29 "setjmp.h", "semaphore.h", "search.h", "sched.h", "regex.h",
30 "pwd.h", "pthread.h", "poll.h", "nl_types.h", "netinet/tcp.h",
31 "netinet/in.h", "net/if.h", "netdb.h", "ndbm.h", "mqueue.h",
32 "monetary.h", "math.h", "locale.h", "libgen.h", "limits.h",
33 "langinfo.h", "iso646.h", "inttypes.h", "iconv.h", "grp.h",
34 "glob.h", "ftw.h", "fnmatch.h", "fmtmsg.h", "float.h", "fenv.h",
35 "fcntl.h", "errno.h", "dlfcn.h", "dirent.h", "ctype.h", "cpio.h",
36 "complex.h", "assert.h", "arpa/inet.h", "aio.h");
39 $CFLAGS_namespace = "$flags -fno-builtin $CFLAGS{$standard} -D_ISOMAC";
40 $CFLAGS = "$CFLAGS_namespace '-D__attribute__(x)='";
42 # Check standard name for validity.
43 die "unknown standard \"$standard\"" if ($CFLAGS{$standard} eq "");
45 # if ($standard ne "XOPEN2K8" && $standard ne "POSIX2008") {
46 # # Some headers need a bit more attention. At least with XPG7
47 # # all headers should be self-contained.
48 # $mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
49 # $mustprepend{'glob.h'} = "#include <sys/types.h>\n";
50 # $mustprepend{'grp.h'} = "#include <sys/types.h>\n";
51 # $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
52 # $mustprepend{'pwd.h'} = "#include <sys/types.h>\n";
53 # $mustprepend{'sched.h'} = "#include <sys/types.h>\n";
54 # $mustprepend{'signal.h'} = "#include <pthread.h>\n#include <sys/types.h>\n";
55 # $mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
56 # $mustprepend{'sys/stat.h'} = "#include <sys/types.h>\n";
57 # $mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
58 # $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
61 # These are the ISO C90 keywords.
62 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
63 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
64 'if', 'int', 'long', 'register', 'return',
65 'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
66 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
67 if ($CFLAGS{$standard} =~ /-std=(c99|c1x)/) {
68 push (@keywords, 'inline', 'restrict');
71 # Make a hash table from this information.
72 while ($#keywords >= 0) {
73 $iskeyword{pop (@keywords)} = 1;
87 printf ("Ignoring this failure.\n");
95 my($pattern, $string) = @_;
96 my($strlen) = length ($string);
99 if (substr ($pattern, 0, 1) eq '*') {
100 my($patlen) = length ($pattern) - 1;
101 $res = ($strlen >= $patlen
102 && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
103 } elsif (substr ($pattern, -1, 1) eq '*') {
104 if (substr ($pattern, -2, 1) eq ']') {
105 my($patlen) = index ($pattern, '[');
106 my($range) = substr ($pattern, $patlen + 1, -2);
107 $res = ($strlen > $patlen
108 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen)
109 && index ($range, substr ($string, $patlen, 1)) != -1);
111 my($patlen) = length ($pattern) - 1;
112 $res = ($strlen >= $patlen
113 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
116 $res = $pattern eq $string;
124 my($fnamebase, $msg, $errmsg, $skip, $optional, $xfail) = @_;
135 $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
137 if ($optional != 0) {
138 printf (" $errmsg\n");
143 printf (" $errmsg Compiler message:\n");
151 if ($verbose > 1 && -s
"$fnamebase.out") {
152 # We print all warnings issued.
156 if ($printlog != 0) {
157 printf (" " . "-" x
71 . "\n");
158 open (MESSAGE
, "< $fnamebase.out");
163 printf (" " . "-" x
71 . "\n");
166 unlink "$fnamebase.c";
167 unlink "$fnamebase.o";
168 unlink "$fnamebase.out";
176 my($fnamebase, $msg, $errmsg, $skip, $xfail) = @_;
187 $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
191 printf (" $errmsg Compiler message:\n");
199 # Now run the program. If the exit code is not zero something is wrong.
200 $result = system "$fnamebase > $fnamebase.out2 2>&1";
203 if ($verbose > 1 && -s
"$fnamebase.out") {
204 # We print all warnings issued.
206 system "cat $fnamebase.out2 >> $fnamebase.out";
212 unlink "$fnamebase.out";
213 rename "$fnamebase.out2", "$fnamebase.out";
216 if ($printlog != 0) {
217 printf (" " . "-" x
71 . "\n");
218 open (MESSAGE
, "< $fnamebase.out");
223 printf (" " . "-" x
71 . "\n");
227 unlink "$fnamebase.c";
228 unlink "$fnamebase.o";
229 unlink "$fnamebase.out";
230 unlink "$fnamebase.out2";
237 my($token, @allow) = @_;
240 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
242 for ($idx = 0; $idx <= $#allow; ++$idx) {
243 return if (poorfnmatch
($allow[$idx], $token));
254 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
256 if (exists $errors{$token}) {
257 undef $errors{$token};
263 my($h, $fnamebase, @allow) = @_;
267 # Generate a program to get the contents of this header.
268 open (TESTFILE
, ">$fnamebase.c");
269 print TESTFILE
"#include <$h>\n";
273 open (CONTENT
, "$CC $CFLAGS_namespace -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
274 loop: while (<CONTENT
>) {
276 if (/^#define (.*)/) {
277 newtoken
($1, @allow);
278 } elsif (/^#undef (.*)/) {
281 # We have to tokenize the line.
284 $str =~ s/"[^"]*"//g;
285 foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
287 newtoken
($token, @allow);
293 unlink "$fnamebase.c";
296 # Sort the output list so it's easier to compare results with diff.
297 foreach $f (sort keys(%errors)) {
298 if ($errors{$f} == 1) {
299 if ($realerror == 0) {
300 printf ("FAIL\n " . "-" x
72 . "\n");
304 printf (" Namespace violation: \"%s\"\n", $f);
307 printf (" " . "-" x
72 . "\n") if ($realerror != 0);
310 if ($realerror == 0) {
316 while ($#headers >= 0) {
317 my($h) = pop (@headers);
320 my($fnamebase) = "$tmpdir/$hf-test";
323 my(@allowheader) = ();
324 my(%seenheader) = ();
325 my($prepend) = $mustprepend{$h};
328 printf ("Testing <$h>\n");
329 printf ("----------" . "-" x
length ($h) . "\n");
331 open (CONTROL
, "$CC -E -D$standard -std=c99 -x c data/$h-data |");
332 control
: while (<CONTROL
>) {
334 next control
if (/^#/);
335 next control
if (/^[ ]*$/);
339 # Generate a program to test for the availability of this header.
340 open (TESTFILE
, ">$fnamebase.c");
341 print TESTFILE
"$prepend";
342 print TESTFILE
"#include <$h>\n";
345 $missing = compiletest
($fnamebase, "Checking whether <$h> is available",
346 "Header <$h> not available", 0, 0, 0);
348 last control
if ($missing);
355 } elsif (/^xfail\[([^\]]*)\]-/) {
356 my($xfail_cond) = $1;
357 s/^xfail\[([^\]]*)\]-//;
358 # "xfail[cond]-" or "xfail[cond1|cond2|...]-" means a failure of
359 # the test is allowed if any of the listed conditions are in the
360 # --xfail command-line option argument.
361 if ($xfail_str =~ /\b($xfail_cond)\b/) {
370 if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
371 my($struct) = "$2$3";
377 # Remember that this name is allowed.
378 push @allow, $member;
380 # Generate a program to test for the availability of this member.
381 open (TESTFILE
, ">$fnamebase.c");
382 print TESTFILE
"$prepend";
383 print TESTFILE
"#include <$h>\n";
384 print TESTFILE
"$struct a;\n";
385 print TESTFILE
"$struct b;\n";
386 print TESTFILE
"extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
387 print TESTFILE
"void foobarbaz (void) {\n";
388 print TESTFILE
" xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
389 print TESTFILE
"}\n";
392 $res = compiletest
($fnamebase, "Testing for member $member",
395 : "Member \"$member\" not available."), $res,
398 if ($res == 0 || $missing != 0 || !$optional) {
399 # Test the types of the members.
400 open (TESTFILE
, ">$fnamebase.c");
401 print TESTFILE
"$prepend";
402 print TESTFILE
"#include <$h>\n";
403 print TESTFILE
"$struct a;\n";
404 print TESTFILE
"extern $type b$rest;\n";
405 print TESTFILE
"extern __typeof__ (a.$member) b;\n";
408 compiletest
($fnamebase, "Testing for type of member $member",
409 "Member \"$member\" does not have the correct type.",
412 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_\\'-]*))?/) {
413 my($symbol_type) = $1;
419 my($mres) = $missing;
420 my($cres) = $missing;
422 # Remember that this name is allowed.
423 push @allow, $symbol;
425 if ($symbol_type =~ /macro/) {
426 # Generate a program to test for availability of this macro.
427 open (TESTFILE
, ">$fnamebase.c");
428 print TESTFILE
"$prepend";
429 print TESTFILE
"#include <$h>\n";
430 print TESTFILE
"#ifndef $symbol\n";
431 print TESTFILE
"# error \"Macro $symbol not defined\"\n";
432 print TESTFILE
"#endif\n";
435 $mres = compiletest
($fnamebase, "Test availability of macro $symbol",
438 : "Macro \"$symbol\" is not available."), $res,
442 if ($symbol_type =~ /constant/) {
443 # Generate a program to test for the availability of this constant.
444 open (TESTFILE
, ">$fnamebase.c");
445 print TESTFILE
"$prepend";
446 print TESTFILE
"#include <$h>\n";
447 print TESTFILE
"__typeof__ ($symbol) a = $symbol;\n";
450 $cres = compiletest
($fnamebase, "Testing for constant $symbol",
453 : "Constant \"$symbol\" not available."), $res,
457 $res = $res || $mres || $cres;
459 if ($symbol_type eq "macro-int-constant" && ($res == 0 || !$optional)) {
460 # Test that the symbol is usable in #if.
461 open (TESTFILE
, ">$fnamebase.c");
462 print TESTFILE
"$prepend";
463 print TESTFILE
"#include <$h>\n";
464 print TESTFILE
"#if $symbol < 0\n";
465 print TESTFILE
"# define conformtest_negative 1\n";
467 for (my $i = 0; $i < 63; $i++) {
468 print TESTFILE
"# if $symbol & (1LL << $i)\n";
469 print TESTFILE
"# define conformtest_bit_$i 0LL\n";
470 print TESTFILE
"# else\n";
471 print TESTFILE
"# define conformtest_bit_$i (1LL << $i)\n";
472 print TESTFILE
"# endif\n";
473 $s .= "|conformtest_bit_$i";
475 print TESTFILE
"# define conformtest_value ~($s)\n";
476 print TESTFILE
"#else\n";
477 print TESTFILE
"# define conformtest_negative 0\n";
479 for (my $i = 0; $i < 64; $i++) {
480 print TESTFILE
"# if $symbol & (1ULL << $i)\n";
481 print TESTFILE
"# define conformtest_bit_$i (1ULL << $i)\n";
482 print TESTFILE
"# else\n";
483 print TESTFILE
"# define conformtest_bit_$i 0ULL\n";
484 print TESTFILE
"# endif\n";
485 $s .= "|conformtest_bit_$i";
487 print TESTFILE
"# define conformtest_value ($s)\n";
488 print TESTFILE
"#endif\n";
489 print TESTFILE
"_Static_assert ((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value), \"value match inside and outside #if\");\n";
492 compiletest
($fnamebase, "Testing for #if usability of symbol $symbol",
493 "Symbol \"$symbol\" not usable in #if.", $res, 0, $xfail);
496 if (defined ($type) && ($res == 0 || !$optional)) {
497 # Test the type of the symbol.
498 open (TESTFILE
, ">$fnamebase.c");
499 print TESTFILE
"$prepend";
500 print TESTFILE
"#include <$h>\n";
501 if ($type =~ /^promoted:/) {
502 $type =~ s/^promoted://;
503 print TESTFILE
"__typeof__ (($type) 0 + ($type) 0) a;\n";
505 print TESTFILE
"__typeof__ (($type) 0) a;\n";
507 print TESTFILE
"extern __typeof__ ($symbol) a;\n";
510 compiletest
($fnamebase, "Testing for type of symbol $symbol",
511 "Symbol \"$symbol\" does not have the correct type.",
515 if (defined ($op) && ($res == 0 || !$optional)) {
516 # Generate a program to test for the value of this symbol.
517 open (TESTFILE
, ">$fnamebase.c");
518 print TESTFILE
"$prepend";
519 print TESTFILE
"#include <$h>\n";
520 print TESTFILE
"_Static_assert ($symbol $op $value, \"value constraint\");\n";
523 $res = compiletest
($fnamebase, "Testing for value of symbol $symbol",
524 "Symbol \"$symbol\" has not the right value.",
527 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
532 # Remember that this name is allowed.
533 push @allow, $symbol;
535 # Generate a program to test for the availability of this constant.
536 open (TESTFILE
, ">$fnamebase.c");
537 print TESTFILE
"$prepend";
538 print TESTFILE
"#include <$h>\n";
539 print TESTFILE
"void foobarbaz (void) {\n";
540 print TESTFILE
"__typeof__ ($symbol) a = $symbol;\n";
541 print TESTFILE
"}\n";
544 $res = compiletest
($fnamebase, "Testing for symbol $symbol",
545 "Symbol \"$symbol\" not available.", $res, 0, $xfail);
548 # Generate a program to test for the value of this constant.
549 open (TESTFILE
, ">$fnamebase.c");
550 print TESTFILE
"$prepend";
551 print TESTFILE
"#include <$h>\n";
552 print TESTFILE
"int main (void) { return $symbol != $value; }\n";
555 $res = runtest
($fnamebase, "Testing for value of symbol $symbol",
556 "Symbol \"$symbol\" has not the right value.", $res,
559 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
561 my($maybe_opaque) = 0;
563 # Remember that this name is allowed.
564 if ($type =~ /^struct *(.*)/) {
566 } elsif ($type =~ /^union *(.*)/) {
573 # Generate a program to test for the availability of this type.
574 open (TESTFILE
, ">$fnamebase.c");
575 print TESTFILE
"$prepend";
576 print TESTFILE
"#include <$h>\n";
577 if ($maybe_opaque == 1) {
578 print TESTFILE
"$type *a;\n";
580 print TESTFILE
"$type a;\n";
584 compiletest
($fnamebase, "Testing for type $type",
587 : "Type \"$type\" not available."), $missing, $optional,
589 } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) {
592 # Remember that this name is allowed.
593 if ($type =~ /^struct *(.*)/) {
595 } elsif ($type =~ /^union *(.*)/) {
601 # Generate a program to test for the availability of this type.
602 open (TESTFILE
, ">$fnamebase.c");
603 print TESTFILE
"$prepend";
604 print TESTFILE
"#include <$h>\n";
605 print TESTFILE
"$type;\n";
608 compiletest
($fnamebase, "Testing for type $type",
609 "Type \"$type\" not available.", $missing, 0, $xfail);
610 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
611 my($rettype) = "$2$3";
616 # Remember that this name is allowed.
619 # Generate a program to test for availability of this function.
620 open (TESTFILE
, ">$fnamebase.c");
621 print TESTFILE
"$prepend";
622 print TESTFILE
"#include <$h>\n";
623 # print TESTFILE "#undef $fname\n";
624 print TESTFILE
"$rettype (*(*foobarbaz) $args = $fname;\n";
627 $res = compiletest
($fnamebase, "Test availability of function $fname",
630 : "Function \"$fname\" is not available."), $res,
633 if ($res == 0 || $missing == 1 || !$optional) {
634 # Generate a program to test for the type of this function.
635 open (TESTFILE
, ">$fnamebase.c");
636 print TESTFILE
"$prepend";
637 print TESTFILE
"#include <$h>\n";
638 # print TESTFILE "#undef $fname\n";
639 print TESTFILE
"extern $rettype (*(*foobarbaz) $args;\n";
640 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
643 compiletest
($fnamebase, "Test for type of function $fname",
644 "Function \"$fname\" has incorrect type.", $res, 0,
647 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
648 my($rettype) = "$2$3";
653 # Remember that this name is allowed.
656 # Generate a program to test for availability of this function.
657 open (TESTFILE
, ">$fnamebase.c");
658 print TESTFILE
"$prepend";
659 print TESTFILE
"#include <$h>\n";
660 # print TESTFILE "#undef $fname\n";
661 print TESTFILE
"$rettype (*foobarbaz) $args = $fname;\n";
664 $res = compiletest
($fnamebase, "Test availability of function $fname",
667 : "Function \"$fname\" is not available."), $res,
670 if ($res == 0 || $missing != 0 || !$optional) {
671 # Generate a program to test for the type of this function.
672 open (TESTFILE
, ">$fnamebase.c");
673 print TESTFILE
"$prepend";
674 print TESTFILE
"#include <$h>\n";
675 # print TESTFILE "#undef $fname\n";
676 print TESTFILE
"extern $rettype (*foobarbaz) $args;\n";
677 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
680 compiletest
($fnamebase, "Test for type of function $fname",
681 "Function \"$fname\" has incorrect type.", $res, 0,
684 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
690 # Remember that this name is allowed.
693 # Generate a program to test for availability 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
"typedef $type xyzzy$rest;\n";
699 print TESTFILE
"$xyzzy *foobarbaz = &$vname;\n";
702 $res = compiletest
($fnamebase, "Test availability of variable $vname",
703 "Variable \"$vname\" is not available.", $res, 0,
706 # Generate a program to test for the type of this function.
707 open (TESTFILE
, ">$fnamebase.c");
708 print TESTFILE
"$prepend";
709 print TESTFILE
"#include <$h>\n";
710 # print TESTFILE "#undef $fname\n";
711 print TESTFILE
"extern $type $vname$rest;\n";
714 compiletest
($fnamebase, "Test for type of variable $fname",
715 "Variable \"$vname\" has incorrect type.", $res, 0, $xfail);
716 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
717 my($rettype) = "$2$3";
722 # Remember that this name is allowed.
725 # Generate a program to test for availability 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
"$rettype (*foobarbaz) $args = $fname;\n";
731 print TESTFILE
"#endif\n";
734 $res = compiletest
($fnamebase, "Test availability of macro $fname",
735 "Function \"$fname\" is not available.", $res, 0,
738 # Generate a program to test for the type of this function.
739 open (TESTFILE
, ">$fnamebase.c");
740 print TESTFILE
"$prepend";
741 print TESTFILE
"#include <$h>\n";
742 print TESTFILE
"#ifndef $fname\n";
743 print TESTFILE
"extern $rettype (*foobarbaz) $args;\n";
744 print TESTFILE
"extern __typeof__ (&$fname) foobarbaz;\n";
745 print TESTFILE
"#endif\n";
748 compiletest
($fnamebase, "Test for type of macro $fname",
749 "Function \"$fname\" has incorrect type.", $res, 0, $xfail);
750 } elsif (/^macro-str *([^ ]*) *(\".*\")/) {
751 # The above regex doesn't handle a \" in a string.
756 # Remember that this name is allowed.
759 # Generate a program to test for availability of this macro.
760 open (TESTFILE
, ">$fnamebase.c");
761 print TESTFILE
"$prepend";
762 print TESTFILE
"#include <$h>\n";
763 print TESTFILE
"#ifndef $macro\n";
764 print TESTFILE
"# error \"Macro $macro not defined\"\n";
765 print TESTFILE
"#endif\n";
768 compiletest
($fnamebase, "Test availability of macro $macro",
769 "Macro \"$macro\" is not available.", $missing, 0, $xfail);
771 # Generate a program to test for the value of this macro.
772 open (TESTFILE
, ">$fnamebase.c");
773 print TESTFILE
"$prepend";
774 print TESTFILE
"#include <$h>\n";
775 # We can't include <string.h> here.
776 print TESTFILE
"extern int (strcmp)(const char *, const char *);\n";
777 print TESTFILE
"int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
780 $res = runtest
($fnamebase, "Testing for value of macro $macro",
781 "Macro \"$macro\" has not the right value.", $res,
783 } elsif (/^allow-header *(.*)/) {
785 if ($seenheader{$pattern} != 1) {
786 push @allowheader, $pattern;
787 $seenheader{$pattern} = 1;
790 } elsif (/^allow *(.*)/) {
792 push @allow, $pattern;
795 # printf ("line is `%s'\n", $_);
803 # Read the data files for the header files which are allowed to be included.
804 while ($#allowheader >= 0) {
805 my($ah) = pop @allowheader;
807 open (ALLOW
, "$CC -E -D$standard -x c data/$ah-data |");
808 acontrol
: while (<ALLOW
>) {
810 next acontrol
if (/^#/);
811 next acontrol
if (/^[ ]*$/);
813 s/^xfail(\[([^\]]*)\])?-//;
815 if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
817 } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
819 } elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
822 # Remember that this name is allowed.
823 if ($type =~ /^struct *(.*)/) {
825 } elsif ($type =~ /^union *(.*)/) {
830 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
832 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
834 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
836 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
838 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
840 } elsif (/^allow-header *(.*)/) {
841 if ($seenheader{$1} != 1) {
842 push @allowheader, $1;
845 } elsif (/^allow *(.*)/) {
853 printf (" Not defined\n");
855 # Now check the namespace.
856 printf (" Checking the namespace of \"%s\"... ", $h);
861 checknamespace
($h, $fnamebase, @allow);
868 printf "-" x
76 . "\n";
869 printf (" Total number of tests : %4d\n", $total);
871 printf (" Number of failed tests : %4d (", $errors);
872 $percent = ($errors * 100) / $total;
873 if ($errors > 0 && $percent < 1.0) {
876 printf ("%3d%%)\n", $percent);
879 printf (" Number of xfailed tests : %4d (", $xerrors);
880 $percent = ($xerrors * 100) / $total;
881 if ($xerrors > 0 && $percent < 1.0) {
884 printf ("%3d%%)\n", $percent);
887 printf (" Number of skipped tests : %4d (", $skipped);
888 $percent = ($skipped * 100) / $total;
889 if ($skipped > 0 && $percent < 1.0) {
892 printf ("%3d%%)\n", $percent);
897 # perl-indent-level: 2