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

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