Blame conform/conformtest.pl

Packit 6c4009
#!/usr/bin/perl
Packit 6c4009
Packit 6c4009
use GlibcConform;
Packit 6c4009
use Getopt::Long;
Packit 6c4009
use POSIX;
Packit 6c4009
Packit 6c4009
$standard = "XOPEN2K8";
Packit 6c4009
$CC = "gcc";
Packit 6c4009
$tmpdir = "/tmp";
Packit 6c4009
$cross = "";
Packit 6c4009
$xfail_str = "";
Packit 6c4009
GetOptions ('headers=s' => \@headers, 'standard=s' => \$standard,
Packit 6c4009
	    'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir,
Packit 6c4009
	    'cross' => \$cross, 'xfail=s' => \$xfail_str);
Packit 6c4009
@headers = split(/,/,join(',',@headers));
Packit 6c4009
Packit 6c4009
# List of the headers we are testing.
Packit 6c4009
if (@headers == ()) {
Packit 6c4009
  @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
Packit 6c4009
	      "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "uchar.h",
Packit 6c4009
	      "time.h", "tgmath.h", "termios.h", "tar.h", "sys/wait.h",
Packit 6c4009
	      "sys/utsname.h", "sys/un.h", "sys/uio.h", "sys/types.h",
Packit 6c4009
	      "sys/times.h", "sys/timeb.h", "sys/time.h", "sys/statvfs.h",
Packit 6c4009
	      "sys/stat.h", "sys/socket.h", "sys/shm.h", "sys/sem.h",
Packit 6c4009
	      "sys/select.h", "sys/resource.h", "sys/msg.h", "sys/mman.h",
Packit 6c4009
	      "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", "string.h",
Packit 6c4009
	      "stdnoreturn.h", "stdlib.h", "stdio.h", "stdint.h", "stddef.h",
Packit 6c4009
	      "stdbool.h", "stdarg.h", "stdalign.h", "spawn.h", "signal.h",
Packit 6c4009
	      "setjmp.h", "semaphore.h", "search.h", "sched.h", "regex.h",
Packit 6c4009
	      "pwd.h", "pthread.h", "poll.h", "nl_types.h", "netinet/tcp.h",
Packit 6c4009
	      "netinet/in.h", "net/if.h", "netdb.h", "ndbm.h", "mqueue.h",
Packit 6c4009
	      "monetary.h", "math.h", "locale.h", "libgen.h", "limits.h",
Packit 6c4009
	      "langinfo.h", "iso646.h", "inttypes.h", "iconv.h", "grp.h",
Packit 6c4009
	      "glob.h", "ftw.h", "fnmatch.h", "fmtmsg.h", "float.h", "fenv.h",
Packit 6c4009
	      "fcntl.h", "errno.h", "dlfcn.h", "dirent.h", "ctype.h", "cpio.h",
Packit 6c4009
	      "complex.h", "assert.h", "arpa/inet.h", "aio.h");
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
$CFLAGS_namespace = "$flags -fno-builtin $CFLAGS{$standard} -D_ISOMAC";
Packit 6c4009
$CFLAGS = "$CFLAGS_namespace '-D__attribute__(x)='";
Packit 6c4009
Packit 6c4009
# Check standard name for validity.
Packit 6c4009
die "unknown standard \"$standard\"" if ($CFLAGS{$standard} eq "");
Packit 6c4009
Packit 6c4009
# if ($standard ne "XOPEN2K8" && $standard ne "POSIX2008") {
Packit 6c4009
#   # Some headers need a bit more attention.  At least with XPG7
Packit 6c4009
#   # all headers should be self-contained.
Packit 6c4009
#   $mustprepend{'inttypes.h'} = "#include <stddef.h>\n";
Packit 6c4009
#   $mustprepend{'glob.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'grp.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'regex.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'pwd.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'sched.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'signal.h'} = "#include <pthread.h>\n#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'stdio.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'sys/stat.h'} = "#include <sys/types.h>\n";
Packit 6c4009
#   $mustprepend{'wchar.h'} = "#include <stdarg.h>\n";
Packit 6c4009
#   $mustprepend{'wordexp.h'} = "#include <stddef.h>\n";
Packit 6c4009
# }
Packit 6c4009
Packit 6c4009
# These are the ISO C90 keywords.
Packit 6c4009
@keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
Packit 6c4009
	     'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto',
Packit 6c4009
	     'if', 'int', 'long', 'register', 'return',
Packit 6c4009
	     'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
Packit 6c4009
	     'typedef', 'union', 'unsigned', 'void', 'volatile', 'while');
