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
38 # don't put fs images in /tmp
44 _scratch_unmount 2>/dev/null
45 umount $imgs.loop 2>/dev/null
46 [ -d $imgs.loop ] && rmdir $imgs.loop
47 umount $imgs.source_dir 2>/dev/null
48 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
49 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
51 trap "_cleanup; exit \$status" 0 1 2 3 15
55 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
56 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
61 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
67 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
68 [ "$FAST_POPULATE" = true ] && return
69 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
70 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
71 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
81 [ $source = $SCRATCH_DEV ] && _scratch_mount
83 echo checking new image
84 _check_xfs_filesystem $target none none
86 echo mounting new image on loopback
87 rmdir $target_dir 2>/dev/null
90 mount -t xfs -o loop $target $target_dir 2>/dev/null
92 echo retrying mount with nouuid option >>$seqres.full
93 mount -t xfs -o loop -o nouuid $target $target_dir
95 echo mount failed - evil!
100 echo comparing new image files to old
101 diff -Naur $source_dir $target_dir
103 echo comparing new image directories to old
104 find $source_dir | _filter_path $source_dir > $tmp.manifest1
105 find $target_dir | _filter_path $target_dir > $tmp.manifest2
106 [ -s $tmp.manifest1 ] || echo no directory output
107 diff -u $tmp.manifest1 $tmp.manifest2
109 echo comparing new image geometry to old
110 xfs_info $source_dir \
111 | _filter_copy $source $source_dir '/dev/loop.' '#' \
114 xfs_info $target_dir \
115 | _filter_copy $target $target_dir '/dev/loop.' '#' \
118 [ -s $tmp.geometry1 ] || echo no geometry output
119 diff -u $tmp.geometry1 $tmp.geometry2
121 echo unmounting and removing new image
123 umount $target_dir > /dev/null 2>&1
127 # real QA test starts here
133 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
134 [ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
141 _scratch_mkfs_xfs -dsize=41m,agcount=2 >>$seqres.full 2>&1
142 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
145 echo === populating scratch device
147 _scratch_unmount 2>/dev/null
150 echo === copying scratch device to single target
151 $XFS_COPY_PROG $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
152 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
155 echo === copying scratch device to single target, duplicate UUID
156 $XFS_COPY_PROG -d $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
157 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
160 echo === copying scratch device to single target, large ro device
161 ${MKFS_XFS_PROG} -dfile,name=$imgs.source,size=100g \
162 | _filter_mkfs 2>/dev/null
163 rmdir $imgs.source_dir 2>/dev/null
164 mkdir $imgs.source_dir
166 mount -t xfs -o loop $imgs.source $imgs.source_dir
167 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
168 cp -a $here $imgs.source_dir
169 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
170 $XFS_COPY_PROG $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
171 _verify_copy $imgs.image $imgs.source $imgs.source_dir
175 # We're done with the nested loop mount, now we have to clean
176 # up the pieces that mount is incapable of doing.
177 losetup -d $loop2 > /dev/null 2>&1
180 echo === copying scratch device to multiple targets
181 $XFS_COPY_PROG -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
182 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
183 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
184 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT