summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichdawe <richdawe@1665872d-e22b-0410-9e5d-a57ad4215e6d>2006-07-25 20:15:33 +0000
committerrichdawe <richdawe@1665872d-e22b-0410-9e5d-a57ad4215e6d>2006-07-25 20:15:33 +0000
commit634ce6211aacf3e1fb1d5be2ecea4f0547948ac8 (patch)
tree602c07f4ab9f922c937edf84c5566832e061a844
parentfc9581c8c079ac882c6ec34ad37172c35e677770 (diff)
downloadportableumem-634ce6211aacf3e1fb1d5be2ecea4f0547948ac8.tar.gz
Add another test program
git-svn-id: https://labs.omniti.com/portableumem/trunk@21 1665872d-e22b-0410-9e5d-a57ad4215e6d
-rw-r--r--.cvsignore1
-rw-r--r--Makefile.am7
-rw-r--r--umem_test2.c62
3 files changed, 68 insertions, 2 deletions
diff --git a/.cvsignore b/.cvsignore
index 3a5c1e6..544bfaf 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -17,6 +17,7 @@ stamp-h
stamp-h.in
stamp-h1
umem_test
+umem_test2
Doxyfile
umem.spec
*.tar.gz
diff --git a/Makefile.am b/Makefile.am
index 4ab8f1e..9086017 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,14 @@
EXTRA_DIST = COPYRIGHT OPENSOLARIS.LICENSE umem.spec Doxyfile
lib_LTLIBRARIES = libumem.la
-noinst_PROGRAMS = umem_test
+noinst_PROGRAMS = umem_test umem_test2
umem_test_SOURCES = umem_test.c
umem_test_LDADD = -lumem -lpthread -ldl
+umem_test2_SOURCES = umem_test2.c
+umem_test2_LDADD = -lumem -lpthread -ldl
+
libumem_la_SOURCES = init_lib.c \
umem_agent_support.c \
umem_fail.c \
@@ -31,7 +34,7 @@ libumem_la_SOURCES = init_lib.c \
nobase_include_HEADERS = umem.h sys/vmem.h
-TESTS = umem_test
+TESTS = umem_test umem_test2
html-local:
mkdir -p docs
diff --git a/umem_test2.c b/umem_test2.c
new file mode 100644
index 0000000..8994b42
--- /dev/null
+++ b/umem_test2.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "umem.h"
+
+static const char *TESTSTRINGS[] = {
+ "fred",
+ "fredfredfred",
+ "thisisabitlongerthantheotherstrings",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890",
+};
+
+#define N_TESTSTRINGS (sizeof(TESTSTRINGS) / sizeof(TESTSTRINGS[0]))
+#define N_TESTS 1000
+
+int
+main (int argc, char *argv[])
+{
+ char *testcases[N_TESTSTRINGS][N_TESTS + 1];
+ size_t len[N_TESTSTRINGS];
+ int i, j;
+
+ memset(testcases, 0, sizeof(testcases));
+
+ umem_startup(NULL, 0, 0, NULL, NULL);
+
+ for (i = 0; i < N_TESTSTRINGS; ++i)
+ {
+ len[i] = strlen(TESTSTRINGS[i]) + 1;
+ }
+
+ puts("Allocating...");
+
+ for (j = 0; j < N_TESTS; ++j)
+ {
+ for (i = 0; i < N_TESTSTRINGS; ++i)
+ {
+ testcases[i][j] = umem_alloc(len[i], UMEM_DEFAULT);
+ strcpy(testcases[i][j], TESTSTRINGS[i]);
+ }
+ }
+
+ puts("Deallocating...");
+
+ for (j = 0; j < N_TESTS; ++j)
+ {
+ for (i = N_TESTSTRINGS - 1; i >= 0; --i)
+ {
+ umem_free(testcases[i][j], len[i]);
+ }
+
+ if ((j % 25) == 0)
+ {
+ puts("Reaping...");
+ umem_reap();
+ }
+ }
+
+ puts("Done");
+
+ return 0;
+}