test: account for proc fd reuse in embedded payload check
Linux / verify (pull_request) Failing after 2m20s
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-static-cli (pull_request) Skipped
Linux / linux-cli-container (pull_request) Skipped
Linux / release-cli (pull_request) Skipped
Linux / verify (pull_request) Failing after 2m20s
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-static-cli (pull_request) Skipped
Linux / linux-cli-container (pull_request) Skipped
Linux / release-cli (pull_request) Skipped
This commit is contained in:
@@ -119,15 +119,25 @@ mod tests {
|
||||
#[test]
|
||||
fn sealed_payload_is_exact_immutable_and_removed_on_drop() {
|
||||
use std::io::Write;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
let engine = materialize(b"immutable fixture bytes").unwrap();
|
||||
let path = engine.executable.clone();
|
||||
assert_eq!(std::fs::read(&path).unwrap(), b"immutable fixture bytes");
|
||||
let metadata = std::fs::metadata(&path).unwrap();
|
||||
let identity = (metadata.dev(), metadata.ino());
|
||||
let mut other = std::fs::OpenOptions::new().write(true).open(&path).unwrap();
|
||||
assert!(other.write_all(b"x").is_err());
|
||||
assert!(other.set_len(0).is_err());
|
||||
assert!(other.set_len(100).is_err());
|
||||
drop(other);
|
||||
drop(engine);
|
||||
assert!(!path.exists());
|
||||
// The path names a process fd, not a persistent file. Rust tests run
|
||||
// concurrently, so another test can reuse that fd number immediately
|
||||
// after drop; assert the original memfd identity disappeared instead.
|
||||
match std::fs::metadata(&path) {
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Ok(after) => assert_ne!((after.dev(), after.ino()), identity),
|
||||
Err(error) => panic!("unexpected fd path metadata error: {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user