expand 252 with more corner case tests

This patch adds additional punch hole tests to 252
that were used to test ext4 punch hole. The _test_generic_punch
routine has been modified to accept two new flags:

-k To keep the test file between tests.
   This will test the handling of existing holes

-d To not sync the file between tests.
   This will test the handling of delayed extents

Four new corner cases have also been added to the routine:
14. data -> hole @ EOF
15. data -> hole @ 0
16. data -> cache cold ->hole
17. data -> hole in single block file

Signed-off-by: Allison Henderson <achender@us.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Allison Henderson
2011-06-06 16:33:50 -07:00
committed by Christoph Hellwig
parent abccd8eb54
commit 0c95fadc35
3 changed files with 330 additions and 22 deletions
+128 -22
View File
@@ -256,8 +256,39 @@ die_now()
# 11. data -> hole -> data
# 12. unwritten -> data -> unwritten
# 13. data -> unwritten -> data
# 14. data -> hole @ EOF
# 15. data -> hole @ 0
# 16. data -> cache cold ->hole
# 17. data -> hole in single block file
#
# Test file is removed, created and sync'd between tests.
#
# Use -k flag to keep the file between tests. This will
# test the handling of pre-existing holes.
#
# Use the -d flag to not sync the file between tests.
# This will test the handling of delayed extents
#
_test_generic_punch()
{
remove_testfile=1
sync_cmd="-c fsync"
OPTIND=1
while getopts 'dk' OPTION
do
case $OPTION in
k) remove_testfile=
;;
d) sync_cmd=
;;
?) echo Invalid flag
exit 1
;;
esac
done
shift $(($OPTIND - 1))
alloc_cmd=$1
punch_cmd=$2
zero_cmd=$3 #if not testing zero just set to punch
@@ -267,22 +298,28 @@ _test_generic_punch()
xfs_io_opt=$7 #needs to be -F if not testing xfs
echo " 1. into a hole"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 2. into allocated space"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 20k" -c "fsync" \
-c "pwrite 0 20k" $sync_cmd \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 3. into unwritten space"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 20k" \
-c "$zero_cmd 4k 8k" \
@@ -290,15 +327,19 @@ _test_generic_punch()
[ $? -ne 0 ] && die_now
echo " 4. hole -> data"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 8k 8k" -c "fsync" \
-c "pwrite 8k 8k" $sync_cmd \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 5. hole -> unwritten"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 8k 8k" \
-c "$zero_cmd 4k 8k" \
@@ -306,24 +347,30 @@ _test_generic_punch()
[ $? -ne 0 ] && die_now
echo " 6. data -> hole"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 8k" -c "fsync" \
-c "pwrite 0 8k" $sync_cmd \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 7. data -> unwritten"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 8k" -c "fsync" \
-c "pwrite 0 8k" $sync_cmd \
-c "$alloc_cmd 8k 8k" \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 8. unwritten -> hole"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 8k" \
-c "$zero_cmd 4k 8k" \
@@ -331,49 +378,108 @@ _test_generic_punch()
[ $? -ne 0 ] && die_now
echo " 9. unwritten -> data"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 8k" \
-c "pwrite 8k 8k" -c "fsync" \
-c "pwrite 8k 8k" $sync_cmd \
-c "$zero_cmd 4k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 10. hole -> data -> hole"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 8k 4k" -c "fsync" \
-c "pwrite 8k 4k" $sync_cmd \
-c "$zero_cmd 4k 12k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 11. data -> hole -> data"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 20k" \
-c "pwrite 0 8k" \
-c "pwrite 12k 8k" -c "fsync" \
-c "pwrite 12k 8k" $sync_cmd \
-c "$punch_cmd 8k 4k" \
-c "$zero_cmd 4k 12k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 12. unwritten -> data -> unwritten"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 20k" \
-c "pwrite 8k 4k" -c "fsync" \
-c "pwrite 8k 4k" $sync_cmd \
-c "$zero_cmd 4k 12k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 13. data -> unwritten -> data"
rm -f $testfile
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "$alloc_cmd 0 20k" \
-c "pwrite 0k 8k" -c "fsync" \
-c "pwrite 0k 8k" $sync_cmd \
-c "pwrite 12k 8k" -c "fsync" \
-c "$zero_cmd 4k 12k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 14. data -> hole @ EOF"
rm -f $testfile
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 20k" $sync_cmd \
-c "$zero_cmd 12k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 15. data -> hole @ 0"
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 20k" $sync_cmd \
-c "$zero_cmd 0k 8k" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
echo " 16. data -> cache cold ->hole"
if [ "$remove_testfile" ]; then
rm -f $testfile
rm -f $testfile.2
else
cp $testfile $testfile.2
fi
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 8k 12k" -c "fsync" $testfile.2 \
> /dev/null
$XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
-c "pwrite 0 20k" $sync_cmd \
-c "$zero_cmd 0k 8k" \
-c "fadvise -d" \
-c "$map_cmd -v" $testfile | $filter_cmd
diff $testfile $testfile.2
[ $? -ne 0 ] && die_now
rm -f $testfile.2
echo " 17. data -> hole in single block file"
if [ "$remove_testfile" ]; then
rm -f $testfile
fi
block_size=`stat -f $TEST_DEV | grep "Block size" | cut -d " " -f3`
$XFS_IO_PROG $xfs_io_opt -f -c "truncate $block_size" \
-c "pwrite 0 $block_size" $sync_cmd \
-c "$zero_cmd 128 128" \
-c "$map_cmd -v" $testfile | $filter_cmd
[ $? -ne 0 ] && die_now
}