tests: add test-libmallocwrap
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 2 Mar 2010 20:04:07 +0000 (15:04 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 2 Mar 2010 20:04:07 +0000 (15:04 -0500)
configure.ac
tests/Makefile.am
tests/test-libmallocwrap/Makefile.am [new file with mode: 0644]
tests/test-libmallocwrap/prog.c [new file with mode: 0644]

index f0c99e6666d6e5c7dba81329c3a2738f5622eab4..e428a4970b121d847f5636bd36ee699416706bd0 100644 (file)
@@ -120,6 +120,7 @@ AC_CONFIG_FILES([
        tests/simple_include/Makefile
        tests/snprintf/Makefile
        tests/test-nevents/Makefile
+       tests/test-libmallocwrap/Makefile
        libmallocwrap/Makefile
        libinterfork/Makefile
        ustd/Makefile
index eca4e20abd42e222c02a5d3f75c34fb622896b71..242933252f6cfe2a7d675744a707dfc4cc90c4c2 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents
+SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libmallocwrap
 
 noinst_SCRIPTS = test_loop runtests trace_matches
diff --git a/tests/test-libmallocwrap/Makefile.am b/tests/test-libmallocwrap/Makefile.am
new file mode 100644 (file)
index 0000000..502d6c4
--- /dev/null
@@ -0,0 +1,5 @@
+#AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_PROGRAMS = prog
+prog_SOURCES = prog.c
+prog_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
diff --git a/tests/test-libmallocwrap/prog.c b/tests/test-libmallocwrap/prog.c
new file mode 100644 (file)
index 0000000..6958a77
--- /dev/null
@@ -0,0 +1,28 @@
+#include <string.h>
+#include <stdlib.h>
+
+#define N_ITER 1000
+
+int main()
+{
+       int i;
+       const char teststr[] = "Hello World! 1234567890abc";
+       void *ptrs[N_ITER];
+
+       for(i=0; i<N_ITER; i++) {
+               ptrs[i] = malloc(i+1000);
+
+               memcpy(ptrs[i], teststr, sizeof(teststr));
+
+               if(i%2 == 0) {
+                       free(ptrs[i]);
+               }
+       }
+
+       for(i=0; i<N_ITER; i++) {
+               if(i%2 == 1)
+                       free(ptrs[i]);
+       }
+
+       return 0;
+}
This page took 0.027427 seconds and 4 git commands to generate.