aboutsummaryrefslogtreecommitdiff
path: root/conform
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-05-01 20:02:48 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-05-01 20:02:48 +0000
commitaafc49b3fccb44f0da4bac49abe55fa3651ecabe (patch)
treefe43778fbbaece7b0f193f080eae8729be737541 /conform
parentfefdf574126726c0a9ed0badd73e187e97dd422a (diff)
downloadglibc-aafc49b3fccb44f0da4bac49abe55fa3651ecabe.zip
glibc-aafc49b3fccb44f0da4bac49abe55fa3651ecabe.tar.gz
glibc-aafc49b3fccb44f0da4bac49abe55fa3651ecabe.tar.bz2
conformtest: Unify "macro" and "constant" handling.
Diffstat (limited to 'conform')
-rw-r--r--conform/conformtest.pl114
1 files changed, 50 insertions, 64 deletions
diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index c38be1d..f5860ac 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -385,54 +385,78 @@ while ($#headers >= 0) {
"Member \"$member\" does not have the correct type.",
$res, 0);
}
- } elsif (/^constant *([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
- my($const) = $1;
- my($type) = $2;
- my($op) = $3;
- my($value) = $4;
+ } elsif (/^(macro|constant|macro-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
+ my($symbol_type) = $1;
+ my($symbol) = $2;
+ my($type) = $3;
+ my($op) = $4;
+ my($value) = $5;
my($res) = $missing;
+ my($mres) = $missing;
+ my($cres) = $missing;
# Remember that this name is allowed.
- push @allow, $const;
+ push @allow, $symbol;
- # 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);
+ if ($symbol_type =~ /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 $symbol\n";
+ print TESTFILE "# error \"Macro $symbol not defined\"\n";
+ print TESTFILE "#endif\n";
+ close (TESTFILE);
- $res = compiletest ($fnamebase, "Testing for constant $const",
- ($optional
- ? "NOT PRESENT"
- : "Constant \"$const\" not available."), $res,
- $optional);
+ $mres = compiletest ($fnamebase, "Test availability of macro $symbol",
+ ($optional
+ ? "NOT PRESENT"
+ : "Macro \"$symbol\" is not available."), $res,
+ $optional);
+ }
+
+ if ($symbol_type =~ /constant/) {
+ # 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__ ($symbol) a = $symbol;\n";
+ close (TESTFILE);
+
+ $cres = compiletest ($fnamebase, "Testing for constant $symbol",
+ ($optional
+ ? "NOT PRESENT"
+ : "Constant \"$symbol\" not available."), $res,
+ $optional);
+ }
+
+ $res = $res || $mres || $cres;
if (defined ($type) && ($res == 0 || !$optional)) {
- # Test the types of the members.
+ # Test the type of the symbol.
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";
+ print TESTFILE "extern __typeof__ ($symbol) a;\n";
close (TESTFILE);
- compiletest ($fnamebase, "Testing for type of constant $const",
- "Constant \"$const\" does not have the correct type.",
+ compiletest ($fnamebase, "Testing for type of symbol $symbol",
+ "Symbol \"$symbol\" does not have the correct type.",
$res, 0);
}
if (defined ($op) && ($res == 0 || !$optional)) {
- # Generate a program to test for the value of this constant.
+ # Generate a program to test for the value of this symbol.
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";
+ print TESTFILE "int main (void) { return !($symbol $op $value); }\n";
close (TESTFILE);
- $res = runtest ($fnamebase, "Testing for value of constant $const",
- "Constant \"$const\" has not the right value.", $res);
+ $res = runtest ($fnamebase, "Testing for value of symbol $symbol",
+ "Symbol \"$symbol\" has not the right value.", $res);
}
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
my($symbol) = $1;
@@ -683,42 +707,6 @@ while ($#headers >= 0) {
$res = runtest ($fnamebase, "Testing for value of macro $macro",
"Macro \"$macro\" has not the right value.", $res);
- } elsif (/^macro *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_]*))?/) {
- my($macro) = "$1";
- my($op) = $2;
- my($value) = $3;
- my($res) = $missing;
-
- # 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);
-
- $res = compiletest ($fnamebase, "Test availability of macro $macro",
- ($optional
- ? "NOT PRESENT"
- : "Macro \"$macro\" is not available."), $res,
- $optional);
-
- if (defined ($op) && ($res == 0 || !$optional)) {
- # 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 !($macro $op $value); }\n";
- close (TESTFILE);
-
- $res = runtest ($fnamebase, "Testing for value of macro $macro",
- "Macro \"$macro\" has not the right value.", $res);
- }
} elsif (/^allow-header *(.*)/) {
my($pattern) = $1;
if ($seenheader{$pattern} != 1) {
@@ -751,7 +739,7 @@ while ($#headers >= 0) {
if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
push @allow, $7;
- } elsif (/^constant *([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
+ } elsif (/^(macro|constant|macro-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
push @allow, $1;
} elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
my($type) = "$3$4";
@@ -772,8 +760,6 @@ while ($#headers >= 0) {
push @allow, $4;
} elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
push @allow, $4;
- } elsif (/^macro *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_]*))?/) {
- push @allow, $1;
} elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
push @allow, $1;
} elsif (/^allow-header *(.*)/) {