2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
5 # FS QA Test No. btrfs/006
7 # run basic btrfs information commands in various ways
8 # sanity tests: filesystem show, label, sync, and device stats
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
27 . ./common/filter.btrfs
29 # real QA test starts here
31 # Modify as appropriate.
34 _require_scratch_dev_pool
38 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
39 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
40 TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
43 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
45 _scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
47 # These have to be done unmounted...?
48 echo "== Set filesystem label to $LABEL"
49 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV $LABEL
50 echo "== Get filesystem label"
51 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV
56 echo "== Show filesystem by label"
57 $BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
58 UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
60 echo "UUID $UUID" >> $seqres.full
62 echo "== Show filesystem by UUID"
63 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
65 echo "== Sync filesystem"
66 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT > /dev/null
68 echo "== Show device stats by mountpoint"
69 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | \
70 _filter_btrfs_device_stats $TOTAL_DEVS | \
72 echo "== Show device stats by first/scratch dev"
73 $BTRFS_UTIL_PROG device stats $SCRATCH_DEV | \
74 _filter_btrfs_device_stats | \
76 echo "== Show device stats by second dev"
77 $BTRFS_UTIL_PROG device stats $FIRST_POOL_DEV | \
78 sed -e "s,$FIRST_POOL_DEV,FIRST_POOL_DEV,g" | \
80 echo "== Show device stats by last dev"
81 $BTRFS_UTIL_PROG device stats $LAST_POOL_DEV | \
82 sed -e "s,$LAST_POOL_DEV,LAST_POOL_DEV,g" | \