MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / test_pread_alloc

Function test_pread_alloc

block/src/qcow_common.rs:412–425  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410
411 #[test]
412 fn test_pread_alloc() {
413 let temp = TempFile::new().unwrap();
414 let file = temp.as_file();
415 let data: Vec<u8> = (0..=255).cycle().take(4096).collect();
416 file.write_all_at(&data, 0).unwrap();
417
418 let buf = pread_alloc(file.as_raw_fd(), 0, 4096).unwrap();
419 assert_eq!(buf, data);
420
421 let buf = pread_alloc(file.as_raw_fd(), 100, 200).unwrap();
422 assert_eq!(buf, &data[100..300]);
423
424 pread_alloc(file.as_raw_fd(), 4000, 200).unwrap_err();
425 }
426
427 #[test]
428 fn test_decompress_cluster() {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
pread_allocFunction · 0.85
takeMethod · 0.80
as_raw_fdMethod · 0.45

Tested by

no test coverage detected