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.
35 _require_scratch_dev_pool
39 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
40 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
41 TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
44 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
46 _scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
48 # These have to be done unmounted...?
49 echo "== Set filesystem label to $LABEL"
50 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV $LABEL
51 echo "== Get filesystem label"
52 $BTRFS_UTIL_PROG filesystem label $SCRATCH_DEV
57 echo "== Show filesystem by label"
58 $BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
59 UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
61 echo "UUID $UUID" >> $seqres.full
63 echo "== Show filesystem by UUID"
64 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
66 echo "== Sync filesystem"
67 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT > /dev/null
69 echo "== Show device stats by mountpoint"
70 $BTRFS_UTIL_PROG device stats $SCRATCH_MNT | \
71 _filter_btrfs_device_stats $TOTAL_DEVS | \
73 echo "== Show device stats by first/scratch dev"
74 $BTRFS_UTIL_PROG device stats $SCRATCH_DEV | \
75 _filter_btrfs_device_stats | \
77 echo "== Show device stats by second dev"
78 $BTRFS_UTIL_PROG device stats $FIRST_POOL_DEV | \
79 sed -e "s,$FIRST_POOL_DEV,FIRST_POOL_DEV,g" | \
81 echo "== Show device stats by last dev"
82 $BTRFS_UTIL_PROG device stats $LAST_POOL_DEV | \
83 sed -e "s,$LAST_POOL_DEV,LAST_POOL_DEV,g" | \