summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorivmai <ivmai>2011-07-26 10:03:09 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:07:00 +0200
commita63d343fb7cf14dcd39ac607761d8addef512359 (patch)
tree32b06c2318e99f30fca64c8d3bd1f0b804ade185 /tests
parent31831b179479d3f73efe5f2629266867cd2f4421 (diff)
2011-07-26 Ivan Maidanski <ivmai@mail.ru>
* tests/realloc_test.c: New file. * tests/tests.am (TESTS, check_PROGRAMS): Add realloc_test. * .cvsignore: Add realloc_test. * configure: Regenerate. * Makefile.in: Ditto.
Diffstat (limited to 'tests')
-rw-r--r--tests/realloc_test.c34
-rw-r--r--tests/tests.am5
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/realloc_test.c b/tests/realloc_test.c
new file mode 100644
index 0000000..370ba46
--- /dev/null
+++ b/tests/realloc_test.c
@@ -0,0 +1,34 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "gc.h"
+
+#define COUNT 10000000
+
+int main(void) {
+ int i;
+ unsigned long last_heap_size = 0;
+
+ GC_INIT();
+
+ for (i = 0; i < COUNT; i++) {
+ int **p = GC_MALLOC(sizeof(int *));
+ int *q = GC_MALLOC_ATOMIC(sizeof(int));
+
+ if (*p != 0) {
+ fprintf(stderr, "GC_malloc returned garbage\n");
+ exit(1);
+ }
+
+ *p = GC_REALLOC(q, 2 * sizeof(int));
+
+ if (i % 10 == 0) {
+ unsigned long heap_size = (unsigned long)GC_get_heap_size();
+ if (heap_size != last_heap_size) {
+ printf("Heap size: %lu\n", heap_size);
+ last_heap_size = heap_size;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/tests/tests.am b/tests/tests.am
index 2ef84ba..f350574 100644
--- a/tests/tests.am
+++ b/tests/tests.am
@@ -45,6 +45,11 @@ check_PROGRAMS += hugetest
hugetest_SOURCES = tests/huge_test.c
hugetest_LDADD = $(test_ldadd)
+TESTS += realloc_test$(EXEEXT)
+check_PROGRAMS += realloc_test
+realloc_test_SOURCES = tests/realloc_test.c
+realloc_test_LDADD = $(test_ldadd)
+
TESTS += staticrootstest$(EXEEXT)
check_PROGRAMS += staticrootstest
staticrootstest_SOURCES = tests/staticrootstest.c