xfstests: rename USE_BIG_LOOPFS to be more generic
[xfstests-dev.git] / 307
1 #! /bin/bash
2 # FS QA Test No. 307
3 #
4 # run basic btrfs information commands in various ways
5 # sanity tests: filesystem show, label, sync, and device stats
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2013 Red Hat, Inc.  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 # creator
25 owner=sandeen@redhat.com
26
27 seq=`basename $0`
28 echo "== QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./btrfs.filter
44
45 # real QA test starts here
46
47 # Modify as appropriate.
48 _supported_fs btrfs
49 _supported_os Linux
50 _require_scratch
51 _require_scratch_dev_pool
52
53 rm -f $seq.full
54
55 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
56 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
57 TOTAL_DEVS=`echo $SCRATCH_DEV $SCRATCH_DEV_POOL | wc -w`
58 LABEL=TestLabel.$seq
59
60 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seq.full
61
62 _scratch_mkfs $SCRATCH_DEV_POOL >> $seq.full 2>&1 || _fail "mkfs failed"
63
64 # These have to be done unmounted...?
65 echo "== Set filesystem label to $LABEL"
66 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV $LABEL
67 echo "== Get filesystem label"
68 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV
69
70 echo "== Mount."
71 _scratch_mount
72
73 echo "== Show filesystem by label"
74 $BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
75 UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
76
77 echo "UUID $UUID" >> $seq.full
78
79 echo "== Show filesystem by UUID"
80 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
81
82 echo "== Sync filesystem"
83 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT | _filter_scratch
84
85 echo "== Show device stats by mountpoint"
86 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_btrfs_device_stats $TOTAL_DEVS
87 echo "== Show device stats by first/scratch dev"
88 $BTRFS_UTIL_PROG device stats $SCRATCH_DEV | _filter_btrfs_device_stats
89 echo "== Show device stats by second dev"
90 $BTRFS_UTIL_PROG device stats $FIRST_POOL_DEV | sed -e "s,$FIRST_POOL_DEV,FIRST_POOL_DEV,g"
91 echo "== Show device stats by last dev"
92 $BTRFS_UTIL_PROG device stats $LAST_POOL_DEV | sed -e "s,$LAST_POOL_DEV,LAST_POOL_DEV,g"
93
94 # success, all done
95 status=0
96 exit