From 854fc1cb6352edd28bbcdcb44d3f0c64df2a5bcc Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 19 Apr 2008 14:46:57 +0000 Subject: [PATCH] Added regression test for mallinfo(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7889 --- none/tests/Makefile.am | 2 ++ none/tests/mallinfo.c | 28 ++++++++++++++++++++++++++++ none/tests/mallinfo.stderr.exp | 3 +++ none/tests/mallinfo.vgtest | 1 + 4 files changed, 34 insertions(+) create mode 100644 none/tests/mallinfo.c create mode 100644 none/tests/mallinfo.stderr.exp create mode 100644 none/tests/mallinfo.vgtest diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 2577e7c03d..ea3ecd1779 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -70,6 +70,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \ fork.stderr.exp fork.stdout.exp fork.vgtest \ fucomip.stderr.exp fucomip.vgtest \ gxx304.stderr.exp gxx304.vgtest \ + mallinfo.stderr.exp mallinfo.vgtest \ manythreads.stdout.exp manythreads.stderr.exp manythreads.vgtest \ map_unaligned.stderr.exp map_unaligned.vgtest \ map_unmap.stderr.exp map_unmap.stdout.exp map_unmap.vgtest \ @@ -140,6 +141,7 @@ check_PROGRAMS = \ fdleak_fcntl fdleak_ipv4 fdleak_open fdleak_pipe \ fdleak_socketpair \ floored fork fucomip manythreads \ + mallinfo \ munmap_exe map_unaligned map_unmap mq mremap mremap2 \ nestedfns \ pending \ diff --git a/none/tests/mallinfo.c b/none/tests/mallinfo.c new file mode 100644 index 0000000000..5dd6264938 --- /dev/null +++ b/none/tests/mallinfo.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + + +int main(int argc, char** argv) +{ + struct mallinfo mi; + int allocated, allocated1, allocated2; + void* p; + + fprintf(stderr, + "Test of mallinfo(). May not trigger any assertion failures.\n"); + + mi = mallinfo(); + assert(mi.arena == mi.uordblks + mi.fordblks); + allocated1 = mi.arena + mi.hblkhd; + allocated = 128*4096; + p = malloc(allocated); + mi = mallinfo(); + assert(mi.arena == mi.uordblks + mi.fordblks); + allocated2 = mi.arena + mi.hblkhd; + assert(allocated2 - allocated1 >= allocated); + free(p); + + return 0; +} diff --git a/none/tests/mallinfo.stderr.exp b/none/tests/mallinfo.stderr.exp new file mode 100644 index 0000000000..c1f4963a6b --- /dev/null +++ b/none/tests/mallinfo.stderr.exp @@ -0,0 +1,3 @@ + +Test of mallinfo(). May not trigger any assertion failures. + diff --git a/none/tests/mallinfo.vgtest b/none/tests/mallinfo.vgtest new file mode 100644 index 0000000000..a918f72515 --- /dev/null +++ b/none/tests/mallinfo.vgtest @@ -0,0 +1 @@ +prog: mallinfo -- 2.47.3