Skip to content

Commit c9fef2b

Browse files
committed
test: fix invalid value for max_background_threads
0 is invalid and will be banned in the latest version. Signed-off-by: Jay Lee <busyjaylee@gmail.com>
1 parent c103179 commit c9fef2b

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

jemalloc-ctl/src/macros.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ macro_rules! r {
9191

9292
/// Write
9393
macro_rules! w {
94-
($id:ident => $ret_ty:ty) => {
94+
($id:ident => ($ret_ty:ty | $test_val:expr)) => {
9595
paste::paste! {
9696
impl $id {
9797
/// Writes `value` using string API.
@@ -112,29 +112,37 @@ macro_rules! w {
112112
#[cfg(test)]
113113
#[test]
114114
fn [<$id _write_test>]() {
115-
match stringify!($id) {
116-
"background_thread" |
117-
"max_background_threads"
118-
if cfg!(target_os = "macos") => return,
119-
_ => (),
115+
if (cfg!(target_os = "macos") && (stringify!($id) == "background_thread"
116+
|| stringify!($id) == "max_background_threads")) {
117+
return;
120118
}
121119

122-
let _ = $id::write($ret_ty::default()).unwrap();
120+
let test_val = $test_val;
121+
122+
let _ = $id::write(test_val).unwrap();
123123

124124
let mib = $id::mib().unwrap();
125-
let _ = mib.write($ret_ty::default()).unwrap();
125+
let _ = mib.write(test_val).unwrap();
126126

127127
#[cfg(feature = "use_std")]
128128
println!(
129129
concat!(
130130
stringify!($id),
131131
" (write): \"{}\""),
132-
$ret_ty::default()
132+
test_val
133133
);
134134

135135
}
136136
}
137137
};
138+
(max_background_threads => $ret_ty:ty) => {
139+
// non-zero
140+
w!(max_background_threads => ($ret_ty | 1));
141+
};
142+
($id:ident => $ret_ty:ty) => {
143+
// general case
144+
w!($id => ($ret_ty | Default::default()));
145+
};
138146
}
139147

140148
/// Update

0 commit comments

Comments
 (0)