Skip to content

Commit

Permalink
test: fix tests when '-' is absent from kernel version (#6681)
Browse files Browse the repository at this point in the history
On my machine, any test that calls `is_pidfd_available` fails as my
kernel string does not contain a '-'; the code expects there to be one.

Fix the test so that is works regardless on whether the kernel string
contains a '-'.
  • Loading branch information
hexagonal-sun authored Jul 14, 2024
1 parent c8f3539 commit 4825c44
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tokio/src/process/unix/pidfd_reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ mod test {
assert!(status.success());
let stdout = String::from_utf8_lossy(&stdout);

let mut kernel_version_iter = stdout.split_once('-').unwrap().0.split('.');
let mut kernel_version_iter = match stdout.split_once('-') {
Some((version, _)) => version,
_ => &stdout,
}
.split('.');

let major: u32 = kernel_version_iter.next().unwrap().parse().unwrap();
let minor: u32 = kernel_version_iter.next().unwrap().parse().unwrap();

Expand Down

0 comments on commit 4825c44

Please sign in to comment.