]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added regression test for mallinfo().
authorBart Van Assche <bvanassche@acm.org>
Sat, 19 Apr 2008 14:46:57 +0000 (14:46 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 19 Apr 2008 14:46:57 +0000 (14:46 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7889

none/tests/Makefile.am
none/tests/mallinfo.c [new file with mode: 0644]
none/tests/mallinfo.stderr.exp [new file with mode: 0644]
none/tests/mallinfo.vgtest [new file with mode: 0644]

index 2577e7c03d944fe87d1208af3ec3b7dad5027513..ea3ecd1779b5dbba81d32251678a4aa081787771 100644 (file)
@@ -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 (file)
index 0000000..5dd6264
--- /dev/null
@@ -0,0 +1,28 @@
+#include <assert.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+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 (file)
index 0000000..c1f4963
--- /dev/null
@@ -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 (file)
index 0000000..a918f72
--- /dev/null
@@ -0,0 +1 @@
+prog: mallinfo