mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Add regtest for the --child-silent-after-fork added in r7177.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7178
This commit is contained in:
parent
29ff6066e9
commit
dfebdf0206
@ -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 \
|
||||
|
||||
42
memcheck/tests/noisy_child.c
Normal file
42
memcheck/tests/noisy_child.c
Normal file
@ -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;
|
||||
|
||||
}
|
||||
19
memcheck/tests/noisy_child.stderr.exp
Normal file
19
memcheck/tests/noisy_child.stderr.exp
Normal file
@ -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
|
||||
0
memcheck/tests/noisy_child.stdout.exp
Normal file
0
memcheck/tests/noisy_child.stdout.exp
Normal file
2
memcheck/tests/noisy_child.vgtest
Normal file
2
memcheck/tests/noisy_child.vgtest
Normal file
@ -0,0 +1,2 @@
|
||||
prog: noisy_child
|
||||
vgopts: --child-silent-after-fork=yes
|
||||
Loading…
x
Reference in New Issue
Block a user