fix25: исправлена идемпотентность swap и удаления default qdisc
This commit is contained in:
@@ -339,7 +339,7 @@ fn render_fstab_line(path: &Path, priority: i32) -> String {
|
|||||||
fn enable_desired_swap(desired: &DesiredSwap) -> anyhow::Result<()> {
|
fn enable_desired_swap(desired: &DesiredSwap) -> anyhow::Result<()> {
|
||||||
let active = read_active_swaps()?;
|
let active = read_active_swaps()?;
|
||||||
if let Some(found) = active.iter().find(|v| v.name == desired.path)
|
if let Some(found) = active.iter().find(|v| v.name == desired.path)
|
||||||
&& found.size_bytes == desired.size_bytes
|
&& active_swap_size_matches(found.size_bytes, desired.size_bytes)
|
||||||
&& found.priority == desired.priority
|
&& found.priority == desired.priority
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -553,8 +553,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn active_swap_size_accepts_mkswap_usable_size_delta() {
|
fn active_swap_size_accepts_mkswap_usable_size_delta() {
|
||||||
|
// Debian 13: swapon may report 4096 bytes less than file size.
|
||||||
assert!(active_swap_size_matches(2147479552, 2147483648));
|
assert!(active_swap_size_matches(2147479552, 2147483648));
|
||||||
|
assert!(active_swap_size_matches(2147483648, 2147483648));
|
||||||
assert!(!active_swap_size_matches(2146435072, 2147483648));
|
assert!(!active_swap_size_matches(2146435072, 2147483648));
|
||||||
|
assert!(!active_swap_size_matches(2147487744, 2147483648));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -600,6 +600,7 @@ fn is_not_found_error(stderr_or_msg: &str) -> bool {
|
|||||||
|| s.contains("cannot find device")
|
|| s.contains("cannot find device")
|
||||||
|| s.contains("no such device")
|
|| s.contains("no such device")
|
||||||
|| s.contains("no such file")
|
|| s.contains("no such file")
|
||||||
|
|| s.contains("handle of zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_root_class_rate_ceil(raw: &str, class_id: &str) -> Option<ClassRateCeil> {
|
fn parse_root_class_rate_ceil(raw: &str, class_id: &str) -> Option<ClassRateCeil> {
|
||||||
@@ -953,6 +954,7 @@ fn run_allow_notfound(transport: &dyn NsTransport, args: &[&str]) -> anyhow::Res
|
|||||||
|| msg.contains("cannot find device")
|
|| msg.contains("cannot find device")
|
||||||
|| msg.contains("no such device")
|
|| msg.contains("no such device")
|
||||||
|| msg.contains("does not exist")
|
|| msg.contains("does not exist")
|
||||||
|
|| msg.contains("handle of zero")
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -1115,6 +1117,9 @@ mod tests {
|
|||||||
assert!(is_not_found_error("RTNETLINK answers: No such device"));
|
assert!(is_not_found_error("RTNETLINK answers: No such device"));
|
||||||
assert!(is_not_found_error("Cannot find device \"ifb0\""));
|
assert!(is_not_found_error("Cannot find device \"ifb0\""));
|
||||||
assert!(is_not_found_error("does not exist"));
|
assert!(is_not_found_error("does not exist"));
|
||||||
|
assert!(is_not_found_error(
|
||||||
|
"Cannot delete qdisc with handle of zero"
|
||||||
|
));
|
||||||
assert!(!is_not_found_error("permission denied"));
|
assert!(!is_not_found_error("permission denied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user