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 echo "QA output created by $seq"
30 status=1 # failure is the default!
32 # get standard environment, filters and checks
36 # don't put fs images in /tmp
42 umount $SCRATCH_MNT 2>/dev/null
43 umount -d $imgs.loop 2>/dev/null
44 [ -d $imgs.loop ] && rmdir $imgs.loop
45 umount -d $imgs.source_dir 2>/dev/null
46 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
47 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
49 trap "_cleanup; exit \$status" 0 1 2 3 15
53 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
54 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
59 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
65 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
66 [ "$FAST_POPULATE" = true ] && return
67 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
68 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
69 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
79 [ $source = $SCRATCH_DEV ] && _scratch_mount
81 echo checking new image
82 _check_xfs_filesystem $target none none
84 echo mounting new image on loopback
85 rmdir $target_dir 2>/dev/null
88 mount -t xfs -o loop $target $target_dir 2>/dev/null
90 echo retrying mount with nouuid option
91 mount -t xfs -o loop -o nouuid $target $target_dir
93 echo mount failed - evil!
98 echo comparing new image files to old
99 diff -Naur $source_dir $target_dir
101 echo comparing new image directories to old
102 find $source_dir | _filter_path $source_dir > $tmp.manifest1
103 find $target_dir | _filter_path $target_dir > $tmp.manifest2
104 [ -s $tmp.manifest1 ] || echo no directory output
105 diff -u $tmp.manifest1 $tmp.manifest2
107 echo comparing new image geometry to old
108 xfs_info $source_dir \
109 | _filter_copy $source $source_dir '/dev/loop.' '#' \
112 xfs_info $target_dir \
113 | _filter_copy $target $target_dir '/dev/loop.' '#' \
116 [ -s $tmp.geometry1 ] || echo no geometry output
117 diff -u $tmp.geometry1 $tmp.geometry2
119 echo unmounting and removing new image
121 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"
136 _scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
137 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
140 echo === populating scratch device
142 umount $SCRATCH_MNT 2>/dev/null
145 echo === copying scratch device to single target
146 $XFS_COPY_PROG $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
147 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
150 echo === copying scratch device to single target, duplicate UUID
151 $XFS_COPY_PROG -d $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, large ro device
156 ${MKFS_PROG}.xfs -dfile,name=$imgs.source,size=100g | _filter_mkfs 2>/dev/null
157 rmdir $imgs.source_dir 2>/dev/null
158 mkdir $imgs.source_dir
160 mount -t xfs -o loop $imgs.source $imgs.source_dir
161 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
162 cp -a $here $imgs.source_dir
163 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
164 $XFS_COPY_PROG $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
165 _verify_copy $imgs.image $imgs.source $imgs.source_dir
169 # We're done with the nested loop mount, now we have to clean
170 # up the pieces that mount is incapable of doing.
171 losetup -d $loop2 > /dev/null 2>&1
174 echo === copying scratch device to multiple targets
175 $XFS_COPY_PROG -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
176 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
177 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
178 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT