Nicholas Nethercote c8d150dbaa Various build system clean-ups and simplifications:
- Created Makefile.tool-tests.am, put standard AM_CFLAGS et al for tests in
  it.
- A number of tests are shared between Helgrind and DRD.  They used to be
  built in both directories.  Now they are only built in helgrind/tests/,
  and the DRD .vgtest files just point to the executable in helgrind/tests/.
  Most of these (about 30) had the source files in helgrind/tests/;  I moved
  the three that were in drd/tests/ into helgrind/tests/ for consistency.
- Fixed rwlock_test, which was failing to run due to a wrong name in the
  .vgtest file.
- Removed remnants of unused 'hello' test for Memcheck.
- Avoided redundant flag specification in various places, esp.
  memcheck/tests/Makefile.am.
- Removed unnecessary _AIX guards in some Linux-only tests.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9202
2009-02-19 09:52:05 +00:00

41 lines
1012 B
C

#include <assert.h>
#include <stdio.h>
#include <sys/syscall.h>
#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++) {
res = (void*)syscall(__NR_brk, vals[i]);
}
assert( 0 == brk(orig_ds) ); // libc brk()
for (i = 0; EOL != vals[i]; i++) {
res = (void*)(long)brk(vals[i]);
}
return 0;
}