summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2022-05-04 11:38:57 -0700
committerQi Wang <interwq@gmail.com>2022-05-04 15:32:57 -0700
commit66c889500a20e6493a6768de6eaa7347daf61483 (patch)
tree86ddaf71c87ff7e48d0d266fccb7c0c16eb4b344
parenta7d73dd4c9ba97bb033f7ae15f218a65d8b8ace6 (diff)
downloadjemalloc-66c889500a20e6493a6768de6eaa7347daf61483.tar.gz
Make test/unit/background_thread_enable more conservative.
To avoid resource exhaustion on 32-bit platforms.
-rw-r--r--test/unit/background_thread_enable.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/unit/background_thread_enable.c b/test/unit/background_thread_enable.c
index 46776f36..44034ac6 100644
--- a/test/unit/background_thread_enable.c
+++ b/test/unit/background_thread_enable.c
@@ -2,12 +2,8 @@
const char *malloc_conf = "background_thread:false,narenas:1,max_background_threads:20";
-TEST_BEGIN(test_deferred) {
- test_skip_if(!have_background_thread);
-
- unsigned id;
- size_t sz_u = sizeof(unsigned);
-
+static unsigned
+max_test_narenas(void) {
/*
* 10 here is somewhat arbitrary, except insofar as we want to ensure
* that the number of background threads is smaller than the number of
@@ -15,7 +11,22 @@ TEST_BEGIN(test_deferred) {
* cpu to handle background purging, so this is a conservative
* approximation.
*/
- for (unsigned i = 0; i < 10 * ncpus; i++) {
+ unsigned ret = 10 * ncpus;
+ /* Limit the max to avoid VM exhaustion on 32-bit . */
+ if (ret > 512) {
+ ret = 512;
+ }
+
+ return ret;
+}
+
+TEST_BEGIN(test_deferred) {
+ test_skip_if(!have_background_thread);
+
+ unsigned id;
+ size_t sz_u = sizeof(unsigned);
+
+ for (unsigned i = 0; i < max_test_narenas(); i++) {
expect_d_eq(mallctl("arenas.create", &id, &sz_u, NULL, 0), 0,
"Failed to create arena");
}
@@ -50,7 +61,7 @@ TEST_BEGIN(test_max_background_threads) {
unsigned id;
size_t sz_u = sizeof(unsigned);
- for (unsigned i = 0; i < 10 * ncpus; i++) {
+ for (unsigned i = 0; i < max_test_narenas(); i++) {
expect_d_eq(mallctl("arenas.create", &id, &sz_u, NULL, 0), 0,
"Failed to create arena");
}