Packit 6c4009
if ($CFLAGS{$standard} =~ /-std=(c99|c1x)/) {
Packit 6c4009
  push (@keywords, 'inline', 'restrict');
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
# Make a hash table from this information.
Packit 6c4009
while ($#keywords >= 0) {
Packit 6c4009
  $iskeyword{pop (@keywords)} = 1;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
$verbose = 1;
Packit 6c4009
Packit 6c4009
$total = 0;
Packit 6c4009
$skipped = 0;
Packit 6c4009
$errors = 0;
Packit 6c4009
$xerrors = 0;
Packit 6c4009
Packit 6c4009
sub note_error {
Packit 6c4009
  my($xfail) = @_;
Packit 6c4009
  if ($xfail) {
Packit 6c4009
    $xerrors++;
Packit 6c4009
    printf ("Ignoring this failure.\n");
Packit 6c4009
  } else {
Packit 6c4009
    $errors++;
Packit 6c4009
  }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub poorfnmatch {
Packit 6c4009
  my($pattern, $string) = @_;
Packit 6c4009
  my($strlen) = length ($string);
Packit 6c4009
  my($res);
Packit 6c4009
Packit 6c4009
  if (substr ($pattern, 0, 1) eq '*') {
Packit 6c4009
    my($patlen) = length ($pattern) - 1;
Packit 6c4009
    $res = ($strlen >= $patlen
Packit 6c4009
	    && substr ($pattern, -$patlen, $patlen) eq substr ($string, -$patlen, $patlen));
Packit 6c4009
  } elsif (substr ($pattern, -1, 1) eq '*') {
Packit 6c4009
    if (substr ($pattern, -2, 1) eq ']') {
Packit 6c4009
      my($patlen) = index ($pattern, '[');
Packit 6c4009
      my($range) = substr ($pattern, $patlen + 1, -2);
Packit 6c4009
      $res = ($strlen > $patlen
Packit 6c4009
	      && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen)
Packit 6c4009
	      && index ($range, substr ($string, $patlen, 1)) != -1);
Packit 6c4009
    } else {
Packit 6c4009
      my($patlen) = length ($pattern) - 1;
Packit 6c4009
      $res = ($strlen >= $patlen
Packit 6c4009
	      && substr ($pattern, 0, $patlen) eq substr ($string, 0, $patlen));
Packit 6c4009
    }
Packit 6c4009
  } else {
Packit 6c4009
    $res = $pattern eq $string;
Packit 6c4009
  }
Packit 6c4009
  return $res;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub compiletest
Packit 6c4009
{
Packit 6c4009
  my($fnamebase, $msg, $errmsg, $skip, $optional, $xfail) = @_;
Packit 6c4009
  my($result) = $skip;
Packit 6c4009
  my($printlog) = 0;
Packit 6c4009
Packit 6c4009
  ++$total;
Packit 6c4009
  printf ("  $msg...");
Packit 6c4009
Packit 6c4009
  if ($skip != 0) {
Packit 6c4009
    ++$skipped;
Packit 6c4009
    printf (" SKIP\n");
Packit 6c4009
  } else {
Packit 6c4009
    $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1;;
Packit 6c4009
    if ($ret != 0) {
Packit 6c4009
      if ($optional != 0) {
Packit 6c4009
	printf (" $errmsg\n");
Packit 6c4009
	$result = 1;
Packit 6c4009
      } else {
Packit 6c4009
	printf (" FAIL\n");
Packit 6c4009
	if ($verbose != 0) {
Packit 6c4009
	  printf ("    $errmsg  Compiler message:\n");
Packit 6c4009
	  $printlog = 1;
Packit 6c4009
	}
Packit 6c4009
	note_error($xfail);
Packit 6c4009
	$result = 1;
Packit 6c4009
      }
Packit 6c4009
    } else {
Packit 6c4009
      printf (" OK\n");
Packit 6c4009
      if ($verbose > 1 && -s "$fnamebase.out") {
Packit 6c4009
	# We print all warnings issued.
Packit 6c4009
	$printlog = 1;
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
    if ($printlog != 0) {
Packit 6c4009
      printf ("    " . "-" x 71 . "\n");
Packit 6c4009
      open (MESSAGE, "< $fnamebase.out");
Packit 6c4009
      while (<MESSAGE>) {
Packit 6c4009
	printf ("    %s", $_);
Packit 6c4009
      }
Packit 6c4009
      close (MESSAGE);
Packit 6c4009
      printf ("    " . "-" x 71 . "\n");
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
  unlink "$fnamebase.c";
Packit 6c4009
  unlink "$fnamebase.o";
Packit 6c4009
  unlink "$fnamebase.out";
Packit 6c4009
Packit 6c4009
  $result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub runtest
Packit 6c4009
{
Packit 6c4009
  my($fnamebase, $msg, $errmsg, $skip, $xfail) = @_;
Packit 6c4009
  my($result) = $skip;
Packit 6c4009
  my($printlog) = 0;
Packit 6c4009
Packit 6c4009
  ++$total;
Packit 6c4009
  printf ("  $msg...");
Packit 6c4009
Packit 6c4009
  if ($skip != 0) {
Packit 6c4009
    ++$skipped;
Packit 6c4009
    printf (" SKIP\n");
Packit 6c4009
  } else {
Packit 6c4009
    $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1;;
Packit 6c4009
    if ($ret != 0) {
Packit 6c4009
      printf (" FAIL\n");
Packit 6c4009
      if ($verbose != 0) {
Packit 6c4009
	printf ("    $errmsg  Compiler message:\n");
Packit 6c4009
	$printlog = 1;
Packit 6c4009
      }
Packit 6c4009
      note_error($xfail);
Packit 6c4009
      $result = 1;
Packit 6c4009
    } elsif ($cross) {
Packit 6c4009
      printf (" SKIP\n");
Packit 6c4009
    } else {
Packit 6c4009
      # Now run the program.  If the exit code is not zero something is wrong.
Packit 6c4009
      $result = system "$fnamebase > $fnamebase.out2 2>&1;;
Packit 6c4009
      if ($result == 0) {
Packit 6c4009
	printf (" OK\n");
Packit 6c4009
	if ($verbose > 1 && -s "$fnamebase.out") {
Packit 6c4009
	  # We print all warnings issued.
Packit 6c4009
	  $printlog = 1;
Packit 6c4009
	  system "cat $fnamebase.out2 >> $fnamebase.out";
Packit 6c4009
	}
Packit 6c4009
      } else {
Packit 6c4009
	printf (" FAIL\n");
Packit 6c4009
	note_error($xfail);
Packit 6c4009
	$printlog = 1;
Packit 6c4009
	unlink "$fnamebase.out";
Packit 6c4009
	rename "$fnamebase.out2", "$fnamebase.out";
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
    if ($printlog != 0) {
Packit 6c4009
      printf ("    " . "-" x 71 . "\n");
Packit 6c4009
      open (MESSAGE, "< $fnamebase.out");
Packit 6c4009
      while (<MESSAGE>) {
Packit 6c4009
	printf ("    %s", $_);
Packit 6c4009
      }
Packit 6c4009
      close (MESSAGE);
Packit 6c4009
      printf ("    " . "-" x 71 . "\n");
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
  unlink "$fnamebase";
Packit 6c4009
  unlink "$fnamebase.c";
Packit 6c4009
  unlink "$fnamebase.o";
Packit 6c4009
  unlink "$fnamebase.out";
Packit 6c4009
  unlink "$fnamebase.out2";
Packit 6c4009
Packit 6c4009
  $result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub newtoken {
Packit 6c4009
  my($token, @allow) = @_;
Packit 6c4009
  my($idx);
Packit 6c4009
Packit 6c4009
  return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
Packit 6c4009
Packit 6c4009
  for ($idx = 0; $idx <= $#allow; ++$idx) {
Packit 6c4009
    return if (poorfnmatch ($allow[$idx], $token));
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  $errors{$token} = 1;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub removetoken {
Packit 6c4009
  my($token) = @_;
Packit 6c4009
  my($idx);
Packit 6c4009
Packit 6c4009
  return if ($token =~ /^[0-9_]/ || $iskeyword{$token});
Packit 6c4009
Packit 6c4009
  if (exists $errors{$token}) {
Packit 6c4009
    undef $errors{$token};
Packit 6c4009
  }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
sub checknamespace {
Packit 6c4009
  my($h, $fnamebase, @allow) = @_;
Packit 6c4009
Packit 6c4009
  ++$total;
Packit 6c4009
Packit 6c4009
  # Generate a program to get the contents of this header.
Packit 6c4009
  open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
  print TESTFILE "#include <$h>\n";
Packit 6c4009
  close (TESTFILE);
Packit 6c4009
Packit 6c4009
  undef %errors;
Packit 6c4009
  open (CONTENT, "$CC $CFLAGS_namespace -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
Packit 6c4009
  loop: while (<CONTENT>) {
Packit 6c4009
    chop;
Packit 6c4009
    if (/^#define (.*)/) {
Packit 6c4009
      newtoken ($1, @allow);
Packit 6c4009
    } elsif (/^#undef (.*)/) {
Packit 6c4009
      removetoken ($1);
Packit 6c4009
    } else {
Packit 6c4009
      # We have to tokenize the line.
Packit 6c4009
      my($str) = $_;
Packit 6c4009
Packit 6c4009
      $str =~ s/"[^"]*"//g;
Packit 6c4009
      foreach $token (split(/[^a-zA-Z0-9_]/, $str)) {
Packit 6c4009
	if ($token ne "") {
Packit 6c4009
	  newtoken ($token, @allow);
Packit 6c4009
	}
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
  close (CONTENT);
Packit 6c4009
  unlink "$fnamebase.c";
Packit 6c4009
  $realerror = 0;
Packit 6c4009
  if ($#errors != 0) {
Packit 6c4009
    # Sort the output list so it's easier to compare results with diff.
Packit 6c4009
    foreach $f (sort keys(%errors)) {
Packit 6c4009
      if ($errors{$f} == 1) {
Packit 6c4009
	if ($realerror == 0) {
Packit 6c4009
	  printf ("FAIL\n    " . "-" x 72 . "\n");
Packit 6c4009
	  $realerror = 1;
Packit 6c4009
	  ++$errors;
Packit 6c4009
	}
Packit 6c4009
	printf ("    Namespace violation: \"%s\"\n", $f);
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
    printf ("    " . "-" x 72 . "\n") if ($realerror != 0);
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  if ($realerror == 0) {
Packit 6c4009
    printf ("OK\n");
Packit 6c4009
  }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
while ($#headers >= 0) {
Packit 6c4009
  my($h) = pop (@headers);
Packit 6c4009
  my($hf) = $h;
Packit 6c4009
  $hf =~ s|/|-|;
Packit 6c4009
  my($fnamebase) = "$tmpdir/$hf-test";
Packit 6c4009
  my($missing) = 1;
Packit 6c4009
  my(@allow) = ();
Packit 6c4009
  my(@allowheader) = ();
Packit 6c4009
  my(%seenheader) = ();
Packit 6c4009
  my($prepend) = $mustprepend{$h};
Packit 6c4009
  my($test_exist) = 1;
Packit 6c4009
Packit 6c4009
  printf ("Testing <$h>\n");
Packit 6c4009
  printf ("----------" . "-" x length ($h) . "\n");
Packit 6c4009
Packit 6c4009
  open (CONTROL, "$CC -E -D$standard -std=c99 -x c data/$h-data |");
Packit 6c4009
  control: while (<CONTROL>) {
Packit 6c4009
    chop;
Packit 6c4009
    next control if (/^#/);
Packit 6c4009
    next control if (/^[	]*$/);
Packit 6c4009
Packit 6c4009
    if ($test_exist) {
Packit 6c4009
      $test_exist = 0;
Packit 6c4009
      # Generate a program to test for the availability of this header.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $missing = compiletest ($fnamebase, "Checking whether <$h> is available",
Packit 6c4009
			      "Header <$h> not available", 0, 0, 0);
Packit 6c4009
      printf ("\n");
Packit 6c4009
      last control if ($missing);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
    my($xfail) = 0;
Packit 6c4009
    if (/^xfail-/) {
Packit 6c4009
      s/^xfail-//;
Packit 6c4009
      $xfail = 1;
Packit 6c4009
    } elsif (/^xfail\[([^\]]*)\]-/) {
Packit 6c4009
      my($xfail_cond) = $1;
Packit 6c4009
      s/^xfail\[([^\]]*)\]-//;
Packit 6c4009
      # "xfail[cond]-" or "xfail[cond1|cond2|...]-" means a failure of
Packit 6c4009
      # the test is allowed if any of the listed conditions are in the
Packit 6c4009
      # --xfail command-line option argument.
Packit 6c4009
      if ($xfail_str =~ /\b($xfail_cond)\b/) {
Packit 6c4009
	$xfail = 1;
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
    my($optional) = 0;
Packit 6c4009
    if (/^optional-/) {
Packit 6c4009
      s/^optional-//;
Packit 6c4009
      $optional = 1;
Packit 6c4009
    }
Packit 6c4009
    if (/^element *(\{([^}]*)\}|([^{ ]*)) *(\{([^}]*)\}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
Packit 6c4009
      my($struct) = "$2$3";
Packit 6c4009
      my($type) = "$5$6";
Packit 6c4009
      my($member) = "$7";
Packit 6c4009
      my($rest) = "$8";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $member;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the availability of this member.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "$struct a;\n";
Packit 6c4009
      print TESTFILE "$struct b;\n";
Packit 6c4009
      print TESTFILE "extern void xyzzy (__typeof__ (&b.$member), __typeof__ (&a.$member), unsigned);\n";
Packit 6c4009
      print TESTFILE "void foobarbaz (void) {\n";
Packit 6c4009
      print TESTFILE "  xyzzy (&a.$member, &b.$member, sizeof (a.$member));\n";
Packit 6c4009
      print TESTFILE "}\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Testing for member $member",
Packit 6c4009
			  ($optional
Packit 6c4009
			   ? "NOT AVAILABLE."
Packit 6c4009
			   : "Member \"$member\" not available."), $res,
Packit 6c4009
			  $optional, $xfail);
Packit 6c4009
Packit 6c4009
      if ($res == 0 || $missing != 0 || !$optional) {
Packit 6c4009
	# Test the types of the members.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "$struct a;\n";
Packit 6c4009
	print TESTFILE "extern $type b$rest;\n";
Packit 6c4009
	print TESTFILE "extern __typeof__ (a.$member) b;\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	compiletest ($fnamebase, "Testing for type of member $member",
Packit 6c4009
		     "Member \"$member\" does not have the correct type.",
Packit 6c4009
		     $res, 0, $xfail);
Packit 6c4009
      }
Packit 6c4009
    } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=
Packit 6c4009
      my($symbol_type) = $1;
Packit 6c4009
      my($symbol) = $2;
Packit 6c4009
      my($type) = $3;
Packit 6c4009
      my($op) = $4;
Packit 6c4009
      my($value) = $5;
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
      my($mres) = $missing;
Packit 6c4009
      my($cres) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $symbol;
Packit 6c4009
Packit 6c4009
      if ($symbol_type =~ /macro/) {
Packit 6c4009
	# Generate a program to test for availability of this macro.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "#ifndef $symbol\n";
Packit 6c4009
	print TESTFILE "# error \"Macro $symbol not defined\"\n";
Packit 6c4009
	print TESTFILE "#endif\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	$mres = compiletest ($fnamebase, "Test availability of macro $symbol",
Packit 6c4009
			     ($optional
Packit 6c4009
			      ? "NOT PRESENT"
Packit 6c4009
			      : "Macro \"$symbol\" is not available."), $res,
Packit 6c4009
			     $optional, $xfail);
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      if ($symbol_type =~ /constant/) {
Packit 6c4009
	# Generate a program to test for the availability of this constant.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	$cres = compiletest ($fnamebase, "Testing for constant $symbol",
Packit 6c4009
			     ($optional
Packit 6c4009
			      ? "NOT PRESENT"
Packit 6c4009
			      : "Constant \"$symbol\" not available."), $res,
Packit 6c4009
			     $optional, $xfail);
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      $res = $res || $mres || $cres;
Packit 6c4009
Packit 6c4009
      if ($symbol_type eq "macro-int-constant" && ($res == 0 || !$optional)) {
Packit 6c4009
	# Test that the symbol is usable in #if.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "#if $symbol < 0\n";
Packit 6c4009
	print TESTFILE "# define conformtest_negative 1\n";
Packit 6c4009
	my($s) = "0";
Packit 6c4009
	for (my $i = 0; $i < 63; $i++) {
Packit 6c4009
	  print TESTFILE "# if $symbol & (1LL << $i)\n";
Packit 6c4009
	  print TESTFILE "#  define conformtest_bit_$i 0LL\n";
Packit 6c4009
	  print TESTFILE "# else\n";
Packit 6c4009
	  print TESTFILE "#  define conformtest_bit_$i (1LL << $i)\n";
Packit 6c4009
	  print TESTFILE "# endif\n";
Packit 6c4009
	  $s .= "|conformtest_bit_$i";
Packit 6c4009
	}
Packit 6c4009
	print TESTFILE "# define conformtest_value ~($s)\n";
Packit 6c4009
	print TESTFILE "#else\n";
Packit 6c4009
	print TESTFILE "# define conformtest_negative 0\n";
Packit 6c4009
	$s = "0";
Packit 6c4009
	for (my $i = 0; $i < 64; $i++) {
Packit 6c4009
	  print TESTFILE "# if $symbol & (1ULL << $i)\n";
Packit 6c4009
	  print TESTFILE "#  define conformtest_bit_$i (1ULL << $i)\n";
Packit 6c4009
	  print TESTFILE "# else\n";
Packit 6c4009
	  print TESTFILE "#  define conformtest_bit_$i 0ULL\n";
Packit 6c4009
	  print TESTFILE "# endif\n";
Packit 6c4009
	  $s .= "|conformtest_bit_$i";
Packit 6c4009
	}
Packit 6c4009
	print TESTFILE "# define conformtest_value ($s)\n";
Packit 6c4009
	print TESTFILE "#endif\n";
Packit 6c4009
	print TESTFILE "_Static_assert ((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value), \"value match inside and outside #if\");\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	compiletest ($fnamebase, "Testing for #if usability of symbol $symbol",
Packit 6c4009
		     "Symbol \"$symbol\" not usable in #if.", $res, 0, $xfail);
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      if (defined ($type) && ($res == 0 || !$optional)) {
Packit 6c4009
	# Test the type of the symbol.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	if ($type =~ /^promoted:/) {
Packit 6c4009
	  $type =~ s/^promoted://;
Packit 6c4009
	  print TESTFILE "__typeof__ (($type) 0 + ($type) 0) a;\n";
Packit 6c4009
	} else {
Packit 6c4009
	  print TESTFILE "__typeof__ (($type) 0) a;\n";
Packit 6c4009
	}
Packit 6c4009
	print TESTFILE "extern __typeof__ ($symbol) a;\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	compiletest ($fnamebase, "Testing for type of symbol $symbol",
Packit 6c4009
		     "Symbol \"$symbol\" does not have the correct type.",
Packit 6c4009
		     $res, 0, $xfail);
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      if (defined ($op) && ($res == 0 || !$optional)) {
Packit 6c4009
	# Generate a program to test for the value of this symbol.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "_Static_assert ($symbol $op $value, \"value constraint\");\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	$res = compiletest ($fnamebase, "Testing for value of symbol $symbol",
Packit 6c4009
			    "Symbol \"$symbol\" has not the right value.",
Packit 6c4009
			    $res, 0, $xfail);
Packit 6c4009
      }
Packit 6c4009
    } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
Packit 6c4009
      my($symbol) = $1;
Packit 6c4009
      my($value) = $2;
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $symbol;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the availability of this constant.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "void foobarbaz (void) {\n";
Packit 6c4009
      print TESTFILE "__typeof__ ($symbol) a = $symbol;\n";
Packit 6c4009
      print TESTFILE "}\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Testing for symbol $symbol",
Packit 6c4009
			  "Symbol \"$symbol\" not available.", $res, 0, $xfail);
Packit 6c4009
Packit 6c4009
      if ($value ne "") {
Packit 6c4009
	# Generate a program to test for the value of this constant.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	print TESTFILE "int main (void) { return $symbol != $value; }\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	$res = runtest ($fnamebase, "Testing for value of symbol $symbol",
Packit 6c4009
			"Symbol \"$symbol\" has not the right value.", $res,
Packit 6c4009
			$xfail);
Packit 6c4009
      }
Packit 6c4009
    } elsif (/^type *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
Packit 6c4009
      my($type) = "$2$3";
Packit 6c4009
      my($maybe_opaque) = 0;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      if ($type =~ /^struct *(.*)/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      } elsif ($type =~ /^union *(.*)/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      } else {
Packit 6c4009
	push @allow, $type;
Packit 6c4009
	$maybe_opaque = 1;
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the availability of this type.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      if ($maybe_opaque == 1) {
Packit 6c4009
	print TESTFILE "$type *a;\n";
Packit 6c4009
      } else {
Packit 6c4009
	print TESTFILE "$type a;\n";
Packit 6c4009
      }
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      compiletest ($fnamebase, "Testing for type $type",
Packit 6c4009
		   ($optional
Packit 6c4009
		    ? "NOT AVAILABLE"
Packit 6c4009
		    : "Type \"$type\" not available."), $missing, $optional,
Packit 6c4009
		   $xfail);
Packit 6c4009
    } elsif (/^tag *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
Packit 6c4009
      my($type) = "$2$3";
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      if ($type =~ /^struct *(.*)/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      } elsif ($type =~ /^union *(.*)/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      } else {
Packit 6c4009
	push @allow, $type;
Packit 6c4009
      }
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the availability of this type.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "$type;\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      compiletest ($fnamebase, "Testing for type $type",
Packit 6c4009
		   "Type \"$type\" not available.", $missing, 0, $xfail);
Packit 6c4009
    } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
      my($rettype) = "$2$3";
Packit 6c4009
      my($fname) = "$4";
Packit 6c4009
      my($args) = "$5";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $fname;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for availability of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      # print TESTFILE "#undef $fname\n";
Packit 6c4009
      print TESTFILE "$rettype (*(*foobarbaz) $args = $fname;\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Test availability of function $fname",
Packit 6c4009
			  ($optional
Packit 6c4009
			   ? "NOT AVAILABLE"
Packit 6c4009
			   : "Function \"$fname\" is not available."), $res,
Packit 6c4009
			  $optional, $xfail);
Packit 6c4009
Packit 6c4009
      if ($res == 0 || $missing == 1 || !$optional) {
Packit 6c4009
	# Generate a program to test for the type of this function.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	# print TESTFILE "#undef $fname\n";
Packit 6c4009
	print TESTFILE "extern $rettype (*(*foobarbaz) $args;\n";
Packit 6c4009
	print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	compiletest ($fnamebase, "Test for type of function $fname",
Packit 6c4009
		     "Function \"$fname\" has incorrect type.", $res, 0,
Packit 6c4009
		     $xfail);
Packit 6c4009
      }
Packit 6c4009
    } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
      my($rettype) = "$2$3";
Packit 6c4009
      my($fname) = "$4";
Packit 6c4009
      my($args) = "$5";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $fname;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for availability of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      # print TESTFILE "#undef $fname\n";
Packit 6c4009
      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Test availability of function $fname",
Packit 6c4009
			  ($optional
Packit 6c4009
			   ? "NOT AVAILABLE"
Packit 6c4009
			   : "Function \"$fname\" is not available."), $res,
Packit 6c4009
			  $optional, $xfail);
Packit 6c4009
Packit 6c4009
      if ($res == 0 || $missing != 0 || !$optional) {
Packit 6c4009
	# Generate a program to test for the type of this function.
Packit 6c4009
	open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
	print TESTFILE "$prepend";
Packit 6c4009
	print TESTFILE "#include <$h>\n";
Packit 6c4009
	# print TESTFILE "#undef $fname\n";
Packit 6c4009
	print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
Packit 6c4009
	print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
Packit 6c4009
	close (TESTFILE);
Packit 6c4009
Packit 6c4009
	compiletest ($fnamebase, "Test for type of function $fname",
Packit 6c4009
		     "Function \"$fname\" has incorrect type.", $res, 0,
Packit 6c4009
		     $xfail);
Packit 6c4009
      }
Packit 6c4009
    } elsif (/^variable *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
Packit 6c4009
      my($type) = "$2$3";
Packit 6c4009
      my($vname) = "$4";
Packit 6c4009
      my($rest) = "$5";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $vname;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for availability of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      # print TESTFILE "#undef $fname\n";
Packit 6c4009
      print TESTFILE "typedef $type xyzzy$rest;\n";
Packit 6c4009
      print TESTFILE "$xyzzy *foobarbaz = &$vname;\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Test availability of variable $vname",
Packit 6c4009
			  "Variable \"$vname\" is not available.", $res, 0,
Packit 6c4009
			  $xfail);
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the type of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      # print TESTFILE "#undef $fname\n";
Packit 6c4009
      print TESTFILE "extern $type $vname$rest;\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      compiletest ($fnamebase, "Test for type of variable $fname",
Packit 6c4009
		   "Variable \"$vname\" has incorrect type.", $res, 0, $xfail);
Packit 6c4009
    } elsif (/^macro-function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
      my($rettype) = "$2$3";
Packit 6c4009
      my($fname) = "$4";
Packit 6c4009
      my($args) = "$5";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $fname;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for availability of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "#ifndef $fname\n";
Packit 6c4009
      print TESTFILE "$rettype (*foobarbaz) $args = $fname;\n";
Packit 6c4009
      print TESTFILE "#endif\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = compiletest ($fnamebase, "Test availability of macro $fname",
Packit 6c4009
			  "Function \"$fname\" is not available.", $res, 0,
Packit 6c4009
			  $xfail);
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the type of this function.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "#ifndef $fname\n";
Packit 6c4009
      print TESTFILE "extern $rettype (*foobarbaz) $args;\n";
Packit 6c4009
      print TESTFILE "extern __typeof__ (&$fname) foobarbaz;\n";
Packit 6c4009
      print TESTFILE "#endif\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      compiletest ($fnamebase, "Test for type of macro $fname",
Packit 6c4009
		   "Function \"$fname\" has incorrect type.", $res, 0, $xfail);
Packit 6c4009
    } elsif (/^macro-str *([^	 ]*) *(\".*\")/) {
Packit 6c4009
      # The above regex doesn't handle a \" in a string.
Packit 6c4009
      my($macro) = "$1";
Packit 6c4009
      my($string) = "$2";
Packit 6c4009
      my($res) = $missing;
Packit 6c4009
Packit 6c4009
      # Remember that this name is allowed.
Packit 6c4009
      push @allow, $macro;
Packit 6c4009
Packit 6c4009
      # Generate a program to test for availability of this macro.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      print TESTFILE "#ifndef $macro\n";
Packit 6c4009
      print TESTFILE "# error \"Macro $macro not defined\"\n";
Packit 6c4009
      print TESTFILE "#endif\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      compiletest ($fnamebase, "Test availability of macro $macro",
Packit 6c4009
		   "Macro \"$macro\" is not available.", $missing, 0, $xfail);
Packit 6c4009
Packit 6c4009
      # Generate a program to test for the value of this macro.
Packit 6c4009
      open (TESTFILE, ">$fnamebase.c");
Packit 6c4009
      print TESTFILE "$prepend";
Packit 6c4009
      print TESTFILE "#include <$h>\n";
Packit 6c4009
      # We can't include <string.h> here.
Packit 6c4009
      print TESTFILE "extern int (strcmp)(const char *, const char *);\n";
Packit 6c4009
      print TESTFILE "int main (void) { return (strcmp) ($macro, $string) != 0;}\n";
Packit 6c4009
      close (TESTFILE);
Packit 6c4009
Packit 6c4009
      $res = runtest ($fnamebase, "Testing for value of macro $macro",
Packit 6c4009
		      "Macro \"$macro\" has not the right value.", $res,
Packit 6c4009
		      $xfail);
Packit 6c4009
    } elsif (/^allow-header *(.*)/) {
Packit 6c4009
      my($pattern) = $1;
Packit 6c4009
      if ($seenheader{$pattern} != 1) {
Packit 6c4009
	push @allowheader, $pattern;
Packit 6c4009
	$seenheader{$pattern} = 1;
Packit 6c4009
      }
Packit 6c4009
      next control;
Packit 6c4009
    } elsif (/^allow *(.*)/) {
Packit 6c4009
      my($pattern) = $1;
Packit 6c4009
      push @allow, $pattern;
Packit 6c4009
      next control;
Packit 6c4009
    } else {
Packit 6c4009
      # printf ("line is `%s'\n", $_);
Packit 6c4009
      next control;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
    printf ("\n");
Packit 6c4009
  }
Packit 6c4009
  close (CONTROL);
Packit 6c4009
Packit 6c4009
  # Read the data files for the header files which are allowed to be included.
Packit 6c4009
  while ($#allowheader >= 0) {
Packit 6c4009
    my($ah) = pop @allowheader;
Packit 6c4009
Packit 6c4009
    open (ALLOW, "$CC -E -D$standard -x c data/$ah-data |");
Packit 6c4009
    acontrol: while (<ALLOW>) {
Packit 6c4009
      chop;
Packit 6c4009
      next acontrol if (/^#/);
Packit 6c4009
      next acontrol if (/^[	]*$/);
Packit 6c4009
Packit 6c4009
      s/^xfail(\[([^\]]*)\])?-//;
Packit 6c4009
      s/^optional-//;
Packit 6c4009
      if (/^element *(\{([^}]*)\}|([^ ]*)) *(\{([^}]*)\}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
Packit 6c4009
	push @allow, $7;
Packit 6c4009
      } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=
Packit 6c4009
	push @allow, $2;
Packit 6c4009
      } elsif (/^(type|tag) *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
Packit 6c4009
	my($type) = "$3$4";
Packit 6c4009
Packit 6c4009
	# Remember that this name is allowed.
Packit 6c4009
	if ($type =~ /^struct *(.*)/) {
Packit 6c4009
	  push @allow, $1;
Packit 6c4009
	} elsif ($type =~ /^union *(.*)/) {
Packit 6c4009
	  push @allow, $1;
Packit 6c4009
	} else {
Packit 6c4009
	  push @allow, $type;
Packit 6c4009
	}
Packit 6c4009
      } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
	push @allow, $4;
Packit 6c4009
      } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
	push @allow, $4;
Packit 6c4009
      } elsif (/^variable *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
Packit 6c4009
	push @allow, $4;
Packit 6c4009
      } elsif (/^macro-function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
Packit 6c4009
	push @allow, $4;
Packit 6c4009
      } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      } elsif (/^allow-header *(.*)/) {
Packit 6c4009
	if ($seenheader{$1} != 1) {
Packit 6c4009
	  push @allowheader, $1;
Packit 6c4009
	  $seenheader{$1} = 1;
Packit 6c4009
	}
Packit 6c4009
      } elsif (/^allow *(.*)/) {
Packit 6c4009
	push @allow, $1;
Packit 6c4009
      }
Packit 6c4009
    }
Packit 6c4009
    close (ALLOW);
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  if ($test_exist) {
Packit 6c4009
    printf ("  Not defined\n");
Packit 6c4009
  } else {
Packit 6c4009
    # Now check the namespace.
Packit 6c4009
    printf ("  Checking the namespace of \"%s\"... ", $h);
Packit 6c4009
    if ($missing) {
Packit 6c4009
      ++$skipped;
Packit 6c4009
      printf ("SKIP\n");
Packit 6c4009
    } else {
Packit 6c4009
      checknamespace ($h, $fnamebase, @allow);
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  printf ("\n\n");
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
printf "-" x 76 . "\n";
Packit 6c4009
printf ("  Total number of tests   : %4d\n", $total);
Packit 6c4009
Packit 6c4009
printf ("  Number of failed tests  : %4d (", $errors);
Packit 6c4009
$percent = ($errors * 100) / $total;
Packit 6c4009
if ($errors > 0 && $percent < 1.0) {
Packit 6c4009
  printf (" <1%%)\n");
Packit 6c4009
} else {
Packit 6c4009
  printf ("%3d%%)\n", $percent);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
printf ("  Number of xfailed tests : %4d (", $xerrors);
Packit 6c4009
$percent = ($xerrors * 100) / $total;
Packit 6c4009
if ($xerrors > 0 && $percent < 1.0) {
Packit 6c4009
  printf (" <1%%)\n");
Packit 6c4009
} else {
Packit 6c4009
  printf ("%3d%%)\n", $percent);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
printf ("  Number of skipped tests : %4d (", $skipped);
Packit 6c4009
$percent = ($skipped * 100) / $total;
Packit 6c4009
if ($skipped > 0 && $percent < 1.0) {
Packit 6c4009
  printf (" <1%%)\n");
Packit 6c4009
} else {
Packit 6c4009
  printf ("%3d%%)\n", $percent);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
exit $errors != 0;
Packit 6c4009
# Local Variables:
Packit 6c4009
#  perl-indent-level: 2
Packit 6c4009
# End: