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 #-----------------------------------------------------------------------
26 echo "== QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
43 # real QA test starts here
45 # Modify as appropriate.
49 _require_scratch_dev_pool
53 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
54 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
55 TOTAL_DEVS=`echo $SCRATCH_DEV $SCRATCH_DEV_POOL | wc -w`
58 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seq.full
60 _scratch_mkfs $SCRATCH_DEV_POOL >> $seq.full 2>&1 || _fail "mkfs failed"
62 # These have to be done unmounted...?
63 echo "== Set filesystem label to $LABEL"
64 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV $LABEL
65 echo "== Get filesystem label"
66 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV
71 echo "== Show filesystem by label"
72 $BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
73 UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
75 echo "UUID $UUID" >> $seq.full
77 echo "== Show filesystem by UUID"
78 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
80 echo "== Sync filesystem"
81 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT | _filter_scratch
83 echo "== Show device stats by mountpoint"
84 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_btrfs_device_stats $TOTAL_DEVS
85 echo "== Show device stats by first/scratch dev"
86 $BTRFS_UTIL_PROG device stats $SCRATCH_DEV | _filter_btrfs_device_stats
87 echo "== Show device stats by second dev"
88 $BTRFS_UTIL_PROG device stats $FIRST_POOL_DEV | sed -e "s,$FIRST_POOL_DEV,FIRST_POOL_DEV,g"
89 echo "== Show device stats by last dev"
90 $BTRFS_UTIL_PROG device stats $LAST_POOL_DEV | sed -e "s,$LAST_POOL_DEV,LAST_POOL_DEV,g"