Author: sewardj
Date: 2007-11-17 23:00:47 +0000 (Sat, 17 Nov 2007)
New Revision: 7178

Log:
Add regtest for the --child-silent-after-fork added in r7177.

Added:
   trunk/memcheck/tests/noisy_child.c
   trunk/memcheck/tests/noisy_child.stderr.exp
   trunk/memcheck/tests/noisy_child.stdout.exp
   trunk/memcheck/tests/noisy_child.vgtest
Modified:
   trunk/memcheck/tests/Makefile.am


Modified: trunk/memcheck/tests/Makefile.am
===================================================================
--- trunk/memcheck/tests/Makefile.am    2007-11-17 22:29:25 UTC (rev 7177)
+++ trunk/memcheck/tests/Makefile.am    2007-11-17 23:00:47 UTC (rev 7178)
@@ -86,6 +86,7 @@
        nanoleak2.stderr.exp nanoleak2.vgtest \
        new_nothrow.stderr.exp new_nothrow.vgtest \
        new_override.stderr.exp new_override.stdout.exp new_override.vgtest \
+       noisy_child.vgtest noisy_child.stderr.exp noisy_child.stdout.exp \
        null_socket.stderr.exp null_socket.vgtest \
        overlap.stderr.exp overlap.stdout.exp overlap.vgtest \
        oset_test.stderr.exp oset_test.stdout.exp oset_test.vgtest \
@@ -160,6 +161,7 @@
        match-overrun \
        memalign_test memalign2 memcmptest mempool mmaptest \
        nanoleak nanoleak2 new_nothrow \
+       noisy_child \
        null_socket oset_test overlap \
        partiallydefinedeq \
        partial_load pdb-realloc pdb-realloc2 \

Added: trunk/memcheck/tests/noisy_child.c
===================================================================
--- trunk/memcheck/tests/noisy_child.c                          (rev 0)
+++ trunk/memcheck/tests/noisy_child.c  2007-11-17 23:00:47 UTC (rev 7178)
@@ -0,0 +1,42 @@
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <assert.h>
+
+void do_child_badness ( char* p )
+{
+   /* Free it a second time */
+   free(p);
+}
+
+void do_parent_badness ( char* p )
+{
+   /* Do a write off the end */
+   p[10] = 42;
+}
+
+
+int main ( void )
+{
+  pid_t child;
+  char* p = malloc(10); assert(p);
+  free(p);
+
+  /* parent does something bad */
+  p[5] = 22;
+
+  child = fork();
+  assert(child != -1); /* assert fork did not fail */
+
+  if (child == 0) {
+     /* I am the child */
+     do_child_badness(p);
+  } else {
+     /* I am the parent */
+     do_parent_badness(p);
+  }
+
+  return 0;
+
+}

Added: trunk/memcheck/tests/noisy_child.stderr.exp
===================================================================
--- trunk/memcheck/tests/noisy_child.stderr.exp                         (rev 0)
+++ trunk/memcheck/tests/noisy_child.stderr.exp 2007-11-17 23:00:47 UTC (rev 
7178)
@@ -0,0 +1,19 @@
+
+Invalid write of size 1
+   at 0x........: main (noisy_child.c:27)
+ Address 0x........ is 5 bytes inside a block of size 10 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: main (noisy_child.c:24)
+
+Invalid write of size 1
+   at 0x........: do_parent_badness (noisy_child.c:16)
+   by 0x........: main (noisy_child.c:37)
+ Address 0x........ is 0 bytes after a block of size 10 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: main (noisy_child.c:24)
+
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 1 allocs, 1 frees, 10 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v

Added: trunk/memcheck/tests/noisy_child.stdout.exp
===================================================================

Added: trunk/memcheck/tests/noisy_child.vgtest
===================================================================
--- trunk/memcheck/tests/noisy_child.vgtest                             (rev 0)
+++ trunk/memcheck/tests/noisy_child.vgtest     2007-11-17 23:00:47 UTC (rev 
7178)
@@ -0,0 +1,2 @@
+prog: noisy_child
+vgopts: --child-silent-after-fork=yes


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to