From: Julian Seward Date: Sat, 17 Nov 2007 23:00:47 +0000 (+0000) Subject: Add regtest for the --child-silent-after-fork added in r7177. X-Git-Tag: svn/VALGRIND_3_3_0~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfebdf020603b3aace331883b0c6b8da2309937c;p=thirdparty%2Fvalgrind.git Add regtest for the --child-silent-after-fork added in r7177. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7178 --- diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 3331b637f4..98cb1cb1a3 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -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 index 0000000000..7e30e38949 --- /dev/null +++ b/memcheck/tests/noisy_child.c @@ -0,0 +1,42 @@ + +#include +#include +#include +#include + +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 index 0000000000..b2a3b7ac93 --- /dev/null +++ b/memcheck/tests/noisy_child.stderr.exp @@ -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 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/noisy_child.vgtest b/memcheck/tests/noisy_child.vgtest new file mode 100644 index 0000000000..83a3b217c4 --- /dev/null +++ b/memcheck/tests/noisy_child.vgtest @@ -0,0 +1,2 @@ +prog: noisy_child +vgopts: --child-silent-after-fork=yes