X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=conform%2Fconformtest.pl;h=dc3712ea66fd1bb7bea5aeb6f3550059572d552d;hb=d22956c99b81958fdfb8437361f92b9d8a6e7984;hp=6a780203ceb06b5f0b4382b5ade23750c835f1ee;hpb=d94a4670800de6e8f088b8630ad5142866127980;p=platform%2Fupstream%2Fglibc.git diff --git a/conform/conformtest.pl b/conform/conformtest.pl index 6a78020..dc3712e 100644 --- a/conform/conformtest.pl +++ b/conform/conformtest.pl @@ -3,11 +3,11 @@ use Getopt::Long; use POSIX; +$standard = "XOPEN2K8"; $CC = "gcc"; - -$standard="XOPEN2K8"; +$tmpdir = "/tmp"; GetOptions ('headers=s' => \@headers, 'standard=s' => \$standard, - 'flags=s' => \$flags, 'cc=s' => \$CC); + 'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir); @headers = split(/,/,join(',',@headers)); # List of the headers we are testing. @@ -36,10 +36,10 @@ $CFLAGS{"ISO"} = "-ansi"; $CFLAGS{"ISO99"} = "-std=c99"; $CFLAGS{"ISO11"} = "-std=c1x -D_ISOC11_SOURCE"; $CFLAGS{"POSIX"} = "-D_POSIX_C_SOURCE=199912 -ansi"; -$CFLAGS{"XPG3"} = "-D_XOPEN_SOURCE"; -$CFLAGS{"XPG4"} = "-D_XOPEN_SOURCE_EXTENDED"; -$CFLAGS{"UNIX98"} = "-D_XOPEN_SOURCE=500"; -$CFLAGS{"XOPEN2K"} = "-D_XOPEN_SOURCE=600"; +$CFLAGS{"XPG3"} = "-ansi -D_XOPEN_SOURCE"; +$CFLAGS{"XPG4"} = "-ansi -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"; +$CFLAGS{"UNIX98"} = "-ansi -D_XOPEN_SOURCE=500"; +$CFLAGS{"XOPEN2K"} = "-std=c99 -D_XOPEN_SOURCE=600"; $CFLAGS{"XOPEN2K8"} = "-std=c99 -D_XOPEN_SOURCE=700"; $CFLAGS{"POSIX2008"} = "-std=c99 -D_POSIX_C_SOURCE=200809L"; @@ -76,19 +76,6 @@ while ($#keywords >= 0) { $iskeyword{pop (@keywords)} = 1; } -# These are symbols which are known to pollute the namespace. -@knownproblems = ('unix', 'linux', 'i386'); - -# Make a hash table from the known problems. -while ($#knownproblems >= 0) { - $isknown{pop (@knownproblems)} = 1; -} - -$uid = getuid(); -($pwname,$pwpasswd,$pwuid,$pwgid, - $pwquota,$pwcomment,$pwgcos,$pwdir,$pwshell,$pwexpire) = getpwuid($uid); -$tmpdir = "$pwdir"; - $verbose = 1; $total = 0; @@ -245,10 +232,6 @@ sub newtoken { for ($idx = 0; $idx <= $#allow; ++$idx) { return if (poorfnmatch ($allow[$idx], $token)); } - - unless ($isknown{$token}) { - $errors{$token} = 1; - } } @@ -355,6 +338,11 @@ while ($#headers >= 0) { last control if ($missing); } + my($optional) = 0; + if (/^optional-/) { + s/^optional-//; + $optional = 1; + } if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) { my($struct) = "$2$3"; my($type) = "$5$6"; @@ -378,47 +366,12 @@ while ($#headers >= 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Testing for member $member", - "Member \"$member\" not available.", $res, 0); - + ($optional + ? "NOT AVAILABLE." + : "Member \"$member\" not available."), $res, + $optional); - # Test the types of the members. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "$struct a;\n"; - print TESTFILE "extern $type b$rest;\n"; - print TESTFILE "extern __typeof__ (a.$member) b;\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Testing for type of member $member", - "Member \"$member\" does not have the correct type.", - $res, 0); - } elsif (/^optional-element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) { - my($struct) = "$2$3"; - my($type) = "$5$6"; - my($member) = "$7"; - my($rest) = "$8"; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $member; - - # Generate a program to test for the availability of this member. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "$struct a;\n"; - print TESTFILE "$struct b;\n"; - print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n"; - print TESTFILE "void foobarbaz (void) {\n"; - print TESTFILE " xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n"; - print TESTFILE "}\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for member $member", - "NOT AVAILABLE.", $res, 1); - - if ($res == 0 || $missing != 0) { + if ($res == 0 || $missing != 0 || !$optional) { # Test the types of the members. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -432,7 +385,7 @@ while ($#headers >= 0) { "Member \"$member\" does not have the correct type.", $res, 0); } - } elsif (/^optional-constant *([a-zA-Z0-9_]*) ([>=== 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Testing for constant $const", - "NOT PRESENT", $res, 1); + ($optional + ? "NOT PRESENT" + : "Constant \"$const\" not available."), $res, + $optional); - if ($value ne "" && $res == 0) { - # Generate a program to test for the value of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - # Negate the value since 0 means ok - print TESTFILE "int main (void) { return !($const $op $value); }\n"; - close (TESTFILE); - - $res = runtest ($fnamebase, "Testing for value of constant $const", - "Constant \"$const\" has not the right value.", $res); - } - } elsif (/^constant *([a-zA-Z0-9_]*) *([>=$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ ($const) a = $const;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for constant $const", - "Constant \"$const\" not available.", $res, 0); - - if ($value ne "") { + if (defined ($op) && ($res == 0 || !$optional)) { # Generate a program to test for the value of this constant. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -536,64 +461,6 @@ while ($#headers >= 0) { $res = runtest ($fnamebase, "Testing for value of constant $const", "Constant \"$const\" has not the right value.", $res); } - } elsif (/^optional-constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) { - my($const) = $1; - my($value) = $2; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $const; - - # Generate a program to test for the availability of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ ($const) a = $const;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for constant $const", - "NOT PRESENT", $res, 1); - - if ($value ne "" && $res == 0) { - # Generate a program to test for the value of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "int main (void) { return $const != $value; }\n"; - close (TESTFILE); - - $res = runtest ($fnamebase, "Testing for value of constant $const", - "Constant \"$const\" has not the right value.", $res); - } - } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) { - my($const) = $1; - my($value) = $2; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $const; - - # Generate a program to test for the availability of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ ($const) a = $const;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for constant $const", - "Constant \"$const\" not available.", $res, 0); - - if ($value ne "") { - # Generate a program to test for the value of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "int main (void) { return $const != $value; }\n"; - close (TESTFILE); - - $res = runtest ($fnamebase, "Testing for value of constant $const", - "Constant \"$const\" has not the right value.", $res); - } } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) { my($symbol) = $1; my($value) = $2; @@ -625,75 +492,6 @@ while ($#headers >= 0) { $res = runtest ($fnamebase, "Testing for value of symbol $symbol", "Symbol \"$symbol\" has not the right value.", $res); } - } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_-]*)?/) { - my($const) = $1; - my($type) = "$3$4"; - my($value) = $5; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $const; - - # Generate a program to test for the availability of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ ($const) a = $const;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for constant $const", - "Constant \"$const\" not available.", $res, 0); - - # Test the types of the members. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ (($type) 0) a;\n"; - print TESTFILE "extern __typeof__ ($const) a;\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Testing for type of constant $const", - "Constant \"$const\" does not have the correct type.", - $res, 0); - - if ($value ne "") { - # Generate a program to test for the value of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "int main (void) { return $const != $value; }\n"; - close (TESTFILE); - - $res = runtest ($fnamebase, "Testing for value of constant $const", - "Constant \"$const\" has not the right value.", $res); - } - } elsif (/^optional-type *({([^}]*)|([a-zA-Z0-9_]*))/) { - my($type) = "$2$3"; - my($maybe_opaque) = 0; - - # Remember that this name is allowed. - if ($type =~ /^struct *(.*)/) { - push @allow, $1; - } elsif ($type =~ /^union *(.*)/) { - push @allow, $1; - } else { - push @allow, $type; - $maybe_opaque = 1; - } - - # Generate a program to test for the availability of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - if ($maybe_opaque == 1) { - print TESTFILE "$type *a;\n"; - } else { - print TESTFILE "$type a;\n"; - } - close (TESTFILE); - - compiletest ($fnamebase, "Testing for type $type", - "NOT AVAILABLE", $missing, 1); } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) { my($type) = "$2$3"; my($maybe_opaque) = 0; @@ -720,7 +518,9 @@ while ($#headers >= 0) { close (TESTFILE); compiletest ($fnamebase, "Testing for type $type", - "Type \"$type\" not available.", $missing, 0); + ($optional + ? "NOT AVAILABLE" + : "Type \"$type\" not available."), $missing, $optional); } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) { my($type) = "$2$3"; @@ -742,7 +542,7 @@ while ($#headers >= 0) { compiletest ($fnamebase, "Testing for type $type", "Type \"$type\" not available.", $missing, 0); - } elsif (/^optional-function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) { + } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) { my($rettype) = "$2$3"; my($fname) = "$4"; my($args) = "$5"; @@ -760,9 +560,12 @@ while ($#headers >= 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Test availability of function $fname", - "NOT AVAILABLE", $res, 1); + ($optional + ? "NOT AVAILABLE" + : "Function \"$fname\" is not available."), $res, + $optional); - if ($res == 0 || $missing == 1) { + if ($res == 0 || $missing == 1 || !$optional) { # Generate a program to test for the type of this function. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -775,38 +578,7 @@ while ($#headers >= 0) { compiletest ($fnamebase, "Test for type of function $fname", "Function \"$fname\" has incorrect type.", $res, 0); } - } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) { - my($rettype) = "$2$3"; - my($fname) = "$4"; - my($args) = "$5"; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $fname; - - # Generate a program to test for availability of this function. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - # print TESTFILE "#undef $fname\n"; - print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Test availability of function $fname", - "Function \"$fname\" is not available.", $res, 0); - - # Generate a program to test for the type of this function. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - # print TESTFILE "#undef $fname\n"; - print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n"; - print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Test for type of function $fname", - "Function \"$fname\" has incorrect type.", $res, 0); - } elsif (/^optional-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) { + } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) { my($rettype) = "$2$3"; my($fname) = "$4"; my($args) = "$5"; @@ -824,9 +596,12 @@ while ($#headers >= 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Test availability of function $fname", - "NOT AVAILABLE", $res, 1); + ($optional + ? "NOT AVAILABLE" + : "Function \"$fname\" is not available."), $res, + $optional); - if ($res == 0 || $missing != 0) { + if ($res == 0 || $missing != 0 || !$optional) { # Generate a program to test for the type of this function. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -839,37 +614,6 @@ while ($#headers >= 0) { compiletest ($fnamebase, "Test for type of function $fname", "Function \"$fname\" has incorrect type.", $res, 0); } - } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) { - my($rettype) = "$2$3"; - my($fname) = "$4"; - my($args) = "$5"; - my($res) = $missing; - - # Remember that this name is allowed. - push @allow, $fname; - - # Generate a program to test for availability of this function. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - # print TESTFILE "#undef $fname\n"; - print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Test availability of function $fname", - "Function \"$fname\" is not available.", $res, 0); - - # Generate a program to test for the type of this function. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - # print TESTFILE "#undef $fname\n"; - print TESTFILE "extern $rettype (*foobarbaz) $args;\n"; - print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Test for type of function $fname", - "Function \"$fname\" has incorrect type.", $res, 0); } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) { my($type) = "$2$3"; my($vname) = "$4"; @@ -966,23 +710,6 @@ while ($#headers >= 0) { $res = runtest ($fnamebase, "Testing for value of macro $macro", "Macro \"$macro\" has not the right value.", $res); - } elsif (/^optional-macro *([^ ]*)/) { - my($macro) = "$1"; - - # Remember that this name is allowed. - push @allow, $macro; - - # Generate a program to test for availability of this macro. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "#ifndef $macro\n"; - print TESTFILE "# error \"Macro $macro not defined\"\n"; - print TESTFILE "#endif\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Test availability of macro $macro", - "NOT PRESENT", $missing, 1); } elsif (/^macro *([a-zA-Z0-9_]*) *([>== 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Test availability of macro $macro", - "Macro \"$macro\" is not available.", $res, 0); + ($optional + ? "NOT PRESENT" + : "Macro \"$macro\" is not available."), $res, + $optional); - if ($value ne "") { + if ($value ne "" && ($res == 0 || !$optional)) { # Generate a program to test for the value of this constant. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -1034,9 +764,12 @@ while ($#headers >= 0) { close (TESTFILE); $res = compiletest ($fnamebase, "Test availability of macro $macro", - "Macro \"$macro\" is not available.", $res, 0); + ($optional + ? "NOT PRESENT" + : "Macro \"$macro\" is not available."), $res, + $optional); - if ($value ne "") { + if ($value ne "" && ($res == 0 || !$optional)) { # Generate a program to test for the value of this constant. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; @@ -1064,7 +797,10 @@ while ($#headers >= 0) { close (TESTFILE); compiletest ($fnamebase, "Test availability of macro $macro", - "Macro \"$macro\" is not available.", $missing, 0); + ($optional + ? "NOT PRESENT" + : "Macro \"$macro\" is not available."), $missing, + $optional); } elsif (/^allow-header *(.*)/) { my($pattern) = $1; if ($seenheader{$pattern} != 1) { @@ -1097,10 +833,10 @@ while ($#headers >= 0) { if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) { push @allow, $7; - } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) { + } elsif (/^constant *([a-zA-Z0-9_]*) *(?:([>== 0) { push @allow, $4; } elsif (/^macro *([^ ]*)/) { push @allow, $1; + } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) { + push @allow, $1; } elsif (/^allow-header *(.*)/) { if ($seenheader{$1} != 1) { push @allowheader, $1;