From: Nicholas Nethercote Date: Mon, 16 Feb 2009 00:42:10 +0000 (+0000) Subject: Merge r9175 (don't run inappropriate OS- and platform-specific tests) from X-Git-Tag: svn/VALGRIND_3_5_0~972 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=108768ee9893ca2314d1a43ec625603c06687160;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/configure.in b/configure.in index 3e9e76c4da..63fa8e4d08 100644 --- a/configure.in +++ b/configure.in @@ -1690,6 +1690,7 @@ AC_OUTPUT( docs/xml/Makefile tests/Makefile tests/vg_regtest + tests/os_test perf/Makefile perf/vg_perf include/Makefile diff --git a/docs/internals/porting-HOWTO.txt b/docs/internals/porting-HOWTO.txt index 121e39c856..abc9a97e37 100644 --- a/docs/internals/porting-HOWTO.txt +++ b/docs/internals/porting-HOWTO.txt @@ -68,8 +68,9 @@ Once it compiles ok, get it to run: Once it runs ok: -- Add the cpu to the tests/cputest.c file so the reg test script will work. - (Don't forget to add it to all_archs[].) +- Add the arch to the tests/arch_test.c file so the reg test script will work. + (Don't forget to add it to all_archs[].) Likewise for os_test.in and + platform_test. - Ensure the regression tests work, and add some arch-specific tests to none/tests directory. diff --git a/docs/internals/porting-to-ARM.txt b/docs/internals/porting-to-ARM.txt index d99f9adb4e..4e54d2476f 100644 --- a/docs/internals/porting-to-ARM.txt +++ b/docs/internals/porting-to-ARM.txt @@ -156,7 +156,7 @@ From coregrind/m_signals.c # error VG_UCONTEXT_SYSCALL_RET undefined for ARM/Linux ============================================================================= -From tests/cputest.c +From tests/arch_test.c ============================================================================= - You'll need to add "arm" to all_archs[]. diff --git a/memcheck/tests/x86/fxsave.vgtest b/memcheck/tests/x86/fxsave.vgtest index 1049e63307..93a87a9ad2 100644 --- a/memcheck/tests/x86/fxsave.vgtest +++ b/memcheck/tests/x86/fxsave.vgtest @@ -1,4 +1,4 @@ prog: fxsave -prereq: ../../../tests/cputest x86-sse +prereq: ../../../tests/arch_test x86-sse vgopts: -q args: x diff --git a/memcheck/tests/x86/sse1_memory.vgtest b/memcheck/tests/x86/sse1_memory.vgtest index 5134ea9170..cf6cd55f2c 100644 --- a/memcheck/tests/x86/sse1_memory.vgtest +++ b/memcheck/tests/x86/sse1_memory.vgtest @@ -1,4 +1,4 @@ prog: sse_memory vgopts: -q args: sse1 -prereq: ../../../tests/cputest x86-sse +prereq: ../../../tests/arch_test x86-sse diff --git a/memcheck/tests/x86/sse2_memory.vgtest b/memcheck/tests/x86/sse2_memory.vgtest index 8eaeca60bf..1fe8856d77 100644 --- a/memcheck/tests/x86/sse2_memory.vgtest +++ b/memcheck/tests/x86/sse2_memory.vgtest @@ -1,4 +1,4 @@ prog: sse_memory vgopts: -q args: sse2 -prereq: ../../../tests/cputest x86-sse2 +prereq: ../../../tests/arch_test x86-sse2 diff --git a/memcheck/tests/x86/xor-undef-x86.vgtest b/memcheck/tests/x86/xor-undef-x86.vgtest index daa648bb36..495a57c77b 100644 --- a/memcheck/tests/x86/xor-undef-x86.vgtest +++ b/memcheck/tests/x86/xor-undef-x86.vgtest @@ -1,2 +1,2 @@ prog: xor-undef-x86 -prereq: ../../../tests/cputest x86-sse +prereq: ../../../tests/arch_test x86-sse diff --git a/none/tests/amd64/insn_sse3.vgtest b/none/tests/amd64/insn_sse3.vgtest index af3d9c6072..ccf6cffe93 100644 --- a/none/tests/amd64/insn_sse3.vgtest +++ b/none/tests/amd64/insn_sse3.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/amd64/insn_sse3 -prereq: ../../../tests/cputest amd64-sse3 +prereq: ../../../tests/arch_test amd64-sse3 vgopts: -q diff --git a/none/tests/amd64/insn_ssse3.vgtest b/none/tests/amd64/insn_ssse3.vgtest index 311d8f24c1..d08dc3d654 100644 --- a/none/tests/amd64/insn_ssse3.vgtest +++ b/none/tests/amd64/insn_ssse3.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/amd64/insn_ssse3 -prereq: ../../../tests/cputest amd64-ssse3 +prereq: ../../../tests/arch_test amd64-ssse3 vgopts: -q diff --git a/none/tests/amd64/ssse3_misaligned.vgtest b/none/tests/amd64/ssse3_misaligned.vgtest index ba7656859a..76255d9412 100644 --- a/none/tests/amd64/ssse3_misaligned.vgtest +++ b/none/tests/amd64/ssse3_misaligned.vgtest @@ -1,3 +1,3 @@ prog: ssse3_misaligned -prereq: ../../../tests/cputest amd64-ssse3 +prereq: ../../../tests/arch_test amd64-ssse3 vgopts: -q diff --git a/none/tests/x86/bug137714-x86.vgtest b/none/tests/x86/bug137714-x86.vgtest index 35bd7dfb48..ab1560e85f 100644 --- a/none/tests/x86/bug137714-x86.vgtest +++ b/none/tests/x86/bug137714-x86.vgtest @@ -1,3 +1,3 @@ prog: bug137714-x86 -prereq: ../../../tests/cputest x86-sse2 +prereq: ../../../tests/arch_test x86-sse2 vgopts: -q diff --git a/none/tests/x86/cse_fail.vgtest b/none/tests/x86/cse_fail.vgtest index 13e64bd0c5..6c0092cbc9 100644 --- a/none/tests/x86/cse_fail.vgtest +++ b/none/tests/x86/cse_fail.vgtest @@ -1,3 +1,3 @@ prog: cse_fail -prereq: ../../../tests/cputest x86-sse +prereq: ../../../tests/arch_test x86-sse vgopts: -q diff --git a/none/tests/x86/insn_cmov.vgtest b/none/tests/x86/insn_cmov.vgtest index e4cf756971..42b44b9936 100644 --- a/none/tests/x86/insn_cmov.vgtest +++ b/none/tests/x86/insn_cmov.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_cmov -prereq: ../../../tests/cputest x86-cmov +prereq: ../../../tests/arch_test x86-cmov vgopts: -q diff --git a/none/tests/x86/insn_fpu.vgtest b/none/tests/x86/insn_fpu.vgtest index cb7cb8b1c7..01e514a378 100644 --- a/none/tests/x86/insn_fpu.vgtest +++ b/none/tests/x86/insn_fpu.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_fpu -prereq: ../../../tests/cputest x86-fpu +prereq: ../../../tests/arch_test x86-fpu vgopts: -q diff --git a/none/tests/x86/insn_mmx.vgtest b/none/tests/x86/insn_mmx.vgtest index 301f38a7b2..88adf5b10e 100644 --- a/none/tests/x86/insn_mmx.vgtest +++ b/none/tests/x86/insn_mmx.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_mmx -prereq: ../../../tests/cputest x86-mmx +prereq: ../../../tests/arch_test x86-mmx vgopts: -q diff --git a/none/tests/x86/insn_mmxext.vgtest b/none/tests/x86/insn_mmxext.vgtest index 42dc0e1ef1..2b42ff4227 100644 --- a/none/tests/x86/insn_mmxext.vgtest +++ b/none/tests/x86/insn_mmxext.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_mmxext -prereq: ../../../tests/cputest x86-mmxext +prereq: ../../../tests/arch_test x86-mmxext vgopts: -q diff --git a/none/tests/x86/insn_sse.vgtest b/none/tests/x86/insn_sse.vgtest index 731dae81dc..24a7f066e2 100644 --- a/none/tests/x86/insn_sse.vgtest +++ b/none/tests/x86/insn_sse.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_sse -prereq: ../../../tests/cputest x86-sse +prereq: ../../../tests/arch_test x86-sse vgopts: -q diff --git a/none/tests/x86/insn_sse2.vgtest b/none/tests/x86/insn_sse2.vgtest index 7f4bbaf323..a13a51d619 100644 --- a/none/tests/x86/insn_sse2.vgtest +++ b/none/tests/x86/insn_sse2.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_sse2 -prereq: ../../../tests/cputest x86-sse2 +prereq: ../../../tests/arch_test x86-sse2 vgopts: -q diff --git a/none/tests/x86/insn_sse3.vgtest b/none/tests/x86/insn_sse3.vgtest index c471163be9..6c679991be 100644 --- a/none/tests/x86/insn_sse3.vgtest +++ b/none/tests/x86/insn_sse3.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_sse3 -prereq: ../../../tests/cputest x86-sse3 +prereq: ../../../tests/arch_test x86-sse3 vgopts: -q diff --git a/none/tests/x86/insn_ssse3.vgtest b/none/tests/x86/insn_ssse3.vgtest index 10c976cee4..c9b5a61603 100644 --- a/none/tests/x86/insn_ssse3.vgtest +++ b/none/tests/x86/insn_ssse3.vgtest @@ -1,3 +1,3 @@ prog: ../../../none/tests/x86/insn_ssse3 -prereq: ../../../tests/cputest x86-ssse3 +prereq: ../../../tests/arch_test x86-ssse3 vgopts: -q diff --git a/none/tests/x86/ssse3_misaligned.vgtest b/none/tests/x86/ssse3_misaligned.vgtest index 15e8324281..bd570b65ee 100644 --- a/none/tests/x86/ssse3_misaligned.vgtest +++ b/none/tests/x86/ssse3_misaligned.vgtest @@ -1,3 +1,3 @@ prog: ssse3_misaligned -prereq: ../../../tests/cputest x86-ssse3 +prereq: ../../../tests/arch_test x86-ssse3 vgopts: -q diff --git a/tests/Makefile.am b/tests/Makefile.am index bb4670314f..9109378b79 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_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g $(AM_FLAG_M3264_PRI) 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 fc82b73928..398cb67e6f 100644 --- a/tests/cputest.c +++ b/tests/arch_test.c @@ -92,9 +92,39 @@ static void cpuid ( unsigned int n, #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 @@ static Bool go(char* cpu) } 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 main(int argc, char **argv) { int i; if ( argc != 2 ) { - fprintf( stderr, "usage: cputest \n" ); + fprintf( stderr, "usage: arch_test \n" ); exit( 2 ); } if (go( argv[1] )) { diff --git a/tests/os_test.in b/tests/os_test.in new file mode 100644 index 0000000000..27410dd474 --- /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 " + 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 0000000000..e11d5d8537 --- /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 " + 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 bc065da1cd..1d397a6896 100755 --- a/tests/vg_regtest.in +++ b/tests/vg_regtest.in @@ -378,14 +378,18 @@ sub test_one_dir($$) # 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";