xfstests: remove stale machine configs
[xfstests-dev.git] / common.filter.btrfs
1 # Filters for btrfs command output
2
3 . ./common.filter.btrfs
4
5 # Some, but not all, commands emit "Btrfs <version>"
6 _filter_btrfs_version()
7 {
8         sed -e "s/^Btrfs.*//g"
9 }
10
11 _filter_devid()
12 {
13         sed -e "s/\(devid\s\+\)[0-9]\+/\1 <DEVID>/g"
14 }
15
16 # If passed a number as first arg, filter that number of devices
17 # If passed a UUID as second arg, filter that exact UUID
18 _filter_btrfs_filesystem_show()
19 {
20         if [ ! -z $1 ]; then
21                 NUMDEVS=$1
22                 NUM_SUBST="<EXACTNUM>"
23         else
24                 NUMDEVS="[0-9]\+"
25                 NUM_SUBST="<NUM>"
26         fi
27
28         UUID=""
29         if [ ! -z $2 ]; then
30                 UUID=$2
31         fi
32
33         # the uniq collapses all device lines into 1
34         _filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
35         _filter_size | _filter_btrfs_version | _filter_devid | \
36         sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
37         uniq
38 }
39
40 # This eliminates all numbers, and shows only unique lines,
41 # to accomodate a varying nr. of devices.
42 # If given an argument, make sure we saw that many devices
43 # in total.
44 _filter_btrfs_device_stats()
45 {
46         if [ ! -z $1 ]; then
47                 NUMDEVS=$1
48                 UNIQ_OPT="-c"
49         else
50                 NUMDEVS="thiswillnotmatch"
51                 UNIQ_OPT=""
52         fi
53
54         _filter_scratch | _filter_scratch_pool | \
55         sed -e "s/[0-9]\+$/<NUM>/g" | sort | uniq $UNIQ_OPT | \
56         sed -e "s/$NUMDEVS /<NUMDEVS> /g"
57 }
58
59 # make sure this script returns success
60 /bin/true