|
|
| File: [Development] / xfs-cmds / xfstests / dmapi / src / suite2 / bindir / test_allocinfo_2 (download)
Revision 1.6, Wed Nov 9 02:50:19 2005 UTC (11 years, 11 months ago) by nathans.longdrop.melbourne.sgi.com
Update copyright annotations and license boilerplates to correspond with SGI Legals preferences. Merge of master-melb:xfs-cmds:24329a by kenmcd. |
#!/bin/ksh
#
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
#
# Dump the same holey file a random number of times, each time
# using one less extent structure than the previous time.
# The grep and diff code checks to make sure that you get the
# same answer each time, no matter how many extents you use.
typeset -i offset
typeset -i length
typeset -i max
# Verify correct usage
if [[ $# != 2 ]]
then print "usage: ${0##*/} bindir testdir"
exit 1
fi
# Check bindir for needed programs.
if [[ ! ( -r "$1/wf" ) ]]
then print "Aborting: necessary program wf is not in $1/."
if [[ ! ( -r "$1/dump_allocinfo" ) ]]
then print " necessary program dump_allocinfo is also missing."
fi
exit 1
fi
if [[ ! ( -r "$1/dump_allocinfo" ) ]]
then print "Aborting: necessary program dump_allocinfo is not in $1/."
exit 1
fi
print "Multiple-buffer-sizes test of get_allocinfo beginning..."
RANDOM=$SECONDS
offset=0
length=$RANDOM
filename=DMAPI_alloc_test_2
((max = $RANDOM/256))
count=$max
# Holey file creation: put about $max holes into the file.
while (( count > 0 ))
do
$1/wf -l $length -L $offset -b 512 $2/$filename > /dev/null
(( offset = RANDOM * 512 + offset + length ))
(( length = RANDOM ))
(( count = count - 1 ))
done
count=$max
# Now count down from $max to 1 and try dump_allocinfo with a buffer that
# can hold that many dm_extent_t structures.
while [[ $count > 0 ]]
do
$1/dump_allocinfo -n $count $2/$filename | grep '\[' > $2/x.$count
if (( count < max ))
then diff $2/x.$count $2/x.$max > /dev/null
if [[ $? != 0 ]]
then print "ERROR in trial #$count:"
diff $2/x.$count $2/x.$max
fi
rm $2/x.$count
fi
(( count = count - 1 ))
done
rm $2/x.$max
rm $2/$filename
print "Test complete."