summaryrefslogtreecommitdiffstats
path: root/test/unit/background_thread_enable.c
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2019-04-03 00:50:42 (GMT)
committerQi Wang <interwq@gwu.edu>2019-04-03 00:50:42 (GMT)
commitb0b3e49a54ec29e32636f4577d9d5a896d67fd20 (patch)
treee80fd5feaedd401e7e2c884e73f8c884f51b5a65 /test/unit/background_thread_enable.c
parent61efbda7098de6fe64c362d309824864308c36d4 (diff)
parentf7489dc8f1fac233b0cd4e40331de8b738b1f2e2 (diff)
downloadjemalloc-5.2.0.zip
jemalloc-5.2.0.tar.gz
jemalloc-5.2.0.tar.bz2
Merge branch 'dev'5.2.0
Diffstat (limited to 'test/unit/background_thread_enable.c')
-rw-r--r--test/unit/background_thread_enable.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/test/unit/background_thread_enable.c b/test/unit/background_thread_enable.c
index ff95e67..d894e93 100644
--- a/test/unit/background_thread_enable.c
+++ b/test/unit/background_thread_enable.c
@@ -33,20 +33,19 @@ TEST_END
TEST_BEGIN(test_max_background_threads) {
test_skip_if(!have_background_thread);
- size_t maxt;
- size_t opt_maxt;
- size_t sz_m = sizeof(maxt);
+ size_t max_n_thds;
+ size_t opt_max_n_thds;
+ size_t sz_m = sizeof(max_n_thds);
assert_d_eq(mallctl("opt.max_background_threads",
- &opt_maxt, &sz_m, NULL, 0), 0,
- "Failed to get opt.max_background_threads");
- assert_d_eq(mallctl("max_background_threads", &maxt, &sz_m, NULL, 0), 0,
- "Failed to get max background threads");
- assert_zu_eq(20, maxt, "should be ncpus");
- assert_zu_eq(opt_maxt, maxt,
- "max_background_threads and "
- "opt.max_background_threads should match");
- assert_d_eq(mallctl("max_background_threads", NULL, NULL, &maxt, sz_m),
- 0, "Failed to set max background threads");
+ &opt_max_n_thds, &sz_m, NULL, 0), 0,
+ "Failed to get opt.max_background_threads");
+ assert_d_eq(mallctl("max_background_threads", &max_n_thds, &sz_m, NULL,
+ 0), 0, "Failed to get max background threads");
+ assert_zu_eq(opt_max_n_thds, max_n_thds,
+ "max_background_threads and "
+ "opt.max_background_threads should match");
+ assert_d_eq(mallctl("max_background_threads", NULL, NULL, &max_n_thds,
+ sz_m), 0, "Failed to set max background threads");
unsigned id;
size_t sz_u = sizeof(unsigned);
@@ -60,18 +59,21 @@ TEST_BEGIN(test_max_background_threads) {
size_t sz_b = sizeof(bool);
assert_d_eq(mallctl("background_thread", NULL, NULL, &enable, sz_b), 0,
"Failed to enable background threads");
- assert_zu_eq(n_background_threads, maxt,
- "Number of background threads should be 3.\n");
- maxt = 10;
- assert_d_eq(mallctl("max_background_threads", NULL, NULL, &maxt, sz_m),
- 0, "Failed to set max background threads");
- assert_zu_eq(n_background_threads, maxt,
- "Number of background threads should be 10.\n");
- maxt = 3;
- assert_d_eq(mallctl("max_background_threads", NULL, NULL, &maxt, sz_m),
- 0, "Failed to set max background threads");
- assert_zu_eq(n_background_threads, maxt,
- "Number of background threads should be 3.\n");
+ assert_zu_eq(n_background_threads, max_n_thds,
+ "Number of background threads should not change.\n");
+ size_t new_max_thds = max_n_thds - 1;
+ if (new_max_thds > 0) {
+ assert_d_eq(mallctl("max_background_threads", NULL, NULL,
+ &new_max_thds, sz_m), 0,
+ "Failed to set max background threads");
+ assert_zu_eq(n_background_threads, new_max_thds,
+ "Number of background threads should decrease by 1.\n");
+ }
+ new_max_thds = 1;
+ assert_d_eq(mallctl("max_background_threads", NULL, NULL, &new_max_thds,
+ sz_m), 0, "Failed to set max background threads");
+ assert_zu_eq(n_background_threads, new_max_thds,
+ "Number of background threads should be 1.\n");
}
TEST_END