xfs/realtime: Add require_no_realtime function
[xfstests-dev.git] / tests / xfs / 284
1 #! /bin/bash
2 # FS QA Test 284
3 #
4 # Do xfs_metadump, xfs_mdrestore, xfs_copy, xfs_db, xfs_repair and mkfs.xfs
5 # on mounted XFS to make sure they refuse to proceed.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Red Hat.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36         cd /
37         rm -f $tmp.*
38         rm -f $METADUMP_FILE 2>/dev/null
39         rm -f $COPY_FILE 2>/dev/null
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 # real QA test starts here
50 _supported_fs xfs
51 _supported_os Linux
52 # xfs_copy does not support realtime devices
53 _require_no_realtime
54 _require_test
55 _require_scratch
56
57 function filter_mounted()
58 {
59         grep "mounted" | _filter_scratch | head -1
60 }
61
62 METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
63 COPY_FILE="${TEST_DIR}/${seq}_copyfile"
64
65 # Test dump a mounted device
66 # xfs_metadump should refuse to dump a mounted device
67 _scratch_mount
68 _scratch_metadump $METADUMP_FILE 2>&1 | filter_mounted
69 _scratch_unmount
70
71 # Test restore to a mounted device
72 # xfs_mdrestore should refuse to restore to a mounted device
73 _scratch_metadump $METADUMP_FILE
74 _scratch_mount
75 xfs_mdrestore $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
76 _scratch_unmount
77
78 # Test xfs_copy to a mounted device
79 # If source is mounted, xfs_copy will print a warning, but still
80 # keep on copying. If target is mounted, xfs_copy should fail.
81 $XFS_COPY_PROG $SCRATCH_DEV $COPY_FILE >/dev/null
82 _scratch_mount
83 $XFS_COPY_PROG $COPY_FILE $SCRATCH_DEV 2>&1 | filter_mounted
84 _scratch_unmount
85
86 # Test xfs_db a mounted device
87 # xfs_db a mounted device without readonly (-r) option should fail
88 _scratch_mount
89 $XFS_DB_PROG -c sb $SCRATCH_DEV 2>&1 | filter_mounted
90 _scratch_unmount
91
92 # Test mkfs.xfs a mounted device
93 # Generally mkfs will report device is mounted, but if it can't find
94 # device is mounted, it'll report device busy.
95 _scratch_mount
96 _scratch_mkfs 2>&1 | filter_mounted
97 _scratch_unmount
98
99 # Test xfs_repair (with/without modify flag) a mounted device
100 # xfs_repair (with/without modify flag) a mounted device should fail(don't
101 # test -d option at here)
102 _scratch_mount
103 _scratch_xfs_repair -n 2>&1 | filter_mounted
104 _scratch_xfs_repair 2>&1 | filter_mounted
105 _scratch_unmount
106
107 # success, all done
108 status=0
109 exit