|
From: <sv...@va...> - 2005-11-08 13:20:32
|
Author: sewardj
Date: 2005-11-08 13:20:24 +0000 (Tue, 08 Nov 2005)
New Revision: 5038
Log:
Add tests for --partial-loads-ok=3D flag.
Added:
trunk/memcheck/tests/partial_load.c
trunk/memcheck/tests/partial_load_dflt.stderr.exp
trunk/memcheck/tests/partial_load_dflt.vgtest
trunk/memcheck/tests/partial_load_ok.stderr.exp
trunk/memcheck/tests/partial_load_ok.vgtest
Modified:
trunk/memcheck/tests/Makefile.am
Modified: trunk/memcheck/tests/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/Makefile.am 2005-11-08 12:28:35 UTC (rev 5037)
+++ trunk/memcheck/tests/Makefile.am 2005-11-08 13:20:24 UTC (rev 5038)
@@ -63,6 +63,8 @@
oset_test.stderr.exp oset_test.stdout.exp oset_test.vgtest \
partiallydefinedeq.vgtest partiallydefinedeq.stderr.exp \
partiallydefinedeq.stdout.exp \
+ partial_load_ok.vgtest partial_load_ok.stderr.exp \
+ partial_load_dflt.vgtest partial_load_dflt.stderr.exp \
pipe.stderr.exp pipe.vgtest \
pointer-trace.vgtest \
pointer-trace.stderr.exp pointer-trace.stderr.exp64 \
@@ -109,6 +111,7 @@
nanoleak new_nothrow \
null_socket oset_test overlap \
partiallydefinedeq \
+ partial_load \
pipe pointer-trace \
post-syscall \
realloc1 realloc2 realloc3 \
Added: trunk/memcheck/tests/partial_load.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/partial_load.c 2005-11-08 12:28:35 UTC (rev 5037=
)
+++ trunk/memcheck/tests/partial_load.c 2005-11-08 13:20:24 UTC (rev 5038=
)
@@ -0,0 +1,45 @@
+
+#include <stdlib.h>
+#include <assert.h>
+
+int main ( void )
+{
+ long w;
+ int i;
+ char* p;
+
+ assert(sizeof(long) =3D=3D sizeof(void*));
+
+ /* partial load, which --partial-loads-ok=3Dyes should suppress */
+ p =3D calloc( sizeof(long)-1, 1 );
+ assert(p);
+ w =3D *(long*)p;
+ free(p);
+
+ /* partial but misaligned, cannot be suppressed */
+ p =3D calloc( sizeof(long), 1 );
+ assert(p);
+ p++;
+ w +=3D *(long*)p;
+ p--;
+ free(p);
+
+ /* partial but not word sized, cannot be suppressed */
+ p =3D calloc( sizeof(short)-1, 1 );
+ assert(p);
+ w +=3D (long)( *(short*)p );
+ free(p);
+
+ /* aligned, word sized, but completely invalid - cannot be suppressed =
*/
+ p =3D calloc( sizeof(long), 1 );
+ assert(p);
+ free(p);
+ w +=3D *(long*)p;
+
+ /* dump result in a way gcc can't understand */
+ for (i =3D 0; i < 64; i++)
+ w <<=3D 1;
+
+ return (int)w;
+}
+
Added: trunk/memcheck/tests/partial_load_dflt.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/partial_load_dflt.stderr.exp 2005-11-08 12:28:35=
UTC (rev 5037)
+++ trunk/memcheck/tests/partial_load_dflt.stderr.exp 2005-11-08 13:20:24=
UTC (rev 5038)
@@ -0,0 +1,30 @@
+
+Invalid read of size 4
+ at 0x........: main (partial_load.c:16)
+ Address 0x........ is 0 bytes inside a block of size 3 alloc'd
+ at 0x........: calloc (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:14)
+
+Invalid read of size 4
+ at 0x........: main (partial_load.c:23)
+ Address 0x........ is 1 bytes inside a block of size 4 alloc'd
+ at 0x........: calloc (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:20)
+
+Invalid read of size 2
+ at 0x........: main (partial_load.c:30)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+ at 0x........: calloc (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:28)
+
+Invalid read of size 4
+ at 0x........: main (partial_load.c:37)
+ Address 0x........ is 0 bytes inside a block of size 4 free'd
+ at 0x........: free (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:36)
+
+ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 4 allocs, 4 frees, 12 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=3Dyes
+For counts of detected errors, rerun with: -v
Added: trunk/memcheck/tests/partial_load_dflt.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/partial_load_dflt.vgtest 2005-11-08 12:28:35 UTC=
(rev 5037)
+++ trunk/memcheck/tests/partial_load_dflt.vgtest 2005-11-08 13:20:24 UTC=
(rev 5038)
@@ -0,0 +1 @@
+prog: partial_load
Added: trunk/memcheck/tests/partial_load_ok.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/partial_load_ok.stderr.exp 2005-11-08 12:28:35 U=
TC (rev 5037)
+++ trunk/memcheck/tests/partial_load_ok.stderr.exp 2005-11-08 13:20:24 U=
TC (rev 5038)
@@ -0,0 +1,24 @@
+
+Invalid read of size 4
+ at 0x........: main (partial_load.c:23)
+ Address 0x........ is 1 bytes inside a block of size 4 alloc'd
+ at 0x........: calloc (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:20)
+
+Invalid read of size 2
+ at 0x........: main (partial_load.c:30)
+ Address 0x........ is 0 bytes inside a block of size 1 alloc'd
+ at 0x........: calloc (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:28)
+
+Invalid read of size 4
+ at 0x........: main (partial_load.c:37)
+ Address 0x........ is 0 bytes inside a block of size 4 free'd
+ at 0x........: free (vg_replace_malloc.c:...)
+ by 0x........: main (partial_load.c:36)
+
+ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 4 allocs, 4 frees, 12 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=3Dyes
+For counts of detected errors, rerun with: -v
Added: trunk/memcheck/tests/partial_load_ok.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/tests/partial_load_ok.vgtest 2005-11-08 12:28:35 UTC (=
rev 5037)
+++ trunk/memcheck/tests/partial_load_ok.vgtest 2005-11-08 13:20:24 UTC (=
rev 5038)
@@ -0,0 +1,2 @@
+prog: partial_load
+vgopts: --partial-loads-ok=3Dyes
|