4 # run basic btrfs information commands in various ways
5 # sanity tests: filesystem show, label, sync, and device stats
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
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.
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.
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 #-----------------------------------------------------------------------
25 owner=sandeen@redhat.com
28 echo "== QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
45 # real QA test starts here
47 # Modify as appropriate.
51 _require_scratch_dev_pool
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`
60 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seq.full
62 _scratch_mkfs $SCRATCH_DEV_POOL >> $seq.full 2>&1 || _fail "mkfs failed"
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
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}'`
77 echo "UUID $UUID" >> $seq.full
79 echo "== Show filesystem by UUID"
80 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
82 echo "== Sync filesystem"
83 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT | _filter_scratch
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"