summary refs log tree commit diff
path: root/conform/conformtest.pl
diff options
context:
space:
mode:
Diffstat (limited to 'conform/conformtest.pl')
-rw-r--r--conform/conformtest.pl69
1 files changed, 41 insertions, 28 deletions
diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index e2c3b06b62..9424203ec9 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -1,26 +1,46 @@
 #! /usr/bin/perl
 
+use Getopt::Long;
+
 $CC = "gcc";
-$CFLAGS = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=600";
+
+$dialect="XOPEN2K";
+GetOptions ('headers=s' => \@headers, 'dialect=s' => \$dialect);
+@headers = split(/,/,join(',',@headers));
 
 # List of the headers we are testing.
-@headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
-	    "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h",
-	    "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h", "sys/un.h",
-	    "sys/uio.h", "sys/types.h", "sys/times.h", "sys/timeb.h",
-	    "sys/time.h", "sys/statvfs.h", "sys/stat.h", "sys/socket.h",
-	    "sys/shm.h", "sys/sem.h", "sys/resource.h", "sys/msg.h",
-	    "sys/mman.h", "sys/ipc.h", "syslog.h", "stropts.h", "strings.h",
-	    "string.h", "stdlib.h", "stdio.h", "stddef.h", "stdarg.h",
-	    "spawn.h", "signal.h", "setjmp.h", "semaphore.h",
-	    "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h",
-	    "poll.h", "nl_types.h", "netinet/tcp.h", "netinet/in.h",
-	    "net/if.h", "netdb.h", "ndbm.h", "mqueue.h", "monetary.h",
-	    "math.h", "locale.h", "libgen.h", "limits.h", "langinfo.h",
-	    "iso646.h", "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h",
-	    "fnmatch.h", "fmtmsg.h", "float.h", "fcntl.h", "errno.h",
-	    "dlfcn.h", "dirent.h", "ctype.h", "cpio.h", "assert.h",
-	    "arpa/inet.h", "aio.h");
+if (@headers == ()) {
+  @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h",
+	      "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h",
+	      "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h", "sys/un.h",
+	      "sys/uio.h", "sys/types.h", "sys/times.h", "sys/timeb.h",
+	      "sys/time.h", "sys/statvfs.h", "sys/stat.h", "sys/socket.h",
+	      "sys/shm.h", "sys/sem.h", "sys/resource.h", "sys/msg.h",
+	      "sys/mman.h", "sys/ipc.h", "syslog.h", "stropts.h", "strings.h",
+	      "string.h", "stdlib.h", "stdio.h", "stddef.h", "stdarg.h",
+	      "spawn.h", "signal.h", "setjmp.h", "semaphore.h",
+	      "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h",
+	      "poll.h", "nl_types.h", "netinet/tcp.h", "netinet/in.h",
+	      "net/if.h", "netdb.h", "ndbm.h", "mqueue.h", "monetary.h",
+	      "math.h", "locale.h", "libgen.h", "limits.h", "langinfo.h",
+	      "iso646.h", "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h",
+	      "fnmatch.h", "fmtmsg.h", "float.h", "fcntl.h", "errno.h",
+	      "dlfcn.h", "dirent.h", "ctype.h", "cpio.h", "assert.h",
+	      "arpa/inet.h", "aio.h");
+}
+
+if ($dialect ne "ISO" && $dialect ne "POSIX" && $dialect ne "XPG3"
+    && $dialect ne "XPG4" && $dialect ne "UNIX98" && $dialect ne "XOPEN2K") {
+  die "unknown dialect \"$dialect\"";
+}
+
+$CFLAGS{"ISO"} = "-I. '-D__attribute__(x)=' -ansi";
+$CFLAGS{"POSIX"} = "-I. '-D__attribute__(x)=' -D_POSIX_C_SOURCE=199912";
+$CFLAGS{"XPG3"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE";
+$CFLAGS{"XPG4"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE_EXTENDED";
+$CFLAGS{"UNIX98"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=500";
+$CFLAGS{"XOPEN2K"} = "-I. '-D__attribute__(x)=' -D_XOPEN_SOURCE=600";
+
 
 # These are the ISO C99 keywords.
 @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default',
@@ -54,13 +74,6 @@ $total = 0;
 $skipped = 0;
 $errors = 0;
 
-#$dialect = "ISO";
-#$dialect = "POSIX";
-#$dialect = "XPG3";
-#$dialect = "XPG4";
-#$dialect = "UNIX98";
-$dialect = "XOPEN2K";
-
 
 sub poorfnmatch {
   my($pattern, $string) = @_;
@@ -95,7 +108,7 @@ sub compiletest
     ++$skipped;
     printf (" SKIP\n");
   } else {
-    $ret = system "$CC $CFLAGS -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
+    $ret = system "$CC $CFLAGS{$dialect} -c $fnamebase.c -o $fnamebase.o > $fnamebase.out 2>&1";
     if ($ret != 0) {
       if ($optional != 0) {
 	printf (" $errmsg\n");
@@ -147,7 +160,7 @@ sub runtest
     ++$skipped;
     printf (" SKIP\n");
   } else {
-    $ret = system "$CC $CFLAGS -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
+    $ret = system "$CC $CFLAGS{$dialect} -o $fnamebase $fnamebase.c > $fnamebase.out 2>&1";
     if ($ret != 0) {
       printf (" FAIL\n");
       if ($verbose != 0) {
@@ -227,7 +240,7 @@ sub checknamespace {
 
   $nerrors = 0;
   $nknown = 0;
-  open (CONTENT, "$CC $CFLAGS -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
+  open (CONTENT, "$CC $CFLAGS{$dialect} -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
   loop: while (<CONTENT>) {
     next loop if (/^#undef /);
     chop;