mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
test: fix tests when '-' is absent from kernel version (#6681)
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 '-'.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user