Skip to content

Commit 619184f

Browse files
committed
Handle Error::NOSYS in tests for Linux-specific syscalls.
Linux 2.6.32 doesn't support `prlimit64` or `memfd_create`, so handle `Error::NOSYS` gracefully in tests.
1 parent f5b1acf commit 619184f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/io/seals.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ use std::io::Write;
55

66
#[test]
77
fn test_seals() {
8-
let fd = memfd_create("test", MemfdFlags::CLOEXEC | MemfdFlags::ALLOW_SEALING).unwrap();
8+
let fd = match memfd_create("test", MemfdFlags::CLOEXEC | MemfdFlags::ALLOW_SEALING) {
9+
Ok(fd) => fd,
10+
Err(rustix::io::Error::NOSYS) => return,
11+
Err(err) => Err(err).unwrap(),
12+
};
913
let mut file = File::from_fd(fd.into());
1014

1115
writeln!(&mut file, "Hello!").unwrap();

tests/process/rlimit.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ fn test_prlimit() {
2626

2727
let first = rustix::process::getrlimit(Resource::Core);
2828

29-
let old = rustix::process::prlimit(None, Resource::Core, new.clone()).unwrap();
29+
let old = match rustix::process::prlimit(None, Resource::Core, new.clone()) {
30+
Ok(rlimit) => rlimit,
31+
Err(rustix::io::Error::NOSYS) => return,
32+
Err(e) => Err(e).unwrap(),
33+
};
3034

3135
assert_eq!(first, old);
3236

0 commit comments

Comments
 (0)