[PATCH 7/7] Replace fprintf with malloc_printf in tests.
Mike Hommey
mh+jemalloc at glandium.org
Mon Apr 16 07:30:26 PDT 2012
From: Mike Hommey <mh at glandium.org>
---
Makefile.in | 6 ++-
include/jemalloc/internal/jemalloc_internal.h.in | 3 ++
test/aligned_alloc.c | 18 ++++----
test/allocated.c | 18 ++++----
test/allocm.c | 54 +++++++++++-----------
test/bitmap.c | 10 +---
test/jemalloc_test.h.in | 1 +
test/mremap.c | 12 ++---
test/posix_memalign.c | 18 ++++----
test/rallocm.c | 52 ++++++++++-----------
test/thread_arena.c | 16 +++----
test/thread_tcache_enabled.c | 8 ++--
12 files changed, 108 insertions(+), 108 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index ef8f717..0dfddea 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -148,10 +148,12 @@ $(objroot)test/%.$(O): $(srcroot)test/%.c
$(CC) $(CFLAGS) -c $(CPPFLAGS) -I$(objroot)test -o $@ $<
@$(CC) -MM $(CPPFLAGS) -I$(objroot)test -MT $@ -o $(@:%.$(O)=%.d) $<
-$(objroot)test/%$(EXE): $(objroot)test/%.$(O) \
+$(objroot)test/bitmap$(EXE): $(objroot)src/bitmap.$(O)
+
+$(objroot)test/%$(EXE): $(objroot)test/%.$(O) $(objroot)src/util.$(O) \
$(objroot)lib/$(LIBJEMALLOC).$(SO)
@mkdir -p $(@D)
- $(CC) -o $@ $< $(call RPATH,$(objroot)lib) -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
+ $(CC) -o $@ $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
build_lib_shared: $(DSOS)
build_lib_static: $(STATIC_LIBS)
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index aa21aa5..7b16b6c 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -1,3 +1,5 @@
+#ifndef jemalloc_internal_h
+#define jemalloc_internal_h
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/syscall.h>
@@ -868,3 +870,4 @@ malloc_tsd_funcs(JEMALLOC_INLINE, thread_allocated, thread_allocated_t,
#undef JEMALLOC_H_INLINES
/******************************************************************************/
+#endif
diff --git a/test/aligned_alloc.c b/test/aligned_alloc.c
index 2a95604..81b8f93 100644
--- a/test/aligned_alloc.c
+++ b/test/aligned_alloc.c
@@ -20,14 +20,14 @@ main(void)
unsigned i;
void *p, *ps[NITER];
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
/* Test error conditions. */
alignment = 0;
errno = 0;
p = aligned_alloc(alignment, 1);
if (p != NULL || errno != EINVAL) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for invalid alignment %zu\n", alignment);
}
@@ -36,7 +36,7 @@ main(void)
errno = 0;
p = aligned_alloc(alignment + 1, 1);
if (p != NULL || errno != EINVAL) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for invalid alignment %zu\n",
alignment + 1);
}
@@ -52,7 +52,7 @@ main(void)
errno = 0;
p = aligned_alloc(alignment, size);
if (p != NULL || errno != ENOMEM) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for aligned_alloc(%zu, %zu)\n",
alignment, size);
}
@@ -67,7 +67,7 @@ main(void)
errno = 0;
p = aligned_alloc(alignment, size);
if (p != NULL || errno != ENOMEM) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for aligned_alloc(%zu, %zu)\n",
alignment, size);
}
@@ -81,7 +81,7 @@ main(void)
errno = 0;
p = aligned_alloc(alignment, size);
if (p != NULL || errno != ENOMEM) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for aligned_alloc(&p, %zu, %zu)\n",
alignment, size);
}
@@ -93,14 +93,14 @@ main(void)
alignment <= MAXALIGN;
alignment <<= 1) {
total = 0;
- fprintf(stderr, "Alignment: %zu\n", alignment);
+ malloc_printf("Alignment: %zu\n", alignment);
for (size = 1;
size < 3 * alignment && size < (1U << 31);
size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
for (i = 0; i < NITER; i++) {
ps[i] = aligned_alloc(alignment, size);
if (ps[i] == NULL) {
- fprintf(stderr,
+ malloc_printf(
"Error for size %zu (%#zx): %s\n",
size, size, strerror(errno));
exit(1);
@@ -118,6 +118,6 @@ main(void)
}
}
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (0);
}
diff --git a/test/allocated.c b/test/allocated.c
index 921ab3a..81cd4ca 100644
--- a/test/allocated.c
+++ b/test/allocated.c
@@ -27,7 +27,7 @@ thread_start(void *arg)
#endif
goto label_return;
}
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
exit(1);
}
@@ -39,7 +39,7 @@ thread_start(void *arg)
#endif
goto label_return;
}
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
exit(1);
}
@@ -53,7 +53,7 @@ thread_start(void *arg)
#endif
goto label_return;
}
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
exit(1);
}
@@ -65,7 +65,7 @@ thread_start(void *arg)
#endif
goto label_return;
}
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
exit(1);
}
@@ -73,7 +73,7 @@ thread_start(void *arg)
p = malloc(1);
if (p == NULL) {
- fprintf(stderr, "%s(): Error in malloc()\n", __func__);
+ malloc_printf("%s(): Error in malloc()\n", __func__);
exit(1);
}
@@ -108,13 +108,13 @@ main(void)
int ret = 0;
pthread_t thread;
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
thread_start(NULL);
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
- fprintf(stderr, "%s(): Error in pthread_create()\n", __func__);
+ malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
@@ -124,7 +124,7 @@ main(void)
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
- fprintf(stderr, "%s(): Error in pthread_create()\n", __func__);
+ malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
@@ -133,6 +133,6 @@ main(void)
thread_start(NULL);
label_return:
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (ret);
}
diff --git a/test/allocm.c b/test/allocm.c
index 3aa0fd2..c6bc6f8 100644
--- a/test/allocm.c
+++ b/test/allocm.c
@@ -19,52 +19,52 @@ main(void)
unsigned i;
void *ps[NITER];
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
sz = 42;
nsz = 0;
r = nallocm(&nsz, sz, 0);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected nallocm() error\n");
+ malloc_printf("Unexpected nallocm() error\n");
abort();
}
rsz = 0;
r = allocm(&p, &rsz, sz, 0);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected allocm() error\n");
+ malloc_printf("Unexpected allocm() error\n");
abort();
}
if (rsz < sz)
- fprintf(stderr, "Real size smaller than expected\n");
+ malloc_printf("Real size smaller than expected\n");
if (nsz != rsz)
- fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
+ malloc_printf("nallocm()/allocm() rsize mismatch\n");
if (dallocm(p, 0) != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected dallocm() error\n");
+ malloc_printf("Unexpected dallocm() error\n");
r = allocm(&p, NULL, sz, 0);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected allocm() error\n");
+ malloc_printf("Unexpected allocm() error\n");
abort();
}
if (dallocm(p, 0) != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected dallocm() error\n");
+ malloc_printf("Unexpected dallocm() error\n");
nsz = 0;
r = nallocm(&nsz, sz, ALLOCM_ZERO);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected nallocm() error\n");
+ malloc_printf("Unexpected nallocm() error\n");
abort();
}
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ZERO);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected allocm() error\n");
+ malloc_printf("Unexpected allocm() error\n");
abort();
}
if (nsz != rsz)
- fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
+ malloc_printf("nallocm()/allocm() rsize mismatch\n");
if (dallocm(p, 0) != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected dallocm() error\n");
+ malloc_printf("Unexpected dallocm() error\n");
#if LG_SIZEOF_PTR == 3
alignment = UINT64_C(0x8000000000000000);
@@ -76,19 +76,19 @@ main(void)
nsz = 0;
r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for nallocm(&nsz, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
if (nsz != rsz)
- fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
+ malloc_printf("nallocm()/allocm() rsize mismatch\n");
#if LG_SIZEOF_PTR == 3
alignment = UINT64_C(0x4000000000000000);
@@ -100,11 +100,11 @@ main(void)
nsz = 0;
r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected nallocm() error\n");
+ malloc_printf("Unexpected nallocm() error\n");
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
@@ -118,19 +118,19 @@ main(void)
nsz = 0;
r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for nallocm(&nsz, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
if (nsz != rsz)
- fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
+ malloc_printf("nallocm()/allocm() rsize mismatch\n");
for (i = 0; i < NITER; i++)
ps[i] = NULL;
@@ -139,7 +139,7 @@ main(void)
alignment <= MAXALIGN;
alignment <<= 1) {
total = 0;
- fprintf(stderr, "Alignment: %zu\n", alignment);
+ malloc_printf("Alignment: %zu\n", alignment);
for (sz = 1;
sz < 3 * alignment && sz < (1U << 31);
sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
@@ -148,7 +148,7 @@ main(void)
r = nallocm(&nsz, sz,
ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"nallocm() error for size %zu"
" (%#zx): %d\n",
sz, sz, r);
@@ -158,24 +158,24 @@ main(void)
r = allocm(&ps[i], &rsz, sz,
ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr,
+ malloc_printf(
"allocm() error for size %zu"
" (%#zx): %d\n",
sz, sz, r);
exit(1);
}
if (rsz < sz) {
- fprintf(stderr,
+ malloc_printf(
"Real size smaller than"
" expected\n");
}
if (nsz != rsz) {
- fprintf(stderr,
+ malloc_printf(
"nallocm()/allocm() rsize"
" mismatch\n");
}
if ((uintptr_t)p & (alignment-1)) {
- fprintf(stderr,
+ malloc_printf(
"%p inadequately aligned for"
" alignment: %zu\n", p, alignment);
}
@@ -193,6 +193,6 @@ main(void)
}
}
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (0);
}
diff --git a/test/bitmap.c b/test/bitmap.c
index adfaacf..ee9b1ec 100644
--- a/test/bitmap.c
+++ b/test/bitmap.c
@@ -7,12 +7,6 @@
* */
#include <assert.h>
-/*
- * Directly include the bitmap code, since it isn't exposed outside
- * libjemalloc.
- */
-#include "../src/bitmap.c"
-
#if (LG_BITMAP_MAXBITS > 12)
# define MAXBITS 4500
#else
@@ -144,7 +138,7 @@ test_bitmap_sfu(void)
int
main(void)
{
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
test_bitmap_size();
test_bitmap_init();
@@ -152,6 +146,6 @@ main(void)
test_bitmap_unset();
test_bitmap_sfu();
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (0);
}
diff --git a/test/jemalloc_test.h.in b/test/jemalloc_test.h.in
index 0c48895..58fa08e 100644
--- a/test/jemalloc_test.h.in
+++ b/test/jemalloc_test.h.in
@@ -4,3 +4,4 @@
* have a different name.
*/
#include "jemalloc/jemalloc at install_suffix@.h"
+#include "jemalloc/internal/jemalloc_internal.h"
diff --git a/test/mremap.c b/test/mremap.c
index cac3bd8..84c0349 100644
--- a/test/mremap.c
+++ b/test/mremap.c
@@ -14,12 +14,12 @@ main(void)
size_t sz, lg_chunk, chunksize, i;
char *p, *q;
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
sz = sizeof(lg_chunk);
if ((err = mallctl("opt.lg_chunk", &lg_chunk, &sz, NULL, 0))) {
assert(err != ENOENT);
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
ret = 1;
goto label_return;
@@ -28,7 +28,7 @@ main(void)
p = (char *)malloc(chunksize);
if (p == NULL) {
- fprintf(stderr, "malloc(%zu) --> %p\n", chunksize, p);
+ malloc_printf("malloc(%zu) --> %p\n", chunksize, p);
ret = 1;
goto label_return;
}
@@ -36,7 +36,7 @@ main(void)
q = (char *)realloc(p, chunksize * 2);
if (q == NULL) {
- fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize * 2,
+ malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize * 2,
q);
ret = 1;
goto label_return;
@@ -49,7 +49,7 @@ main(void)
q = (char *)realloc(p, chunksize);
if (q == NULL) {
- fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize, q);
+ malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize, q);
ret = 1;
goto label_return;
}
@@ -61,6 +61,6 @@ main(void)
ret = 0;
label_return:
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (ret);
}
diff --git a/test/posix_memalign.c b/test/posix_memalign.c
index 0ea35c8..e1302df 100644
--- a/test/posix_memalign.c
+++ b/test/posix_memalign.c
@@ -21,13 +21,13 @@ main(void)
int err;
void *p, *ps[NITER];
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
/* Test error conditions. */
for (alignment = 0; alignment < sizeof(void *); alignment++) {
err = posix_memalign(&p, alignment, 1);
if (err != EINVAL) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for invalid alignment %zu\n",
alignment);
}
@@ -37,7 +37,7 @@ main(void)
alignment <<= 1) {
err = posix_memalign(&p, alignment + 1, 1);
if (err == 0) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for invalid alignment %zu\n",
alignment + 1);
}
@@ -52,7 +52,7 @@ main(void)
#endif
err = posix_memalign(&p, alignment, size);
if (err == 0) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for posix_memalign(&p, %zu, %zu)\n",
alignment, size);
}
@@ -66,7 +66,7 @@ main(void)
#endif
err = posix_memalign(&p, alignment, size);
if (err == 0) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for posix_memalign(&p, %zu, %zu)\n",
alignment, size);
}
@@ -79,7 +79,7 @@ main(void)
#endif
err = posix_memalign(&p, alignment, size);
if (err == 0) {
- fprintf(stderr,
+ malloc_printf(
"Expected error for posix_memalign(&p, %zu, %zu)\n",
alignment, size);
}
@@ -91,7 +91,7 @@ main(void)
alignment <= MAXALIGN;
alignment <<= 1) {
total = 0;
- fprintf(stderr, "Alignment: %zu\n", alignment);
+ malloc_printf("Alignment: %zu\n", alignment);
for (size = 1;
size < 3 * alignment && size < (1U << 31);
size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
@@ -99,7 +99,7 @@ main(void)
err = posix_memalign(&ps[i],
alignment, size);
if (err) {
- fprintf(stderr,
+ malloc_printf(
"Error for size %zu (%#zx): %s\n",
size, size, strerror(err));
exit(1);
@@ -117,6 +117,6 @@ main(void)
}
}
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (0);
}
diff --git a/test/rallocm.c b/test/rallocm.c
index 9c0df40..18db5ee 100644
--- a/test/rallocm.c
+++ b/test/rallocm.c
@@ -15,7 +15,7 @@ main(void)
size_t sz, tsz;
int r;
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
/* Get page size. */
{
@@ -26,51 +26,51 @@ main(void)
r = allocm(&p, &sz, 42, 0);
if (r != ALLOCM_SUCCESS) {
- fprintf(stderr, "Unexpected allocm() error\n");
+ malloc_printf("Unexpected allocm() error\n");
abort();
}
q = p;
r = rallocm(&q, &tsz, sz, 0, ALLOCM_NO_MOVE);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q != p)
- fprintf(stderr, "Unexpected object move\n");
+ malloc_printf("Unexpected object move\n");
if (tsz != sz) {
- fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+ malloc_printf("Unexpected size change: %zu --> %zu\n",
sz, tsz);
}
q = p;
r = rallocm(&q, &tsz, sz, 5, ALLOCM_NO_MOVE);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q != p)
- fprintf(stderr, "Unexpected object move\n");
+ malloc_printf("Unexpected object move\n");
if (tsz != sz) {
- fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+ malloc_printf("Unexpected size change: %zu --> %zu\n",
sz, tsz);
}
q = p;
r = rallocm(&q, &tsz, sz + 5, 0, ALLOCM_NO_MOVE);
if (r != ALLOCM_ERR_NOT_MOVED)
- fprintf(stderr, "Unexpected rallocm() result\n");
+ malloc_printf("Unexpected rallocm() result\n");
if (q != p)
- fprintf(stderr, "Unexpected object move\n");
+ malloc_printf("Unexpected object move\n");
if (tsz != sz) {
- fprintf(stderr, "Unexpected size change: %zu --> %zu\n",
+ malloc_printf("Unexpected size change: %zu --> %zu\n",
sz, tsz);
}
q = p;
r = rallocm(&q, &tsz, sz + 5, 0, 0);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q == p)
- fprintf(stderr, "Expected object move\n");
+ malloc_printf("Expected object move\n");
if (tsz == sz) {
- fprintf(stderr, "Expected size change: %zu --> %zu\n",
+ malloc_printf("Expected size change: %zu --> %zu\n",
sz, tsz);
}
p = q;
@@ -78,11 +78,11 @@ main(void)
r = rallocm(&q, &tsz, pagesize*2, 0, 0);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q == p)
- fprintf(stderr, "Expected object move\n");
+ malloc_printf("Expected object move\n");
if (tsz == sz) {
- fprintf(stderr, "Expected size change: %zu --> %zu\n",
+ malloc_printf("Expected size change: %zu --> %zu\n",
sz, tsz);
}
p = q;
@@ -90,9 +90,9 @@ main(void)
r = rallocm(&q, &tsz, pagesize*4, 0, 0);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (tsz == sz) {
- fprintf(stderr, "Expected size change: %zu --> %zu\n",
+ malloc_printf("Expected size change: %zu --> %zu\n",
sz, tsz);
}
p = q;
@@ -100,28 +100,28 @@ main(void)
r = rallocm(&q, &tsz, pagesize*2, 0, ALLOCM_NO_MOVE);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q != p)
- fprintf(stderr, "Unexpected object move\n");
+ malloc_printf("Unexpected object move\n");
if (tsz == sz) {
- fprintf(stderr, "Expected size change: %zu --> %zu\n",
+ malloc_printf("Expected size change: %zu --> %zu\n",
sz, tsz);
}
sz = tsz;
r = rallocm(&q, &tsz, pagesize*4, 0, ALLOCM_NO_MOVE);
if (r != ALLOCM_SUCCESS)
- fprintf(stderr, "Unexpected rallocm() error\n");
+ malloc_printf("Unexpected rallocm() error\n");
if (q != p)
- fprintf(stderr, "Unexpected object move\n");
+ malloc_printf("Unexpected object move\n");
if (tsz == sz) {
- fprintf(stderr, "Expected size change: %zu --> %zu\n",
+ malloc_printf("Expected size change: %zu --> %zu\n",
sz, tsz);
}
sz = tsz;
dallocm(p, 0);
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (0);
}
diff --git a/test/thread_arena.c b/test/thread_arena.c
index 9b7b2dd..e443b71 100644
--- a/test/thread_arena.c
+++ b/test/thread_arena.c
@@ -20,14 +20,14 @@ thread_start(void *arg)
p = malloc(1);
if (p == NULL) {
- fprintf(stderr, "%s(): Error in malloc()\n", __func__);
+ malloc_printf("%s(): Error in malloc()\n", __func__);
return (void *)1;
}
size = sizeof(arena_ind);
if ((err = mallctl("thread.arena", &arena_ind, &size, &main_arena_ind,
sizeof(main_arena_ind)))) {
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
return (void *)1;
}
@@ -35,7 +35,7 @@ thread_start(void *arg)
size = sizeof(arena_ind);
if ((err = mallctl("thread.arena", &arena_ind, &size, NULL,
0))) {
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
return (void *)1;
}
@@ -55,18 +55,18 @@ main(void)
pthread_t threads[NTHREADS];
unsigned i;
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
p = malloc(1);
if (p == NULL) {
- fprintf(stderr, "%s(): Error in malloc()\n", __func__);
+ malloc_printf("%s(): Error in malloc()\n", __func__);
ret = 1;
goto label_return;
}
size = sizeof(arena_ind);
if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) {
- fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
+ malloc_printf("%s(): Error in mallctl(): %s\n", __func__,
strerror(err));
ret = 1;
goto label_return;
@@ -75,7 +75,7 @@ main(void)
for (i = 0; i < NTHREADS; i++) {
if (pthread_create(&threads[i], NULL, thread_start,
(void *)&arena_ind) != 0) {
- fprintf(stderr, "%s(): Error in pthread_create()\n",
+ malloc_printf("%s(): Error in pthread_create()\n",
__func__);
ret = 1;
goto label_return;
@@ -86,6 +86,6 @@ main(void)
pthread_join(threads[i], (void *)&ret);
label_return:
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (ret);
}
diff --git a/test/thread_tcache_enabled.c b/test/thread_tcache_enabled.c
index 0a3e45a..59b76a2 100644
--- a/test/thread_tcache_enabled.c
+++ b/test/thread_tcache_enabled.c
@@ -79,13 +79,13 @@ main(void)
int ret = 0;
pthread_t thread;
- fprintf(stderr, "Test begin\n");
+ malloc_printf("Test begin\n");
thread_start(NULL);
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
- fprintf(stderr, "%s(): Error in pthread_create()\n", __func__);
+ malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
@@ -95,7 +95,7 @@ main(void)
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
- fprintf(stderr, "%s(): Error in pthread_create()\n", __func__);
+ malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
@@ -104,6 +104,6 @@ main(void)
thread_start(NULL);
label_return:
- fprintf(stderr, "Test end\n");
+ malloc_printf("Test end\n");
return (ret);
}
--
1.7.10
More information about the jemalloc-discuss
mailing list