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:
Qi Wang
2021-05-12 16:00:38 -07:00
committed by Qi Wang
parent 5417938215
commit 08089589f7
6 changed files with 30 additions and 34 deletions

View File

@@ -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);