|
From: <sv...@va...> - 2008-04-22 16:11:34
|
Author: bart
Date: 2008-04-22 17:11:23 +0100 (Tue, 22 Apr 2008)
New Revision: 7903
Log:
Moved mallinfo regression test from none/tests to memcheck/tests.
Added:
trunk/memcheck/tests/mallinfo.c
trunk/memcheck/tests/mallinfo.stderr.exp
trunk/memcheck/tests/mallinfo.vgtest
Removed:
trunk/none/tests/mallinfo.c
trunk/none/tests/mallinfo.stderr.exp
trunk/none/tests/mallinfo.vgtest
Modified:
trunk/memcheck/tests/Makefile.am
trunk/none/tests/Makefile.am
Modified: trunk/memcheck/tests/Makefile.am
===================================================================
--- trunk/memcheck/tests/Makefile.am 2008-04-21 17:41:32 UTC (rev 7902)
+++ trunk/memcheck/tests/Makefile.am 2008-04-22 16:11:23 UTC (rev 7903)
@@ -69,6 +69,7 @@
long_namespace_xml.stderr.exp \
lsframe1.vgtest lsframe1.stdout.exp lsframe1.stderr.exp \
lsframe2.vgtest lsframe2.stdout.exp lsframe2.stderr.exp \
+ mallinfo.stderr.exp mallinfo.vgtest \
malloc_free_fill.vgtest malloc_free_fill.stdout.exp \
malloc_free_fill.stderr.exp-glibc25-amd64 \
malloc_free_fill.stderr.exp-glibc25-x86 \
@@ -171,6 +172,7 @@
leak-0 leak-cycle leak-pool leak-tree leak-regroot leakotron \
long_namespace_xml \
lsframe1 lsframe2 \
+ mallinfo \
malloc_free_fill \
malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
match-overrun \
Copied: trunk/memcheck/tests/mallinfo.c (from rev 7902, trunk/none/tests/mallinfo.c)
===================================================================
--- trunk/memcheck/tests/mallinfo.c (rev 0)
+++ trunk/memcheck/tests/mallinfo.c 2008-04-22 16:11:23 UTC (rev 7903)
@@ -0,0 +1,113 @@
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h> // getopt()
+
+
+static int s_quiet = 0;
+
+static size_t check(size_t min, size_t max)
+{
+ struct mallinfo mi;
+ size_t used;
+
+ mi = mallinfo();
+
+ if (! s_quiet)
+ {
+ printf("arena = %d\n", mi.arena); /* non-mmapped space allocated from system */
+ printf("ordblks = %d\n", mi.ordblks); /* number of free chunks */
+ printf("smblks = %d\n", mi.smblks); /* number of fastbin blocks */
+ printf("hblks = %d\n", mi.hblks); /* number of mmapped regions */
+ printf("hblkhd = %d\n", mi.hblkhd); /* space in mmapped regions */
+ printf("usmblks = %d\n", mi.usmblks); /* maximum total allocated space */
+ printf("fsmblks = %d\n", mi.fsmblks); /* space available in freed fastbin blocks */
+ printf("uordblks = %d\n", mi.uordblks); /* total allocated space */
+ printf("fordblks = %d\n", mi.fordblks); /* total free space */
+ printf("keepcost = %d\n", mi.keepcost); /* top-most, releasable (via malloc_trim) space */
+ printf("(min = %zu, max = %zu)\n", min, max);
+ }
+
+ // size checks
+ used = mi.uordblks + mi.hblkhd;
+ if (used < min)
+ exit(1);
+
+ if (used > max)
+ exit(2);
+
+ // used should be reasonably close to min
+ // define "reasonably" as within 20%
+ if (used/5*4 > min)
+ exit(3);
+
+ // sanity checks
+ if ((mi.ordblks == 0) != (mi.fordblks == 0))
+ exit(10);
+
+ if ((mi.smblks == 0) != (mi.fsmblks == 0))
+ exit(11);
+
+ if ((mi.hblks == 0) != (mi.hblkhd == 0))
+ exit(12);
+
+ if (mi.keepcost > mi.fordblks)
+ exit(13);
+
+ if (mi.fsmblks > mi.fordblks)
+ exit(14);
+
+ // arena should be reasonably close to fordblks + uordblks
+ if (mi.arena < mi.fordblks + mi.uordblks)
+ exit(15);
+
+ if (mi.arena/5*4 > mi.fordblks + mi.uordblks)
+ exit(16);
+
+ return used;
+}
+
+int main(int argc, char** argv)
+{
+ void* ptr[40];
+ int i;
+ size_t min, max;
+ int optchar;
+
+ while ((optchar = getopt(argc, argv, "q")) != EOF)
+ {
+ switch (optchar)
+ {
+ case 'q':
+ s_quiet = 1;
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [-q].\n", argv[0]);
+ return 1;
+ }
+ }
+
+ min = 0;
+ for (i = 1; i <= 40; i++)
+ {
+ int size = i * i * 8;
+ min += size;
+ ptr[i - 1] = malloc(size);
+ };
+
+ max = check(min, (size_t)-1);
+
+ for (i = 1; i <= 20; i++)
+ {
+ int size = i * i * 8;
+ min -= size;
+ max -= size;
+ free(ptr[i - 1]);
+ };
+
+ check(min, max);
+
+ fprintf(stderr, "Success.\n");
+
+ return 0;
+}
Copied: trunk/memcheck/tests/mallinfo.stderr.exp (from rev 7902, trunk/none/tests/mallinfo.stderr.exp)
===================================================================
--- trunk/memcheck/tests/mallinfo.stderr.exp (rev 0)
+++ trunk/memcheck/tests/mallinfo.stderr.exp 2008-04-22 16:11:23 UTC (rev 7903)
@@ -0,0 +1,3 @@
+
+Success.
+
Copied: trunk/memcheck/tests/mallinfo.vgtest (from rev 7902, trunk/none/tests/mallinfo.vgtest)
===================================================================
--- trunk/memcheck/tests/mallinfo.vgtest (rev 0)
+++ trunk/memcheck/tests/mallinfo.vgtest 2008-04-22 16:11:23 UTC (rev 7903)
@@ -0,0 +1,2 @@
+prog: mallinfo
+args: -q
Modified: trunk/none/tests/Makefile.am
===================================================================
--- trunk/none/tests/Makefile.am 2008-04-21 17:41:32 UTC (rev 7902)
+++ trunk/none/tests/Makefile.am 2008-04-22 16:11:23 UTC (rev 7903)
@@ -70,7 +70,6 @@
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 \
@@ -141,7 +140,6 @@
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 \
Deleted: trunk/none/tests/mallinfo.c
===================================================================
--- trunk/none/tests/mallinfo.c 2008-04-21 17:41:32 UTC (rev 7902)
+++ trunk/none/tests/mallinfo.c 2008-04-22 16:11:23 UTC (rev 7903)
@@ -1,113 +0,0 @@
-#include <malloc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h> // getopt()
-
-
-static int s_quiet = 0;
-
-static size_t check(size_t min, size_t max)
-{
- struct mallinfo mi;
- size_t used;
-
- mi = mallinfo();
-
- if (! s_quiet)
- {
- printf("arena = %d\n", mi.arena); /* non-mmapped space allocated from system */
- printf("ordblks = %d\n", mi.ordblks); /* number of free chunks */
- printf("smblks = %d\n", mi.smblks); /* number of fastbin blocks */
- printf("hblks = %d\n", mi.hblks); /* number of mmapped regions */
- printf("hblkhd = %d\n", mi.hblkhd); /* space in mmapped regions */
- printf("usmblks = %d\n", mi.usmblks); /* maximum total allocated space */
- printf("fsmblks = %d\n", mi.fsmblks); /* space available in freed fastbin blocks */
- printf("uordblks = %d\n", mi.uordblks); /* total allocated space */
- printf("fordblks = %d\n", mi.fordblks); /* total free space */
- printf("keepcost = %d\n", mi.keepcost); /* top-most, releasable (via malloc_trim) space */
- printf("(min = %zu, max = %zu)\n", min, max);
- }
-
- // size checks
- used = mi.uordblks + mi.hblkhd;
- if (used < min)
- exit(1);
-
- if (used > max)
- exit(2);
-
- // used should be reasonably close to min
- // define "reasonably" as within 20%
- if (used/5*4 > min)
- exit(3);
-
- // sanity checks
- if ((mi.ordblks == 0) != (mi.fordblks == 0))
- exit(10);
-
- if ((mi.smblks == 0) != (mi.fsmblks == 0))
- exit(11);
-
- if ((mi.hblks == 0) != (mi.hblkhd == 0))
- exit(12);
-
- if (mi.keepcost > mi.fordblks)
- exit(13);
-
- if (mi.fsmblks > mi.fordblks)
- exit(14);
-
- // arena should be reasonably close to fordblks + uordblks
- if (mi.arena < mi.fordblks + mi.uordblks)
- exit(15);
-
- if (mi.arena/5*4 > mi.fordblks + mi.uordblks)
- exit(16);
-
- return used;
-}
-
-int main(int argc, char** argv)
-{
- void* ptr[40];
- int i;
- size_t min, max;
- int optchar;
-
- while ((optchar = getopt(argc, argv, "q")) != EOF)
- {
- switch (optchar)
- {
- case 'q':
- s_quiet = 1;
- break;
- default:
- fprintf(stderr, "Usage: %s [-q].\n", argv[0]);
- return 1;
- }
- }
-
- min = 0;
- for (i = 1; i <= 40; i++)
- {
- int size = i * i * 8;
- min += size;
- ptr[i - 1] = malloc(size);
- };
-
- max = check(min, (size_t)-1);
-
- for (i = 1; i <= 20; i++)
- {
- int size = i * i * 8;
- min -= size;
- max -= size;
- free(ptr[i - 1]);
- };
-
- check(min, max);
-
- fprintf(stderr, "Success.\n");
-
- return 0;
-}
Deleted: trunk/none/tests/mallinfo.stderr.exp
===================================================================
--- trunk/none/tests/mallinfo.stderr.exp 2008-04-21 17:41:32 UTC (rev 7902)
+++ trunk/none/tests/mallinfo.stderr.exp 2008-04-22 16:11:23 UTC (rev 7903)
@@ -1,3 +0,0 @@
-
-Success.
-
Deleted: trunk/none/tests/mallinfo.vgtest
===================================================================
--- trunk/none/tests/mallinfo.vgtest 2008-04-21 17:41:32 UTC (rev 7902)
+++ trunk/none/tests/mallinfo.vgtest 2008-04-22 16:11:23 UTC (rev 7903)
@@ -1,2 +0,0 @@
-prog: mallinfo
-args: -q
|