xfs: add a _require_xfs_copy helper
[xfstests-dev.git] / tests / xfs / 503
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 503
6 #
7 # Populate a XFS filesystem and ensure that metadump, mdrestore, and copy
8 # all work properly.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.* $testdir
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/populate
29
30 testdir=$TEST_DIR/test-$seq
31
32 # real QA test starts here
33 _supported_os Linux
34 _supported_fs xfs
35
36 _require_xfs_copy
37 _require_scratch_nocheck
38 _require_populate_commands
39
40 echo "Format and populate"
41 _scratch_populate_cached nofill > $seqres.full 2>&1
42
43 mkdir -p $testdir
44 metadump_file=$testdir/scratch.md
45 metadump_file_a=${metadump_file}.a
46 metadump_file_g=${metadump_file}.g
47 metadump_file_ag=${metadump_file}.ag
48 copy_file=$testdir/copy.img
49
50 echo metadump
51 _scratch_metadump $metadump_file >> $seqres.full
52
53 echo metadump a
54 _scratch_metadump $metadump_file_a -a >> $seqres.full
55
56 echo metadump g
57 _scratch_metadump $metadump_file_g -g >> $seqres.full
58
59 echo metadump ag
60 _scratch_metadump $metadump_file_ag -a -g >> $seqres.full
61
62 echo copy
63 $XFS_COPY_PROG $SCRATCH_DEV $copy_file >> $seqres.full
64 _check_scratch_fs $copy_file
65
66 echo recopy
67 $XFS_COPY_PROG $copy_file $SCRATCH_DEV >> $seqres.full
68 _scratch_mount
69 _check_scratch_fs
70 _scratch_unmount
71
72 echo mdrestore
73 xfs_mdrestore $metadump_file $SCRATCH_DEV
74 _scratch_mount
75 _check_scratch_fs
76 _scratch_unmount
77
78 echo mdrestore a
79 xfs_mdrestore $metadump_file_a $SCRATCH_DEV
80 _scratch_mount
81 _check_scratch_fs
82 _scratch_unmount
83
84 echo mdrestore g
85 xfs_mdrestore $metadump_file_g $SCRATCH_DEV
86 _scratch_mount
87 _check_scratch_fs
88 _scratch_unmount
89
90 echo mdrestore ag
91 xfs_mdrestore $metadump_file_ag $SCRATCH_DEV
92 _scratch_mount
93 _check_scratch_fs
94 _scratch_unmount
95
96 # success, all done
97 status=0
98 exit