Files
apfstests/219
T
Jan Kara 09584ace12 xfstests: Use qa_user and qa_group for test 219
Test 219 requires a special user. Use $qa_user and $qa_group (added in this
patch) for that purpose instead of hardcoded uid & gid. This also fixes
a false failure when repquota does not report quota for users not in passwd.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
2013-01-04 12:42:02 -06:00

137 lines
3.7 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 219
#
# Simple quota accounting test for direct/buffered/mmap IO.
#
#-----------------------------------------------------------------------
# Copyright (c) 2009 Eric Sandeen. All Rights Reserved.
#
# Based on test 108,
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#-----------------------------------------------------------------------
#
# creator
owner=sandeen@sandeen.net
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.quota
# real QA test starts here
_supported_fs generic
_supported_os Linux #IRIX
_require_scratch
_require_quota
_require_user
_require_group
test_files()
{
echo; echo "### create files, setting up ownership (type=$type)"
rm -f $SCRATCH_MNT/{buffer,direct,mmap}
touch $SCRATCH_MNT/{buffer,direct,mmap}
chown $qa_user $SCRATCH_MNT/{buffer,direct,mmap}
chgrp $qa_group $SCRATCH_MNT/{buffer,direct,mmap}
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
$here/src/lstat64 $file | head -2 | _filter_scratch
done
}
check_usage()
{
wroteblocks=$1
wrotefiles=$2
read id exceed blocks bsoft bhard inodes isoft ihard
if [ "$blocks" -lt "$wroteblocks" ]; then
echo "Too few blocks used (type=$type)"
# Save 5% for overhead of metadata or different block size
elif [ "$blocks" -gt $((wroteblocks+wroteblocks/20)) ]; then
echo "Too many blocks used (type=$type)"
elif [ "$inodes" != "$wrotefiles" ]; then
echo "Bad number of inodes used (type=$type)"
else
echo "Usage OK (type=$type)"
fi
}
test_accounting()
{
echo "### some controlled buffered, direct and mmapd IO (type=$type)"
echo "--- initiating parallel IO..." >>$seq.full
# Small ios here because ext3 will account for indirect blocks too ...
# 48k will fit w/o indirect for 4k blocks (default blocksize)
$XFS_IO_PROG -F -c 'pwrite 0 48k' -c 'fsync' \
$SCRATCH_MNT/buffer >>$seq.full 2>&1 &
$XFS_IO_PROG -F -c 'pwrite 0 48k' -d \
$SCRATCH_MNT/direct >>$seq.full 2>&1 &
$XFS_IO_PROG -F -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
$SCRATCH_MNT/mmap >>$seq.full 2>&1 &
wait
echo "--- completed parallel IO ($type)" >>$seq.full
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
$here/src/lstat64 $file | head -2 | _filter_scratch
done
if [ $type == 'u' ]; then
id=$qa_user
else
id=$qa_group
fi
repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
}
# real QA test starts here
rm -f $seq.full
umount $SCRATCH_DEV 2>/dev/null
_scratch_mkfs >> $seq.full 2>&1
_scratch_mount "-o usrquota,grpquota"
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
quotaon $SCRATCH_MNT 2>/dev/null
umount $SCRATCH_DEV
echo; echo "### test user accounting"
export MOUNT_OPTIONS="-o usrquota"
_qmount
quotaon $SCRATCH_MNT 2>/dev/null
type=u
test_files
test_accounting
umount $SCRATCH_DEV 2>/dev/null
echo; echo "### test group accounting"
export MOUNT_OPTIONS="-o grpquota"
_qmount
quotaon $SCRATCH_MNT 2>/dev/null
type=g
test_files
test_accounting
umount $SCRATCH_DEV 2>/dev/null
status=0
exit