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 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "== QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
45 . ./common/filter.btrfs
47 # real QA test starts here
49 # Modify as appropriate.
53 _require_scratch_dev_pool
57 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
58 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
59 TOTAL_DEVS=`echo $SCRATCH_DEV $SCRATCH_DEV_POOL | wc -w`
62 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
64 _scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
66 # These have to be done unmounted...?
67 echo "== Set filesystem label to $LABEL"
68 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV $LABEL
69 echo "== Get filesystem label"
70 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV
75 echo "== Show filesystem by label"
76 $BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
77 UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
79 echo "UUID $UUID" >> $seqres.full
81 echo "== Show filesystem by UUID"
82 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
84 echo "== Sync filesystem"
85 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT | _filter_scratch
87 echo "== Show device stats by mountpoint"
88 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_btrfs_device_stats $TOTAL_DEVS
89 echo "== Show device stats by first/scratch dev"
90 $BTRFS_UTIL_PROG device stats $SCRATCH_DEV | _filter_btrfs_device_stats
91 echo "== Show device stats by second dev"
92 $BTRFS_UTIL_PROG device stats $FIRST_POOL_DEV | sed -e "s,$FIRST_POOL_DEV,FIRST_POOL_DEV,g"
93 echo "== Show device stats by last dev"
94 $BTRFS_UTIL_PROG device stats $LAST_POOL_DEV | sed -e "s,$LAST_POOL_DEV,LAST_POOL_DEV,g"