()
| 3295 | |
| 3296 | #[test] |
| 3297 | fn write_zeroes_read() { |
| 3298 | with_basic_file(&valid_header_v3(), |disk_file: RawFile| { |
| 3299 | let mut q = QcowFile::from(disk_file).unwrap(); |
| 3300 | // Write some test data. |
| 3301 | let b = [0x55u8; 0x1000]; |
| 3302 | q.seek(SeekFrom::Start(0xfff2000)).expect("Failed to seek."); |
| 3303 | q.write_all(&b).expect("Failed to write test string."); |
| 3304 | // Overwrite the test data with zeroes. |
| 3305 | q.seek(SeekFrom::Start(0xfff2000)).expect("Failed to seek."); |
| 3306 | let nwritten = q.write_zeroes(0x200).expect("Failed to write zeroes."); |
| 3307 | assert_eq!(nwritten, 0x200); |
| 3308 | // Verify that the correct part of the data was zeroed out. |
| 3309 | let mut buf = [0u8; 0x1000]; |
| 3310 | q.seek(SeekFrom::Start(0xfff2000)).expect("Failed to seek."); |
| 3311 | q.read_exact(&mut buf).expect("Failed to read."); |
| 3312 | assert_eq!(buf[0], 0); |
| 3313 | assert_eq!(buf[0x1FF], 0); |
| 3314 | assert_eq!(buf[0x200], 0x55); |
| 3315 | assert_eq!(buf[0xFFF], 0x55); |
| 3316 | }); |
| 3317 | } |
| 3318 | |
| 3319 | #[test] |
| 3320 | fn write_zeroes_full_cluster() { |
nothing calls this directly
no test coverage detected