]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add regtest for the --child-silent-after-fork added in r7177.
authorJulian Seward <jseward@acm.org>
Sat, 17 Nov 2007 23:00:47 +0000 (23:00 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 17 Nov 2007 23:00:47 +0000 (23:00 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7178

memcheck/tests/Makefile.am
memcheck/tests/noisy_child.c [new file with mode: 0644]
memcheck/tests/noisy_child.stderr.exp [new file with mode: 0644]
memcheck/tests/noisy_child.stdout.exp [new file with mode: 0644]
memcheck/tests/noisy_child.vgtest [new file with mode: 0644]

index 3331b637f452fcde473837c4dcdf9ffdf4a326f5..98cb1cb1a33214876dc88b1ccb3b13a9cc114a78 100644 (file)
@@ -86,6 +86,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        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 @@ check_PROGRAMS = \
        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 \
diff --git a/memcheck/tests/noisy_child.c b/memcheck/tests/noisy_child.c
new file mode 100644 (file)
index 0000000..7e30e38
--- /dev/null
@@ -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;
+
+}
diff --git a/memcheck/tests/noisy_child.stderr.exp b/memcheck/tests/noisy_child.stderr.exp
new file mode 100644 (file)
index 0000000..b2a3b7a
--- /dev/null
@@ -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
diff --git a/memcheck/tests/noisy_child.stdout.exp b/memcheck/tests/noisy_child.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/noisy_child.vgtest b/memcheck/tests/noisy_child.vgtest
new file mode 100644 (file)
index 0000000..83a3b21
--- /dev/null
@@ -0,0 +1,2 @@
+prog: noisy_child
+vgopts: --child-silent-after-fork=yes