pv 955274 - Print out hex instead of char for non-printable characters.
[xfstests-dev.git] / 019
1 #! /bin/sh
2 # FS QA Test No. 019
3 #
4 # mkfs protofile test
5 #
6 #-----------------------------------------------------------------------
7 #  Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=dxm@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 seqfull="$seq.full"
19 status=1        # failure is the default!
20 # get standard environment, filters and checks
21 . ./common.rc
22 . ./common.filter
23
24 _cleanup()
25 {
26     echo "*** unmount"
27     umount $SCRATCH_MNT 2>/dev/null
28     rm -f $tmp.*
29 }
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 _full()
33 {
34     echo ""            >>$seqfull
35     echo "*** $* ***"  >>$seqfull
36     echo ""            >>$seqfull
37 }
38
39 _filter_stat()
40 {
41     sed '
42         /^Access:/d;
43         /^Modify:/d;
44         /^Change:/d;
45         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
46         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
47         s/Size: *[0-9][0-9]* *Filetype: Dir/Size: <DSIZE> Filetype: Dir/;
48     ' | tr -s ' '
49 }
50
51 # real QA test starts here
52 _supported_fs xfs
53 _supported_os IRIX Linux
54
55 _require_scratch
56
57 protofile=$tmp.proto
58 tempfile=$tmp.file
59
60 echo fish >$tempfile
61 $here/src/devzero -b 2048 -n 2 -c -v 44 $tempfile.2 
62
63 cat >$protofile <<EOF
64 DUMMY1
65 0 0
66 : root directory
67 d--777 3 1
68 : a directory
69 directory d--755 3 1 
70 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_0 ---755 3 1 $tempfile
71 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_1 ---755 3 1 $tempfile
72 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_2 ---755 3 1 $tempfile
73 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_3 ---755 3 1 $tempfile
74 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_4 ---755 3 1 $tempfile
75 $
76 : back in the root
77 setuid -u-666 0 0 $tempfile
78 setgid --g666 0 0 $tempfile
79 setugid -ug666 0 0 $tempfile
80 block_device b--012 3 1 161 162 
81 char_device c--345 3 1 177 178
82 pipe p--670 0 0
83 symlink l--123 0 0 bigfile
84 : a file we actually read
85 bigfile ---666 3 0 $tempfile.2
86 : done
87 $
88 EOF
89
90 if [ $? -ne 0 ]
91 then
92     _fail "failed to create test protofile"
93 fi
94
95 _verify_fs()
96 {
97         echo "*** create FS version $1"
98         VERSION="-n version=$1"
99
100         rm -f $seqfull
101         umount $SCRATCH_DEV >/dev/null 2>&1
102
103         _full "mkfs"
104         _scratch_mkfs_xfs $VERSION -p $protofile >>$seqfull 2>&1 \
105                 || _fail "mkfs failed"
106
107         echo "*** check FS"
108         _check_scratch_fs
109
110         echo "*** mount FS"
111         _full " mount"
112         _scratch_mount >>$seqfull 2>&1 \
113                 || _fail "mount failed"
114
115         echo "*** verify FS"
116         (cd $SCRATCH_MNT ; find . | LC_COLLATE=POSIX sort \
117                 | xargs $here/src/lstat64 | _filter_stat)
118         diff -q $SCRATCH_MNT/bigfile $tempfile.2 \
119                 || _fail "bigfile corrupted"
120     
121         echo "*** unmount FS"
122         _full "umount"
123         umount $SCRATCH_DEV >>$seqfull 2>&1 \
124                 || _fail "umount failed"
125             
126         echo "*** check FS"
127         _check_scratch_fs
128 }
129
130 #_verify_fs 1
131 _verify_fs 2
132
133 echo "*** done"
134 rm $seqfull
135 status=0
136 exit