Update brace style.
Add braces around single-line blocks, and remove line breaks before function-opening braces. This resolves #537.
This commit is contained in:
@@ -1449,8 +1449,7 @@ static const uint64_t init_by_array_64_expected[] = {
|
||||
KQU(15570163926716513029), KQU(13356980519185762498)
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_gen_rand_32)
|
||||
{
|
||||
TEST_BEGIN(test_gen_rand_32) {
|
||||
uint32_t array32[BLOCK_SIZE] JEMALLOC_ATTR(aligned(16));
|
||||
uint32_t array32_2[BLOCK_SIZE] JEMALLOC_ATTR(aligned(16));
|
||||
int i;
|
||||
@@ -1484,8 +1483,7 @@ TEST_BEGIN(test_gen_rand_32)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_by_array_32)
|
||||
{
|
||||
TEST_BEGIN(test_by_array_32) {
|
||||
uint32_t array32[BLOCK_SIZE] JEMALLOC_ATTR(aligned(16));
|
||||
uint32_t array32_2[BLOCK_SIZE] JEMALLOC_ATTR(aligned(16));
|
||||
int i;
|
||||
@@ -1520,8 +1518,7 @@ TEST_BEGIN(test_by_array_32)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_gen_rand_64)
|
||||
{
|
||||
TEST_BEGIN(test_gen_rand_64) {
|
||||
uint64_t array64[BLOCK_SIZE64] JEMALLOC_ATTR(aligned(16));
|
||||
uint64_t array64_2[BLOCK_SIZE64] JEMALLOC_ATTR(aligned(16));
|
||||
int i;
|
||||
@@ -1556,8 +1553,7 @@ TEST_BEGIN(test_gen_rand_64)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_by_array_64)
|
||||
{
|
||||
TEST_BEGIN(test_by_array_64) {
|
||||
uint64_t array64[BLOCK_SIZE64] JEMALLOC_ATTR(aligned(16));
|
||||
uint64_t array64_2[BLOCK_SIZE64] JEMALLOC_ATTR(aligned(16));
|
||||
int i;
|
||||
@@ -1594,8 +1590,7 @@ TEST_BEGIN(test_by_array_64)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_gen_rand_32,
|
||||
test_by_array_32,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_a0)
|
||||
{
|
||||
TEST_BEGIN(test_a0) {
|
||||
void *p;
|
||||
|
||||
p = a0malloc(1);
|
||||
@@ -11,8 +10,7 @@ TEST_BEGIN(test_a0)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test_no_malloc_init(
|
||||
test_a0));
|
||||
}
|
||||
|
@@ -5,8 +5,7 @@
|
||||
#include "test/extent_hooks.h"
|
||||
|
||||
static unsigned
|
||||
get_nsizes_impl(const char *cmd)
|
||||
{
|
||||
get_nsizes_impl(const char *cmd) {
|
||||
unsigned ret;
|
||||
size_t z;
|
||||
|
||||
@@ -18,20 +17,17 @@ get_nsizes_impl(const char *cmd)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_nsmall(void)
|
||||
{
|
||||
get_nsmall(void) {
|
||||
return (get_nsizes_impl("arenas.nbins"));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
get_nlarge(void)
|
||||
{
|
||||
get_nlarge(void) {
|
||||
return (get_nsizes_impl("arenas.nlextents"));
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_size_impl(const char *cmd, size_t ind)
|
||||
{
|
||||
get_size_impl(const char *cmd, size_t ind) {
|
||||
size_t ret;
|
||||
size_t z;
|
||||
size_t mib[4];
|
||||
@@ -49,35 +45,33 @@ get_size_impl(const char *cmd, size_t ind)
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_small_size(size_t ind)
|
||||
{
|
||||
get_small_size(size_t ind) {
|
||||
return (get_size_impl("arenas.bin.0.size", ind));
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_large_size(size_t ind)
|
||||
{
|
||||
get_large_size(size_t ind) {
|
||||
return (get_size_impl("arenas.lextent.0.size", ind));
|
||||
}
|
||||
|
||||
/* Like ivsalloc(), but safe to call on discarded allocations. */
|
||||
static size_t
|
||||
vsalloc(tsdn_t *tsdn, const void *ptr)
|
||||
{
|
||||
vsalloc(tsdn_t *tsdn, const void *ptr) {
|
||||
extent_t *extent;
|
||||
|
||||
extent = extent_lookup(tsdn, ptr, false);
|
||||
if (extent == NULL)
|
||||
if (extent == NULL) {
|
||||
return (0);
|
||||
if (!extent_active_get(extent))
|
||||
}
|
||||
if (!extent_active_get(extent)) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (isalloc(tsdn, extent, ptr));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
do_arena_create(extent_hooks_t *h)
|
||||
{
|
||||
do_arena_create(extent_hooks_t *h) {
|
||||
unsigned arena_ind;
|
||||
size_t sz = sizeof(unsigned);
|
||||
assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz,
|
||||
@@ -87,8 +81,7 @@ do_arena_create(extent_hooks_t *h)
|
||||
}
|
||||
|
||||
static void
|
||||
do_arena_reset_pre(unsigned arena_ind, void ***ptrs, unsigned *nptrs)
|
||||
{
|
||||
do_arena_reset_pre(unsigned arena_ind, void ***ptrs, unsigned *nptrs) {
|
||||
#define NLARGE 32
|
||||
unsigned nsmall, nlarge, i;
|
||||
size_t sz;
|
||||
@@ -127,8 +120,7 @@ do_arena_reset_pre(unsigned arena_ind, void ***ptrs, unsigned *nptrs)
|
||||
}
|
||||
|
||||
static void
|
||||
do_arena_reset_post(void **ptrs, unsigned nptrs)
|
||||
{
|
||||
do_arena_reset_post(void **ptrs, unsigned nptrs) {
|
||||
tsdn_t *tsdn;
|
||||
unsigned i;
|
||||
|
||||
@@ -144,8 +136,7 @@ do_arena_reset_post(void **ptrs, unsigned nptrs)
|
||||
}
|
||||
|
||||
static void
|
||||
do_arena_reset_destroy(const char *name, unsigned arena_ind)
|
||||
{
|
||||
do_arena_reset_destroy(const char *name, unsigned arena_ind) {
|
||||
size_t mib[3];
|
||||
size_t miblen;
|
||||
|
||||
@@ -158,19 +149,16 @@ do_arena_reset_destroy(const char *name, unsigned arena_ind)
|
||||
}
|
||||
|
||||
static void
|
||||
do_arena_reset(unsigned arena_ind)
|
||||
{
|
||||
do_arena_reset(unsigned arena_ind) {
|
||||
do_arena_reset_destroy("arena.0.reset", arena_ind);
|
||||
}
|
||||
|
||||
static void
|
||||
do_arena_destroy(unsigned arena_ind)
|
||||
{
|
||||
do_arena_destroy(unsigned arena_ind) {
|
||||
do_arena_reset_destroy("arena.0.destroy", arena_ind);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_arena_reset)
|
||||
{
|
||||
TEST_BEGIN(test_arena_reset) {
|
||||
unsigned arena_ind;
|
||||
void **ptrs;
|
||||
unsigned nptrs;
|
||||
@@ -183,8 +171,7 @@ TEST_BEGIN(test_arena_reset)
|
||||
TEST_END
|
||||
|
||||
static bool
|
||||
arena_i_initialized(unsigned arena_ind, bool refresh)
|
||||
{
|
||||
arena_i_initialized(unsigned arena_ind, bool refresh) {
|
||||
bool initialized;
|
||||
size_t mib[3];
|
||||
size_t miblen, sz;
|
||||
@@ -206,15 +193,13 @@ arena_i_initialized(unsigned arena_ind, bool refresh)
|
||||
return (initialized);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_arena_destroy_initial)
|
||||
{
|
||||
TEST_BEGIN(test_arena_destroy_initial) {
|
||||
assert_false(arena_i_initialized(MALLCTL_ARENAS_DESTROYED, false),
|
||||
"Destroyed arena stats should not be initialized");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_destroy_hooks_default)
|
||||
{
|
||||
TEST_BEGIN(test_arena_destroy_hooks_default) {
|
||||
unsigned arena_ind, arena_ind_another, arena_ind_prev;
|
||||
void **ptrs;
|
||||
unsigned nptrs;
|
||||
@@ -260,8 +245,7 @@ TEST_END
|
||||
*/
|
||||
static bool
|
||||
extent_dalloc_unmap(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
bool committed, unsigned arena_ind)
|
||||
{
|
||||
bool committed, unsigned arena_ind) {
|
||||
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, committed=%s, "
|
||||
"arena_ind=%u)\n", __func__, extent_hooks, addr, size, committed ?
|
||||
"true" : "false", arena_ind);
|
||||
@@ -270,8 +254,9 @@ extent_dalloc_unmap(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
||||
assert_ptr_eq(extent_hooks->dalloc, extent_dalloc_unmap,
|
||||
"Wrong hook function");
|
||||
called_dalloc = true;
|
||||
if (!try_dalloc)
|
||||
if (!try_dalloc) {
|
||||
return (true);
|
||||
}
|
||||
pages_unmap(addr, size);
|
||||
did_dalloc = true;
|
||||
return (false);
|
||||
@@ -290,8 +275,7 @@ static extent_hooks_t hooks_unmap = {
|
||||
extent_merge_hook
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_arena_destroy_hooks_unmap)
|
||||
{
|
||||
TEST_BEGIN(test_arena_destroy_hooks_unmap) {
|
||||
unsigned arena_ind;
|
||||
void **ptrs;
|
||||
unsigned nptrs;
|
||||
@@ -328,8 +312,7 @@ TEST_BEGIN(test_arena_destroy_hooks_unmap)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_arena_reset,
|
||||
test_arena_destroy_initial,
|
||||
|
@@ -66,8 +66,7 @@ typedef struct p##_test_s p##_test_t;
|
||||
} while (0)
|
||||
|
||||
TEST_STRUCT(u64, uint64_t)
|
||||
TEST_BEGIN(test_atomic_u64)
|
||||
{
|
||||
TEST_BEGIN(test_atomic_u64) {
|
||||
#if !(LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
|
||||
test_skip("64-bit atomic operations not supported");
|
||||
#else
|
||||
@@ -77,36 +76,31 @@ TEST_BEGIN(test_atomic_u64)
|
||||
TEST_END
|
||||
|
||||
TEST_STRUCT(u32, uint32_t)
|
||||
TEST_BEGIN(test_atomic_u32)
|
||||
{
|
||||
TEST_BEGIN(test_atomic_u32) {
|
||||
TEST_BODY(u32, uint32_t, uint32_t, u32, "#"FMTx32);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_STRUCT(p, void *)
|
||||
TEST_BEGIN(test_atomic_p)
|
||||
{
|
||||
TEST_BEGIN(test_atomic_p) {
|
||||
TEST_BODY(p, void *, uintptr_t, ptr, "p");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_STRUCT(zu, size_t)
|
||||
TEST_BEGIN(test_atomic_zu)
|
||||
{
|
||||
TEST_BEGIN(test_atomic_zu) {
|
||||
TEST_BODY(zu, size_t, size_t, zu, "#zx");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_STRUCT(u, unsigned)
|
||||
TEST_BEGIN(test_atomic_u)
|
||||
{
|
||||
TEST_BEGIN(test_atomic_u) {
|
||||
TEST_BODY(u, unsigned, unsigned, u, "#x");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_atomic_u64,
|
||||
test_atomic_u32,
|
||||
|
@@ -24,8 +24,7 @@ static extent_hooks_t hooks_not_null = {
|
||||
NULL /* merge */
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_base_hooks_default)
|
||||
{
|
||||
TEST_BEGIN(test_base_hooks_default) {
|
||||
tsdn_t *tsdn;
|
||||
base_t *base;
|
||||
size_t allocated0, allocated1, resident, mapped;
|
||||
@@ -52,8 +51,7 @@ TEST_BEGIN(test_base_hooks_default)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_base_hooks_null)
|
||||
{
|
||||
TEST_BEGIN(test_base_hooks_null) {
|
||||
extent_hooks_t hooks_orig;
|
||||
tsdn_t *tsdn;
|
||||
base_t *base;
|
||||
@@ -92,8 +90,7 @@ TEST_BEGIN(test_base_hooks_null)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_base_hooks_not_null)
|
||||
{
|
||||
TEST_BEGIN(test_base_hooks_not_null) {
|
||||
extent_hooks_t hooks_orig;
|
||||
tsdn_t *tsdn;
|
||||
base_t *base;
|
||||
@@ -214,8 +211,7 @@ TEST_BEGIN(test_base_hooks_not_null)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_base_hooks_default,
|
||||
test_base_hooks_null,
|
||||
|
@@ -93,8 +93,7 @@
|
||||
NB(16384) \
|
||||
|
||||
static void
|
||||
test_bitmap_initializer_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
test_bitmap_initializer_body(const bitmap_info_t *binfo, size_t nbits) {
|
||||
bitmap_info_t binfo_dyn;
|
||||
bitmap_info_init(&binfo_dyn, nbits);
|
||||
|
||||
@@ -124,8 +123,7 @@ test_bitmap_initializer_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_initializer)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_initializer) {
|
||||
#define NB(nbits) { \
|
||||
if (nbits <= BITMAP_MAXBITS) { \
|
||||
bitmap_info_t binfo = \
|
||||
@@ -140,8 +138,7 @@ TEST_END
|
||||
|
||||
static size_t
|
||||
test_bitmap_size_body(const bitmap_info_t *binfo, size_t nbits,
|
||||
size_t prev_size)
|
||||
{
|
||||
size_t prev_size) {
|
||||
size_t size = bitmap_size(binfo);
|
||||
assert_zu_ge(size, (nbits >> 3),
|
||||
"Bitmap size is smaller than expected");
|
||||
@@ -149,8 +146,7 @@ test_bitmap_size_body(const bitmap_info_t *binfo, size_t nbits,
|
||||
return (size);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_size)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_size) {
|
||||
size_t nbits, prev_size;
|
||||
|
||||
prev_size = 0;
|
||||
@@ -171,8 +167,7 @@ TEST_BEGIN(test_bitmap_size)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_bitmap_init_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
test_bitmap_init_body(const bitmap_info_t *binfo, size_t nbits) {
|
||||
size_t i;
|
||||
bitmap_t *bitmap = (bitmap_t *)malloc(bitmap_size(binfo));
|
||||
assert_ptr_not_null(bitmap, "Unexpected malloc() failure");
|
||||
@@ -185,8 +180,7 @@ test_bitmap_init_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
free(bitmap);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_init)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_init) {
|
||||
size_t nbits;
|
||||
|
||||
for (nbits = 1; nbits <= BITMAP_MAXBITS; nbits++) {
|
||||
@@ -204,21 +198,20 @@ TEST_BEGIN(test_bitmap_init)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_bitmap_set_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
test_bitmap_set_body(const bitmap_info_t *binfo, size_t nbits) {
|
||||
size_t i;
|
||||
bitmap_t *bitmap = (bitmap_t *)malloc(bitmap_size(binfo));
|
||||
assert_ptr_not_null(bitmap, "Unexpected malloc() failure");
|
||||
bitmap_init(bitmap, binfo);
|
||||
|
||||
for (i = 0; i < nbits; i++)
|
||||
for (i = 0; i < nbits; i++) {
|
||||
bitmap_set(bitmap, binfo, i);
|
||||
}
|
||||
assert_true(bitmap_full(bitmap, binfo), "All bits should be set");
|
||||
free(bitmap);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_set)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_set) {
|
||||
size_t nbits;
|
||||
|
||||
for (nbits = 1; nbits <= BITMAP_MAXBITS; nbits++) {
|
||||
@@ -236,26 +229,27 @@ TEST_BEGIN(test_bitmap_set)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_bitmap_unset_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
test_bitmap_unset_body(const bitmap_info_t *binfo, size_t nbits) {
|
||||
size_t i;
|
||||
bitmap_t *bitmap = (bitmap_t *)malloc(bitmap_size(binfo));
|
||||
assert_ptr_not_null(bitmap, "Unexpected malloc() failure");
|
||||
bitmap_init(bitmap, binfo);
|
||||
|
||||
for (i = 0; i < nbits; i++)
|
||||
for (i = 0; i < nbits; i++) {
|
||||
bitmap_set(bitmap, binfo, i);
|
||||
}
|
||||
assert_true(bitmap_full(bitmap, binfo), "All bits should be set");
|
||||
for (i = 0; i < nbits; i++)
|
||||
for (i = 0; i < nbits; i++) {
|
||||
bitmap_unset(bitmap, binfo, i);
|
||||
for (i = 0; i < nbits; i++)
|
||||
}
|
||||
for (i = 0; i < nbits; i++) {
|
||||
bitmap_set(bitmap, binfo, i);
|
||||
}
|
||||
assert_true(bitmap_full(bitmap, binfo), "All bits should be set");
|
||||
free(bitmap);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_unset)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_unset) {
|
||||
size_t nbits;
|
||||
|
||||
for (nbits = 1; nbits <= BITMAP_MAXBITS; nbits++) {
|
||||
@@ -273,8 +267,7 @@ TEST_BEGIN(test_bitmap_unset)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_bitmap_sfu_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
{
|
||||
test_bitmap_sfu_body(const bitmap_info_t *binfo, size_t nbits) {
|
||||
size_t i;
|
||||
bitmap_t *bitmap = (bitmap_t *)malloc(bitmap_size(binfo));
|
||||
assert_ptr_not_null(bitmap, "Unexpected malloc() failure");
|
||||
@@ -317,8 +310,7 @@ test_bitmap_sfu_body(const bitmap_info_t *binfo, size_t nbits)
|
||||
free(bitmap);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_bitmap_sfu)
|
||||
{
|
||||
TEST_BEGIN(test_bitmap_sfu) {
|
||||
size_t nbits;
|
||||
|
||||
for (nbits = 1; nbits <= BITMAP_MAXBITS; nbits++) {
|
||||
@@ -336,8 +328,7 @@ TEST_BEGIN(test_bitmap_sfu)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_bitmap_initializer,
|
||||
test_bitmap_size,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_new_delete)
|
||||
{
|
||||
TEST_BEGIN(test_new_delete) {
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
|
||||
@@ -17,8 +16,7 @@ TEST_BEGIN(test_new_delete)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_count_insert_search_remove)
|
||||
{
|
||||
TEST_BEGIN(test_count_insert_search_remove) {
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
const char *strs[] = {
|
||||
@@ -105,8 +103,7 @@ TEST_BEGIN(test_count_insert_search_remove)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_insert_iter_remove)
|
||||
{
|
||||
TEST_BEGIN(test_insert_iter_remove) {
|
||||
#define NITEMS ZU(1000)
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
@@ -174,10 +171,12 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < i + 1; j++)
|
||||
for (j = 0; j < i + 1; j++) {
|
||||
assert_true(seen[j], "Item %zu not seen", j);
|
||||
for (; j < NITEMS; j++)
|
||||
}
|
||||
for (; j < NITEMS; j++) {
|
||||
assert_false(seen[j], "Item %zu seen", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,8 +203,7 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_new_delete,
|
||||
test_count_insert_search_remove,
|
||||
|
@@ -10,22 +10,20 @@ static nstime_t time_mock;
|
||||
static bool monotonic_mock;
|
||||
|
||||
static bool
|
||||
nstime_monotonic_mock(void)
|
||||
{
|
||||
nstime_monotonic_mock(void) {
|
||||
return (monotonic_mock);
|
||||
}
|
||||
|
||||
static bool
|
||||
nstime_update_mock(nstime_t *time)
|
||||
{
|
||||
nstime_update_mock(nstime_t *time) {
|
||||
nupdates_mock++;
|
||||
if (monotonic_mock)
|
||||
if (monotonic_mock) {
|
||||
nstime_copy(time, &time_mock);
|
||||
}
|
||||
return (!monotonic_mock);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_decay_ticks)
|
||||
{
|
||||
TEST_BEGIN(test_decay_ticks) {
|
||||
ticker_t *decay_ticker;
|
||||
unsigned tick0, tick1;
|
||||
size_t sz, large0;
|
||||
@@ -197,8 +195,7 @@ TEST_BEGIN(test_decay_ticks)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_decay_ticker)
|
||||
{
|
||||
TEST_BEGIN(test_decay_ticker) {
|
||||
#define NPS 1024
|
||||
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
|
||||
void *ps[NPS];
|
||||
@@ -284,14 +281,14 @@ TEST_BEGIN(test_decay_ticker)
|
||||
nstime_update(&time);
|
||||
} while (nstime_compare(&time, &deadline) <= 0 && npurge1 == npurge0);
|
||||
|
||||
if (config_stats)
|
||||
if (config_stats) {
|
||||
assert_u64_gt(npurge1, npurge0, "Expected purging to occur");
|
||||
}
|
||||
#undef NPS
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_decay_nonmonotonic)
|
||||
{
|
||||
TEST_BEGIN(test_decay_nonmonotonic) {
|
||||
#define NPS (SMOOTHSTEP_NSTEPS + 1)
|
||||
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
|
||||
void *ps[NPS];
|
||||
@@ -343,8 +340,9 @@ TEST_BEGIN(test_decay_nonmonotonic)
|
||||
assert_d_eq(mallctl("stats.arenas.0.npurge", (void *)&npurge1, &sz,
|
||||
NULL, 0), config_stats ? 0 : ENOENT, "Unexpected mallctl result");
|
||||
|
||||
if (config_stats)
|
||||
if (config_stats) {
|
||||
assert_u64_eq(npurge0, npurge1, "Unexpected purging occurred");
|
||||
}
|
||||
|
||||
nstime_monotonic = nstime_monotonic_orig;
|
||||
nstime_update = nstime_update_orig;
|
||||
@@ -353,8 +351,7 @@ TEST_BEGIN(test_decay_nonmonotonic)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_decay_ticks,
|
||||
test_decay_ticker,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_small_extent_size)
|
||||
{
|
||||
TEST_BEGIN(test_small_extent_size) {
|
||||
unsigned nbins, i;
|
||||
size_t sz, extent_size;
|
||||
size_t mib[4];
|
||||
@@ -35,8 +34,7 @@ TEST_BEGIN(test_small_extent_size)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_large_extent_size)
|
||||
{
|
||||
TEST_BEGIN(test_large_extent_size) {
|
||||
bool cache_oblivious;
|
||||
unsigned nlextents, i;
|
||||
size_t sz, extent_size_prev, ceil_prev;
|
||||
@@ -100,8 +98,7 @@ TEST_BEGIN(test_large_extent_size)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_monotonic)
|
||||
{
|
||||
TEST_BEGIN(test_monotonic) {
|
||||
#define SZ_MAX ZU(4 * 1024 * 1024)
|
||||
unsigned i;
|
||||
size_t floor_prev, ceil_prev;
|
||||
@@ -136,8 +133,7 @@ TEST_BEGIN(test_monotonic)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_small_extent_size,
|
||||
test_large_extent_size,
|
||||
|
@@ -4,8 +4,7 @@
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
TEST_BEGIN(test_fork)
|
||||
{
|
||||
TEST_BEGIN(test_fork) {
|
||||
#ifndef _WIN32
|
||||
void *p;
|
||||
pid_t pid;
|
||||
@@ -32,8 +31,9 @@ TEST_BEGIN(test_fork)
|
||||
|
||||
/* Parent. */
|
||||
while (true) {
|
||||
if (waitpid(pid, &status, 0) == -1)
|
||||
if (waitpid(pid, &status, 0) == -1) {
|
||||
test_fail("Unexpected waitpid() failure");
|
||||
}
|
||||
if (WIFSIGNALED(status)) {
|
||||
test_fail("Unexpected child termination due to "
|
||||
"signal %d", WTERMSIG(status));
|
||||
@@ -56,8 +56,7 @@ TEST_BEGIN(test_fork)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_fork));
|
||||
}
|
||||
|
@@ -36,8 +36,7 @@ typedef enum {
|
||||
} hash_variant_t;
|
||||
|
||||
static int
|
||||
hash_variant_bits(hash_variant_t variant)
|
||||
{
|
||||
hash_variant_bits(hash_variant_t variant) {
|
||||
switch (variant) {
|
||||
case hash_variant_x86_32: return (32);
|
||||
case hash_variant_x86_128: return (128);
|
||||
@@ -47,8 +46,7 @@ hash_variant_bits(hash_variant_t variant)
|
||||
}
|
||||
|
||||
static const char *
|
||||
hash_variant_string(hash_variant_t variant)
|
||||
{
|
||||
hash_variant_string(hash_variant_t variant) {
|
||||
switch (variant) {
|
||||
case hash_variant_x86_32: return ("hash_x86_32");
|
||||
case hash_variant_x86_128: return ("hash_x86_128");
|
||||
@@ -59,8 +57,7 @@ hash_variant_string(hash_variant_t variant)
|
||||
|
||||
#define KEY_SIZE 256
|
||||
static void
|
||||
hash_variant_verify_key(hash_variant_t variant, uint8_t *key)
|
||||
{
|
||||
hash_variant_verify_key(hash_variant_t variant, uint8_t *key) {
|
||||
const int hashbytes = hash_variant_bits(variant) / 8;
|
||||
const int hashes_size = hashbytes * 256;
|
||||
VARIABLE_ARRAY(uint8_t, hashes, hashes_size);
|
||||
@@ -139,39 +136,35 @@ hash_variant_verify_key(hash_variant_t variant, uint8_t *key)
|
||||
}
|
||||
|
||||
static void
|
||||
hash_variant_verify(hash_variant_t variant)
|
||||
{
|
||||
hash_variant_verify(hash_variant_t variant) {
|
||||
#define MAX_ALIGN 16
|
||||
uint8_t key[KEY_SIZE + (MAX_ALIGN - 1)];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MAX_ALIGN; i++)
|
||||
for (i = 0; i < MAX_ALIGN; i++) {
|
||||
hash_variant_verify_key(variant, &key[i]);
|
||||
}
|
||||
#undef MAX_ALIGN
|
||||
}
|
||||
#undef KEY_SIZE
|
||||
|
||||
TEST_BEGIN(test_hash_x86_32)
|
||||
{
|
||||
TEST_BEGIN(test_hash_x86_32) {
|
||||
hash_variant_verify(hash_variant_x86_32);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_hash_x86_128)
|
||||
{
|
||||
TEST_BEGIN(test_hash_x86_128) {
|
||||
hash_variant_verify(hash_variant_x86_128);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_hash_x64_128)
|
||||
{
|
||||
TEST_BEGIN(test_hash_x64_128) {
|
||||
hash_variant_verify(hash_variant_x64_128);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_hash_x86_32,
|
||||
test_hash_x86_128,
|
||||
|
@@ -15,15 +15,13 @@ static void *watch_for_junking;
|
||||
static bool saw_junking;
|
||||
|
||||
static void
|
||||
watch_junking(void *p)
|
||||
{
|
||||
watch_junking(void *p) {
|
||||
watch_for_junking = p;
|
||||
saw_junking = false;
|
||||
}
|
||||
|
||||
static void
|
||||
arena_dalloc_junk_small_intercept(void *ptr, const arena_bin_info_t *bin_info)
|
||||
{
|
||||
arena_dalloc_junk_small_intercept(void *ptr, const arena_bin_info_t *bin_info) {
|
||||
size_t i;
|
||||
|
||||
arena_dalloc_junk_small_orig(ptr, bin_info);
|
||||
@@ -32,13 +30,13 @@ arena_dalloc_junk_small_intercept(void *ptr, const arena_bin_info_t *bin_info)
|
||||
"Missing junk fill for byte %zu/%zu of deallocated region",
|
||||
i, bin_info->reg_size);
|
||||
}
|
||||
if (ptr == watch_for_junking)
|
||||
if (ptr == watch_for_junking) {
|
||||
saw_junking = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
large_dalloc_junk_intercept(void *ptr, size_t usize)
|
||||
{
|
||||
large_dalloc_junk_intercept(void *ptr, size_t usize) {
|
||||
size_t i;
|
||||
|
||||
large_dalloc_junk_orig(ptr, usize);
|
||||
@@ -47,21 +45,21 @@ large_dalloc_junk_intercept(void *ptr, size_t usize)
|
||||
"Missing junk fill for byte %zu/%zu of deallocated region",
|
||||
i, usize);
|
||||
}
|
||||
if (ptr == watch_for_junking)
|
||||
if (ptr == watch_for_junking) {
|
||||
saw_junking = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
large_dalloc_maybe_junk_intercept(void *ptr, size_t usize)
|
||||
{
|
||||
large_dalloc_maybe_junk_intercept(void *ptr, size_t usize) {
|
||||
large_dalloc_maybe_junk_orig(ptr, usize);
|
||||
if (ptr == watch_for_junking)
|
||||
if (ptr == watch_for_junking) {
|
||||
saw_junking = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_junk(size_t sz_min, size_t sz_max)
|
||||
{
|
||||
test_junk(size_t sz_min, size_t sz_max) {
|
||||
uint8_t *s;
|
||||
size_t sz_prev, sz, i;
|
||||
|
||||
@@ -126,23 +124,20 @@ test_junk(size_t sz_min, size_t sz_max)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_junk_small)
|
||||
{
|
||||
TEST_BEGIN(test_junk_small) {
|
||||
test_skip_if(!config_fill);
|
||||
test_junk(1, SMALL_MAXCLASS-1);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_junk_large)
|
||||
{
|
||||
TEST_BEGIN(test_junk_large) {
|
||||
test_skip_if(!config_fill);
|
||||
test_junk(SMALL_MAXCLASS+1, (1U << (LG_LARGE_MINCLASS+1)));
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_junk_small,
|
||||
test_junk_large));
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_mallctl_errors)
|
||||
{
|
||||
TEST_BEGIN(test_mallctl_errors) {
|
||||
uint64_t epoch;
|
||||
size_t sz;
|
||||
|
||||
@@ -28,8 +27,7 @@ TEST_BEGIN(test_mallctl_errors)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctlnametomib_errors)
|
||||
{
|
||||
TEST_BEGIN(test_mallctlnametomib_errors) {
|
||||
size_t mib[1];
|
||||
size_t miblen;
|
||||
|
||||
@@ -39,8 +37,7 @@ TEST_BEGIN(test_mallctlnametomib_errors)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctlbymib_errors)
|
||||
{
|
||||
TEST_BEGIN(test_mallctlbymib_errors) {
|
||||
uint64_t epoch;
|
||||
size_t sz;
|
||||
size_t mib[1];
|
||||
@@ -76,8 +73,7 @@ TEST_BEGIN(test_mallctlbymib_errors)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctl_read_write)
|
||||
{
|
||||
TEST_BEGIN(test_mallctl_read_write) {
|
||||
uint64_t old_epoch, new_epoch;
|
||||
size_t sz = sizeof(old_epoch);
|
||||
|
||||
@@ -104,8 +100,7 @@ TEST_BEGIN(test_mallctl_read_write)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctlnametomib_short_mib)
|
||||
{
|
||||
TEST_BEGIN(test_mallctlnametomib_short_mib) {
|
||||
size_t mib[4];
|
||||
size_t miblen;
|
||||
|
||||
@@ -119,8 +114,7 @@ TEST_BEGIN(test_mallctlnametomib_short_mib)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctl_config)
|
||||
{
|
||||
TEST_BEGIN(test_mallctl_config) {
|
||||
#define TEST_MALLCTL_CONFIG(config, t) do { \
|
||||
t oldval; \
|
||||
size_t sz = sizeof(oldval); \
|
||||
@@ -149,8 +143,7 @@ TEST_BEGIN(test_mallctl_config)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_mallctl_opt)
|
||||
{
|
||||
TEST_BEGIN(test_mallctl_opt) {
|
||||
bool config_always = true;
|
||||
|
||||
#define TEST_MALLCTL_OPT(t, opt, config) do { \
|
||||
@@ -189,8 +182,7 @@ TEST_BEGIN(test_mallctl_opt)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_manpage_example)
|
||||
{
|
||||
TEST_BEGIN(test_manpage_example) {
|
||||
unsigned nbins, i;
|
||||
size_t mib[4];
|
||||
size_t len, miblen;
|
||||
@@ -214,8 +206,7 @@ TEST_BEGIN(test_manpage_example)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_tcache_none)
|
||||
{
|
||||
TEST_BEGIN(test_tcache_none) {
|
||||
void *p0, *q, *p1;
|
||||
|
||||
test_skip_if(!config_tcache);
|
||||
@@ -240,8 +231,7 @@ TEST_BEGIN(test_tcache_none)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_tcache)
|
||||
{
|
||||
TEST_BEGIN(test_tcache) {
|
||||
#define NTCACHES 10
|
||||
unsigned tis[NTCACHES];
|
||||
void *ps[NTCACHES];
|
||||
@@ -312,11 +302,13 @@ TEST_BEGIN(test_tcache)
|
||||
assert_ptr_eq(qs[i], q0,
|
||||
"Expected rallocx() to allocate cached region, i=%u", i);
|
||||
/* Avoid undefined behavior in case of test failure. */
|
||||
if (qs[i] == NULL)
|
||||
if (qs[i] == NULL) {
|
||||
qs[i] = ps[i];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < NTCACHES; i++)
|
||||
for (i = 0; i < NTCACHES; i++) {
|
||||
dallocx(qs[i], MALLOCX_TCACHE(tis[i]));
|
||||
}
|
||||
|
||||
/* Flush some non-empty tcaches. */
|
||||
for (i = 0; i < NTCACHES/2; i++) {
|
||||
@@ -334,8 +326,7 @@ TEST_BEGIN(test_tcache)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_thread_arena)
|
||||
{
|
||||
TEST_BEGIN(test_thread_arena) {
|
||||
unsigned arena_old, arena_new, narenas;
|
||||
size_t sz = sizeof(unsigned);
|
||||
|
||||
@@ -353,8 +344,7 @@ TEST_BEGIN(test_thread_arena)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_i_initialized)
|
||||
{
|
||||
TEST_BEGIN(test_arena_i_initialized) {
|
||||
unsigned narenas, i;
|
||||
size_t sz;
|
||||
size_t mib[3];
|
||||
@@ -392,8 +382,7 @@ TEST_BEGIN(test_arena_i_initialized)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_i_decay_time)
|
||||
{
|
||||
TEST_BEGIN(test_arena_i_decay_time) {
|
||||
ssize_t decay_time, orig_decay_time, prev_decay_time;
|
||||
size_t sz = sizeof(ssize_t);
|
||||
|
||||
@@ -423,8 +412,7 @@ TEST_BEGIN(test_arena_i_decay_time)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_i_purge)
|
||||
{
|
||||
TEST_BEGIN(test_arena_i_purge) {
|
||||
unsigned narenas;
|
||||
size_t sz = sizeof(unsigned);
|
||||
size_t mib[3];
|
||||
@@ -447,8 +435,7 @@ TEST_BEGIN(test_arena_i_purge)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_i_decay)
|
||||
{
|
||||
TEST_BEGIN(test_arena_i_decay) {
|
||||
unsigned narenas;
|
||||
size_t sz = sizeof(unsigned);
|
||||
size_t mib[3];
|
||||
@@ -471,8 +458,7 @@ TEST_BEGIN(test_arena_i_decay)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arena_i_dss)
|
||||
{
|
||||
TEST_BEGIN(test_arena_i_dss) {
|
||||
const char *dss_prec_old, *dss_prec_new;
|
||||
size_t sz = sizeof(dss_prec_old);
|
||||
size_t mib[3];
|
||||
@@ -517,8 +503,7 @@ TEST_BEGIN(test_arena_i_dss)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arenas_decay_time)
|
||||
{
|
||||
TEST_BEGIN(test_arenas_decay_time) {
|
||||
ssize_t decay_time, orig_decay_time, prev_decay_time;
|
||||
size_t sz = sizeof(ssize_t);
|
||||
|
||||
@@ -548,8 +533,7 @@ TEST_BEGIN(test_arenas_decay_time)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arenas_constants)
|
||||
{
|
||||
TEST_BEGIN(test_arenas_constants) {
|
||||
#define TEST_ARENAS_CONSTANT(t, name, expected) do { \
|
||||
t name; \
|
||||
size_t sz = sizeof(t); \
|
||||
@@ -567,8 +551,7 @@ TEST_BEGIN(test_arenas_constants)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arenas_bin_constants)
|
||||
{
|
||||
TEST_BEGIN(test_arenas_bin_constants) {
|
||||
#define TEST_ARENAS_BIN_CONSTANT(t, name, expected) do { \
|
||||
t name; \
|
||||
size_t sz = sizeof(t); \
|
||||
@@ -586,8 +569,7 @@ TEST_BEGIN(test_arenas_bin_constants)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arenas_lextent_constants)
|
||||
{
|
||||
TEST_BEGIN(test_arenas_lextent_constants) {
|
||||
#define TEST_ARENAS_LEXTENT_CONSTANT(t, name, expected) do { \
|
||||
t name; \
|
||||
size_t sz = sizeof(t); \
|
||||
@@ -602,8 +584,7 @@ TEST_BEGIN(test_arenas_lextent_constants)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_arenas_create)
|
||||
{
|
||||
TEST_BEGIN(test_arenas_create) {
|
||||
unsigned narenas_before, arena, narenas_after;
|
||||
size_t sz = sizeof(unsigned);
|
||||
|
||||
@@ -620,8 +601,7 @@ TEST_BEGIN(test_arenas_create)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_arenas)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas) {
|
||||
#define TEST_STATS_ARENAS(t, name) do { \
|
||||
t name; \
|
||||
size_t sz = sizeof(t); \
|
||||
@@ -640,8 +620,7 @@ TEST_BEGIN(test_stats_arenas)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_mallctl_errors,
|
||||
test_mallctlnametomib_errors,
|
||||
|
@@ -14,30 +14,29 @@
|
||||
#endif
|
||||
|
||||
static bool
|
||||
double_eq_rel(double a, double b, double max_rel_err, double max_abs_err)
|
||||
{
|
||||
double_eq_rel(double a, double b, double max_rel_err, double max_abs_err) {
|
||||
double rel_err;
|
||||
|
||||
if (fabs(a - b) < max_abs_err)
|
||||
if (fabs(a - b) < max_abs_err) {
|
||||
return (true);
|
||||
}
|
||||
rel_err = (fabs(b) > fabs(a)) ? fabs((a-b)/b) : fabs((a-b)/a);
|
||||
return (rel_err < max_rel_err);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
factorial(unsigned x)
|
||||
{
|
||||
factorial(unsigned x) {
|
||||
uint64_t ret = 1;
|
||||
unsigned i;
|
||||
|
||||
for (i = 2; i <= x; i++)
|
||||
for (i = 2; i <= x; i++) {
|
||||
ret *= (uint64_t)i;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_ln_gamma_factorial)
|
||||
{
|
||||
TEST_BEGIN(test_ln_gamma_factorial) {
|
||||
unsigned x;
|
||||
|
||||
/* exp(ln_gamma(x)) == (x-1)! for integer x. */
|
||||
@@ -188,8 +187,7 @@ static const double ln_gamma_misc_expected[] = {
|
||||
359.13420536957539753
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_ln_gamma_misc)
|
||||
{
|
||||
TEST_BEGIN(test_ln_gamma_misc) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 1; i < sizeof(ln_gamma_misc_expected)/sizeof(double); i++) {
|
||||
@@ -239,8 +237,7 @@ static const double pt_norm_expected[] = {
|
||||
1.88079360815125041, 2.05374891063182208, 2.32634787404084076
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_pt_norm)
|
||||
{
|
||||
TEST_BEGIN(test_pt_norm) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 1; i < sizeof(pt_norm_expected)/sizeof(double); i++) {
|
||||
@@ -289,8 +286,7 @@ static const double pt_chi2_expected[] = {
|
||||
1046.4872561869577, 1063.5717461999654, 1107.0741966053859
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_pt_chi2)
|
||||
{
|
||||
TEST_BEGIN(test_pt_chi2) {
|
||||
unsigned i, j;
|
||||
unsigned e = 0;
|
||||
|
||||
@@ -351,8 +347,7 @@ static const double pt_gamma_expected[] = {
|
||||
4.7230515633946677, 5.6417477865306020, 8.4059469148854635
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_pt_gamma_shape)
|
||||
{
|
||||
TEST_BEGIN(test_pt_gamma_shape) {
|
||||
unsigned i, j;
|
||||
unsigned e = 0;
|
||||
|
||||
@@ -371,8 +366,7 @@ TEST_BEGIN(test_pt_gamma_shape)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_pt_gamma_scale)
|
||||
{
|
||||
TEST_BEGIN(test_pt_gamma_scale) {
|
||||
double shape = 1.0;
|
||||
double ln_gamma_shape = ln_gamma(shape);
|
||||
|
||||
@@ -385,8 +379,7 @@ TEST_BEGIN(test_pt_gamma_scale)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_ln_gamma_factorial,
|
||||
test_ln_gamma_misc,
|
||||
|
@@ -9,8 +9,7 @@ struct mq_msg_s {
|
||||
};
|
||||
mq_gen(static, mq_, mq_t, mq_msg_t, link)
|
||||
|
||||
TEST_BEGIN(test_mq_basic)
|
||||
{
|
||||
TEST_BEGIN(test_mq_basic) {
|
||||
mq_t mq;
|
||||
mq_msg_t msg;
|
||||
|
||||
@@ -31,8 +30,7 @@ TEST_BEGIN(test_mq_basic)
|
||||
TEST_END
|
||||
|
||||
static void *
|
||||
thd_receiver_start(void *arg)
|
||||
{
|
||||
thd_receiver_start(void *arg) {
|
||||
mq_t *mq = (mq_t *)arg;
|
||||
unsigned i;
|
||||
|
||||
@@ -45,8 +43,7 @@ thd_receiver_start(void *arg)
|
||||
}
|
||||
|
||||
static void *
|
||||
thd_sender_start(void *arg)
|
||||
{
|
||||
thd_sender_start(void *arg) {
|
||||
mq_t *mq = (mq_t *)arg;
|
||||
unsigned i;
|
||||
|
||||
@@ -61,8 +58,7 @@ thd_sender_start(void *arg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_mq_threaded)
|
||||
{
|
||||
TEST_BEGIN(test_mq_threaded) {
|
||||
mq_t mq;
|
||||
thd_t receiver;
|
||||
thd_t senders[NSENDERS];
|
||||
@@ -71,20 +67,21 @@ TEST_BEGIN(test_mq_threaded)
|
||||
assert_false(mq_init(&mq), "Unexpected mq_init() failure");
|
||||
|
||||
thd_create(&receiver, thd_receiver_start, (void *)&mq);
|
||||
for (i = 0; i < NSENDERS; i++)
|
||||
for (i = 0; i < NSENDERS; i++) {
|
||||
thd_create(&senders[i], thd_sender_start, (void *)&mq);
|
||||
}
|
||||
|
||||
thd_join(receiver, NULL);
|
||||
for (i = 0; i < NSENDERS; i++)
|
||||
for (i = 0; i < NSENDERS; i++) {
|
||||
thd_join(senders[i], NULL);
|
||||
}
|
||||
|
||||
mq_fini(&mq);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_mq_basic,
|
||||
test_mq_threaded));
|
||||
|
@@ -3,8 +3,7 @@
|
||||
#define NTHREADS 2
|
||||
#define NINCRS 2000000
|
||||
|
||||
TEST_BEGIN(test_mtx_basic)
|
||||
{
|
||||
TEST_BEGIN(test_mtx_basic) {
|
||||
mtx_t mtx;
|
||||
|
||||
assert_false(mtx_init(&mtx), "Unexpected mtx_init() failure");
|
||||
@@ -20,8 +19,7 @@ typedef struct {
|
||||
} thd_start_arg_t;
|
||||
|
||||
static void *
|
||||
thd_start(void *varg)
|
||||
{
|
||||
thd_start(void *varg) {
|
||||
thd_start_arg_t *arg = (thd_start_arg_t *)varg;
|
||||
unsigned i;
|
||||
|
||||
@@ -33,26 +31,26 @@ thd_start(void *varg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_mtx_race)
|
||||
{
|
||||
TEST_BEGIN(test_mtx_race) {
|
||||
thd_start_arg_t arg;
|
||||
thd_t thds[NTHREADS];
|
||||
unsigned i;
|
||||
|
||||
assert_false(mtx_init(&arg.mtx), "Unexpected mtx_init() failure");
|
||||
arg.x = 0;
|
||||
for (i = 0; i < NTHREADS; i++)
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_create(&thds[i], thd_start, (void *)&arg);
|
||||
for (i = 0; i < NTHREADS; i++)
|
||||
}
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_join(thds[i], NULL);
|
||||
}
|
||||
assert_u_eq(arg.x, NTHREADS * NINCRS,
|
||||
"Race-related counter corruption");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_mtx_basic,
|
||||
test_mtx_race));
|
||||
|
@@ -2,8 +2,7 @@
|
||||
|
||||
#define BILLION UINT64_C(1000000000)
|
||||
|
||||
TEST_BEGIN(test_nstime_init)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_init) {
|
||||
nstime_t nst;
|
||||
|
||||
nstime_init(&nst, 42000000043);
|
||||
@@ -13,8 +12,7 @@ TEST_BEGIN(test_nstime_init)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_init2)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_init2) {
|
||||
nstime_t nst;
|
||||
|
||||
nstime_init2(&nst, 42, 43);
|
||||
@@ -23,8 +21,7 @@ TEST_BEGIN(test_nstime_init2)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_copy)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_copy) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -35,8 +32,7 @@ TEST_BEGIN(test_nstime_copy)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_compare)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_compare) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -70,8 +66,7 @@ TEST_BEGIN(test_nstime_compare)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_add)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_add) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -90,8 +85,7 @@ TEST_BEGIN(test_nstime_add)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_subtract)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_subtract) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -110,8 +104,7 @@ TEST_BEGIN(test_nstime_subtract)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_imultiply)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_imultiply) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -128,8 +121,7 @@ TEST_BEGIN(test_nstime_imultiply)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_idivide)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_idivide) {
|
||||
nstime_t nsta, nstb;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -148,8 +140,7 @@ TEST_BEGIN(test_nstime_idivide)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_divide)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_divide) {
|
||||
nstime_t nsta, nstb, nstc;
|
||||
|
||||
nstime_init2(&nsta, 42, 43);
|
||||
@@ -176,14 +167,12 @@ TEST_BEGIN(test_nstime_divide)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_monotonic)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_monotonic) {
|
||||
nstime_monotonic();
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_nstime_update)
|
||||
{
|
||||
TEST_BEGIN(test_nstime_update) {
|
||||
nstime_t nst;
|
||||
|
||||
nstime_init(&nst, 0);
|
||||
@@ -208,8 +197,7 @@ TEST_BEGIN(test_nstime_update)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_nstime_init,
|
||||
test_nstime_init2,
|
||||
|
@@ -20,8 +20,7 @@ const char *malloc_conf = "decay_time:-1";
|
||||
#define NSLABS 8
|
||||
|
||||
static unsigned
|
||||
binind_compute(void)
|
||||
{
|
||||
binind_compute(void) {
|
||||
size_t sz;
|
||||
unsigned nbins, i;
|
||||
|
||||
@@ -41,8 +40,9 @@ binind_compute(void)
|
||||
sz = sizeof(size);
|
||||
assert_d_eq(mallctlbymib(mib, miblen, (void *)&size, &sz, NULL,
|
||||
0), 0, "Unexpected mallctlbymib failure");
|
||||
if (size == SZ)
|
||||
if (size == SZ) {
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
|
||||
test_fail("Unable to compute nregs_per_run");
|
||||
@@ -50,8 +50,7 @@ binind_compute(void)
|
||||
}
|
||||
|
||||
static size_t
|
||||
nregs_per_run_compute(void)
|
||||
{
|
||||
nregs_per_run_compute(void) {
|
||||
uint32_t nregs;
|
||||
size_t sz;
|
||||
unsigned binind = binind_compute();
|
||||
@@ -68,8 +67,7 @@ nregs_per_run_compute(void)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
arenas_create_mallctl(void)
|
||||
{
|
||||
arenas_create_mallctl(void) {
|
||||
unsigned arena_ind;
|
||||
size_t sz;
|
||||
|
||||
@@ -81,8 +79,7 @@ arenas_create_mallctl(void)
|
||||
}
|
||||
|
||||
static void
|
||||
arena_reset_mallctl(unsigned arena_ind)
|
||||
{
|
||||
arena_reset_mallctl(unsigned arena_ind) {
|
||||
size_t mib[3];
|
||||
size_t miblen = sizeof(mib)/sizeof(size_t);
|
||||
|
||||
@@ -93,8 +90,7 @@ arena_reset_mallctl(unsigned arena_ind)
|
||||
"Unexpected mallctlbymib() failure");
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_pack)
|
||||
{
|
||||
TEST_BEGIN(test_pack) {
|
||||
unsigned arena_ind = arenas_create_mallctl();
|
||||
size_t nregs_per_run = nregs_per_run_compute();
|
||||
size_t nregs = nregs_per_run * NSLABS;
|
||||
@@ -125,8 +121,9 @@ TEST_BEGIN(test_pack)
|
||||
i++, offset = (offset + 1) % nregs_per_run) {
|
||||
for (j = 0; j < nregs_per_run; j++) {
|
||||
void *p = ptrs[(i * nregs_per_run) + j];
|
||||
if (offset == j)
|
||||
if (offset == j) {
|
||||
continue;
|
||||
}
|
||||
dallocx(p, MALLOCX_ARENA(arena_ind) |
|
||||
MALLOCX_TCACHE_NONE);
|
||||
}
|
||||
@@ -143,8 +140,9 @@ TEST_BEGIN(test_pack)
|
||||
for (j = 0; j < nregs_per_run; j++) {
|
||||
void *p;
|
||||
|
||||
if (offset == j)
|
||||
if (offset == j) {
|
||||
continue;
|
||||
}
|
||||
p = mallocx(SZ, MALLOCX_ARENA(arena_ind) |
|
||||
MALLOCX_TCACHE_NONE);
|
||||
assert_ptr_eq(p, ptrs[(i * nregs_per_run) + j],
|
||||
@@ -159,8 +157,7 @@ TEST_BEGIN(test_pack)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_pack));
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_pages_huge)
|
||||
{
|
||||
TEST_BEGIN(test_pages_huge) {
|
||||
size_t alloc_size;
|
||||
bool commit;
|
||||
void *pages, *hugepage;
|
||||
@@ -22,8 +21,7 @@ TEST_BEGIN(test_pages_huge)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_pages_huge));
|
||||
}
|
||||
|
@@ -10,8 +10,7 @@ struct node_s {
|
||||
};
|
||||
|
||||
static int
|
||||
node_cmp(const node_t *a, const node_t *b)
|
||||
{
|
||||
node_cmp(const node_t *a, const node_t *b) {
|
||||
int ret;
|
||||
|
||||
ret = (a->key > b->key) - (a->key < b->key);
|
||||
@@ -39,18 +38,19 @@ typedef ph(node_t) heap_t;
|
||||
ph_gen(static, heap_, heap_t, node_t, link, node_cmp_magic);
|
||||
|
||||
static void
|
||||
node_print(const node_t *node, unsigned depth)
|
||||
{
|
||||
node_print(const node_t *node, unsigned depth) {
|
||||
unsigned i;
|
||||
node_t *leftmost_child, *sibling;
|
||||
|
||||
for (i = 0; i < depth; i++)
|
||||
for (i = 0; i < depth; i++) {
|
||||
malloc_printf("\t");
|
||||
}
|
||||
malloc_printf("%2"FMTu64"\n", node->key);
|
||||
|
||||
leftmost_child = phn_lchild_get(node_t, link, node);
|
||||
if (leftmost_child == NULL)
|
||||
if (leftmost_child == NULL) {
|
||||
return;
|
||||
}
|
||||
node_print(leftmost_child, depth + 1);
|
||||
|
||||
for (sibling = phn_next_get(node_t, link, leftmost_child); sibling !=
|
||||
@@ -60,13 +60,13 @@ node_print(const node_t *node, unsigned depth)
|
||||
}
|
||||
|
||||
static void
|
||||
heap_print(const heap_t *heap)
|
||||
{
|
||||
heap_print(const heap_t *heap) {
|
||||
node_t *auxelm;
|
||||
|
||||
malloc_printf("vvv heap %p vvv\n", heap);
|
||||
if (heap->ph_root == NULL)
|
||||
if (heap->ph_root == NULL) {
|
||||
goto label_return;
|
||||
}
|
||||
|
||||
node_print(heap->ph_root, 0);
|
||||
|
||||
@@ -83,8 +83,7 @@ label_return:
|
||||
}
|
||||
|
||||
static unsigned
|
||||
node_validate(const node_t *node, const node_t *parent)
|
||||
{
|
||||
node_validate(const node_t *node, const node_t *parent) {
|
||||
unsigned nnodes = 1;
|
||||
node_t *leftmost_child, *sibling;
|
||||
|
||||
@@ -94,8 +93,9 @@ node_validate(const node_t *node, const node_t *parent)
|
||||
}
|
||||
|
||||
leftmost_child = phn_lchild_get(node_t, link, node);
|
||||
if (leftmost_child == NULL)
|
||||
if (leftmost_child == NULL) {
|
||||
return (nnodes);
|
||||
}
|
||||
assert_ptr_eq((void *)phn_prev_get(node_t, link, leftmost_child),
|
||||
(void *)node, "Leftmost child does not link to node");
|
||||
nnodes += node_validate(leftmost_child, node);
|
||||
@@ -111,13 +111,13 @@ node_validate(const node_t *node, const node_t *parent)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
heap_validate(const heap_t *heap)
|
||||
{
|
||||
heap_validate(const heap_t *heap) {
|
||||
unsigned nnodes = 0;
|
||||
node_t *auxelm;
|
||||
|
||||
if (heap->ph_root == NULL)
|
||||
if (heap->ph_root == NULL) {
|
||||
goto label_return;
|
||||
}
|
||||
|
||||
nnodes += node_validate(heap->ph_root, NULL);
|
||||
|
||||
@@ -130,13 +130,13 @@ heap_validate(const heap_t *heap)
|
||||
}
|
||||
|
||||
label_return:
|
||||
if (false)
|
||||
if (false) {
|
||||
heap_print(heap);
|
||||
}
|
||||
return (nnodes);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_ph_empty)
|
||||
{
|
||||
TEST_BEGIN(test_ph_empty) {
|
||||
heap_t heap;
|
||||
|
||||
heap_new(&heap);
|
||||
@@ -146,23 +146,20 @@ TEST_BEGIN(test_ph_empty)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
node_remove(heap_t *heap, node_t *node)
|
||||
{
|
||||
node_remove(heap_t *heap, node_t *node) {
|
||||
heap_remove(heap, node);
|
||||
|
||||
node->magic = 0;
|
||||
}
|
||||
|
||||
static node_t *
|
||||
node_remove_first(heap_t *heap)
|
||||
{
|
||||
node_remove_first(heap_t *heap) {
|
||||
node_t *node = heap_remove_first(heap);
|
||||
node->magic = 0;
|
||||
return (node);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_ph_random)
|
||||
{
|
||||
TEST_BEGIN(test_ph_random) {
|
||||
#define NNODES 25
|
||||
#define NBAGS 250
|
||||
#define SEED 42
|
||||
@@ -177,17 +174,20 @@ TEST_BEGIN(test_ph_random)
|
||||
switch (i) {
|
||||
case 0:
|
||||
/* Insert in order. */
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = j;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Insert in reverse order. */
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = NNODES - j - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = gen_rand64_range(sfmt, NNODES);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 1; j <= NNODES; j++) {
|
||||
@@ -280,8 +280,7 @@ TEST_BEGIN(test_ph_random)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_ph_empty,
|
||||
test_ph_random));
|
||||
|
@@ -1,8 +1,7 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
static void
|
||||
test_prng_lg_range_u32(bool atomic)
|
||||
{
|
||||
test_prng_lg_range_u32(bool atomic) {
|
||||
uint32_t sa, sb, ra, rb;
|
||||
unsigned lg_range;
|
||||
|
||||
@@ -38,8 +37,7 @@ test_prng_lg_range_u32(bool atomic)
|
||||
}
|
||||
|
||||
static void
|
||||
test_prng_lg_range_u64(void)
|
||||
{
|
||||
test_prng_lg_range_u64(void) {
|
||||
uint64_t sa, sb, ra, rb;
|
||||
unsigned lg_range;
|
||||
|
||||
@@ -75,8 +73,7 @@ test_prng_lg_range_u64(void)
|
||||
}
|
||||
|
||||
static void
|
||||
test_prng_lg_range_zu(bool atomic)
|
||||
{
|
||||
test_prng_lg_range_zu(bool atomic) {
|
||||
size_t sa, sb, ra, rb;
|
||||
unsigned lg_range;
|
||||
|
||||
@@ -112,39 +109,33 @@ test_prng_lg_range_zu(bool atomic)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prng_lg_range_u32_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_lg_range_u32_nonatomic) {
|
||||
test_prng_lg_range_u32(false);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_lg_range_u32_atomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_lg_range_u32_atomic) {
|
||||
test_prng_lg_range_u32(true);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_lg_range_u64_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_lg_range_u64_nonatomic) {
|
||||
test_prng_lg_range_u64();
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_lg_range_zu_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_lg_range_zu_nonatomic) {
|
||||
test_prng_lg_range_zu(false);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_lg_range_zu_atomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_lg_range_zu_atomic) {
|
||||
test_prng_lg_range_zu(true);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_prng_range_u32(bool atomic)
|
||||
{
|
||||
test_prng_range_u32(bool atomic) {
|
||||
uint32_t range;
|
||||
#define MAX_RANGE 10000000
|
||||
#define RANGE_STEP 97
|
||||
@@ -164,8 +155,7 @@ test_prng_range_u32(bool atomic)
|
||||
}
|
||||
|
||||
static void
|
||||
test_prng_range_u64(void)
|
||||
{
|
||||
test_prng_range_u64(void) {
|
||||
uint64_t range;
|
||||
#define MAX_RANGE 10000000
|
||||
#define RANGE_STEP 97
|
||||
@@ -185,8 +175,7 @@ test_prng_range_u64(void)
|
||||
}
|
||||
|
||||
static void
|
||||
test_prng_range_zu(bool atomic)
|
||||
{
|
||||
test_prng_range_zu(bool atomic) {
|
||||
size_t range;
|
||||
#define MAX_RANGE 10000000
|
||||
#define RANGE_STEP 97
|
||||
@@ -205,39 +194,33 @@ test_prng_range_zu(bool atomic)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prng_range_u32_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_range_u32_nonatomic) {
|
||||
test_prng_range_u32(false);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_range_u32_atomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_range_u32_atomic) {
|
||||
test_prng_range_u32(true);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_range_u64_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_range_u64_nonatomic) {
|
||||
test_prng_range_u64();
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_range_zu_nonatomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_range_zu_nonatomic) {
|
||||
test_prng_range_zu(false);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_prng_range_zu_atomic)
|
||||
{
|
||||
TEST_BEGIN(test_prng_range_zu_atomic) {
|
||||
test_prng_range_zu(true);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_prng_lg_range_u32_nonatomic,
|
||||
test_prng_lg_range_u32_atomic,
|
||||
|
@@ -11,8 +11,7 @@ const char *malloc_conf =
|
||||
#endif
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
@@ -22,14 +21,12 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
}
|
||||
|
||||
static void *
|
||||
alloc_from_permuted_backtrace(unsigned thd_ind, unsigned iteration)
|
||||
{
|
||||
alloc_from_permuted_backtrace(unsigned thd_ind, unsigned iteration) {
|
||||
return (btalloc(1, thd_ind*NALLOCS_PER_THREAD + iteration));
|
||||
}
|
||||
|
||||
static void *
|
||||
thd_start(void *varg)
|
||||
{
|
||||
thd_start(void *varg) {
|
||||
unsigned thd_ind = *(unsigned *)varg;
|
||||
size_t bt_count_prev, bt_count;
|
||||
unsigned i_prev, i;
|
||||
@@ -57,8 +54,7 @@ thd_start(void *varg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_idump)
|
||||
{
|
||||
TEST_BEGIN(test_idump) {
|
||||
bool active;
|
||||
thd_t thds[NTHREADS];
|
||||
unsigned thd_args[NTHREADS];
|
||||
@@ -77,14 +73,14 @@ TEST_BEGIN(test_idump)
|
||||
thd_args[i] = i;
|
||||
thd_create(&thds[i], thd_start, (void *)&thd_args[i]);
|
||||
}
|
||||
for (i = 0; i < NTHREADS; i++)
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_join(thds[i], NULL);
|
||||
}
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_idump));
|
||||
}
|
||||
|
@@ -6,8 +6,7 @@ const char *malloc_conf =
|
||||
#endif
|
||||
|
||||
static void
|
||||
mallctl_bool_get(const char *name, bool expected, const char *func, int line)
|
||||
{
|
||||
mallctl_bool_get(const char *name, bool expected, const char *func, int line) {
|
||||
bool old;
|
||||
size_t sz;
|
||||
|
||||
@@ -20,8 +19,7 @@ mallctl_bool_get(const char *name, bool expected, const char *func, int line)
|
||||
|
||||
static void
|
||||
mallctl_bool_set(const char *name, bool old_expected, bool val_new,
|
||||
const char *func, int line)
|
||||
{
|
||||
const char *func, int line) {
|
||||
bool old;
|
||||
size_t sz;
|
||||
|
||||
@@ -36,8 +34,7 @@ mallctl_bool_set(const char *name, bool old_expected, bool val_new,
|
||||
|
||||
static void
|
||||
mallctl_prof_active_get_impl(bool prof_active_old_expected, const char *func,
|
||||
int line)
|
||||
{
|
||||
int line) {
|
||||
mallctl_bool_get("prof.active", prof_active_old_expected, func, line);
|
||||
}
|
||||
#define mallctl_prof_active_get(a) \
|
||||
@@ -45,8 +42,7 @@ mallctl_prof_active_get_impl(bool prof_active_old_expected, const char *func,
|
||||
|
||||
static void
|
||||
mallctl_prof_active_set_impl(bool prof_active_old_expected,
|
||||
bool prof_active_new, const char *func, int line)
|
||||
{
|
||||
bool prof_active_new, const char *func, int line) {
|
||||
mallctl_bool_set("prof.active", prof_active_old_expected,
|
||||
prof_active_new, func, line);
|
||||
}
|
||||
@@ -55,8 +51,7 @@ mallctl_prof_active_set_impl(bool prof_active_old_expected,
|
||||
|
||||
static void
|
||||
mallctl_thread_prof_active_get_impl(bool thread_prof_active_old_expected,
|
||||
const char *func, int line)
|
||||
{
|
||||
const char *func, int line) {
|
||||
mallctl_bool_get("thread.prof.active", thread_prof_active_old_expected,
|
||||
func, line);
|
||||
}
|
||||
@@ -65,8 +60,7 @@ mallctl_thread_prof_active_get_impl(bool thread_prof_active_old_expected,
|
||||
|
||||
static void
|
||||
mallctl_thread_prof_active_set_impl(bool thread_prof_active_old_expected,
|
||||
bool thread_prof_active_new, const char *func, int line)
|
||||
{
|
||||
bool thread_prof_active_new, const char *func, int line) {
|
||||
mallctl_bool_set("thread.prof.active", thread_prof_active_old_expected,
|
||||
thread_prof_active_new, func, line);
|
||||
}
|
||||
@@ -74,8 +68,7 @@ mallctl_thread_prof_active_set_impl(bool thread_prof_active_old_expected,
|
||||
mallctl_thread_prof_active_set_impl(a, b, __func__, __LINE__)
|
||||
|
||||
static void
|
||||
prof_sampling_probe_impl(bool expect_sample, const char *func, int line)
|
||||
{
|
||||
prof_sampling_probe_impl(bool expect_sample, const char *func, int line) {
|
||||
void *p;
|
||||
size_t expected_backtraces = expect_sample ? 1 : 0;
|
||||
|
||||
@@ -90,8 +83,7 @@ prof_sampling_probe_impl(bool expect_sample, const char *func, int line)
|
||||
#define prof_sampling_probe(a) \
|
||||
prof_sampling_probe_impl(a, __func__, __LINE__)
|
||||
|
||||
TEST_BEGIN(test_prof_active)
|
||||
{
|
||||
TEST_BEGIN(test_prof_active) {
|
||||
test_skip_if(!config_prof);
|
||||
|
||||
mallctl_prof_active_get(true);
|
||||
@@ -124,8 +116,7 @@ TEST_BEGIN(test_prof_active)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_prof_active));
|
||||
}
|
||||
|
@@ -7,8 +7,7 @@ const char *malloc_conf = "prof:true,prof_active:false,prof_gdump:true";
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
did_prof_dump_open = true;
|
||||
@@ -19,8 +18,7 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
return (fd);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_gdump)
|
||||
{
|
||||
TEST_BEGIN(test_gdump) {
|
||||
bool active, gdump, gdump_old;
|
||||
void *p, *q, *r, *s;
|
||||
size_t sz;
|
||||
@@ -74,8 +72,7 @@ TEST_BEGIN(test_gdump)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_gdump));
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@ const char *malloc_conf = ""
|
||||
static bool did_prof_dump_open;
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
did_prof_dump_open = true;
|
||||
@@ -28,8 +27,7 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
return (fd);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_idump)
|
||||
{
|
||||
TEST_BEGIN(test_idump) {
|
||||
bool active;
|
||||
void *p;
|
||||
|
||||
@@ -51,8 +49,7 @@ TEST_BEGIN(test_idump)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_idump));
|
||||
}
|
||||
|
@@ -6,8 +6,7 @@ const char *malloc_conf =
|
||||
#endif
|
||||
|
||||
static int
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
{
|
||||
prof_dump_open_intercept(bool propagate_err, const char *filename) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
@@ -17,15 +16,13 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
}
|
||||
|
||||
static void
|
||||
set_prof_active(bool active)
|
||||
{
|
||||
set_prof_active(bool active) {
|
||||
assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,
|
||||
sizeof(active)), 0, "Unexpected mallctl failure");
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_lg_prof_sample(void)
|
||||
{
|
||||
get_lg_prof_sample(void) {
|
||||
size_t lg_prof_sample;
|
||||
size_t sz = sizeof(size_t);
|
||||
|
||||
@@ -36,8 +33,7 @@ get_lg_prof_sample(void)
|
||||
}
|
||||
|
||||
static void
|
||||
do_prof_reset(size_t lg_prof_sample)
|
||||
{
|
||||
do_prof_reset(size_t lg_prof_sample) {
|
||||
assert_d_eq(mallctl("prof.reset", NULL, NULL,
|
||||
(void *)&lg_prof_sample, sizeof(size_t)), 0,
|
||||
"Unexpected mallctl failure while resetting profile data");
|
||||
@@ -45,8 +41,7 @@ do_prof_reset(size_t lg_prof_sample)
|
||||
"Expected profile sample rate change");
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prof_reset_basic)
|
||||
{
|
||||
TEST_BEGIN(test_prof_reset_basic) {
|
||||
size_t lg_prof_sample_orig, lg_prof_sample, lg_prof_sample_next;
|
||||
size_t sz;
|
||||
unsigned i;
|
||||
@@ -95,16 +90,14 @@ bool prof_dump_header_intercepted = false;
|
||||
prof_cnt_t cnt_all_copy = {0, 0, 0, 0};
|
||||
static bool
|
||||
prof_dump_header_intercept(tsdn_t *tsdn, bool propagate_err,
|
||||
const prof_cnt_t *cnt_all)
|
||||
{
|
||||
const prof_cnt_t *cnt_all) {
|
||||
prof_dump_header_intercepted = true;
|
||||
memcpy(&cnt_all_copy, cnt_all, sizeof(prof_cnt_t));
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prof_reset_cleanup)
|
||||
{
|
||||
TEST_BEGIN(test_prof_reset_cleanup) {
|
||||
void *p;
|
||||
prof_dump_header_t *prof_dump_header_orig;
|
||||
|
||||
@@ -148,8 +141,7 @@ TEST_END
|
||||
#define RESET_INTERVAL (1U << 10)
|
||||
#define DUMP_INTERVAL 3677
|
||||
static void *
|
||||
thd_start(void *varg)
|
||||
{
|
||||
thd_start(void *varg) {
|
||||
unsigned thd_ind = *(unsigned *)varg;
|
||||
unsigned i;
|
||||
void *objs[OBJ_RING_BUF_COUNT];
|
||||
@@ -192,8 +184,7 @@ thd_start(void *varg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prof_reset)
|
||||
{
|
||||
TEST_BEGIN(test_prof_reset) {
|
||||
size_t lg_prof_sample_orig;
|
||||
thd_t thds[NTHREADS];
|
||||
unsigned thd_args[NTHREADS];
|
||||
@@ -216,8 +207,9 @@ TEST_BEGIN(test_prof_reset)
|
||||
thd_args[i] = i;
|
||||
thd_create(&thds[i], thd_start, (void *)&thd_args[i]);
|
||||
}
|
||||
for (i = 0; i < NTHREADS; i++)
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_join(thds[i], NULL);
|
||||
}
|
||||
|
||||
assert_zu_eq(prof_bt_count(), bt_count,
|
||||
"Unexpected bactrace count change");
|
||||
@@ -237,8 +229,7 @@ TEST_END
|
||||
|
||||
/* Test sampling at the same allocation site across resets. */
|
||||
#define NITER 10
|
||||
TEST_BEGIN(test_xallocx)
|
||||
{
|
||||
TEST_BEGIN(test_xallocx) {
|
||||
size_t lg_prof_sample_orig;
|
||||
unsigned i;
|
||||
void *ptrs[NITER];
|
||||
@@ -288,8 +279,7 @@ TEST_END
|
||||
#undef NITER
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
/* Intercept dumping prior to running any tests. */
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
|
||||
|
@@ -4,8 +4,7 @@
|
||||
const char *malloc_conf = "prof:true,lg_prof_sample:0";
|
||||
#endif
|
||||
|
||||
TEST_BEGIN(test_prof_realloc)
|
||||
{
|
||||
TEST_BEGIN(test_prof_realloc) {
|
||||
tsdn_t *tsdn;
|
||||
int flags;
|
||||
void *p, *q;
|
||||
@@ -50,8 +49,7 @@ TEST_BEGIN(test_prof_realloc)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return test(
|
||||
test_prof_realloc);
|
||||
}
|
||||
|
@@ -6,8 +6,7 @@ const char *malloc_conf = "prof:true,prof_active:false";
|
||||
|
||||
static void
|
||||
mallctl_thread_name_get_impl(const char *thread_name_expected, const char *func,
|
||||
int line)
|
||||
{
|
||||
int line) {
|
||||
const char *thread_name_old;
|
||||
size_t sz;
|
||||
|
||||
@@ -24,8 +23,7 @@ mallctl_thread_name_get_impl(const char *thread_name_expected, const char *func,
|
||||
|
||||
static void
|
||||
mallctl_thread_name_set_impl(const char *thread_name, const char *func,
|
||||
int line)
|
||||
{
|
||||
int line) {
|
||||
assert_d_eq(mallctl("thread.prof.name", NULL, NULL,
|
||||
(void *)&thread_name, sizeof(thread_name)), 0,
|
||||
"%s():%d: Unexpected mallctl failure reading thread.prof.name",
|
||||
@@ -35,8 +33,7 @@ mallctl_thread_name_set_impl(const char *thread_name, const char *func,
|
||||
#define mallctl_thread_name_set(a) \
|
||||
mallctl_thread_name_set_impl(a, __func__, __LINE__)
|
||||
|
||||
TEST_BEGIN(test_prof_thread_name_validation)
|
||||
{
|
||||
TEST_BEGIN(test_prof_thread_name_validation) {
|
||||
const char *thread_name;
|
||||
|
||||
test_skip_if(!config_prof);
|
||||
@@ -78,8 +75,7 @@ TEST_END
|
||||
#define NTHREADS 4
|
||||
#define NRESET 25
|
||||
static void *
|
||||
thd_start(void *varg)
|
||||
{
|
||||
thd_start(void *varg) {
|
||||
unsigned thd_ind = *(unsigned *)varg;
|
||||
char thread_name[16] = "";
|
||||
unsigned i;
|
||||
@@ -101,8 +97,7 @@ thd_start(void *varg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_prof_thread_name_threaded)
|
||||
{
|
||||
TEST_BEGIN(test_prof_thread_name_threaded) {
|
||||
thd_t thds[NTHREADS];
|
||||
unsigned thd_args[NTHREADS];
|
||||
unsigned i;
|
||||
@@ -113,16 +108,16 @@ TEST_BEGIN(test_prof_thread_name_threaded)
|
||||
thd_args[i] = i;
|
||||
thd_create(&thds[i], thd_start, (void *)&thd_args[i]);
|
||||
}
|
||||
for (i = 0; i < NTHREADS; i++)
|
||||
for (i = 0; i < NTHREADS; i++) {
|
||||
thd_join(thds[i], NULL);
|
||||
}
|
||||
}
|
||||
TEST_END
|
||||
#undef NTHREADS
|
||||
#undef NRESET
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_prof_thread_name_validation,
|
||||
test_prof_thread_name_threaded));
|
||||
|
@@ -12,8 +12,7 @@ struct list_s {
|
||||
};
|
||||
|
||||
static void
|
||||
test_empty_list(list_head_t *head)
|
||||
{
|
||||
test_empty_list(list_head_t *head) {
|
||||
list_t *t;
|
||||
unsigned i;
|
||||
|
||||
@@ -34,8 +33,7 @@ test_empty_list(list_head_t *head)
|
||||
assert_u_eq(i, 0, "Unexpected element for empty list");
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_ql_empty)
|
||||
{
|
||||
TEST_BEGIN(test_ql_empty) {
|
||||
list_head_t head;
|
||||
|
||||
ql_new(&head);
|
||||
@@ -44,8 +42,7 @@ TEST_BEGIN(test_ql_empty)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
init_entries(list_t *entries, unsigned nentries)
|
||||
{
|
||||
init_entries(list_t *entries, unsigned nentries) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < nentries; i++) {
|
||||
@@ -55,8 +52,7 @@ init_entries(list_t *entries, unsigned nentries)
|
||||
}
|
||||
|
||||
static void
|
||||
test_entries_list(list_head_t *head, list_t *entries, unsigned nentries)
|
||||
{
|
||||
test_entries_list(list_head_t *head, list_t *entries, unsigned nentries) {
|
||||
list_t *t;
|
||||
unsigned i;
|
||||
|
||||
@@ -91,31 +87,31 @@ test_entries_list(list_head_t *head, list_t *entries, unsigned nentries)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_ql_tail_insert)
|
||||
{
|
||||
TEST_BEGIN(test_ql_tail_insert) {
|
||||
list_head_t head;
|
||||
list_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
ql_new(&head);
|
||||
init_entries(entries, sizeof(entries)/sizeof(list_t));
|
||||
for (i = 0; i < NENTRIES; i++)
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
ql_tail_insert(&head, &entries[i], link);
|
||||
}
|
||||
|
||||
test_entries_list(&head, entries, NENTRIES);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ql_tail_remove)
|
||||
{
|
||||
TEST_BEGIN(test_ql_tail_remove) {
|
||||
list_head_t head;
|
||||
list_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
ql_new(&head);
|
||||
init_entries(entries, sizeof(entries)/sizeof(list_t));
|
||||
for (i = 0; i < NENTRIES; i++)
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
ql_tail_insert(&head, &entries[i], link);
|
||||
}
|
||||
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
test_entries_list(&head, entries, NENTRIES-i);
|
||||
@@ -125,31 +121,31 @@ TEST_BEGIN(test_ql_tail_remove)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ql_head_insert)
|
||||
{
|
||||
TEST_BEGIN(test_ql_head_insert) {
|
||||
list_head_t head;
|
||||
list_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
ql_new(&head);
|
||||
init_entries(entries, sizeof(entries)/sizeof(list_t));
|
||||
for (i = 0; i < NENTRIES; i++)
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
ql_head_insert(&head, &entries[NENTRIES-i-1], link);
|
||||
}
|
||||
|
||||
test_entries_list(&head, entries, NENTRIES);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ql_head_remove)
|
||||
{
|
||||
TEST_BEGIN(test_ql_head_remove) {
|
||||
list_head_t head;
|
||||
list_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
ql_new(&head);
|
||||
init_entries(entries, sizeof(entries)/sizeof(list_t));
|
||||
for (i = 0; i < NENTRIES; i++)
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
ql_head_insert(&head, &entries[NENTRIES-i-1], link);
|
||||
}
|
||||
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
test_entries_list(&head, &entries[i], NENTRIES-i);
|
||||
@@ -159,8 +155,7 @@ TEST_BEGIN(test_ql_head_remove)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ql_insert)
|
||||
{
|
||||
TEST_BEGIN(test_ql_insert) {
|
||||
list_head_t head;
|
||||
list_t entries[8];
|
||||
list_t *a, *b, *c, *d, *e, *f, *g, *h;
|
||||
@@ -196,8 +191,7 @@ TEST_BEGIN(test_ql_insert)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_ql_empty,
|
||||
test_ql_tail_insert,
|
||||
|
@@ -13,8 +13,7 @@ struct ring_s {
|
||||
};
|
||||
|
||||
static void
|
||||
init_entries(ring_t *entries)
|
||||
{
|
||||
init_entries(ring_t *entries) {
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
@@ -24,8 +23,7 @@ init_entries(ring_t *entries)
|
||||
}
|
||||
|
||||
static void
|
||||
test_independent_entries(ring_t *entries)
|
||||
{
|
||||
test_independent_entries(ring_t *entries) {
|
||||
ring_t *t;
|
||||
unsigned i, j;
|
||||
|
||||
@@ -61,8 +59,7 @@ test_independent_entries(ring_t *entries)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_qr_one)
|
||||
{
|
||||
TEST_BEGIN(test_qr_one) {
|
||||
ring_t entries[NENTRIES];
|
||||
|
||||
init_entries(entries);
|
||||
@@ -71,8 +68,7 @@ TEST_BEGIN(test_qr_one)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_entries_ring(ring_t *entries)
|
||||
{
|
||||
test_entries_ring(ring_t *entries) {
|
||||
ring_t *t;
|
||||
unsigned i, j;
|
||||
|
||||
@@ -104,27 +100,27 @@ test_entries_ring(ring_t *entries)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_qr_after_insert)
|
||||
{
|
||||
TEST_BEGIN(test_qr_after_insert) {
|
||||
ring_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
init_entries(entries);
|
||||
for (i = 1; i < NENTRIES; i++)
|
||||
for (i = 1; i < NENTRIES; i++) {
|
||||
qr_after_insert(&entries[i - 1], &entries[i], link);
|
||||
}
|
||||
test_entries_ring(entries);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_qr_remove)
|
||||
{
|
||||
TEST_BEGIN(test_qr_remove) {
|
||||
ring_t entries[NENTRIES];
|
||||
ring_t *t;
|
||||
unsigned i, j;
|
||||
|
||||
init_entries(entries);
|
||||
for (i = 1; i < NENTRIES; i++)
|
||||
for (i = 1; i < NENTRIES; i++) {
|
||||
qr_after_insert(&entries[i - 1], &entries[i], link);
|
||||
}
|
||||
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
j = 0;
|
||||
@@ -145,15 +141,15 @@ TEST_BEGIN(test_qr_remove)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_qr_before_insert)
|
||||
{
|
||||
TEST_BEGIN(test_qr_before_insert) {
|
||||
ring_t entries[NENTRIES];
|
||||
ring_t *t;
|
||||
unsigned i, j;
|
||||
|
||||
init_entries(entries);
|
||||
for (i = 1; i < NENTRIES; i++)
|
||||
for (i = 1; i < NENTRIES; i++) {
|
||||
qr_before_insert(&entries[i - 1], &entries[i], link);
|
||||
}
|
||||
for (i = 0; i < NENTRIES; i++) {
|
||||
j = 0;
|
||||
qr_foreach(t, &entries[i], link) {
|
||||
@@ -184,8 +180,7 @@ TEST_BEGIN(test_qr_before_insert)
|
||||
TEST_END
|
||||
|
||||
static void
|
||||
test_split_entries(ring_t *entries)
|
||||
{
|
||||
test_split_entries(ring_t *entries) {
|
||||
ring_t *t;
|
||||
unsigned i, j;
|
||||
|
||||
@@ -206,14 +201,14 @@ test_split_entries(ring_t *entries)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_qr_meld_split)
|
||||
{
|
||||
TEST_BEGIN(test_qr_meld_split) {
|
||||
ring_t entries[NENTRIES];
|
||||
unsigned i;
|
||||
|
||||
init_entries(entries);
|
||||
for (i = 1; i < NENTRIES; i++)
|
||||
for (i = 1; i < NENTRIES; i++) {
|
||||
qr_after_insert(&entries[i - 1], &entries[i], link);
|
||||
}
|
||||
|
||||
qr_split(&entries[0], &entries[SPLIT_INDEX], ring_t, link);
|
||||
test_split_entries(entries);
|
||||
@@ -236,8 +231,7 @@ TEST_BEGIN(test_qr_meld_split)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_qr_one,
|
||||
test_qr_after_insert,
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#define rbtn_black_height(a_type, a_field, a_rbt, r_height) do { \
|
||||
a_type *rbp_bh_t; \
|
||||
for (rbp_bh_t = (a_rbt)->rbt_root, (r_height) = 0; \
|
||||
rbp_bh_t != NULL; \
|
||||
rbp_bh_t = rbtn_left_get(a_type, a_field, rbp_bh_t)) { \
|
||||
if (!rbtn_red_get(a_type, a_field, rbp_bh_t)) { \
|
||||
(r_height)++; \
|
||||
a_type *rbp_bh_t; \
|
||||
for (rbp_bh_t = (a_rbt)->rbt_root, (r_height) = 0; rbp_bh_t != \
|
||||
NULL; rbp_bh_t = rbtn_left_get(a_type, a_field, \
|
||||
rbp_bh_t)) { \
|
||||
if (!rbtn_red_get(a_type, a_field, rbp_bh_t)) { \
|
||||
(r_height)++; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct node_s node_t;
|
||||
@@ -42,8 +42,7 @@ node_cmp(const node_t *a, const node_t *b) {
|
||||
typedef rb_tree(node_t) tree_t;
|
||||
rb_gen(static, tree_, tree_t, node_t, link, node_cmp);
|
||||
|
||||
TEST_BEGIN(test_rb_empty)
|
||||
{
|
||||
TEST_BEGIN(test_rb_empty) {
|
||||
tree_t tree;
|
||||
node_t key;
|
||||
|
||||
@@ -68,52 +67,56 @@ TEST_BEGIN(test_rb_empty)
|
||||
TEST_END
|
||||
|
||||
static unsigned
|
||||
tree_recurse(node_t *node, unsigned black_height, unsigned black_depth)
|
||||
{
|
||||
tree_recurse(node_t *node, unsigned black_height, unsigned black_depth) {
|
||||
unsigned ret = 0;
|
||||
node_t *left_node;
|
||||
node_t *right_node;
|
||||
|
||||
if (node == NULL)
|
||||
if (node == NULL) {
|
||||
return (ret);
|
||||
}
|
||||
|
||||
left_node = rbtn_left_get(node_t, link, node);
|
||||
right_node = rbtn_right_get(node_t, link, node);
|
||||
|
||||
if (!rbtn_red_get(node_t, link, node))
|
||||
if (!rbtn_red_get(node_t, link, node)) {
|
||||
black_depth++;
|
||||
}
|
||||
|
||||
/* Red nodes must be interleaved with black nodes. */
|
||||
if (rbtn_red_get(node_t, link, node)) {
|
||||
if (left_node != NULL)
|
||||
if (left_node != NULL) {
|
||||
assert_false(rbtn_red_get(node_t, link, left_node),
|
||||
"Node should be black");
|
||||
if (right_node != NULL)
|
||||
}
|
||||
if (right_node != NULL) {
|
||||
assert_false(rbtn_red_get(node_t, link, right_node),
|
||||
"Node should be black");
|
||||
}
|
||||
}
|
||||
|
||||
/* Self. */
|
||||
assert_u32_eq(node->magic, NODE_MAGIC, "Bad magic");
|
||||
|
||||
/* Left subtree. */
|
||||
if (left_node != NULL)
|
||||
if (left_node != NULL) {
|
||||
ret += tree_recurse(left_node, black_height, black_depth);
|
||||
else
|
||||
} else {
|
||||
ret += (black_depth != black_height);
|
||||
}
|
||||
|
||||
/* Right subtree. */
|
||||
if (right_node != NULL)
|
||||
if (right_node != NULL) {
|
||||
ret += tree_recurse(right_node, black_height, black_depth);
|
||||
else
|
||||
} else {
|
||||
ret += (black_depth != black_height);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static node_t *
|
||||
tree_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
{
|
||||
tree_iterate_cb(tree_t *tree, node_t *node, void *data) {
|
||||
unsigned *i = (unsigned *)data;
|
||||
node_t *search_node;
|
||||
|
||||
@@ -140,8 +143,7 @@ tree_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
tree_iterate(tree_t *tree)
|
||||
{
|
||||
tree_iterate(tree_t *tree) {
|
||||
unsigned i;
|
||||
|
||||
i = 0;
|
||||
@@ -151,8 +153,7 @@ tree_iterate(tree_t *tree)
|
||||
}
|
||||
|
||||
static unsigned
|
||||
tree_iterate_reverse(tree_t *tree)
|
||||
{
|
||||
tree_iterate_reverse(tree_t *tree) {
|
||||
unsigned i;
|
||||
|
||||
i = 0;
|
||||
@@ -162,8 +163,7 @@ tree_iterate_reverse(tree_t *tree)
|
||||
}
|
||||
|
||||
static void
|
||||
node_remove(tree_t *tree, node_t *node, unsigned nnodes)
|
||||
{
|
||||
node_remove(tree_t *tree, node_t *node, unsigned nnodes) {
|
||||
node_t *search_node;
|
||||
unsigned black_height, imbalances;
|
||||
|
||||
@@ -195,8 +195,7 @@ node_remove(tree_t *tree, node_t *node, unsigned nnodes)
|
||||
}
|
||||
|
||||
static node_t *
|
||||
remove_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
{
|
||||
remove_iterate_cb(tree_t *tree, node_t *node, void *data) {
|
||||
unsigned *nnodes = (unsigned *)data;
|
||||
node_t *ret = tree_next(tree, node);
|
||||
|
||||
@@ -206,8 +205,7 @@ remove_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
}
|
||||
|
||||
static node_t *
|
||||
remove_reverse_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
{
|
||||
remove_reverse_iterate_cb(tree_t *tree, node_t *node, void *data) {
|
||||
unsigned *nnodes = (unsigned *)data;
|
||||
node_t *ret = tree_prev(tree, node);
|
||||
|
||||
@@ -217,16 +215,14 @@ remove_reverse_iterate_cb(tree_t *tree, node_t *node, void *data)
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_cb(node_t *node, void *data)
|
||||
{
|
||||
destroy_cb(node_t *node, void *data) {
|
||||
unsigned *nnodes = (unsigned *)data;
|
||||
|
||||
assert_u_gt(*nnodes, 0, "Destruction removed too many nodes");
|
||||
(*nnodes)--;
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_rb_random)
|
||||
{
|
||||
TEST_BEGIN(test_rb_random) {
|
||||
#define NNODES 25
|
||||
#define NBAGS 250
|
||||
#define SEED 42
|
||||
@@ -241,17 +237,20 @@ TEST_BEGIN(test_rb_random)
|
||||
switch (i) {
|
||||
case 0:
|
||||
/* Insert in order. */
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = j;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Insert in reverse order. */
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = NNODES - j - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (j = 0; j < NNODES; j++)
|
||||
for (j = 0; j < NNODES; j++) {
|
||||
bag[j] = gen_rand64_range(sfmt, NNODES);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 1; j <= NNODES; j++) {
|
||||
@@ -292,12 +291,14 @@ TEST_BEGIN(test_rb_random)
|
||||
/* Remove nodes. */
|
||||
switch (i % 5) {
|
||||
case 0:
|
||||
for (k = 0; k < j; k++)
|
||||
for (k = 0; k < j; k++) {
|
||||
node_remove(&tree, &nodes[k], j - k);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (k = j; k > 0; k--)
|
||||
for (k = j; k > 0; k--) {
|
||||
node_remove(&tree, &nodes[k-1], k);
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
node_t *start;
|
||||
@@ -345,8 +346,7 @@ TEST_BEGIN(test_rb_random)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_rb_empty,
|
||||
test_rb_random));
|
||||
|
@@ -6,12 +6,12 @@ rtree_node_dalloc_t *rtree_node_dalloc_orig;
|
||||
rtree_t *test_rtree;
|
||||
|
||||
static rtree_elm_t *
|
||||
rtree_node_alloc_intercept(tsdn_t *tsdn, rtree_t *rtree, size_t nelms)
|
||||
{
|
||||
rtree_node_alloc_intercept(tsdn_t *tsdn, rtree_t *rtree, size_t nelms) {
|
||||
rtree_elm_t *node;
|
||||
|
||||
if (rtree != test_rtree)
|
||||
if (rtree != test_rtree) {
|
||||
return rtree_node_alloc_orig(tsdn, rtree, nelms);
|
||||
}
|
||||
|
||||
malloc_mutex_unlock(tsdn, &rtree->init_lock);
|
||||
node = (rtree_elm_t *)calloc(nelms, sizeof(rtree_elm_t));
|
||||
@@ -22,8 +22,7 @@ rtree_node_alloc_intercept(tsdn_t *tsdn, rtree_t *rtree, size_t nelms)
|
||||
}
|
||||
|
||||
static void
|
||||
rtree_node_dalloc_intercept(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node)
|
||||
{
|
||||
rtree_node_dalloc_intercept(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node) {
|
||||
if (rtree != test_rtree) {
|
||||
rtree_node_dalloc_orig(tsdn, rtree, node);
|
||||
return;
|
||||
@@ -32,8 +31,7 @@ rtree_node_dalloc_intercept(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node)
|
||||
free(node);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_rtree_read_empty)
|
||||
{
|
||||
TEST_BEGIN(test_rtree_read_empty) {
|
||||
tsdn_t *tsdn;
|
||||
unsigned i;
|
||||
|
||||
@@ -65,8 +63,7 @@ typedef struct {
|
||||
} thd_start_arg_t;
|
||||
|
||||
static void *
|
||||
thd_start(void *varg)
|
||||
{
|
||||
thd_start(void *varg) {
|
||||
thd_start_arg_t *arg = (thd_start_arg_t *)varg;
|
||||
rtree_ctx_t rtree_ctx = RTREE_CTX_INITIALIZER;
|
||||
sfmt_t *sfmt;
|
||||
@@ -98,8 +95,9 @@ thd_start(void *varg)
|
||||
"Unexpected rtree_elm_acquire() failure");
|
||||
rtree_elm_read_acquired(tsdn, &arg->rtree, elm);
|
||||
rtree_elm_release(tsdn, &arg->rtree, elm);
|
||||
} else
|
||||
} else {
|
||||
rtree_read(tsdn, &arg->rtree, &rtree_ctx, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
free(extent);
|
||||
@@ -107,8 +105,7 @@ thd_start(void *varg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_rtree_concurrent)
|
||||
{
|
||||
TEST_BEGIN(test_rtree_concurrent) {
|
||||
thd_start_arg_t arg;
|
||||
thd_t thds[NTHREADS];
|
||||
sfmt_t *sfmt;
|
||||
@@ -123,10 +120,12 @@ TEST_BEGIN(test_rtree_concurrent)
|
||||
assert_false(rtree_new(&arg.rtree, arg.nbits),
|
||||
"Unexpected rtree_new() failure");
|
||||
arg.seed = gen_rand32(sfmt);
|
||||
for (j = 0; j < NTHREADS; j++)
|
||||
for (j = 0; j < NTHREADS; j++) {
|
||||
thd_create(&thds[j], thd_start, (void *)&arg);
|
||||
for (j = 0; j < NTHREADS; j++)
|
||||
}
|
||||
for (j = 0; j < NTHREADS; j++) {
|
||||
thd_join(thds[j], NULL);
|
||||
}
|
||||
rtree_delete(tsdn, &arg.rtree);
|
||||
test_rtree = NULL;
|
||||
}
|
||||
@@ -139,8 +138,7 @@ TEST_END
|
||||
#undef NITERS
|
||||
#undef SEED
|
||||
|
||||
TEST_BEGIN(test_rtree_extrema)
|
||||
{
|
||||
TEST_BEGIN(test_rtree_extrema) {
|
||||
unsigned i;
|
||||
extent_t extent_a, extent_b;
|
||||
tsdn_t *tsdn;
|
||||
@@ -173,8 +171,7 @@ TEST_BEGIN(test_rtree_extrema)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_rtree_bits)
|
||||
{
|
||||
TEST_BEGIN(test_rtree_bits) {
|
||||
tsdn_t *tsdn;
|
||||
unsigned i, j, k;
|
||||
|
||||
@@ -217,8 +214,7 @@ TEST_BEGIN(test_rtree_bits)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_rtree_random)
|
||||
{
|
||||
TEST_BEGIN(test_rtree_random) {
|
||||
unsigned i;
|
||||
sfmt_t *sfmt;
|
||||
tsdn_t *tsdn;
|
||||
@@ -280,8 +276,7 @@ TEST_BEGIN(test_rtree_random)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
rtree_node_alloc_orig = rtree_node_alloc;
|
||||
rtree_node_alloc = rtree_node_alloc_intercept;
|
||||
rtree_node_dalloc_orig = rtree_node_dalloc;
|
||||
|
@@ -1,8 +1,7 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
static size_t
|
||||
get_max_size_class(void)
|
||||
{
|
||||
get_max_size_class(void) {
|
||||
unsigned nlextents;
|
||||
size_t mib[4];
|
||||
size_t sz, miblen, max_size_class;
|
||||
@@ -23,8 +22,7 @@ get_max_size_class(void)
|
||||
return (max_size_class);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_size_classes)
|
||||
{
|
||||
TEST_BEGIN(test_size_classes) {
|
||||
size_t size_class, max_size_class;
|
||||
szind_t index, max_index;
|
||||
|
||||
@@ -80,8 +78,7 @@ TEST_BEGIN(test_size_classes)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_psize_classes)
|
||||
{
|
||||
TEST_BEGIN(test_psize_classes) {
|
||||
size_t size_class, max_psz;
|
||||
pszind_t pind, max_pind;
|
||||
|
||||
@@ -136,8 +133,7 @@ TEST_BEGIN(test_psize_classes)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_overflow)
|
||||
{
|
||||
TEST_BEGIN(test_overflow) {
|
||||
size_t max_size_class, max_psz;
|
||||
|
||||
max_size_class = get_max_size_class();
|
||||
@@ -176,8 +172,7 @@ TEST_BEGIN(test_overflow)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_size_classes,
|
||||
test_psize_classes,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_arena_slab_regind)
|
||||
{
|
||||
TEST_BEGIN(test_arena_slab_regind) {
|
||||
szind_t binind;
|
||||
|
||||
for (binind = 0; binind < NBINS; binind++) {
|
||||
@@ -27,8 +26,7 @@ TEST_BEGIN(test_arena_slab_regind)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_arena_slab_regind));
|
||||
}
|
||||
|
@@ -7,8 +7,7 @@ static const uint64_t smoothstep_tab[] = {
|
||||
#undef STEP
|
||||
};
|
||||
|
||||
TEST_BEGIN(test_smoothstep_integral)
|
||||
{
|
||||
TEST_BEGIN(test_smoothstep_integral) {
|
||||
uint64_t sum, min, max;
|
||||
unsigned i;
|
||||
|
||||
@@ -20,8 +19,9 @@ TEST_BEGIN(test_smoothstep_integral)
|
||||
* integral may be off by as much as SMOOTHSTEP_NSTEPS ulps.
|
||||
*/
|
||||
sum = 0;
|
||||
for (i = 0; i < SMOOTHSTEP_NSTEPS; i++)
|
||||
for (i = 0; i < SMOOTHSTEP_NSTEPS; i++) {
|
||||
sum += smoothstep_tab[i];
|
||||
}
|
||||
|
||||
max = (KQU(1) << (SMOOTHSTEP_BFP-1)) * (SMOOTHSTEP_NSTEPS+1);
|
||||
min = max - SMOOTHSTEP_NSTEPS;
|
||||
@@ -36,8 +36,7 @@ TEST_BEGIN(test_smoothstep_integral)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_smoothstep_monotonic)
|
||||
{
|
||||
TEST_BEGIN(test_smoothstep_monotonic) {
|
||||
uint64_t prev_h;
|
||||
unsigned i;
|
||||
|
||||
@@ -58,8 +57,7 @@ TEST_BEGIN(test_smoothstep_monotonic)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_smoothstep_slope)
|
||||
{
|
||||
TEST_BEGIN(test_smoothstep_slope) {
|
||||
uint64_t prev_h, prev_delta;
|
||||
unsigned i;
|
||||
|
||||
@@ -96,8 +94,7 @@ TEST_BEGIN(test_smoothstep_slope)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_smoothstep_integral,
|
||||
test_smoothstep_monotonic,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_stats_summary)
|
||||
{
|
||||
TEST_BEGIN(test_stats_summary) {
|
||||
size_t sz, allocated, active, resident, mapped;
|
||||
int expected = config_stats ? 0 : ENOENT;
|
||||
|
||||
@@ -26,8 +25,7 @@ TEST_BEGIN(test_stats_summary)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_large)
|
||||
{
|
||||
TEST_BEGIN(test_stats_large) {
|
||||
void *p;
|
||||
uint64_t epoch;
|
||||
size_t allocated;
|
||||
@@ -67,8 +65,7 @@ TEST_BEGIN(test_stats_large)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_arenas_summary)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas_summary) {
|
||||
unsigned arena;
|
||||
void *little, *large;
|
||||
uint64_t epoch;
|
||||
@@ -118,22 +115,19 @@ TEST_BEGIN(test_stats_arenas_summary)
|
||||
TEST_END
|
||||
|
||||
void *
|
||||
thd_start(void *arg)
|
||||
{
|
||||
thd_start(void *arg) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
no_lazy_lock(void)
|
||||
{
|
||||
no_lazy_lock(void) {
|
||||
thd_t thd;
|
||||
|
||||
thd_create(&thd, thd_start, NULL);
|
||||
thd_join(thd, NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_stats_arenas_small)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas_small) {
|
||||
unsigned arena;
|
||||
void *p;
|
||||
size_t sz, allocated;
|
||||
@@ -183,8 +177,7 @@ TEST_BEGIN(test_stats_arenas_small)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_arenas_large)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas_large) {
|
||||
unsigned arena;
|
||||
void *p;
|
||||
size_t sz, allocated;
|
||||
@@ -224,8 +217,7 @@ TEST_BEGIN(test_stats_arenas_large)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_arenas_bins)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas_bins) {
|
||||
unsigned arena;
|
||||
void *p;
|
||||
size_t sz, curslabs, curregs;
|
||||
@@ -299,8 +291,7 @@ TEST_BEGIN(test_stats_arenas_bins)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_stats_arenas_lextents)
|
||||
{
|
||||
TEST_BEGIN(test_stats_arenas_lextents) {
|
||||
unsigned arena;
|
||||
void *p;
|
||||
uint64_t epoch, nmalloc, ndalloc;
|
||||
@@ -347,8 +338,7 @@ TEST_BEGIN(test_stats_arenas_lextents)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_stats_summary,
|
||||
test_stats_large,
|
||||
|
@@ -39,8 +39,7 @@ struct parser_s {
|
||||
|
||||
static void
|
||||
token_init(token_t *token, parser_t *parser, token_type_t token_type,
|
||||
size_t pos, size_t len, size_t line, size_t col)
|
||||
{
|
||||
size_t pos, size_t len, size_t line, size_t col) {
|
||||
token->parser = parser;
|
||||
token->token_type = token_type;
|
||||
token->pos = pos;
|
||||
@@ -50,8 +49,7 @@ token_init(token_t *token, parser_t *parser, token_type_t token_type,
|
||||
}
|
||||
|
||||
static void
|
||||
token_error(token_t *token)
|
||||
{
|
||||
token_error(token_t *token) {
|
||||
if (!token->parser->verbose) {
|
||||
return;
|
||||
}
|
||||
@@ -72,8 +70,7 @@ token_error(token_t *token)
|
||||
}
|
||||
|
||||
static void
|
||||
parser_init(parser_t *parser, bool verbose)
|
||||
{
|
||||
parser_init(parser_t *parser, bool verbose) {
|
||||
parser->verbose = verbose;
|
||||
parser->buf = NULL;
|
||||
parser->len = 0;
|
||||
@@ -83,16 +80,14 @@ parser_init(parser_t *parser, bool verbose)
|
||||
}
|
||||
|
||||
static void
|
||||
parser_fini(parser_t *parser)
|
||||
{
|
||||
parser_fini(parser_t *parser) {
|
||||
if (parser->buf != NULL) {
|
||||
dallocx(parser->buf, MALLOCX_TCACHE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_append(parser_t *parser, const char *str)
|
||||
{
|
||||
parser_append(parser_t *parser, const char *str) {
|
||||
size_t len = strlen(str);
|
||||
char *buf = (parser->buf == NULL) ? mallocx(len + 1,
|
||||
MALLOCX_TCACHE_NONE) : rallocx(parser->buf, parser->len + len + 1,
|
||||
@@ -107,8 +102,7 @@ parser_append(parser_t *parser, const char *str)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_tokenize(parser_t *parser)
|
||||
{
|
||||
parser_tokenize(parser_t *parser) {
|
||||
enum {
|
||||
STATE_START,
|
||||
STATE_EOI,
|
||||
@@ -667,8 +661,7 @@ static bool parser_parse_array(parser_t *parser);
|
||||
static bool parser_parse_object(parser_t *parser);
|
||||
|
||||
static bool
|
||||
parser_parse_value(parser_t *parser)
|
||||
{
|
||||
parser_parse_value(parser_t *parser) {
|
||||
switch (parser->token.token_type) {
|
||||
case TOKEN_TYPE_NULL:
|
||||
case TOKEN_TYPE_FALSE:
|
||||
@@ -687,8 +680,7 @@ parser_parse_value(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse_pair(parser_t *parser)
|
||||
{
|
||||
parser_parse_pair(parser_t *parser) {
|
||||
assert_d_eq(parser->token.token_type, TOKEN_TYPE_STRING,
|
||||
"Pair should start with string");
|
||||
if (parser_tokenize(parser)) {
|
||||
@@ -706,8 +698,7 @@ parser_parse_pair(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse_values(parser_t *parser)
|
||||
{
|
||||
parser_parse_values(parser_t *parser) {
|
||||
if (parser_parse_value(parser)) {
|
||||
return true;
|
||||
}
|
||||
@@ -734,8 +725,7 @@ parser_parse_values(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse_array(parser_t *parser)
|
||||
{
|
||||
parser_parse_array(parser_t *parser) {
|
||||
assert_d_eq(parser->token.token_type, TOKEN_TYPE_LBRACKET,
|
||||
"Array should start with [");
|
||||
if (parser_tokenize(parser)) {
|
||||
@@ -751,8 +741,7 @@ parser_parse_array(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse_pairs(parser_t *parser)
|
||||
{
|
||||
parser_parse_pairs(parser_t *parser) {
|
||||
assert_d_eq(parser->token.token_type, TOKEN_TYPE_STRING,
|
||||
"Object should start with string");
|
||||
if (parser_parse_pair(parser)) {
|
||||
@@ -787,8 +776,7 @@ parser_parse_pairs(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse_object(parser_t *parser)
|
||||
{
|
||||
parser_parse_object(parser_t *parser) {
|
||||
assert_d_eq(parser->token.token_type, TOKEN_TYPE_LBRACE,
|
||||
"Object should start with {");
|
||||
if (parser_tokenize(parser)) {
|
||||
@@ -806,8 +794,7 @@ parser_parse_object(parser_t *parser)
|
||||
}
|
||||
|
||||
static bool
|
||||
parser_parse(parser_t *parser)
|
||||
{
|
||||
parser_parse(parser_t *parser) {
|
||||
if (parser_tokenize(parser)) {
|
||||
goto label_error;
|
||||
}
|
||||
@@ -831,8 +818,7 @@ label_error:
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_json_parser)
|
||||
{
|
||||
TEST_BEGIN(test_json_parser) {
|
||||
size_t i;
|
||||
const char *invalid_inputs[] = {
|
||||
/* Tokenizer error case tests. */
|
||||
@@ -929,16 +915,14 @@ TEST_BEGIN(test_json_parser)
|
||||
TEST_END
|
||||
|
||||
void
|
||||
write_cb(void *opaque, const char *str)
|
||||
{
|
||||
write_cb(void *opaque, const char *str) {
|
||||
parser_t *parser = (parser_t *)opaque;
|
||||
if (parser_append(parser, str)) {
|
||||
test_fail("Unexpected input appending failure");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_stats_print_json)
|
||||
{
|
||||
TEST_BEGIN(test_stats_print_json) {
|
||||
const char *opts[] = {
|
||||
"J",
|
||||
"Jg",
|
||||
@@ -998,8 +982,7 @@ TEST_BEGIN(test_stats_print_json)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_json_parser,
|
||||
test_stats_print_json));
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
TEST_BEGIN(test_ticker_tick)
|
||||
{
|
||||
TEST_BEGIN(test_ticker_tick) {
|
||||
#define NREPS 2
|
||||
#define NTICKS 3
|
||||
ticker_t ticker;
|
||||
@@ -26,8 +25,7 @@ TEST_BEGIN(test_ticker_tick)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ticker_ticks)
|
||||
{
|
||||
TEST_BEGIN(test_ticker_ticks) {
|
||||
#define NTICKS 3
|
||||
ticker_t ticker;
|
||||
|
||||
@@ -45,8 +43,7 @@ TEST_BEGIN(test_ticker_ticks)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_ticker_copy)
|
||||
{
|
||||
TEST_BEGIN(test_ticker_copy) {
|
||||
#define NTICKS 3
|
||||
ticker_t ta, tb;
|
||||
|
||||
@@ -66,8 +63,7 @@ TEST_BEGIN(test_ticker_copy)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_ticker_tick,
|
||||
test_ticker_ticks,
|
||||
|
@@ -10,8 +10,7 @@ malloc_tsd_types(data_, data_t)
|
||||
malloc_tsd_protos(, data_, data_t)
|
||||
|
||||
void
|
||||
data_cleanup(void *arg)
|
||||
{
|
||||
data_cleanup(void *arg) {
|
||||
data_t *data = (data_t *)arg;
|
||||
|
||||
if (!data_cleanup_executed) {
|
||||
@@ -53,8 +52,7 @@ malloc_tsd_data(, data_, data_t, DATA_INIT)
|
||||
malloc_tsd_funcs(, data_, data_t, DATA_INIT, data_cleanup)
|
||||
|
||||
static void *
|
||||
thd_start(void *arg)
|
||||
{
|
||||
thd_start(void *arg) {
|
||||
data_t d = (data_t)(uintptr_t)arg;
|
||||
void *p;
|
||||
|
||||
@@ -76,14 +74,12 @@ thd_start(void *arg)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_tsd_main_thread)
|
||||
{
|
||||
TEST_BEGIN(test_tsd_main_thread) {
|
||||
thd_start((void *)(uintptr_t)0xa5f3e329);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_tsd_sub_thread)
|
||||
{
|
||||
TEST_BEGIN(test_tsd_sub_thread) {
|
||||
thd_t thd;
|
||||
|
||||
data_cleanup_executed = false;
|
||||
@@ -95,8 +91,7 @@ TEST_BEGIN(test_tsd_sub_thread)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
/* Core tsd bootstrapping must happen prior to data_tsd_boot(). */
|
||||
if (nallocx(1, 0) == 0) {
|
||||
malloc_printf("Initialization error");
|
||||
|
@@ -31,26 +31,22 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
TEST_BEGIN(test_pow2_ceil_u64)
|
||||
{
|
||||
TEST_BEGIN(test_pow2_ceil_u64) {
|
||||
TEST_POW2_CEIL(uint64_t, u64, FMTu64);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_pow2_ceil_u32)
|
||||
{
|
||||
TEST_BEGIN(test_pow2_ceil_u32) {
|
||||
TEST_POW2_CEIL(uint32_t, u32, FMTu32);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_pow2_ceil_zu)
|
||||
{
|
||||
TEST_BEGIN(test_pow2_ceil_zu) {
|
||||
TEST_POW2_CEIL(size_t, zu, "zu");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_malloc_strtoumax_no_endptr)
|
||||
{
|
||||
TEST_BEGIN(test_malloc_strtoumax_no_endptr) {
|
||||
int err;
|
||||
|
||||
set_errno(0);
|
||||
@@ -60,8 +56,7 @@ TEST_BEGIN(test_malloc_strtoumax_no_endptr)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_malloc_strtoumax)
|
||||
{
|
||||
TEST_BEGIN(test_malloc_strtoumax) {
|
||||
struct test_s {
|
||||
const char *input;
|
||||
const char *expected_remainder;
|
||||
@@ -155,8 +150,7 @@ TEST_BEGIN(test_malloc_strtoumax)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_malloc_snprintf_truncated)
|
||||
{
|
||||
TEST_BEGIN(test_malloc_snprintf_truncated) {
|
||||
#define BUFLEN 15
|
||||
char buf[BUFLEN];
|
||||
size_t result;
|
||||
@@ -188,8 +182,7 @@ TEST_BEGIN(test_malloc_snprintf_truncated)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_malloc_snprintf)
|
||||
{
|
||||
TEST_BEGIN(test_malloc_snprintf) {
|
||||
#define BUFLEN 128
|
||||
char buf[BUFLEN];
|
||||
size_t result;
|
||||
@@ -302,8 +295,7 @@ TEST_BEGIN(test_malloc_snprintf)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_pow2_ceil_u64,
|
||||
test_pow2_ceil_u32,
|
||||
|
@@ -12,32 +12,27 @@ static bool saw_lockless_error;
|
||||
|
||||
static void
|
||||
witness_lock_error_intercept(const witness_list_t *witnesses,
|
||||
const witness_t *witness)
|
||||
{
|
||||
const witness_t *witness) {
|
||||
saw_lock_error = true;
|
||||
}
|
||||
|
||||
static void
|
||||
witness_owner_error_intercept(const witness_t *witness)
|
||||
{
|
||||
witness_owner_error_intercept(const witness_t *witness) {
|
||||
saw_owner_error = true;
|
||||
}
|
||||
|
||||
static void
|
||||
witness_not_owner_error_intercept(const witness_t *witness)
|
||||
{
|
||||
witness_not_owner_error_intercept(const witness_t *witness) {
|
||||
saw_not_owner_error = true;
|
||||
}
|
||||
|
||||
static void
|
||||
witness_lockless_error_intercept(const witness_list_t *witnesses)
|
||||
{
|
||||
witness_lockless_error_intercept(const witness_list_t *witnesses) {
|
||||
saw_lockless_error = true;
|
||||
}
|
||||
|
||||
static int
|
||||
witness_comp(const witness_t *a, void *oa, const witness_t *b, void *ob)
|
||||
{
|
||||
witness_comp(const witness_t *a, void *oa, const witness_t *b, void *ob) {
|
||||
assert_u_eq(a->rank, b->rank, "Witnesses should have equal rank");
|
||||
|
||||
assert(oa == (void *)a);
|
||||
@@ -47,8 +42,8 @@ witness_comp(const witness_t *a, void *oa, const witness_t *b, void *ob)
|
||||
}
|
||||
|
||||
static int
|
||||
witness_comp_reverse(const witness_t *a, void *oa, const witness_t *b, void *ob)
|
||||
{
|
||||
witness_comp_reverse(const witness_t *a, void *oa, const witness_t *b,
|
||||
void *ob) {
|
||||
assert_u_eq(a->rank, b->rank, "Witnesses should have equal rank");
|
||||
|
||||
assert(oa == (void *)a);
|
||||
@@ -57,8 +52,7 @@ witness_comp_reverse(const witness_t *a, void *oa, const witness_t *b, void *ob)
|
||||
return (-strcmp(a->name, b->name));
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_witness)
|
||||
{
|
||||
TEST_BEGIN(test_witness) {
|
||||
witness_t a, b;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -85,8 +79,7 @@ TEST_BEGIN(test_witness)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_witness_comp)
|
||||
{
|
||||
TEST_BEGIN(test_witness_comp) {
|
||||
witness_t a, b, c, d;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -135,8 +128,7 @@ TEST_BEGIN(test_witness_comp)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_witness_reversal)
|
||||
{
|
||||
TEST_BEGIN(test_witness_reversal) {
|
||||
witness_t a, b;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -167,8 +159,7 @@ TEST_BEGIN(test_witness_reversal)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_witness_recursive)
|
||||
{
|
||||
TEST_BEGIN(test_witness_recursive) {
|
||||
witness_t a;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -205,8 +196,7 @@ TEST_BEGIN(test_witness_recursive)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_witness_unlock_not_owned)
|
||||
{
|
||||
TEST_BEGIN(test_witness_unlock_not_owned) {
|
||||
witness_t a;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -232,8 +222,7 @@ TEST_BEGIN(test_witness_unlock_not_owned)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_witness_lockful)
|
||||
{
|
||||
TEST_BEGIN(test_witness_lockful) {
|
||||
witness_t a;
|
||||
tsdn_t *tsdn;
|
||||
|
||||
@@ -265,8 +254,7 @@ TEST_BEGIN(test_witness_lockful)
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_witness,
|
||||
test_witness_comp,
|
||||
|
@@ -6,8 +6,7 @@ const char *malloc_conf =
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_zero(size_t sz_min, size_t sz_max)
|
||||
{
|
||||
test_zero(size_t sz_min, size_t sz_max) {
|
||||
uint8_t *s;
|
||||
size_t sz_prev, sz, i;
|
||||
#define MAGIC ((uint8_t)0x61)
|
||||
@@ -45,23 +44,20 @@ test_zero(size_t sz_min, size_t sz_max)
|
||||
#undef MAGIC
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_zero_small)
|
||||
{
|
||||
TEST_BEGIN(test_zero_small) {
|
||||
test_skip_if(!config_fill);
|
||||
test_zero(1, SMALL_MAXCLASS-1);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_zero_large)
|
||||
{
|
||||
TEST_BEGIN(test_zero_large) {
|
||||
test_skip_if(!config_fill);
|
||||
test_zero(SMALL_MAXCLASS+1, (1U << (LG_LARGE_MINCLASS+1)));
|
||||
}
|
||||
TEST_END
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
return (test(
|
||||
test_zero_small,
|
||||
test_zero_large));
|
||||
|
Reference in New Issue
Block a user