[BACK]Return to 073 CVS log [TXT][DIR] Up to [Development] / xfs-cmds / xfstests

File: [Development] / xfs-cmds / xfstests / 073 (download)

Revision 1.4, Tue Jun 15 07:32:36 2004 UTC (13 years, 4 months ago) by ptools
Branch: MAIN
Changes since 1.3: +8 -3 lines

Fixed merge problems
 


#! /bin/sh
# FS QA Test No. 073
#
# Test xfs_copy
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 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.
# 
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like.  Any license provided herein, whether implied or
# otherwise, applies only to this software file.  Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
# 
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
# Mountain View, CA  94043, or:
# 
# http://www.sgi.com 
# 
# For further information regarding this notice, see: 
# 
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
#-----------------------------------------------------------------------
#
# creator
owner=nathans@sgi.com

seq=`basename $0`
echo "QA output created by $seq"

here=`pwd`
tmp=/tmp/$$
status=1	# failure is the default!
_cleanup()
{
	cd /
	umount $SCRATCH_MNT 2>/dev/null
	umount $tmp.loop 2>/dev/null
	[ -d $tmp.loop ] && rmdir $tmp.loop
	[ -d $tmp.source_dir ] && rmdir $tmp.source_dir
	rm -f $tmp.* /var/tmp/xfs_copy.log.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15

_filter_copy()
{
	sed -e "s,$1,<FSIMAGE1>,g" -e "s,$2,<FSIMAGE2>,g"
}

_populate_scratch()
{
	POSIXLY_CORRECT=yes \
		dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
	[ "$FAST_POPULATE" = true ] && return
	echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
	$here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
		--dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
}

_verify_copy()
{
	target=$1
	target_dir=$tmp.loop
	source=$2
	source_dir=$3

	[ $source = $SCRATCH_DEV ] && _scratch_mount

	echo checking new image
	_check_xfs_filesystem $target

	echo mounting new image on loopback
	rmdir $target_dir 2>/dev/null
	mkdir $target_dir
	mount -t xfs -o loop $target $target_dir 2>/dev/null
	if [ $? -ne 0 ]; then
		echo retrying mount with nouuid option
		mount -t xfs -o loop -o nouuid $target $target_dir
		if [ $? -ne 0 ]; then
			echo mount failed - evil!
			return
		fi
	fi

	echo comparing new image files to old
	diff -Naur $source_dir $target_dir

	echo comparing new image directories to old
	find $source_dir \
		| _filter_copy $source_dir '#' \
		| LC_COLLATE=POSIX sort \
		> $tmp.manifest1
	find $target_dir \
		| _filter_copy $target_dir '#' \
		| LC_COLLATE=POSIX sort \
		> $tmp.manifest2
	[ -s $tmp.manifest1 ] || echo no directory output
	diff -u $tmp.manifest1 $tmp.manifest2

	echo comparing new image geometry to old
	xfs_info $source_dir \
		| _filter_copy $source_dir '#' \
		| tr -s ' ' \
		> $tmp.geometry1
	xfs_info $target_dir \
		| _filter_copy $target_dir '#' \
		| tr -s ' ' \
		> $tmp.geometry2
	[ -s $tmp.geometry1 ] || echo no geometry output
	diff -u $tmp.geometry1 $tmp.geometry2

	echo unmounting and removing new image
	umount $source $target
	rm -f $target
}

# get standard environment, filters and checks
. ./common.rc
. ./common.filter


# real QA test starts here
_supported_fs xfs
_supported_os Linux

[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
[ -x /usr/sbin/xfs_copy ] || _notrun "xfs_copy binary not yet installed"

_require_scratch
_require_loop

_scratch_mkfs_xfs -dsize=41m | _filter_mkfs 2>/dev/null
_scratch_mount 2>/dev/null || _fail "initial scratch mount failed"

echo
echo === populating scratch device
_populate_scratch
umount $SCRATCH_MNT 2>/dev/null

echo
echo === copying scratch device to single target
xfs_copy $SCRATCH_DEV $tmp.image | _filter_copy $tmp.image
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT

echo
echo === copying scratch device to single target, duplicate UUID
xfs_copy -d $SCRATCH_DEV $tmp.image | _filter_copy $tmp.image
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT

echo 
echo === copying scratch device to single target, large ro device
/sbin/mkfs.xfs -dfile,name=$tmp.source,size=100g | _filter_mkfs 2>/dev/null
rmdir $tmp.source_dir 2>/dev/null
mkdir $tmp.source_dir
mount -t xfs -o loop $tmp.source $tmp.source_dir
cp -a $here $tmp.source_dir
mount -t xfs -o remount,ro $tmp.source $tmp.source_dir
xfs_copy $tmp.source $tmp.image | _filter_copy $tmp.image
_verify_copy $tmp.image $tmp.source $tmp.source_dir

echo
echo === copying scratch device to multiple targets
xfs_copy -L$tmp.log -b $SCRATCH_DEV $tmp.image1 $tmp.image2 \
	| _filter_copy $tmp.image1 $tmp.image2
_verify_copy $tmp.image1 $SCRATCH_DEV $SCRATCH_MNT
_verify_copy $tmp.image2 $SCRATCH_DEV $SCRATCH_MNT

# success, all done
status=0
exit