Files
apfstests/tests/xfs/052
T
Zhihao Cheng b7cecbea22 fstests: Add path $here before src/<file>
Calling src/<file> without path '$here' may cause the problem that
the file cannot be found.

For example, Running generic/192 with overlayfs(Let ubifs as base
fs) yields the following output:

  generic/192 - output mismatch
     QA output created by 192
     sleep for 5 seconds
     test
    +./common/rc: line 316: src/t_dir_type: No such file or directory
     delta1 is in range
     delta2 is in range
    ...

When the use case fails, the call stack in generic/192 is:

  local unknowns=$(src/t_dir_type $dir u | wc -l)	common/rc
  _supports_filetype					common/rc
  _overlay_mount					common/overlay
  _overlay_test_mount					common/overlay
  _test_mount						common/rc
  _test_cycle_mount					generic/192

Before _test_cycle_mount() being invoked, generic/192 executed 'cd
/' to change work dir from 'xfstests-dev' to '/', so src/t_dir_type
was not found.

[Eryu: some tests run src/<file> as regular user, don't add $here
prefix in such case, as a regular user may have no search permission
on $here]

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2019-10-23 23:12:42 +08:00

119 lines
2.9 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
#
# FS QA Test No. 052
#
# Ensure that quota(1) displays blocksizes matching ondisk dquots.
#
# MOUNT_OPTIONS can be set to gquota to test group quota,
# defaults to uquota if MOUNT_OPTIONS is not set.
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/quota
_cleanup()
{
cd /
_scratch_unmount 2>/dev/null
rm -f $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# real QA test starts here
_supported_fs xfs
_supported_os Linux
rm -f $seqres.full
_require_scratch
_require_xfs_quota
_require_nobody
# setup a default run
_qmount_option uquota
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
cat $tmp.mkfs >>$seqres.full
chmod a+w $seqres.full # arbitrary users will write here
# keep the blocksize from mkfs ($dbsize)
. $tmp.mkfs
_qmount
# setup user/group to test
if $here/src/feature -U $SCRATCH_DEV ; then
type=u; eval `_choose_uid`
elif $here/src/feature -G $SCRATCH_DEV ; then
type=g; eval `_choose_gid`
elif $here/src/feature -P $SCRATCH_DEV ; then
type=p; eval `_choose_prid`
else
_notrun "No quota support at mount time"
fi
# create 100 (fs-blocksize) blocks
_file_as_id $SCRATCH_MNT/foo $id $type $dbsize 220
sync
# set limit at 1001 (1k) blocks
bsoft=1001
bhard=1001
isoft=10
ihard=10
xfs_quota -x \
-c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
-c "limit -$type isoft=$isoft ihard=$ihard $id" \
$SCRATCH_DEV
# cross check blks, softblks, hardblks <-> quota, xfs_db
xfs_quota -c "quota -$type -birnN $id" $SCRATCH_DEV |
tr -d '\n' | tr -s '[:space:]' | tee -a $seqres.full |
perl -ne 'if (m[^\s*'$SCRATCH_DEV'\s+(\d+)\s+(\d+)\s+(\d+)]) {
print "used_blocks=", $1, "\n";
print "soft_blocks=", $2, "\n";
print "hard_blocks=", $3, "\n";
$next = 0;
}' | LC_COLLATE=POSIX sort >$tmp.quota
echo ===quota output >> $seqres.full
cat $tmp.quota >> $seqres.full
[ ! -s $tmp.quota ] && echo "warning: quota output file is empty"
_scratch_unmount
# note - does (insitu) conversion from fs blocks to 1K blocks
_scratch_xfs_db -rc "dquot -$type $id" -c p | tee -a $seqres.full | perl -ne '
if (/^diskdq.bcount = (\d+)$/) {
print "used_blocks=", $1 * '$dbsize' / 1024, "\n";
}
elsif (/^diskdq.blk_hardlimit = (\d+)$/) {
print "hard_blocks=", $1 * '$dbsize' / 1024, "\n";
}
elsif (/^diskdq.blk_softlimit = (\d+)$/) {
print "soft_blocks=", $1 * '$dbsize' / 1024, "\n";
}' | LC_COLLATE=POSIX sort >$tmp.xfs_db
echo ===xfs_db output >> $seqres.full
cat $tmp.xfs_db >> $seqres.full
[ ! -s $tmp.xfs_db ] && echo "warning: xfs_db output file is empty"
echo Comparing out of xfs_quota and xfs_db
diff $tmp.quota $tmp.xfs_db
[ $? -eq 0 ] && echo OK.
# success, all done
status=0
exit