Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision 10876)
+++ tests/Makefile.am	(working copy)
@@ -17,8 +17,7 @@
 	sys_mman.h
 
 check_PROGRAMS = \
-	arch_test \
-	os_test \
+	arch_display \
 	true \
 	x86_amd64_features
 
Index: tests/vg_regtest.in
===================================================================
--- tests/vg_regtest.in	(revision 10876)
+++ tests/vg_regtest.in	(working copy)
@@ -128,10 +128,82 @@
 
 my $valgrind_lib = "$tests_dir/.in_place";
 
+my $val_src_dir = $tests_dir;
+
 # default filter is the one named "filter_stderr" in the test's directory
 my $default_stderr_filter = "filter_stderr";
 
+# Maintain a list of supported operating systems and architectures.
+my %os_convert;
 
+my @platforms = qw(x86-linux amd64-linux ppc32-linux ppc64-linux ppc32-aix5 ppc64-aix5 x86-darwin amd64-darwin);
+my @all_arches = qw(x86 amd64 ppc32 ppc64);
+# Convert from the output of `uname -o` to a OS.
+$os_convert{"GNU/Linux"} = "linux";
+#$os_convert{"Darwin"} = "darwin";
+#$os_convert{"aix"} = "aix5";
+
+# Convert the above lists into something we can work with.
+my %platforms;
+map {$platforms{$_} = 1 } @platforms;
+
+my %os_convert_reverse;
+map { $os_convert_reverse{$os_convert{$_}} = $_ } keys(%os_convert);
+
+my %all_arches_reverse;
+map {$all_arches_reverse{$_} = 1 } @all_arches;
+
+my %supported_arches;
+
+# Load the current OS.
+chomp(my $this_os_uname = `uname -o`);
+my $this_os = $os_convert{$this_os_uname};
+
+# Load the list of architectures supported by this build.
+chomp(my $supported_arches = `./tests/arch_display`);
+map { $supported_arches{$_} = 1 } split(",",$supported_arches);
+
+# Take the name of a target os and test it, return codes:
+# 0 - The name given is the currently running OS.
+# 1 - The name given is a known OS.
+# 2 - The name given isn't known.
+sub os_test ($)
+{
+    my ($os) = @_;
+    return 0 if ( $os eq $this_os );
+
+    return 1 if ( defined $os_convert_reverse{$os} );
+
+    return 2;
+
+}
+
+# Take the name of a arch and test it, return codes:
+# 0 - This arch is supported by this build.
+# 1 - This arch is known but not supported by this build.
+# 2 - This arch isn't known.
+sub arch_test ($)
+{
+    my ($arch) = @_;
+    
+    return 0 if ( defined $supported_arches{$arch});
+    
+    return 1 if ( defined $all_arches_reverse{$arch});
+
+    return 2;
+}
+
+sub platform_test ($$)
+{
+    my ($arch,$os) = @_;
+    
+    return 0 if ( arch_test($arch) == 0 and os_test($os) == 0 );
+    
+    return 1 if (defined $platforms{"$arch-$os"});
+
+    return 2;
+}
+
 #----------------------------------------------------------------------------
 # Process command line, setup
 #----------------------------------------------------------------------------
@@ -175,6 +247,8 @@
                 $valgrind = $1;
             } elsif ($arg =~ /^--valgrind-lib=(.*)$/) {
                 $valgrind_lib = $1;
+            } elsif ($arg =~ /^--valgrind-src-dir=(.*)$/) {
+                $val_src_dir = $1;
             } else {
                 die $usage;
             }
@@ -394,19 +468,16 @@
 
     # Ignore dirs into which we should not recurse.
     if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }
-
-    (-x "$tests_dir/tests/arch_test") or die 
-        "vg_regtest: 'arch_test' is missing.  Did you forget to 'make check'?\n";
     
     # Ignore any dir whose name matches that of an architecture which is not
     # the architecture we are running on.  Eg. when running on x86, ignore
     # ppc/ directories ('arch_test' returns 1 for this case).  Likewise for
     # the OS and platform.
-    # Nb: weird Perl-ism -- exit code of '1' is seen by Perl as 256...
-    if (256 == system("$tests_dir/tests/arch_test $dir"))  { return; }
-    if (256 == system("$tests_dir/tests/os_test   $dir"))  { return; }
-    if ($dir =~ /(\w+)-(\w+)/ &&
-        256 == system("sh $tests_dir/tests/platform_test $1 $2")) { return; }
+    if ( arch_test($dir) == 1 ) { return; }
+    if ( os_test($dir) == 1 ) { return; }
+    if ($dir =~ /(\w+)-(\w+)/ ) {
+	if ( platform_test($1,$2) == 1 ) { return; }
+    }
     
     chdir($dir) or die "Could not change into $dir\n";
 
Index: tests/arch_display.c
===================================================================
--- tests/arch_display.c	(revision 0)
+++ tests/arch_display.c	(revision 0)
@@ -0,0 +1,42 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// This program determines which architectures that this Valgrind installation
+// supports, which depends on the what was chosen at configure-time.  For
+// example, if Valgrind is installed on an AMD64 machine but has been
+// configured with --enable-only32bit then this program will report "x86" but
+// not "amd64".
+//
+// We return a comma seperated list of all target architectures supported.
+
+int main(int argc, char **argv)
+{
+#if defined(VGP_x86_linux) || defined(VGP_x86_darwin)
+   printf("x86\n");
+
+#elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin)
+   printf("x86,amd64\n");
+
+#elif defined(VGP_ppc32_linux)
+   printf("ppc32\n");
+
+#elif defined(VGP_ppc64_linux)
+   printf("ppc64,ppc32\n");
+
+#elif defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+   if (sizeof(void*) == 8) {
+      /* CPU is in 64-bit mode */
+      printf("ppc64,ppc32\n");
+   } else {
+      printf("ppc32\n");
+   }
+
+#else
+#  error Unknown platform
+#endif   // VGP_*
+   return 0;
+}
+
+
