xfstests: remove stale machine configs
[xfstests-dev.git] / 021
1 #! /bin/bash
2 # FS QA Test No. 021
3 #
4 # xfs_db type attr test (pv 797508 linux-xfs & IRIX)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=0        # success is the default!
31 # get standard environment, filters and checks
32 . ./common.rc
33 . ./common.filter
34 . ./common.attr
35
36 _cleanup()
37 {
38         echo "*** unmount"
39         umount $SCRATCH_MNT 2>/dev/null
40         rm -f $tmp.*
41 }
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 _attr()
45 {
46         ${ATTR_PROG} $* 2>$tmp.err >$tmp.out
47         exit=$?
48         sed \
49             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
50             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
51                 $tmp.out
52         sed \
53             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
54             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
55                 $tmp.err 1>&2
56         return $exit
57 }
58
59 _getfattr()
60 {
61         ${GETFATTR_PROG} $* 2>$tmp.err >$tmp.out
62         exit=$?
63         sed \
64             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
65             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
66                 $tmp.out
67         sed \
68             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
69             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
70                 $tmp.err 1>&2
71         return $exit
72 }
73
74 # real QA test starts here
75 _supported_fs xfs
76 _supported_os Linux
77
78 _require_scratch
79 _require_attrs
80
81 rm -f $seq.full
82 umount $SCRATCH_DEV >/dev/null 2>&1
83
84 echo "*** mkfs"
85 _scratch_mkfs_xfs >/dev/null \
86         || _fail "mkfs failed"
87
88 echo "*** mount FS"
89 _scratch_mount >/dev/null \
90         || _fail "mount failed"
91
92 testfile=$SCRATCH_MNT/testfile
93 echo "*** make test file 1"
94
95 touch $testfile.1
96 echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
97 echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
98 _getfattr --absolute-names $testfile.1
99 inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
100
101 echo "*** make test file 2"
102
103 touch $testfile.2
104 echo "value_1" | _attr -s "a1" $testfile.2 >/dev/null
105 echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
106 ( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
107         | _attr -s "a3" $testfile.2 >/dev/null
108 _getfattr --absolute-names $testfile.2
109
110 # print name and size from 1st line of output
111 _attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
112 head -1 $tmp.hahahahaplonk
113 # NOTE:
114 # Above goo works around some truly bizzaro sh/sed/head interaction
115 # for some versions of these tools (fails on Redhat 7+, 6.2 worked)
116
117 # print out the rest of the data apart from the header
118 # the size is +1 for an extra \n at the end
119 echo -n "size of attr value = "
120 # wc inserts different amounts of whitespace in front...
121 _attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//"
122 echo ""
123
124 inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
125
126 echo "*** unmount FS"
127 umount $SCRATCH_DEV >>$seq.full 2>&1 \
128         || _fail "umount failed"
129
130 echo "*** dump attributes (1)"
131
132 xfs_db -r -c "inode $inum_1" -c "print a.sfattr" $SCRATCH_DEV | \
133         sed -e '/secure = /d' | sed -e '/parent = /d'
134
135 echo "*** dump attributes (2)"
136
137 xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print $SCRATCH_DEV \
138         | perl -ne '
139 s/,secure//;
140 s/,parent//;
141 s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/;
142 s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/;
143 s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/;
144         print;'
145
146 echo "*** done"
147 exit