test(kar): cover raw spool I/O failures
Linux / verify (pull_request) Successful in 2m11s
Linux / changed-scope-coverage (pull_request) Skipped
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 1m27s
Linux / linux-static-cli (pull_request) Successful in 5m20s
Linux / release-cli (pull_request) Skipped
Linux / verify (pull_request) Successful in 2m11s
Linux / changed-scope-coverage (pull_request) Skipped
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 1m27s
Linux / linux-static-cli (pull_request) Successful in 5m20s
Linux / release-cli (pull_request) Skipped
This commit is contained in:
@@ -3508,6 +3508,16 @@ mod tests {
|
||||
assert_raw_spool_preserves_existing(&mut source, &fixture.directory.join("owned.raw"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cursor_spool_creation_conflict_preserves_existing_output() {
|
||||
let fixture = overlay_fixture();
|
||||
let path = fixture.directory.join("cursor-owned.raw");
|
||||
fs::write(&path, b"existing bytes").unwrap();
|
||||
let mut reader = std::io::Cursor::new(2.5f32.to_le_bytes().to_vec());
|
||||
assert!(spool_raw_f32(&mut reader, raw_spool_request(&path)).is_err());
|
||||
assert_eq!(fs::read(path).unwrap(), b"existing bytes");
|
||||
}
|
||||
|
||||
fn assert_unsupported_raw_spool_removes_partial(source: &mut File, path: &Path) {
|
||||
let request = RawF32Spool {
|
||||
absolute: 0,
|
||||
@@ -3556,6 +3566,8 @@ mod tests {
|
||||
fn file_backed_raw_spool_reports_write_and_flush_errors() {
|
||||
assert_raw_file_write_error();
|
||||
assert_raw_file_flush_error();
|
||||
assert_cursor_vec_full_device_write_error();
|
||||
assert_file_and_cursor_vec_flush_errors();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3614,6 +3626,16 @@ mod tests {
|
||||
assert_file_reader_full_device_write_error();
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn assert_cursor_vec_full_device_write_error() {
|
||||
let Ok(file) = fs::OpenOptions::new().write(true).open("/dev/full") else {
|
||||
return;
|
||||
};
|
||||
let mut writer = BufWriter::with_capacity(0, file);
|
||||
let mut reader = std::io::Cursor::new(2.5f32.to_le_bytes().to_vec());
|
||||
assert!(write_raw_f32_chunks(&mut reader, 0, 0, 4, &mut writer).is_err());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn assert_file_reader_full_device_write_error() {
|
||||
let fixture = overlay_fixture();
|
||||
@@ -3643,6 +3665,27 @@ mod tests {
|
||||
assert!(write_raw_f32_spool(&mut reader, request, &mut writer, File::sync_all).is_err());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn assert_file_and_cursor_vec_flush_errors() {
|
||||
let fixture = overlay_fixture();
|
||||
let source_path = fixture.directory.join("flush-source.bin");
|
||||
fs::write(&source_path, 2.5f32.to_le_bytes()).unwrap();
|
||||
let mut file_reader = File::open(source_path).unwrap();
|
||||
assert_raw_spool_flush_error(&mut file_reader);
|
||||
let mut cursor_reader = std::io::Cursor::new(2.5f32.to_le_bytes().to_vec());
|
||||
assert_raw_spool_flush_error(&mut cursor_reader);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn assert_raw_spool_flush_error<R: Read + Seek>(reader: &mut R) {
|
||||
let Ok(file) = fs::OpenOptions::new().write(true).open("/dev/full") else {
|
||||
return;
|
||||
};
|
||||
let mut writer = BufWriter::new(file);
|
||||
let request = raw_spool_request(Path::new("unused.raw"));
|
||||
assert!(write_raw_f32_spool(reader, request, &mut writer, File::sync_all).is_err());
|
||||
}
|
||||
|
||||
fn reject_spool_sync(_: &File) -> std::io::Result<()> {
|
||||
Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied))
|
||||
}
|
||||
@@ -3668,6 +3711,32 @@ mod tests {
|
||||
assert!(!path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_spool_sync_failure_propagates_for_borrowed_and_owned_cursors() {
|
||||
let fixture = overlay_fixture();
|
||||
let bytes = 2.5f32.to_le_bytes();
|
||||
let mut borrowed = std::io::Cursor::new(bytes.as_slice());
|
||||
assert_cursor_spool_sync_error(&mut borrowed, &fixture.directory.join("borrowed.raw"));
|
||||
let mut owned = std::io::Cursor::new(bytes.to_vec());
|
||||
assert_cursor_spool_sync_error(&mut owned, &fixture.directory.join("owned.raw"));
|
||||
}
|
||||
|
||||
fn assert_cursor_spool_sync_error<R: Read + Seek>(reader: &mut R, path: &Path) {
|
||||
let file = File::create(path).unwrap();
|
||||
let mut writer = BufWriter::new(file);
|
||||
assert!(
|
||||
write_raw_f32_spool(
|
||||
reader,
|
||||
raw_spool_request(path),
|
||||
&mut writer,
|
||||
reject_spool_sync
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(path.exists());
|
||||
fs::remove_file(path).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn streamed_preparation_detects_identity_tensor_count_changed_before_run() {
|
||||
let fixture = overlay_fixture();
|
||||
|
||||
Reference in New Issue
Block a user