Skip to content

Commit

Permalink
Adapt memory tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Furisto committed Sep 7, 2021
1 parent cbc8d1a commit cf47693
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cgroups/src/v2/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ mod tests {
if linux_memory.limit.is_none() {
return result.is_err();
}
if let Some(limit) = linux_memory.limit {
if limit != -1 && swap != -1 && swap < limit {
return result.is_err();
}
}
}

if let Some(reservation) = linux_memory.reservation {
Expand All @@ -320,7 +325,17 @@ mod tests {
let swap_content = read_to_string(tmp.join(CGROUP_MEMORY_SWAP)).expect("read swap limit to string");
let swap_check = match linux_memory.swap {
Some(swap) if swap == -1 => swap_content == "max",
Some(swap) => swap_content == (swap - linux_memory.limit.unwrap()).to_string(),
Some(swap) => {
if let Some(limit) = linux_memory.limit {
if limit == -1 {
swap_content == swap.to_string()
} else {
swap_content == (swap - linux_memory.limit.unwrap()).to_string()
}
} else {
false
}
}
None => {
match linux_memory.limit {
Some(limit) if limit == -1 => swap_content == "max",
Expand Down

0 comments on commit cf47693

Please sign in to comment.