xfs/419: remove irrelevant swapfile test
[xfstests-dev.git] / tests / xfs / 149
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 149
6 #
7 # Test to ensure xfs_growfs command accepts device nodes if & only
8 # if they are mounted.
9 # This functionality, though undocumented, worked until xfsprogs v4.12
10 # It was added back and documented after xfsprogs v5.2 via
11 #   7e8275f8 xfs_growfs: allow mounted device node as argument
12 #
13 # Based on xfs/289
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 loopfile=$TEST_DIR/fsfile
25 mntdir=$TEST_DIR/mntdir
26 loop_symlink=$TEST_DIR/loop_symlink.$$
27
28 _cleanup()
29 {
30     $UMOUNT_PROG $mntdir
31     [ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
32     rmdir $mntdir
33     rm -f $loop_symlink
34     rm -f $loopfile
35 }
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40
41 # remove previous $seqres.full before test
42 rm -f $seqres.full
43
44 # real QA test starts here
45
46 # Modify as appropriate.
47 _supported_fs xfs
48 _require_test
49 _require_loop
50
51 mkdir -p $mntdir || _fail "!!! failed to create temp mount dir"
52
53 echo "=== mkfs.xfs ==="
54 $MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1
55
56 echo "=== truncate ==="
57 $XFS_IO_PROG -fc "truncate 256m" $loopfile
58
59 echo "=== create loop device ==="
60 loop_dev=$(_create_loop_device $loopfile)
61
62 echo "=== create loop device symlink ==="
63 ln -s $loop_dev $loop_symlink
64
65 echo "loop device is $loop_dev" >> $seqres.full
66
67 # These unmounted operations should fail
68
69 echo "=== xfs_growfs - unmounted device, command should be rejected ==="
70 $XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV:
71
72 echo "=== xfs_growfs - check symlinked dev, unmounted ==="
73 $XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK:
74
75 # These mounted operations should pass
76
77 echo "=== mount ==="
78 $MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount"
79
80 echo "=== xfs_growfs - check device node ==="
81 $XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null
82
83 echo "=== xfs_growfs - check device symlink ==="
84 $XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null
85
86 echo "=== unmount ==="
87 $UMOUNT_PROG $mntdir || _fail "!!! failed to unmount"
88
89 echo "=== mount device symlink ==="
90 $MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount"
91
92 echo "=== xfs_growfs - check device symlink ==="
93 $XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null
94
95 echo "=== xfs_growfs - check device node ==="
96 $XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null
97
98 # success, all done
99 status=0
100 exit