xfs/029: filter out "extended-header: cycle: 1" from output
[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 _supported_os Linux
49 _require_test
50 _require_loop
51
52 mkdir -p $mntdir || _fail "!!! failed to create temp mount dir"
53
54 echo "=== mkfs.xfs ==="
55 $MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1
56
57 echo "=== truncate ==="
58 $XFS_IO_PROG -fc "truncate 256m" $loopfile
59
60 echo "=== create loop device ==="
61 loop_dev=$(_create_loop_device $loopfile)
62
63 echo "=== create loop device symlink ==="
64 ln -s $loop_dev $loop_symlink
65
66 echo "loop device is $loop_dev" >> $seqres.full
67
68 # These unmounted operations should fail
69
70 echo "=== xfs_growfs - unmounted device, command should be rejected ==="
71 $XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV:
72
73 echo "=== xfs_growfs - check symlinked dev, unmounted ==="
74 $XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK:
75
76 # These mounted operations should pass
77
78 echo "=== mount ==="
79 $MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount"
80
81 echo "=== xfs_growfs - check device node ==="
82 $XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null
83
84 echo "=== xfs_growfs - check device symlink ==="
85 $XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null
86
87 echo "=== unmount ==="
88 $UMOUNT_PROG $mntdir || _fail "!!! failed to unmount"
89
90 echo "=== mount device symlink ==="
91 $MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount"
92
93 echo "=== xfs_growfs - check device symlink ==="
94 $XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null
95
96 echo "=== xfs_growfs - check device node ==="
97 $XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null
98
99 # success, all done
100 status=0
101 exit