This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
conformtest: Unify "macro" cases
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Date: Sat, 28 Apr 2012 18:20:11 +0000 (UTC)
- Subject: conformtest: Unify "macro" cases
conformtest.pl has three different cases for parsing "macro" lines and
two different ways of handling expected values for them.
I propose this patch to merge those three into one case and to use
only the form of expected values with an explicit comparison
operator. Tested x86_64.
A subsequent change will combine "macro" and "constant" handling to
allow typed macros and the possibility to specify that something is
both a macro and a constant - since in fact standards do often specify
that, so macro-constant should be a common case.
2012-04-28 Joseph Myers <joseph@codesourcery.com>
* conform/conformtest.pl: Only accept expected macro values with
"==". Parse all "macro" lines in one place.
* conform/data/stdlib.h-data: Use "==" form on "macro" lines.
diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index 0a1a093..c38be1d 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -683,7 +683,7 @@ 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_]*)/) {
+ } elsif (/^macro *([a-zA-Z0-9_]*) *(?:([>=<!]+) ([A-Za-z0-9_]*))?/) {
my($macro) = "$1";
my($op) = $2;
my($value) = $3;
@@ -707,7 +707,7 @@ while ($#headers >= 0) {
: "Macro \"$macro\" is not available."), $res,
$optional);
- if ($value ne "" && ($res == 0 || !$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";
@@ -719,61 +719,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($value) = $2;
- 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 ($value ne "" && ($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 == $value); }\n";
- close (TESTFILE);
-
- $res = runtest ($fnamebase, "Testing for value of macro $macro",
- "Macro \"$macro\" has not the right value.", $res);
- }
- } elsif (/^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",
- ($optional
- ? "NOT PRESENT"
- : "Macro \"$macro\" is not available."), $missing,
- $optional);
} elsif (/^allow-header *(.*)/) {
my($pattern) = $1;
if ($seenheader{$pattern} != 1) {
@@ -827,7 +772,7 @@ while ($#headers >= 0) {
push @allow, $4;
} elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
push @allow, $4;
- } elsif (/^macro *([^ ]*)/) {
+ } 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;
diff --git a/conform/data/stdlib.h-data b/conform/data/stdlib.h-data
index f42d4a7..f13bf3c 100644
--- a/conform/data/stdlib.h-data
+++ b/conform/data/stdlib.h-data
@@ -6,7 +6,7 @@ element ldiv_t long quot
element ldiv_t long rem
macro EXIT_FAILURE
-macro EXIT_SUCCESS 0
+macro EXIT_SUCCESS == 0
macro NULL
constant RAND_MAX >= 32767
--
Joseph S. Myers
joseph@codesourcery.com