Fix an interaction between the oversize_threshold test and bgthds.
Also added the shared utility to check if background_thread is enabled.
This commit is contained in:
@@ -9,18 +9,6 @@ static unsigned nupdates_mock;
|
||||
static nstime_t time_mock;
|
||||
static bool monotonic_mock;
|
||||
|
||||
static bool
|
||||
check_background_thread_enabled(void) {
|
||||
bool enabled;
|
||||
size_t sz = sizeof(bool);
|
||||
int ret = mallctl("background_thread", (void *)&enabled, &sz, NULL,0);
|
||||
if (ret == ENOENT) {
|
||||
return false;
|
||||
}
|
||||
expect_d_eq(ret, 0, "Unexpected mallctl error");
|
||||
return enabled;
|
||||
}
|
||||
|
||||
static bool
|
||||
nstime_monotonic_mock(void) {
|
||||
return monotonic_mock;
|
||||
@@ -184,7 +172,7 @@ generate_dirty(unsigned arena_ind, size_t size) {
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_decay_ticks) {
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
test_skip_if(is_background_thread_enabled());
|
||||
test_skip_if(opt_hpa);
|
||||
|
||||
ticker_geom_t *decay_ticker;
|
||||
@@ -417,7 +405,7 @@ decay_ticker_helper(unsigned arena_ind, int flags, bool dirty, ssize_t dt,
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_decay_ticker) {
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
test_skip_if(is_background_thread_enabled());
|
||||
test_skip_if(opt_hpa);
|
||||
#define NPS 2048
|
||||
ssize_t ddt = opt_dirty_decay_ms;
|
||||
@@ -476,7 +464,7 @@ TEST_BEGIN(test_decay_ticker) {
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_decay_nonmonotonic) {
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
test_skip_if(is_background_thread_enabled());
|
||||
test_skip_if(opt_hpa);
|
||||
#define NPS (SMOOTHSTEP_NSTEPS + 1)
|
||||
int flags = (MALLOCX_ARENA(0) | MALLOCX_TCACHE_NONE);
|
||||
@@ -534,7 +522,7 @@ TEST_BEGIN(test_decay_nonmonotonic) {
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_decay_now) {
|
||||
test_skip_if(check_background_thread_enabled());
|
||||
test_skip_if(is_background_thread_enabled());
|
||||
test_skip_if(opt_hpa);
|
||||
|
||||
unsigned arena_ind = do_arena_create(0, 0);
|
||||
@@ -555,7 +543,7 @@ TEST_BEGIN(test_decay_now) {
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_decay_never) {
|
||||
test_skip_if(check_background_thread_enabled() || !config_stats);
|
||||
test_skip_if(is_background_thread_enabled() || !config_stats);
|
||||
test_skip_if(opt_hpa);
|
||||
|
||||
unsigned arena_ind = do_arena_create(-1, -1);
|
||||
|
@@ -106,14 +106,16 @@ TEST_BEGIN(test_oversize_threshold) {
|
||||
/* Allocating and freeing half a megabyte should leave them dirty. */
|
||||
void *ptr = mallocx(512 * 1024, MALLOCX_ARENA(arena));
|
||||
dallocx(ptr, MALLOCX_TCACHE_NONE);
|
||||
expect_zu_lt(max_purged, 512 * 1024, "Expected no 512k purge");
|
||||
if (!is_background_thread_enabled()) {
|
||||
expect_zu_lt(max_purged, 512 * 1024, "Expected no 512k purge");
|
||||
}
|
||||
|
||||
/* Purge again to reset everything out. */
|
||||
arena_mallctl("arena.%u.purge", arena, NULL, NULL, NULL, 0);
|
||||
max_purged = 0;
|
||||
|
||||
/*
|
||||
* Allocating and freeing 2 megabytes should leave them dirty because of
|
||||
* Allocating and freeing 2 megabytes should have them purged because of
|
||||
* the oversize threshold.
|
||||
*/
|
||||
ptr = mallocx(2 * 1024 * 1024, MALLOCX_ARENA(arena));
|
||||
|
@@ -119,7 +119,7 @@ TEST_BEGIN(test_stats_arenas_summary) {
|
||||
"Unexepected mallctl() result");
|
||||
|
||||
if (config_stats) {
|
||||
if (!background_thread_enabled() && !opt_hpa) {
|
||||
if (!is_background_thread_enabled() && !opt_hpa) {
|
||||
expect_u64_gt(dirty_npurge + muzzy_npurge, 0,
|
||||
"At least one purge should have occurred");
|
||||
}
|
||||
|
Reference in New Issue
Block a user