mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
tweak for new _do command
This commit is contained in:
@@ -70,7 +70,7 @@ _fill()
|
||||
"src/fill2fs --verbose --dir=$1 --seed=0 --filesize=65536 --stddev=32768 --list=- >>$tmp.manifest"
|
||||
}
|
||||
|
||||
_do_die_on_error=y
|
||||
_do_die_on_error=always
|
||||
rm -f $seq.full
|
||||
#agsize=16
|
||||
agsize=32
|
||||
@@ -87,9 +87,7 @@ echo "done"
|
||||
for size in 8448 17512 19200 24576
|
||||
do
|
||||
_fill $SCRATCH_MNT/fill_$size
|
||||
echo -n "Grow filesystem to $size blocks... "
|
||||
_do "xfs_growfs -D ${size} $SCRATCH_MNT"
|
||||
echo "done"
|
||||
_do "Grow filesystem to $size blocks" "xfs_growfs -D ${size} $SCRATCH_MNT"
|
||||
echo -n "Flush filesystem... "
|
||||
_do "umount $SCRATCH_MNT"
|
||||
_do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
|
||||
|
||||
@@ -84,7 +84,8 @@ _cull_files()
|
||||
print MANIFEST $in[$i];
|
||||
}
|
||||
}
|
||||
close MANIFEST;'
|
||||
close MANIFEST;
|
||||
exit(0);'
|
||||
}
|
||||
|
||||
# create a large contiguous file using dd
|
||||
@@ -97,69 +98,63 @@ _cull_files()
|
||||
# check checksums for remaining files
|
||||
# create 3 minimum sized (16Mb) allocation groups
|
||||
# xfs_repair is going to need three to verify the superblock
|
||||
|
||||
rm -f $seq.full
|
||||
bmap_cmd="xfs_bmap -v"
|
||||
mnt_cmd="mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
|
||||
_do_die_on_error=message_only
|
||||
|
||||
echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
|
||||
_do "mkfs -t xfs -d size=48m,agcount=3 -l internal -f $SCRATCH_DEV"
|
||||
_do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
|
||||
_do "$mnt_cmd"
|
||||
echo "done"
|
||||
|
||||
echo -n "Reserve 16 1Mb unfragmented regions... "
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
do
|
||||
_do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
|
||||
_do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
|
||||
_do "xfs_bmap $SCRATCH_MNT/hole$i"
|
||||
_do "$bmap_cmd $SCRATCH_MNT/hole$i"
|
||||
done
|
||||
echo "done"
|
||||
|
||||
# set up filesystem
|
||||
echo -n "Fill filesystem with 4k files, generate manifest... "
|
||||
_do "src/fill2fs --verbose --dir=$SCRATCH_MNT/fill --seed=0 --filesize=4096 --stddev=0 --list=$tmp.manifest"
|
||||
fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
|
||||
_do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
|
||||
echo "done"
|
||||
# flush the filesystem - make sure there is no space "lost" to pre-allocation
|
||||
_do "umount $SCRATCH_MNT"
|
||||
_do "$mnt_cmd"
|
||||
echo -n "Use up any further available space using dd... "
|
||||
_do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
|
||||
echo "done"
|
||||
echo -n "Delete every second file... "
|
||||
if ! _do "_cull_files"; then
|
||||
echo "fail"
|
||||
echo "Could not cull files. Test failed see $seq.full"
|
||||
status=1; exit
|
||||
fi
|
||||
echo "done"
|
||||
|
||||
# create fragmented file
|
||||
_do "Delete every second file" "_cull_files"
|
||||
echo -n "Create one very large file... "
|
||||
_do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
|
||||
echo "done"
|
||||
_do "xfs_bmap $SCRATCH_MNT/fragmented"
|
||||
_do "$bmap_cmd $SCRATCH_MNT/fragmented"
|
||||
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
|
||||
echo -n "Remove other files... "
|
||||
_do "rm -rf $SCRATCH_MNT/{pad,hole*}"
|
||||
echo "done"
|
||||
_do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
|
||||
|
||||
# flush everything
|
||||
_do "umount $SCRATCH_MNT"
|
||||
_do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
|
||||
# defragment
|
||||
_do "Run xfs_fsr on filesystem" "xfs_fsr -v $SCRATCH_DEV"
|
||||
_do "$bmap_cmd $SCRATCH_MNT/fragmented"
|
||||
_do "Check 4k files" "src/fill2fs_check $tmp.manifest"
|
||||
|
||||
echo -n "Run xfs_fsr on filesystem... "
|
||||
_do "xfs_fsr -v $SCRATCH_DEV"
|
||||
echo "done"
|
||||
_do "xfs_bmap $SCRATCH_MNT/fragmented"
|
||||
|
||||
echo -n "Check 4k files... "
|
||||
if ! _do "src/fill2fs_check $tmp.manifest"; then
|
||||
echo "fail"
|
||||
echo "4k file is corrupt/missing after fsr. Test failed see $seq.full"
|
||||
status=1; exit
|
||||
fi
|
||||
echo "done"
|
||||
# check
|
||||
echo -n "Check large file... "
|
||||
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
|
||||
if ! diff $tmp.sum1 $tmp.sum2; then
|
||||
if ! _do "diff $tmp.sum1 $tmp.sum2"; then
|
||||
echo "fail"
|
||||
echo "File is corrupt/missing after fsr. Test failed see $seq.full"
|
||||
status=1; exit
|
||||
fi
|
||||
echo "done"
|
||||
_do "Checking filesystem" "_check_fs $SCRATCH_DEV"
|
||||
|
||||
echo -n "Checking filesystem... "
|
||||
_check_fs $SCRATCH_DEV
|
||||
echo "done"
|
||||
# success, all done
|
||||
echo "xfs_fsr tests passed."
|
||||
status=0 ; exit
|
||||
|
||||
@@ -262,9 +262,16 @@ _is_block_dev()
|
||||
[ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
|
||||
}
|
||||
|
||||
# do a command, log it to $seq.full, optionally test return status
|
||||
# and die if command fails
|
||||
#
|
||||
# Do a command, log it to $seq.full, optionally test return status
|
||||
# and die if command fails. If called with one argument _do executes the
|
||||
# command, logs it, and returns its exit status. With two arguments _do
|
||||
# first prints the message passed in the first argument, and then "done"
|
||||
# or "fail" depending on the return status of the command passed in the
|
||||
# second argument. If the command fails and the variable _do_die_on_error
|
||||
# is set to "always" or the two argument form is used and _do_die_on_error
|
||||
# is set to "message_only" _do will print an error message to
|
||||
# $seq.out and exit.
|
||||
|
||||
_do()
|
||||
{
|
||||
if [ $# -eq 1 ]; then
|
||||
@@ -282,10 +289,18 @@ _do()
|
||||
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
|
||||
cat $tmp._out | _fix_malloc >>$seq.full
|
||||
if [ $# -eq 2 ]; then
|
||||
if [ $ret -eq 0 ]; then echo "done"; else echo "fail"; fi
|
||||
if [ $ret -eq 0 ]; then
|
||||
echo "done"
|
||||
else
|
||||
echo "fail"
|
||||
fi
|
||||
if [ "$_do_die_on_error" -a $ret -ne 0 ]; then
|
||||
eval "echo $_cmd failed \(returned $ret\): see $seq.full"
|
||||
fi
|
||||
if [ $ret -ne 0 ] \
|
||||
&& [ "$_do_die_on_error" = "always" \
|
||||
-o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
|
||||
then
|
||||
[ $# -ne 2 ] && echo
|
||||
eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
|
||||
status=1; exit
|
||||
fi
|
||||
|
||||
@@ -515,7 +530,7 @@ _check_fs()
|
||||
fi
|
||||
|
||||
[ $ok -eq 0 ] && exit 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -182,6 +182,7 @@ GetOptions("bytes=f" => \$bytes,
|
||||
"percent=f" => \$percentage,
|
||||
"seed=i" => \$seed,
|
||||
"stddev=i" => \$stddev,
|
||||
"sync=i" => \$sync_bytes,
|
||||
"verbose!" => \$verbose);
|
||||
|
||||
|
||||
@@ -203,6 +204,7 @@ Options:
|
||||
--percent=num percentage of filesystem to fill
|
||||
--seed=num seed for random number generator
|
||||
--stddev set file size standard deviation
|
||||
--sync=num sync every num bytes written
|
||||
--verbose verbose output
|
||||
EOF
|
||||
exit(1) unless defined $help;
|
||||
@@ -277,6 +279,7 @@ $total = 0;
|
||||
$files = 0;
|
||||
$dirs = 0;
|
||||
$d = 0;
|
||||
$sync_cnt = 1;
|
||||
|
||||
#
|
||||
# fill filesystem
|
||||
@@ -331,6 +334,11 @@ while ($total < $bytes) {
|
||||
}
|
||||
$total += $size;
|
||||
$files++;
|
||||
|
||||
if (defined $sync_bytes && int($total / $sync_bytes) > $sync_cnt) {
|
||||
$sync_cnt++;
|
||||
system("sync");
|
||||
}
|
||||
}
|
||||
# note that if d==0 create directories more frequently than files
|
||||
elsif (($d == 0 && $r >= 0.5) || ($d > 0 && $r >= 2.4 && $r < 2.7)) {
|
||||
|
||||
Reference in New Issue
Block a user