mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-09 05:10:23 +00:00
Move memcheck/tests/brk to the linux/ subdir, as it's Linux-specific (merged
from the DARWIN branch). Also filter the output more so the .stderr.exp2 isn't needed. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9038
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
noinst_SCRIPTS = filter_stderr
|
||||
|
||||
EXTRA_DIST = $(noinst_SCRIPTS) \
|
||||
brk.stderr.exp brk.vgtest \
|
||||
capget capget.stderr.exp \
|
||||
timerfd-syscall timerfd-syscall.stderr.exp
|
||||
|
||||
check_PROGRAMS = \
|
||||
brk \
|
||||
capget \
|
||||
timerfd-syscall
|
||||
|
||||
|
||||
44
memcheck/tests/linux/brk.c
Normal file
44
memcheck/tests/linux/brk.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#if !defined(_AIX)
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// kernel brk() and libc brk() act quite differently...
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
void* orig_ds = sbrk(0);
|
||||
void* ds = orig_ds;
|
||||
void* vals[10];
|
||||
void* res;
|
||||
#define EOL ((void*)( ~(long)0 ))
|
||||
vals[0] = (void*)0;
|
||||
vals[1] = (void*)1;
|
||||
vals[2] = ds - 0x1; // small shrink
|
||||
vals[3] = ds;
|
||||
vals[4] = ds + 0x1000; // small growth
|
||||
vals[5] = ds + 0x40000000; // too-big growth
|
||||
vals[6] = ds + 0x500; // shrink a little, but still above start size
|
||||
vals[7] = ds - 0x1; // shrink below start size
|
||||
// vals[8] = ds - 0x1000; // shrink a lot below start size (into text)
|
||||
// vals[9] = EOL;
|
||||
vals[8] = EOL;
|
||||
|
||||
for (i = 0; EOL != vals[i]; i++) {
|
||||
# if !defined(_AIX)
|
||||
res = (void*)syscall(__NR_brk, vals[i]);
|
||||
# endif
|
||||
}
|
||||
|
||||
assert( 0 == brk(orig_ds) ); // libc brk()
|
||||
|
||||
for (i = 0; EOL != vals[i]; i++) {
|
||||
res = (void*)(long)brk(vals[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
7
memcheck/tests/linux/brk.stderr.exp
Normal file
7
memcheck/tests/linux/brk.stderr.exp
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
malloc/free: in use at exit: ... bytes in ... blocks.
|
||||
malloc/free: ... allocs, ... frees, ... bytes allocated.
|
||||
For a detailed leak analysis, rerun with: --leak-check=yes
|
||||
For counts of detected errors, rerun with: -v
|
||||
2
memcheck/tests/linux/brk.vgtest
Normal file
2
memcheck/tests/linux/brk.vgtest
Normal file
@@ -0,0 +1,2 @@
|
||||
prog: brk
|
||||
stderr_filter: ../filter_allocs
|
||||
Reference in New Issue
Block a user