Merge r9175 (don't run inappropriate OS- and platform-specific tests) from
the DARWIN branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9176 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bb46703..9109378 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,19 +3,21 @@
include $(top_srcdir)/Makefile.flags.am
noinst_SCRIPTS = \
- vg_regtest \
filter_addresses \
filter_discards \
filter_libc \
filter_numbers \
filter_stderr_basic \
filter_sink \
- filter_test_paths
+ filter_test_paths \
+ os_test \
+ platform_test \
+ vg_regtest
EXTRA_DIST = $(noinst_SCRIPTS)
check_PROGRAMS = \
- cputest \
+ arch_test \
toobig-allocs \
true
@@ -23,7 +25,7 @@
AM_CXXFLAGS = $(AM_CFLAGS)
# generic C ones
-cputest_CFLAGS = $(AM_CFLAGS) \
+arch_test_CFLAGS = $(AM_CFLAGS) \
-DVGA_$(VGCONF_ARCH_PRI)=1 \
-DVGO_$(VGCONF_OS)=1 \
-DVGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS)=1
diff --git a/tests/cputest.c b/tests/arch_test.c
similarity index 79%
rename from tests/cputest.c
rename to tests/arch_test.c
index fc82b73..398cb67 100644
--- a/tests/cputest.c
+++ b/tests/arch_test.c
@@ -92,9 +92,39 @@
#endif // VGP_x86_linux || VGP_amd64_linux
//---------------------------------------------------------------------------
-// {x86,amd64}-{linux} (part 2 of 2)
+// {x86,amd64}-darwin (part 1 of 2)
//---------------------------------------------------------------------------
-#if defined(VGP_x86_linux) || defined(VGP_amd64_linux)
+#if defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
+static void cpuid ( unsigned int n,
+ unsigned int* a, unsigned int* b,
+ unsigned int* c, unsigned int* d )
+{
+ __asm__ __volatile__ (
+ "pushl %%eax\n\t"
+ "pushl %%ebx\n\t"
+ "pushl %%ecx\n\t"
+ "pushl %%edx\n\t"
+ "movl %4, %%eax\n\t"
+ "cpuid\n\t"
+ "movl %%eax,%0\n\t"
+ "movl %%ebx,%1\n\t"
+ "movl %%ecx,%2\n\t"
+ "movl %%edx,%3\n\t"
+ "popl %%edx\n\t"
+ "popl %%ecx\n\t"
+ "popl %%ebx\n\t"
+ "popl %%eax\n\t"
+ : "=m" (*a), "=m" (*b), "=m" (*c), "=m" (*d)
+ : "mr" (n)
+ );
+}
+#endif // VGP_x86_darwin || VGP_amd64_darwin
+
+//---------------------------------------------------------------------------
+// {x86,amd64}-{linux,darwin} (part 2 of 2)
+//---------------------------------------------------------------------------
+#if defined(VGP_x86_linux) || defined(VGP_amd64_linux) || \
+ defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
static Bool go(char* cpu)
{
unsigned int level = 0, cmask = 0, dmask = 0, a, b, c, d;
@@ -152,7 +182,8 @@
}
return False;
}
-#endif // VGP_x86_linux || VGP_amd64_linux
+#endif // VGP_x86_linux || VGP_amd64_linux ||
+ // VGP_x86_darwin || VGP_amd64_darwin
//---------------------------------------------------------------------------
@@ -162,7 +193,7 @@
{
int i;
if ( argc != 2 ) {
- fprintf( stderr, "usage: cputest <cpu-type>\n" );
+ fprintf( stderr, "usage: arch_test <cpu-type>\n" );
exit( 2 );
}
if (go( argv[1] )) {
diff --git a/tests/os_test.in b/tests/os_test.in
new file mode 100644
index 0000000..27410dd
--- /dev/null
+++ b/tests/os_test.in
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+# This script determines which OSes that this Valgrind installation
+# supports, which depends on the machine's OS.
+# We return:
+# - 0 if the machine matches the asked-for OS
+# - 1 if it didn't match, but did match the name of another OS
+# - 2 otherwise
+
+# Nb: When updating this file for a new OS, add the name to 'all_OSes'.
+
+all_OSes="linux aix5 darwin"
+
+if [ $# -ne 1 ] ; then
+ echo "usage: os_test <os-type>"
+ exit 2;
+fi
+
+if [ $1 = @VGCONF_OS@ ] ; then
+ exit 0; # Matches this OS.
+fi
+
+for os in $all_OSes ; do
+ if [ $1 = $os ] ; then
+ exit 1; # Matches another Valgrind-supported OS.
+ fi
+done
+
+exit 2; # Doesn't match any Valgrind-supported OS.
diff --git a/tests/platform_test b/tests/platform_test
new file mode 100644
index 0000000..e11d5d8
--- /dev/null
+++ b/tests/platform_test
@@ -0,0 +1,37 @@
+#! /bin/sh
+
+# This script determines which platforms that this Valgrind installation
+# supports.
+# We return:
+# - 0 if the machine matches the asked-for platform
+# - 1 if it didn't match, but did match the name of another platform
+# - 2 otherwise
+
+# Nb: When updating this file for a new platform, add the name to
+# 'all_platforms'.
+
+all_platforms=
+all_platforms="$all_platforms x86-linux amd64-linux ppc32-linux ppc64-linux"
+all_platforms="$all_platforms ppc32-aix5 ppc64-aix5"
+all_platforms="$all_platforms x86-darwin amd64-darwin"
+
+if [ $# -ne 2 ] ; then
+ echo "usage: platform_test <arch-type> <OS-type>"
+ exit 2;
+fi
+
+# Get the directory holding the arch_test and os_test, which will be the same
+# as the one holding this script.
+dir=`dirname $0`
+
+if $dir/arch_test $1 && sh $dir/os_test $2 ; then
+ exit 0; # Matches this platform.
+fi
+
+for p in $all_platforms ; do
+ if [ $1-$2 = $p ] ; then
+ exit 1; # Matches another Valgrind-supported platform.
+ fi
+done
+
+exit 2; # Doesn't match any Valgrind-supported platform.
diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in
index bc065da..1d397a6 100755
--- a/tests/vg_regtest.in
+++ b/tests/vg_regtest.in
@@ -378,14 +378,18 @@
# Ignore dirs into which we should not recurse.
if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }
- (-x "$tests_dir/tests/cputest") or die
- "vg_regtest: 'cputest' is missing. Did you forget to 'make check'?\n";
+ (-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).
+ # 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/cputest $dir")) { return; }
+ if (256 == system( "$tests_dir/tests/arch_test $dir")) { return; }
+ if (256 == system("sh $tests_dir/tests/os_test $dir")) { return; }
+ if ($dir =~ /(\w+)-(\w+)/ &&
+ 256 == system("sh $tests_dir/tests/platform_test $1 $2")) { return; }
chdir($dir) or die "Could not change into $dir\n";