6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003,2008 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
33 # get standard environment, filters and checks
37 # don't put fs images in /tmp
43 umount $SCRATCH_MNT 2>/dev/null
44 umount -d $imgs.loop 2>/dev/null
45 [ -d $imgs.loop ] && rmdir $imgs.loop
46 umount -d $imgs.source_dir 2>/dev/null
47 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
48 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
50 trap "_cleanup; exit \$status" 0 1 2 3 15
54 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
55 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
60 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
66 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
67 [ "$FAST_POPULATE" = true ] && return
68 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
69 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
70 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
80 [ $source = $SCRATCH_DEV ] && _scratch_mount
82 echo checking new image
83 _check_xfs_filesystem $target none none
85 echo mounting new image on loopback
86 rmdir $target_dir 2>/dev/null
89 mount -t xfs -o loop $target $target_dir 2>/dev/null
91 echo retrying mount with nouuid option
92 mount -t xfs -o loop -o nouuid $target $target_dir
94 echo mount failed - evil!
99 echo comparing new image files to old
100 diff -Naur $source_dir $target_dir
102 echo comparing new image directories to old
103 find $source_dir | _filter_path $source_dir > $tmp.manifest1
104 find $target_dir | _filter_path $target_dir > $tmp.manifest2
105 [ -s $tmp.manifest1 ] || echo no directory output
106 diff -u $tmp.manifest1 $tmp.manifest2
108 echo comparing new image geometry to old
109 xfs_info $source_dir \
110 | _filter_copy $source $source_dir '/dev/loop.' '#' \
113 xfs_info $target_dir \
114 | _filter_copy $target $target_dir '/dev/loop.' '#' \
117 [ -s $tmp.geometry1 ] || echo no geometry output
118 diff -u $tmp.geometry1 $tmp.geometry2
120 echo unmounting and removing new image
122 umount -d $target_dir > /dev/null 2>&1
126 # real QA test starts here
130 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
131 [ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
138 _scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
139 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
142 echo === populating scratch device
144 umount $SCRATCH_MNT 2>/dev/null
147 echo === copying scratch device to single target
148 $XFS_COPY_PROG $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
149 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
152 echo === copying scratch device to single target, duplicate UUID
153 $XFS_COPY_PROG -d $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
154 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
157 echo === copying scratch device to single target, large ro device
158 ${MKFS_XFS_PROG} -dfile,name=$imgs.source,size=100g | _filter_mkfs 2>/dev/null
159 rmdir $imgs.source_dir 2>/dev/null
160 mkdir $imgs.source_dir
162 mount -t xfs -o loop $imgs.source $imgs.source_dir
163 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
164 cp -a $here $imgs.source_dir
165 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
166 $XFS_COPY_PROG $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
167 _verify_copy $imgs.image $imgs.source $imgs.source_dir
171 # We're done with the nested loop mount, now we have to clean
172 # up the pieces that mount is incapable of doing.
173 losetup -d $loop2 > /dev/null 2>&1
176 echo === copying scratch device to multiple targets
177 $XFS_COPY_PROG -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
178 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
179 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
180 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT