6 $standard = "XOPEN2K8";
9 GetOptions ('headers=s' => \@headers, 'standard=s' => \$standard,
10 'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir);
11 @headers = split(/,/,join(',',@headers));
13 # List of the headers we are testing.
15 @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
16 "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "uchar.h",
17 "time.h", "tgmath.h", "termios.h", "tar.h", "sys/wait.h",
18 "sys/utsname.h", "sys/un.h", "sys/uio.h", "sys/types.h",
19 "sys/times.h", "sys/timeb.h", "sys/time.h", "sys/statvfs.h",
20 "sys/stat.h", "sys/socket.h", "sys/shm.h", "sys/sem.h",
21 "sys/select.h", "sys/resource.h", "sys/msg.h", "sys/mman.h",
22 "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", "string.h",
23 "stdlib.h", "stdio.h", "stdint.h", "stddef.h", "stdarg.h",
24 "spawn.h", "signal.h", "setjmp.h", "semaphore.h", "search.h",
25 "sched.h", "regex.h", "pwd.h", "pthread.h", "poll.h",
26 "nl_types.h", "netinet/tcp.h", "netinet/in.h", "net/if.h",
27 "netdb.h", "ndbm.h", "mqueue.h", "monetary.h", "math.h",
28 "locale.h", "libgen.h", "limits.h", "langinfo.h", "iso646.h",
29 "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h", "fnmatch.h",
30 "fmtmsg.h", "float.h", "fcntl.h", "errno.h", "dlfcn.h",
31 "dirent.h", "ctype.h", "cpio.h", "complex.h", "assert.h",
32 "arpa/inet.h", "aio.h");
35 $CFLAGS{"ISO"} = "-ansi";
36 $CFLAGS{"ISO99"} = "-std=c99";
37 $CFLAGS{"ISO11"} = "-std=c1x -D_ISOC11_SOURCE";
38 $CFLAGS{"POSIX"} = "-D_POSIX_C_SOURCE=199912 -ansi";
39 $CFLAGS{"XPG3"} = "-ansi -D_XOPEN_SOURCE";
40 $CFLAGS{"XPG4"} = "-ansi -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";
41 $CFLAGS{"UNIX98"} = "-ansi -D_XOPEN_SOURCE=500";
42 $CFLAGS{"XOPEN2K"} = "-std=c99 -D_XOPEN_SOURCE=600";
43 $CFLAGS{"XOPEN2K8"} = "-std=c99 -D_XOPEN_SOURCE=700";
44 $CFLAGS{"POSIX2008"} = "-std=c99 -D_POSIX_C_SOURCE=200809L";
46 $CFLAGS = "$flags -fno-builtin '-D__attribute__(x)=' $CFLAGS{$standard} -D_ISOMAC";
48 # Check standard name for validity.
49 die "unknown standard \"$standard\"" if ($CFLAGS{$standard} eq "");
51 # if ($standard ne "XOPEN2K8" && $standard ne "POSIX2008") {
52 # # Some headers need a bit more attention. At least with XPG7
53 # # all headers should be self-contained.
54 # $mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
55 # $mustprepend{'glob.h'} = "#include <sys/types.h>\n";
56 # $mustprepend{'grp.h'} = "#include <sys/types.h>\n";
57 # $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
58 # $mustprepend{'pwd.h'} = "#include <sys/types.h>\n";
59 # $mustprepend{'sched.h'} = "#include <sys/types.h>\n";
60 # $mustprepend{'signal.h'} = "#include <pthread.h>\n#include <sys/types.h>\n";
61 # $mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
62 # $mustprepend{'sys/stat.h'} = "#include <sys/types.h>\n";
63 # $mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
64 # $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
67 # These are the ISO C99 keywords.
68 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
69 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
70 'if', 'inline', 'int', 'long', 'register', 'restrict', 'return',
71 'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
72 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
74 # Make a hash table from this information.
75 while ($#keywords >= 0) {
76 $iskeyword{pop (@keywords)} = 1;
87 my($pattern, $string) = @_;
88 my($strlen) = length ($string);
91 if (substr ($pattern, 0, 1) eq '*') {
92 my($patlen) = length ($pattern) - 1;
93 $res = ($strlen >= $patlen
94 && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
95 } elsif (substr ($pattern, -1, 1) eq '*') {
96 if (substr ($pattern, -2, 1) eq ']') {
97 my($patlen) = index ($pattern, '[');
98 my($range) = substr ($pattern, $patlen + 1, -2);
99 $res = ($strlen > $patlen
100 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen)
101 && index ($range, substr ($string, $patlen, 1)) != -1);
103 my($patlen) = length ($pattern) - 1;
104 $res = ($strlen >= $patlen
105 && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
108 $res = $pattern eq $string;
116 my($fnamebase, $msg, $errmsg, $skip, $optional) = @_;
127 $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
129 if ($optional != 0) {
130 printf (" $errmsg\n");
135 printf (" $errmsg Compiler message:\n");
143 if ($verbose > 1 && -s "$fnamebase.out") {
144 # We print all warnings issued.
148 if ($printlog != 0) {
149 printf (" " . "-" x 71 . "\n");
150 open (MESSAGE, "< $fnamebase.out");
155 printf (" " . "-" x 71 . "\n");
158 unlink "$fnamebase.c";
159 unlink "$fnamebase.o";
160 unlink "$fnamebase.out";
168 my($fnamebase, $msg, $errmsg, $skip) = @_;
179 $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
183 printf (" $errmsg Compiler message:\n");
189 # Now run the program. If the exit code is not zero something is wrong.
190 $result = system "$fnamebase > $fnamebase.out2 2>&1";
193 if ($verbose > 1 && -s "$fnamebase.out") {
194 # We print all warnings issued.
196 system "cat $fnamebase.out2 >> $fnamebase.out";
202 unlink "$fnamebase.out";
203 rename "$fnamebase.out2", "$fnamebase.out";
206 if ($printlog != 0) {
207 printf (" " . "-" x 71 . "\n");
208 open (MESSAGE, "< $fnamebase.out");
213 printf (" " . "-" x 71 . "\n");
217 unlink "$fnamebase.c";
218 unlink "$fnamebase.o";
219 unlink "$fnamebase.out";
220 unlink "$fnamebase.out2";
227 my($token, @allow) = @_;
230 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
232 for ($idx = 0; $idx <= $#allow; ++$idx) {
233 return if (poorfnmatch ($allow[$idx], $token));
242 return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
244 if (exists $errors{$token}) {
245 undef $errors{$token};
251 my($h, $fnamebase, @allow) = @_;
255 # Generate a program to get the contents of this header.
256 open (TESTFILE, ">$fnamebase.c");
257 print TESTFILE "#include <$h>\n";
262 open (CONTENT, "$CC $CFLAGS -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
263 loop: while (<CONTENT>) {
265 if (/^#define (.*)/) {
266 newtoken ($1, @allow);
267 } elsif (/^#undef (.*)/) {
270 # We have to tokenize the line.
273 my($len) = length ($str);
275 foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
277 newtoken ($token, @allow);
283 unlink "$fnamebase.c";
286 # Sort the output list so it's easier to compare results with diff.
287 foreach $f (sort keys(%errors)) {
288 if ($errors{$f} == 1) {
289 if ($realerror == 0) {
290 printf ("FAIL\n " . "-" x 72 . "\n");
294 printf (" Namespace violation: \"%s\"\n", $f);
297 printf (" " . "-" x 72 . "\n") if ($realerror != 0);
300 if ($realerror == 0) {
306 while ($#headers >= 0) {
307 my($h) = pop (@headers);
310 my($fnamebase) = "$tmpdir/$hf-test";
313 my(@allowheader) = ();
314 my(%seenheader) = ();
315 my($prepend) = $mustprepend{$h};
318 printf ("Testing <$h>\n");
319 printf ("----------" . "-" x length ($h) . "\n");
321 open (CONTROL, "$CC -E -D$standard -x c data/$h-data |");
322 control: while (<CONTROL>) {
324 next control if (/^#/);
325 next control if (/^[ ]*$/);
329 # Generate a program to test for the availability of this header.
330 open (TESTFILE, ">$fnamebase.c");
331 print TESTFILE "$prepend";
332 print TESTFILE "#include <$h>\n";
335 $missing = compiletest ($fnamebase, "Checking whether <$h> is available",
336 "Header <$h> not available", 0, 0);
338 last control if ($missing);
346 if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
347 my($struct) = "$2$3";
353 # Remember that this name is allowed.
354 push @allow, $member;
356 # Generate a program to test for the availability of this member.
357 open (TESTFILE, ">$fnamebase.c");
358 print TESTFILE "$prepend";
359 print TESTFILE "#include <$h>\n";
360 print TESTFILE "$struct a;\n";
361 print TESTFILE "$struct b;\n";
362 print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
363 print TESTFILE "void foobarbaz (void) {\n";
364 print TESTFILE " xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
365 print TESTFILE "}\n";
368 $res = compiletest ($fnamebase, "Testing for member $member",
371 : "Member \"$member\" not available."), $res,
374 if ($res == 0 || $missing != 0 || !$optional) {
375 # Test the types of the members.
376 open (TESTFILE, ">$fnamebase.c");
377 print TESTFILE "$prepend";
378 print TESTFILE "#include <$h>\n";
379 print TESTFILE "$struct a;\n";
380 print TESTFILE "extern $type b$rest;\n";
381 print TESTFILE "extern __typeof__ (a.$member) b;\n";
384 compiletest ($fnamebase, "Testing for type of member $member",
385 "Member \"$member\" does not have the correct type.",
388 } elsif (/^constant *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
394 # Remember that this name is allowed.
397 # Generate a program to test for the availability of this constant.
398 open (TESTFILE, ">$fnamebase.c");
399 print TESTFILE "$prepend";
400 print TESTFILE "#include <$h>\n";
401 print TESTFILE "__typeof__ ($const) a = $const;\n";
404 $res = compiletest ($fnamebase, "Testing for constant $const",
407 : "Constant \"$const\" not available."), $res,
410 if (defined ($op) && ($res == 0 || !$optional)) {
411 # Generate a program to test for the value of this constant.
412 open (TESTFILE, ">$fnamebase.c");
413 print TESTFILE "$prepend";
414 print TESTFILE "#include <$h>\n";
415 # Negate the value since 0 means ok
416 print TESTFILE "int main (void) { return !($const $op $value); }\n";
419 $res = runtest ($fnamebase, "Testing for value of constant $const",
420 "Constant \"$const\" has not the right value.", $res);
422 } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_-]*)?/) {
428 # Remember that this name is allowed.
431 # Generate a program to test for the availability of this constant.
432 open (TESTFILE, ">$fnamebase.c");
433 print TESTFILE "$prepend";
434 print TESTFILE "#include <$h>\n";
435 print TESTFILE "__typeof__ ($const) a = $const;\n";
438 $res = compiletest ($fnamebase, "Testing for constant $const",
439 "Constant \"$const\" not available.", $res, 0);
441 # Test the types of the members.
442 open (TESTFILE, ">$fnamebase.c");
443 print TESTFILE "$prepend";
444 print TESTFILE "#include <$h>\n";
445 print TESTFILE "__typeof__ (($type) 0) a;\n";
446 print TESTFILE "extern __typeof__ ($const) a;\n";
449 compiletest ($fnamebase, "Testing for type of constant $const",
450 "Constant \"$const\" does not have the correct type.",
454 # Generate a program to test for the value of this constant.
455 open (TESTFILE, ">$fnamebase.c");
456 print TESTFILE "$prepend";
457 print TESTFILE "#include <$h>\n";
458 print TESTFILE "int main (void) { return $const != $value; }\n";
461 $res = runtest ($fnamebase, "Testing for value of constant $const",
462 "Constant \"$const\" has not the right value.", $res);
464 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
469 # Remember that this name is allowed.
470 push @allow, $symbol;
472 # Generate a program to test for the availability of this constant.
473 open (TESTFILE, ">$fnamebase.c");
474 print TESTFILE "$prepend";
475 print TESTFILE "#include <$h>\n";
476 print TESTFILE "void foobarbaz (void) {\n";
477 print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
478 print TESTFILE "}\n";
481 $res = compiletest ($fnamebase, "Testing for symbol $symbol",
482 "Symbol \"$symbol\" not available.", $res, 0);
485 # Generate a program to test for the value of this constant.
486 open (TESTFILE, ">$fnamebase.c");
487 print TESTFILE "$prepend";
488 print TESTFILE "#include <$h>\n";
489 print TESTFILE "int main (void) { return $symbol != $value; }\n";
492 $res = runtest ($fnamebase, "Testing for value of symbol $symbol",
493 "Symbol \"$symbol\" has not the right value.", $res);
495 } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
497 my($maybe_opaque) = 0;
499 # Remember that this name is allowed.
500 if ($type =~ /^struct *(.*)/) {
502 } elsif ($type =~ /^union *(.*)/) {
509 # Generate a program to test for the availability of this type.
510 open (TESTFILE, ">$fnamebase.c");
511 print TESTFILE "$prepend";
512 print TESTFILE "#include <$h>\n";
513 if ($maybe_opaque == 1) {
514 print TESTFILE "$type *a;\n";
516 print TESTFILE "$type a;\n";
520 compiletest ($fnamebase, "Testing for type $type",
523 : "Type \"$type\" not available."), $missing, $optional);
524 } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) {
527 # Remember that this name is allowed.
528 if ($type =~ /^struct *(.*)/) {
530 } elsif ($type =~ /^union *(.*)/) {
536 # Generate a program to test for the availability of this type.
537 open (TESTFILE, ">$fnamebase.c");
538 print TESTFILE "$prepend";
539 print TESTFILE "#include <$h>\n";
540 print TESTFILE "$type;\n";
543 compiletest ($fnamebase, "Testing for type $type",
544 "Type \"$type\" not available.", $missing, 0);
545 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
546 my($rettype) = "$2$3";
551 # Remember that this name is allowed.
554 # Generate a program to test for availability of this function.
555 open (TESTFILE, ">$fnamebase.c");
556 print TESTFILE "$prepend";
557 print TESTFILE "#include <$h>\n";
558 # print TESTFILE "#undef $fname\n";
559 print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
562 $res = compiletest ($fnamebase, "Test availability of function $fname",
565 : "Function \"$fname\" is not available."), $res,
568 if ($res == 0 || $missing == 1 || !$optional) {
569 # Generate a program to test for the type of this function.
570 open (TESTFILE, ">$fnamebase.c");
571 print TESTFILE "$prepend";
572 print TESTFILE "#include <$h>\n";
573 # print TESTFILE "#undef $fname\n";
574 print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
575 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
578 compiletest ($fnamebase, "Test for type of function $fname",
579 "Function \"$fname\" has incorrect type.", $res, 0);
581 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
582 my($rettype) = "$2$3";
587 # Remember that this name is allowed.
590 # Generate a program to test for availability of this function.
591 open (TESTFILE, ">$fnamebase.c");
592 print TESTFILE "$prepend";
593 print TESTFILE "#include <$h>\n";
594 # print TESTFILE "#undef $fname\n";
595 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
598 $res = compiletest ($fnamebase, "Test availability of function $fname",
601 : "Function \"$fname\" is not available."), $res,
604 if ($res == 0 || $missing != 0 || !$optional) {
605 # Generate a program to test for the type of this function.
606 open (TESTFILE, ">$fnamebase.c");
607 print TESTFILE "$prepend";
608 print TESTFILE "#include <$h>\n";
609 # print TESTFILE "#undef $fname\n";
610 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
611 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
614 compiletest ($fnamebase, "Test for type of function $fname",
615 "Function \"$fname\" has incorrect type.", $res, 0);
617 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
623 # Remember that this name is allowed.
626 # Generate a program to test for availability of this function.
627 open (TESTFILE, ">$fnamebase.c");
628 print TESTFILE "$prepend";
629 print TESTFILE "#include <$h>\n";
630 # print TESTFILE "#undef $fname\n";
631 print TESTFILE "typedef $type xyzzy$rest;\n";
632 print TESTFILE "$xyzzy *foobarbaz = &$vname;\n";
635 $res = compiletest ($fnamebase, "Test availability of variable $vname",
636 "Variable \"$vname\" is not available.", $res, 0);
638 # Generate a program to test for the type of this function.
639 open (TESTFILE, ">$fnamebase.c");
640 print TESTFILE "$prepend";
641 print TESTFILE "#include <$h>\n";
642 # print TESTFILE "#undef $fname\n";
643 print TESTFILE "extern $type $vname$rest;\n";
646 compiletest ($fnamebase, "Test for type of variable $fname",
647 "Variable \"$vname\" has incorrect type.", $res, 0);
648 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
649 my($rettype) = "$2$3";
654 # Remember that this name is allowed.
657 # Generate a program to test for availability of this function.
658 open (TESTFILE, ">$fnamebase.c");
659 print TESTFILE "$prepend";
660 print TESTFILE "#include <$h>\n";
661 print TESTFILE "#ifndef $fname\n";
662 print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
663 print TESTFILE "#endif\n";
666 $res = compiletest ($fnamebase, "Test availability of macro $fname",
667 "Function \"$fname\" is not available.", $res, 0);
669 # Generate a program to test for the type of this function.
670 open (TESTFILE, ">$fnamebase.c");
671 print TESTFILE "$prepend";
672 print TESTFILE "#include <$h>\n";
673 print TESTFILE "#ifndef $fname\n";
674 print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
675 print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
676 print TESTFILE "#endif\n";
679 compiletest ($fnamebase, "Test for type of macro $fname",
680 "Function \"$fname\" has incorrect type.", $res, 0);
681 } elsif (/^macro-str *([^ ]*) *(\".*\")/) {
682 # The above regex doesn't handle a \" in a string.
687 # Remember that this name is allowed.
690 # Generate a program to test for availability of this macro.
691 open (TESTFILE, ">$fnamebase.c");
692 print TESTFILE "$prepend";
693 print TESTFILE "#include <$h>\n";
694 print TESTFILE "#ifndef $macro\n";
695 print TESTFILE "# error \"Macro $macro not defined\"\n";
696 print TESTFILE "#endif\n";
699 compiletest ($fnamebase, "Test availability of macro $macro",
700 "Macro \"$macro\" is not available.", $missing, 0);
702 # Generate a program to test for the value of this macro.
703 open (TESTFILE, ">$fnamebase.c");
704 print TESTFILE "$prepend";
705 print TESTFILE "#include <$h>\n";
706 # We can't include <string.h> here.
707 print TESTFILE "extern int (strcmp)(const char *, const char *);\n";
708 print TESTFILE "int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
711 $res = runtest ($fnamebase, "Testing for value of macro $macro",
712 "Macro \"$macro\" has not the right value.", $res);
713 } elsif (/^macro *([a-zA-Z0-9_]*) *([>=<!]+) ([A-Za-z0-9_]*)/) {
719 # Remember that this name is allowed.
722 # Generate a program to test for availability of this macro.
723 open (TESTFILE, ">$fnamebase.c");
724 print TESTFILE "$prepend";
725 print TESTFILE "#include <$h>\n";
726 print TESTFILE "#ifndef $macro\n";
727 print TESTFILE "# error \"Macro $macro not defined\"\n";
728 print TESTFILE "#endif\n";
731 $res = compiletest ($fnamebase, "Test availability of macro $macro",
734 : "Macro \"$macro\" is not available."), $res,
737 if ($value ne "" && ($res == 0 || !$optional)) {
738 # Generate a program to test for the value of this constant.
739 open (TESTFILE, ">$fnamebase.c");
740 print TESTFILE "$prepend";
741 print TESTFILE "#include <$h>\n";
742 # Negate the value since 0 means ok
743 print TESTFILE "int main (void) { return !($macro $op $value); }\n";
746 $res = runtest ($fnamebase, "Testing for value of macro $macro",
747 "Macro \"$macro\" has not the right value.", $res);
749 } elsif (/^macro *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)/) {
754 # Remember that this name is allowed.
757 # Generate a program to test for availability of this macro.
758 open (TESTFILE, ">$fnamebase.c");
759 print TESTFILE "$prepend";
760 print TESTFILE "#include <$h>\n";
761 print TESTFILE "#ifndef $macro\n";
762 print TESTFILE "# error \"Macro $macro not defined\"\n";
763 print TESTFILE "#endif\n";
766 $res = compiletest ($fnamebase, "Test availability of macro $macro",
769 : "Macro \"$macro\" is not available."), $res,
772 if ($value ne "" && ($res == 0 || !$optional)) {
773 # Generate a program to test for the value of this constant.
774 open (TESTFILE, ">$fnamebase.c");
775 print TESTFILE "$prepend";
776 print TESTFILE "#include <$h>\n";
777 # Negate the value since 0 means ok
778 print TESTFILE "int main (void) { return !($macro == $value); }\n";
781 $res = runtest ($fnamebase, "Testing for value of macro $macro",
782 "Macro \"$macro\" has not the right value.", $res);
784 } elsif (/^macro *([^ ]*)/) {
787 # Remember that this name is allowed.
790 # Generate a program to test for availability of this macro.
791 open (TESTFILE, ">$fnamebase.c");
792 print TESTFILE "$prepend";
793 print TESTFILE "#include <$h>\n";
794 print TESTFILE "#ifndef $macro\n";
795 print TESTFILE "# error \"Macro $macro not defined\"\n";
796 print TESTFILE "#endif\n";
799 compiletest ($fnamebase, "Test availability of macro $macro",
802 : "Macro \"$macro\" is not available."), $missing,
804 } elsif (/^allow-header *(.*)/) {
806 if ($seenheader{$pattern} != 1) {
807 push @allowheader, $pattern;
808 $seenheader{$pattern} = 1;
811 } elsif (/^allow *(.*)/) {
813 push @allow, $pattern;
816 # printf ("line is `%s'\n", $_);
824 # Read the data files for the header files which are allowed to be included.
825 while ($#allowheader >= 0) {
826 my($ah) = pop @allowheader;
828 open (ALLOW, "$CC -E -D$standard - < data/$ah-data |");
829 acontrol: while (<ALLOW>) {
831 next acontrol if (/^#/);
832 next acontrol if (/^[ ]*$/);
834 if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
836 } elsif (/^constant *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
838 } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) {
840 } elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
843 # Remember that this name is allowed.
844 if ($type =~ /^struct *(.*)/) {
846 } elsif ($type =~ /^union *(.*)/) {
851 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
853 } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
855 } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
857 } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
859 } elsif (/^macro *([^ ]*)/) {
861 } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
863 } elsif (/^allow-header *(.*)/) {
864 if ($seenheader{$1} != 1) {
865 push @allowheader, $1;
868 } elsif (/^allow *(.*)/) {
876 printf (" Not defined\n");
878 # Now check the namespace.
879 printf (" Checking the namespace of \"%s\"... ", $h);
884 checknamespace ($h, $fnamebase, @allow);
891 printf "-" x 76 . "\n";
892 printf (" Total number of tests : %4d\n", $total);
894 printf (" Number of failed tests : %4d (", $errors);
895 $percent = ($errors * 100) / $total;
896 if ($errors > 0 && $percent < 1.0) {
899 printf ("%3d%%)\n", $percent);
902 printf (" Number of skipped tests : %4d (", $skipped);
903 $percent = ($skipped * 100) / $total;
904 if ($skipped > 0 && $percent < 1.0) {
907 printf ("%3d%%)\n", $percent);
912 # perl-indent-level: 2