From 5dea8b5f8a1a380afad27d1f30bf0b0a56bbf8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Fri, 29 Jun 2018 15:38:27 +0200 Subject: [PATCH] Test dirty flags on all FAT variants Flags field offset is different is it makes sense. --- tests/write.rs | 56 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/tests/write.rs b/tests/write.rs index d467d33..529f093 100644 --- a/tests/write.rs +++ b/tests/write.rs @@ -306,26 +306,38 @@ fn test_rename_file_fat32() { call_with_fs(&test_rename_file, FAT32_IMG, 6) } -#[test] -fn test_dirty_flag() { - call_with_tmp_img(&|tmp_path| { - // Open filesystem, make change, and forget it - should become dirty - let fs = open_filesystem_rw(tmp_path); - let status_flags = fs.read_status_flags().unwrap(); - assert_eq!(status_flags.dirty(), false); - assert_eq!(status_flags.io_error(), false); - fs.root_dir().create_file("abc.txt").unwrap(); - mem::forget(fs); - // Check if volume is dirty now - let fs = open_filesystem_rw(tmp_path); - let status_flags = fs.read_status_flags().unwrap(); - assert_eq!(status_flags.dirty(), true); - assert_eq!(status_flags.io_error(), false); - fs.unmount().unwrap(); - // Make sure remounting does not clear the dirty flag - let fs = open_filesystem_rw(tmp_path); - let status_flags = fs.read_status_flags().unwrap(); - assert_eq!(status_flags.dirty(), true); - assert_eq!(status_flags.io_error(), false); - }, FAT32_IMG, 7); +fn test_dirty_flag(tmp_path: &str) { + // Open filesystem, make change, and forget it - should become dirty + let fs = open_filesystem_rw(tmp_path); + let status_flags = fs.read_status_flags().unwrap(); + assert_eq!(status_flags.dirty(), false); + assert_eq!(status_flags.io_error(), false); + fs.root_dir().create_file("abc.txt").unwrap(); + mem::forget(fs); + // Check if volume is dirty now + let fs = open_filesystem_rw(tmp_path); + let status_flags = fs.read_status_flags().unwrap(); + assert_eq!(status_flags.dirty(), true); + assert_eq!(status_flags.io_error(), false); + fs.unmount().unwrap(); + // Make sure remounting does not clear the dirty flag + let fs = open_filesystem_rw(tmp_path); + let status_flags = fs.read_status_flags().unwrap(); + assert_eq!(status_flags.dirty(), true); + assert_eq!(status_flags.io_error(), false); +} + +#[test] +fn test_dirty_flag_fat12() { + call_with_tmp_img(&test_dirty_flag, FAT12_IMG, 7) +} + +#[test] +fn test_dirty_flag_fat16() { + call_with_tmp_img(&test_dirty_flag, FAT16_IMG, 7) +} + +#[test] +fn test_dirty_flag_fat32() { + call_with_tmp_img(&test_dirty_flag, FAT32_IMG, 7) }