test(kar): cover borrowed spool I/O closures
Linux / verify (pull_request) Successful in 2m6s
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 1m36s
Linux / linux-static-cli (pull_request) Successful in 5m34s
Linux / release-cli (pull_request) Skipped

This commit is contained in:
Pavlo Ratushnyi
2026-10-07 04:25:57 +02:00
parent ed7f9fc473
commit 7f4e40d103
+25 -8
View File
@@ -3634,6 +3634,18 @@ mod tests {
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());
assert_borrowed_cursor_full_device_write_error();
}
#[cfg(unix)]
fn assert_borrowed_cursor_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 bytes = 2.5f32.to_le_bytes();
let mut reader = std::io::Cursor::new(bytes.as_slice());
assert!(write_raw_f32_chunks(&mut reader, 0, 0, 4, &mut writer).is_err());
}
#[cfg(unix)]
@@ -3674,6 +3686,9 @@ mod tests {
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);
let bytes = 2.5f32.to_le_bytes();
let mut borrowed_cursor = std::io::Cursor::new(bytes.as_slice());
assert_raw_spool_flush_error(&mut borrowed_cursor);
}
#[cfg(unix)]
@@ -3724,14 +3739,16 @@ mod tests {
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()
let error = write_raw_f32_spool(
reader,
raw_spool_request(path),
&mut writer,
reject_spool_sync,
)
.unwrap_err();
assert_eq!(
error,
std::io::Error::from(std::io::ErrorKind::PermissionDenied).to_string()
);
assert!(path.exists());
fs::remove_file(path).unwrap();