summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
eff343f)
There are some testcases use below two kind of commands to get file
size, generalize the second way as global function _get_filesize()
to simply codes.
1. ls -l $1 | $AWK_PROG '{print $5}'
2. stat -c %s $1
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 files changed:
fi
if [ -f $dir/$file_count ]; then
fi
if [ -f $dir/$file_count ]; then
- bytes_written=$(stat -c '%s' $dir/$file_count)
+ bytes_written=$(_get_filesize $dir/$file_count)
fi
# If there was no room to make the file, then divide it in
fi
# If there was no room to make the file, then divide it in
+_get_filesize()
+{
+ stat -c %s "$1"
+}
+
_mount()
{
$MOUNT_PROG `_mount_ops_filter $*`
_mount()
{
$MOUNT_PROG `_mount_ops_filter $*`
sync # Sync to avoid unwritten extents
cat > $tmp.bytes
sync # Sync to avoid unwritten extents
cat > $tmp.bytes
- local end=$(( offset + $(stat -c %s $tmp.bytes ) ))
+ local end=$(( offset + $(_get_filesize $tmp.bytes ) ))
# For each extent that intersects the requested range in order, add a
# command that writes the next part of the data to that extent.
# For each extent that intersects the requested range in order, add a
# command that writes the next part of the data to that extent.
ext4|f2fs)
# ext4 and f2fs store the Merkle tree after the file contents
# itself, starting at the next 65536-byte aligned boundary.
ext4|f2fs)
# ext4 and f2fs store the Merkle tree after the file contents
# itself, starting at the next 65536-byte aligned boundary.
- (( offset += ($(stat -c %s $file) + 65535) & ~65535 ))
+ (( offset += ($(_get_filesize $file) + 65535) & ~65535 ))
_fsv_scratch_corrupt_bytes $file $offset
;;
*)
_fsv_scratch_corrupt_bytes $file $offset
;;
*)
# supposed to happen and for example it made inode eviction enter an infinite
# loop that dumped a warning trace on each iteration.
$CLONER_PROG -s 0 -d 65536 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
# supposed to happen and for example it made inode eviction enter an infinite
# loop that dumped a warning trace on each iteration.
$CLONER_PROG -s 0 -d 65536 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
-echo "bar file size after clone operation: $(stat -c %s $SCRATCH_MNT/bar)"
+echo "bar file size after clone operation: `_get_filesize $SCRATCH_MNT/bar`"
rm -rf $TEST_DIR/fsstress.$$.*
}
rm -rf $TEST_DIR/fsstress.$$.*
}
-_filesize()
-{
- ls -l $1 | $AWK_PROG '{print " filesize = " $5}'
-}
-
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
du $SCRATCH_MNT/tmp1 >>$seqres.full
# And at least some of it should succeed.
du $SCRATCH_MNT/tmp1 >>$seqres.full
# And at least some of it should succeed.
-_filesize=`ls -l $SCRATCH_MNT/tmp1 | awk '{print $5}'`
+_filesize=`_get_filesize $SCRATCH_MNT/tmp1`
[ $_filesize -lt $((128 * 1024)) ] && \
_fail "Partial write until enospc failed; wrote $_filesize bytes."
[ $_filesize -lt $((128 * 1024)) ] && \
_fail "Partial write until enospc failed; wrote $_filesize bytes."
$here/src/seek_copy_test $src $dest
$here/src/seek_copy_test $src $dest
- test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
+ test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST01: file size check failed"
cmp $src $dest || _fail "TEST01: file bytes check failed"
_fail "TEST01: file size check failed"
cmp $src $dest || _fail "TEST01: file bytes check failed"
$here/src/seek_copy_test $src $dest
$here/src/seek_copy_test $src $dest
- test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
+ test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST02: file size check failed"
cmp $src $dest || _fail "TEST02: file bytes check failed"
_fail "TEST02: file size check failed"
cmp $src $dest || _fail "TEST02: file bytes check failed"
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
- test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
+ test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST03: file size check failed"
cmp $src $dest || _fail "TEST03: file bytes check failed"
_fail "TEST03: file size check failed"
cmp $src $dest || _fail "TEST03: file bytes check failed"
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
- test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
+ test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST04: file size check failed"
cmp $src $dest || _fail "TEST04: file bytes check failed"
_fail "TEST04: file size check failed"
cmp $src $dest || _fail "TEST04: file bytes check failed"
echo "Try to kill reflink after a shorter period of time"
kill_after=2 # give us a shorter time to die
echo "Try to kill reflink after a shorter period of time"
kill_after=2 # give us a shorter time to die
-n=$(stat -c '%s' $testdir/file1)
+n=$(_get_filesize $testdir/file1)
echo "performing kill test on $n bytes..." >> $seqres.full
touch $TEST_DIR/before
$TIMEOUT_PROG -s INT ${kill_after}s $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1
echo "performing kill test on $n bytes..." >> $seqres.full
touch $TEST_DIR/before
$TIMEOUT_PROG -s INT ${kill_after}s $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1
echo "Try to kill reflink after a shorter period of time"
kill_after=2 # give us a shorter time to die
echo "Try to kill reflink after a shorter period of time"
kill_after=2 # give us a shorter time to die
-n=$(stat -c '%s' $testdir/file1)
+n=$(_get_filesize $testdir/file1)
echo "performing kill test on $n bytes..." >> $seqres.full
touch $TEST_DIR/before
urk=$($TIMEOUT_PROG -s KILL ${kill_after}s $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1)
echo "performing kill test on $n bytes..." >> $seqres.full
touch $TEST_DIR/before
urk=$($TIMEOUT_PROG -s KILL ${kill_after}s $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1)
$TEST_DIR/testfile.$seq >>$seqres.full 2>&1
# Verify the file size, it should keep unchanged as 0 in this case
$TEST_DIR/testfile.$seq >>$seqres.full 2>&1
# Verify the file size, it should keep unchanged as 0 in this case
-fsize=`ls -l $TEST_DIR/testfile.$seq | awk '{print $5}'`
+fsize=`_get_filesize $TEST_DIR/testfile.$seq`
[ "$fsize" -eq 0 ] || _fail "File size is changed to ($fsize Bytes)"
# Truncate the file size back to 0
[ "$fsize" -eq 0 ] || _fail "File size is changed to ($fsize Bytes)"
# Truncate the file size back to 0
file_size=0
if [ -e $file ]; then
file_size=0
if [ -e $file ]; then
- file_size=$(stat -c %s $file)
+ file_size=$(_get_filesize $file)
fi
# We shouldn't have been able to write more data than we had space for.
fi
# We shouldn't have been able to write more data than we had space for.
# Create a swap file with a large discontiguous range(?)
echo "large discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len * 2)) $swapfile >> $seqres.full
# Create a swap file with a large discontiguous range(?)
echo "large discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len * 2)) $swapfile >> $seqres.full
-old_sz="$(stat -c '%s' $swapfile)"
+old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse $((len / 2)) $len" $swapfile >> $seqres.full 2>&1
$XFS_IO_PROG -c "fcollapse $((len / 2)) $len" $swapfile >> $seqres.full 2>&1
-new_sz="$(stat -c '%s' $swapfile)"
+new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
# Create a swap file with a small discontiguous range(?)
echo "small discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len + 1024)) $swapfile >> $seqres.full
# Create a swap file with a small discontiguous range(?)
echo "small discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len + 1024)) $swapfile >> $seqres.full
-old_sz="$(stat -c '%s' $swapfile)"
+old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse 66560 1024" $swapfile >> $seqres.full 2>&1
$XFS_IO_PROG -c "fcollapse 66560 1024" $swapfile >> $seqres.full 2>&1
-new_sz="$(stat -c '%s' $swapfile)"
+new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
$XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full
su -s/bin/bash - $qa_user -c "ulimit -f 64 ; $XFS_IO_PROG -f -c \"reflink $SCRATCH_MNT/foo\" $SCRATCH_MNT/bar" >> $seqres.full 2>&1
$XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full
su -s/bin/bash - $qa_user -c "ulimit -f 64 ; $XFS_IO_PROG -f -c \"reflink $SCRATCH_MNT/foo\" $SCRATCH_MNT/bar" >> $seqres.full 2>&1
-sz="$(stat -c '%s' $SCRATCH_MNT/bar)"
+sz="$(_get_filesize $SCRATCH_MNT/bar)"
if [ "$sz" -ne 0 ] && [ "$sz" -ne 65536 ]; then
echo "Oddball file size $sz??"
fi
if [ "$sz" -ne 0 ] && [ "$sz" -ne 65536 ]; then
echo "Oddball file size $sz??"
fi
cp $fsv_orig_file $fsv_file
_fsv_enable $fsv_file >> $seqres.full
cmp $fsv_file $fsv_orig_file
cp $fsv_orig_file $fsv_file
_fsv_enable $fsv_file >> $seqres.full
cmp $fsv_file $fsv_orig_file
_scratch_cycle_mount
cmp $fsv_file $fsv_orig_file
_scratch_cycle_mount
cmp $fsv_file $fsv_orig_file
_fsv_scratch_begin_subtest "Trying to measure non-verity file fails with ENODATA"
echo foo > $fsv_file
_fsv_scratch_begin_subtest "Trying to measure non-verity file fails with ENODATA"
echo foo > $fsv_file
{
local target=$1 expected_size=$2 actual_size
{
local target=$1 expected_size=$2 actual_size
- actual_size=$(stat -c "%s" $target)
+ actual_size=$(_get_filesize $target)
[ "$actual_size" == "$expected_size" ] || echo "Expected file size $expected_size but actual size is $actual_size"
}
[ "$actual_size" == "$expected_size" ] || echo "Expected file size $expected_size but actual size is $actual_size"
}
# write a 4k aligned amount of data to keep the calculations simple
$XFS_IO_PROG -c "pwrite 0 128m" $file >> $seqres.full
# write a 4k aligned amount of data to keep the calculations simple
$XFS_IO_PROG -c "pwrite 0 128m" $file >> $seqres.full
- size=`stat -c "%s" $file`
+ size=`_get_filesize $file`
blocks=`stat -c "%b" $file`
blocksize=`stat -c "%B" $file`
blocks=`stat -c "%b" $file`
blocksize=`stat -c "%B" $file`
# space. Note that we start at the end of the file and work backwards as a
# reverse allocation pattern increases the chances of both left and right sparse
# record merges.
# space. Note that we start at the end of the file and work backwards as a
# reverse allocation pattern increases the chances of both left and right sparse
# record merges.
-offset=`stat -c "%s" $SCRATCH_MNT/spc`
+offset=`_get_filesize $SCRATCH_MNT/spc`
offset=$((offset - $CHUNK_SIZE * 2))
while [ $offset -ge 0 ]; do
$XFS_IO_PROG -c "fpunch $offset $CHUNK_SIZE" $SCRATCH_MNT/spc \
offset=$((offset - $CHUNK_SIZE * 2))
while [ $offset -ge 0 ]; do
$XFS_IO_PROG -c "fpunch $offset $CHUNK_SIZE" $SCRATCH_MNT/spc \
$XFS_IO_PROG -xc "resblks 16" $SCRATCH_MNT >> $seqres.full 2>&1
dd if=/dev/zero of=$SCRATCH_MNT/file bs=4k >> $seqres.full 2>&1
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/file >> $seqres.full 2>&1
$XFS_IO_PROG -xc "resblks 16" $SCRATCH_MNT >> $seqres.full 2>&1
dd if=/dev/zero of=$SCRATCH_MNT/file bs=4k >> $seqres.full 2>&1
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/file >> $seqres.full 2>&1
-size=`stat -c %s $SCRATCH_MNT/file`
+size=`_get_filesize $SCRATCH_MNT/file`
for i in $(seq 0 8192 $size); do
$XFS_IO_PROG -c "fpunch $i 4k" $SCRATCH_MNT/file >> $seqres.full 2>&1
done
for i in $(seq 0 8192 $size); do
$XFS_IO_PROG -c "fpunch $i 4k" $SCRATCH_MNT/file >> $seqres.full 2>&1
done