From: Rhys Kidd Date: Sat, 15 Aug 2015 11:16:35 +0000 (+0000) Subject: Increase test coverage on OS X, by re-enabling the memcheck/tests/amd64/xsave-avx... X-Git-Tag: svn/VALGRIND_3_11_0~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=774dbf0a73cc5eda9b171efaf8ab1f03170876c2;p=thirdparty%2Fvalgrind.git Increase test coverage on OS X, by re-enabling the memcheck/tests/amd64/xsave-avx regression tests with a handy memalign() shim. n-i-bz (Unfortunately I don’t have right here the hw support, but build environment works) $ perl tests/vg_regtest memcheck/tests/amd64/xsave-avx xsave-avx: (skipping, prereq failed: test -x xsave-avx && ../../../tests/x86_amd64_features amd64-avx) == 0 tests, 0 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures == On OS X 10.10 Before: == 594 tests, 215 stderr failures, 9 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures == After: == 594 tests, 215 stderr failures, 9 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures == git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15551 --- diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index 11381be5cb..dc48f417c6 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -46,10 +46,7 @@ check_PROGRAMS = \ sse_memory \ xor-undef-amd64 if BUILD_AVX_TESTS - check_PROGRAMS += sh-mem-vec256 -if !VGCONF_OS_IS_DARWIN - check_PROGRAMS += xsave-avx -endif + check_PROGRAMS += sh-mem-vec256 xsave-avx endif if HAVE_ASM_CONSTRAINT_P check_PROGRAMS += insn-pcmpistri diff --git a/memcheck/tests/amd64/xsave-avx.c b/memcheck/tests/amd64/xsave-avx.c index 0c896febcf..9a3238953a 100644 --- a/memcheck/tests/amd64/xsave-avx.c +++ b/memcheck/tests/amd64/xsave-avx.c @@ -54,9 +54,9 @@ void* my_memcpy(void *dest, const void *src, size_t n) return dest; } -static void* memalign_zeroed(size_t alignment, size_t size) +static void* memalign_zeroed64(size_t size) { - char* p = memalign(alignment, size); + char* p = memalign64(size); if (p && size > 0) { my_memset(p, 0, size); } @@ -203,7 +203,7 @@ void test_xsave ( Bool hideBits64to79 ) UInt rfbm; for (rfbm = 0; rfbm <= 7; rfbm++) { - UChar* saved_img = memalign_zeroed(64, XSAVE_AREA_SIZE); + UChar* saved_img = memalign_zeroed64(XSAVE_AREA_SIZE); my_memset(saved_img, 0xAA, XSAVE_AREA_SIZE); saved_img[512] = 0; @@ -236,7 +236,7 @@ void test_xrstor ( Bool hideBits64to79 ) neither zero nor the data to be loaded. We choose to use 0x55 where possible. */ - UChar* fives = memalign_zeroed(64, XSAVE_AREA_SIZE); + UChar* fives = memalign_zeroed64(XSAVE_AREA_SIZE); my_memset(fives, 0x55, XSAVE_AREA_SIZE); /* Set MXCSR so that the insn doesn't fault */ fives[24] = 0x80; @@ -259,7 +259,7 @@ void test_xrstor ( Bool hideBits64to79 ) fives[4/*FTW*/] = 0xFF; /* (1) (see comment in loop below) */ - UChar* standard_test_data = memalign_zeroed(64, XSAVE_AREA_SIZE); + UChar* standard_test_data = memalign_zeroed64(XSAVE_AREA_SIZE); do_setup_then_xsave(standard_test_data, 7); UInt xstate_bv, rfbm; @@ -283,12 +283,12 @@ void test_xrstor ( Bool hideBits64to79 ) /* (3a). We can't use |standard_test_data| directly, since we need to put in the required |xstate_bv| value. So make a copy and modify that instead. */ - UChar* img_to_restore_from = memalign_zeroed(64, XSAVE_AREA_SIZE); + UChar* img_to_restore_from = memalign_zeroed64(XSAVE_AREA_SIZE); my_memcpy(img_to_restore_from, standard_test_data, XSAVE_AREA_SIZE); img_to_restore_from[512] = xstate_bv; /* (4a) */ - UChar* saved_img = memalign_zeroed(64, XSAVE_AREA_SIZE); + UChar* saved_img = memalign_zeroed64(XSAVE_AREA_SIZE); my_memset(saved_img, 0xAA, XSAVE_AREA_SIZE); saved_img[512] = 0; diff --git a/tests/malloc.h b/tests/malloc.h index 6a73dde1a9..12afdf4a93 100644 --- a/tests/malloc.h +++ b/tests/malloc.h @@ -41,3 +41,19 @@ static void* memalign32(size_t szB) return x; } +// Allocates a 64-aligned block. Asserts if the allocation fails. +__attribute__((unused)) +static void* memalign64(size_t szB) +{ + void* x; +#if defined(VGO_darwin) + // Darwin lacks memalign + posix_memalign((void **)&x, 64, szB); +#else + x = memalign(64, szB); +#endif + assert(x); + assert(0 == ((64-1) & (unsigned long)x)); + return x; +} +