xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / btrfs / 307
1 #! /bin/bash
2 # FS QA Test No. 307
3 #
4 # run basic btrfs information commands in various ways
5 # sanity tests: filesystem show, label, sync, and device stats
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
9 #
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.
13 #
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.
18 #
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 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
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"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     cd /
40     rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common.rc
45 . ./btrfs.filter
46
47 # real QA test starts here
48
49 # Modify as appropriate.
50 _supported_fs btrfs
51 _supported_os Linux
52 _require_scratch
53 _require_scratch_dev_pool
54
55 rm -f $seqres.full
56
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`
60 LABEL=TestLabel.$seq
61
62 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
63
64 _scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
65
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
71
72 echo "== Mount."
73 _scratch_mount
74
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}'`
78
79 echo "UUID $UUID" >> $seqres.full
80
81 echo "== Show filesystem by UUID"
82 $BTRFS_UTIL_PROG filesystem show $UUID | _filter_btrfs_filesystem_show $TOTAL_DEVS $UUID
83
84 echo "== Sync filesystem"
85 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT | _filter_scratch
86
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"
95
96 # success, all done
97 status=0
98 exit