diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:16:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:16:34 +0000 |
commit | a398d2c2b5fd6ab0545d8bb019f9a970b2309404 (patch) | |
tree | 272fc7ab226258d7ceddee12c8c682c8e711c2b0 /debug/test/test_fs_fat | |
parent | Initial commit. (diff) | |
download | parted-a398d2c2b5fd6ab0545d8bb019f9a970b2309404.tar.xz parted-a398d2c2b5fd6ab0545d8bb019f9a970b2309404.zip |
Adding upstream version 3.6.upstream/3.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debug/test/test_fs_fat')
-rwxr-xr-x | debug/test/test_fs_fat | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/debug/test/test_fs_fat b/debug/test/test_fs_fat new file mode 100755 index 0000000..6eddecb --- /dev/null +++ b/debug/test/test_fs_fat @@ -0,0 +1,180 @@ +#! /bin/bash + +do_diff() +{ + mount -t vfat ${TEST_DRIVE}1 $TEST_MOUNT_POINT > /dev/null + + if diff -rq $1 $2 >> test_log; then + ped_test_ok + else + ped_test_failed + fi + + umount $TEST_MOUNT_POINT 2>&1 > /dev/null +} + +do_test_diff() +{ + ped_testing "$1" + if ped_test_get_val "$4" "$5" "$6" "$7"; then + ped_test_failed + return 1 + fi + do_diff "$2" "$3" +} + +test_mkpartfs() +{ + ped_test "mkpartfs fat16 minimum size"\ + "mklabel $TEST_FS_USE_DISK_LABEL\ + mkpartfs primary fat16 0 1\ + check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + + ped_test "mkpartfs fat32 minimum size"\ + "mklabel $TEST_FS_USE_DISK_LABEL\ + mkpartfs primary fat32 0 1\ + check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + + ped_test "mkpartfs"\ + "mklabel $TEST_FS_USE_DISK_LABEL\ + mkpartfs primary fat32 1 $DEFAULT_END\ + check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + + ped_test "mkfs"\ + "mkfs 1 fat32\ + check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" +} + +prepare_resize_tests() +{ + part_num=1 + part=$TEST_DRIVE$part_num + hole_parent=`echo $TEST_DATA_HOLE | sed -e "s/[-_.a-zA-Z0-9]+\///g"` + + umount $TEST_MOUNT_POINT 2>&1 > /dev/null + + mount $part $TEST_MOUNT_POINT -t vfat \ + && cp -r $TEST_DATA/* $TEST_MOUNT_POINT \ + && cp -r $TEST_DATA $TEST_MOUNT_POINT/tmp_copy \ + && rm -rf $TEST_MOUNT_POINT/$TEST_DATA_HOLE \ + && mv $TEST_MOUNT_POINT/tmp_copy/$TEST_DATA_HOLE \ + $TEST_MOUNT_POINT/$hole_parent \ + && rm -rf $TEST_MOUNT_POINT/tmp_copy + umount $TEST_MOUNT_POINT +} + +clearfat() +{ + $TEST_PARTED_CLEARFAT $TEST_DRIVE $1 +} + +test_resize_move_start_forward() +{ +# geometry beforehand: 1 to $DEFAULT_END + do_test_diff "resize: move start forward"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 5 $DEFAULT_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_resize_move_start_backward() +{ +# geometry beforehand: 5 to $DEFAULT_END + do_test_diff "resize: move start backward"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $DEFAULT_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_resize_move_end_forward() +{ +# geometry beforehand: 1 to $DEFAULT_END + do_test_diff "resize: move end forward"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $[ $DEFAULT_END + 5 ] check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_resize_move_end_backward() +{ +# geometry beforehand: 1 to $[$DEFAULT_END + 5] + do_test_diff "resize: move end backward"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $DEFAULT_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_convert_fat16_fat32_shrink_cluster() +{ +# geometry beforehand: 1 to $DEFAULT_END + do_test_diff \ + "resize: convert from FAT16 to FAT32, shrinking the cluster size"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $FAT32_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_convert_fat32_fat16() +{ +# geometry beforehand: 1 to $FAT16_SMALL_END + do_test_diff "resize: convert from FAT32 to FAT16"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $FAT32_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +test_convert_fat16_fat32() +{ +# geometry beforehand: 1 to $FAT32_END + do_test_diff "resize: convert from FAT16 to FAT32"\ + $TEST_DATA $TEST_MOUNT_POINT \ + "resize 1 1 $FAT16_SMALL_END check 1"\ + "/sbin/dosfsck ${TEST_DRIVE}1" + clearfat 1 +} + +#test_convert_fat32_fat16_shrink_cluster() +#{ +#} + +#test_fat16_shrink_cluster() +#{ +#} + +#test_fat32_shrink_cluster() +#{ +#} + +main() +{ + export DEFAULT_END=300 + export FAT32_END=600 + export FAT16_SMALL_END=200 + + if ! test_mkpartfs; then + return 1 + fi + + prepare_resize_tests + test_resize_move_start_forward + test_resize_move_start_backward + test_resize_move_end_forward + test_resize_move_end_backward + +# prepare_resize_tests + test_convert_fat16_fat32_shrink_cluster + test_convert_fat32_fat16 + test_convert_fat16_fat32 +} + +main |