2018-10-24 13:00:40 +00:00
|
|
|
//! Test background threads run-time default settings.
|
2018-11-07 18:57:11 +00:00
|
|
|
|
|
|
|
extern crate jemalloc_ctl;
|
2018-10-24 13:00:40 +00:00
|
|
|
extern crate jemallocator;
|
|
|
|
extern crate libc;
|
|
|
|
|
|
|
|
use jemallocator::Jemalloc;
|
|
|
|
|
|
|
|
#[global_allocator]
|
|
|
|
static A: Jemalloc = Jemalloc;
|
|
|
|
|
|
|
|
// Returns true if background threads are enabled.
|
|
|
|
fn background_threads() -> bool {
|
2018-11-09 09:25:44 +00:00
|
|
|
jemalloc_ctl::opt::background_thread::read().unwrap()
|
2018-10-24 13:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn background_threads_runtime_defaults() {
|
|
|
|
if !cfg!(feature = "background_threads_runtime_support") {
|
|
|
|
// If the crate was compiled without background thread support,
|
|
|
|
// then background threads are always disabled at run-time by default:
|
|
|
|
assert_eq!(background_threads(), false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg!(feature = "background_threads") {
|
|
|
|
// The crate was compiled with background-threads enabled by default:
|
|
|
|
assert_eq!(background_threads(), true);
|
|
|
|
} else {
|
|
|
|
// The crate was compiled with background-threads disabled by default:
|
|
|
|
assert_eq!(background_threads(), false);
|
|
|
|
}
|
|
|
|
}
|