make vfs & filesystems use failable copying
[minix3.git] / test / testmfs.sh
blobc118276e4d936c31757174c5b525a872bd035c9f
1 #!/bin/sh
3 # expected sha1sum of the FS image
4 expect=55d61f457204c206628c848771a1f9d75cfa3afa
6 set -e
8 # ownership matters for the proto file.
9 # the run script runs us with uid 2, gid 0.
10 if [ "`id -u`" != 2 -o "`id -g`" != 0 ]
11 then
12 echo "test script should be run with uid 2, gid 0."
13 exit 1
16 echo -n "mfs test "
18 testdir=fstest
19 protofile=proto
20 fsimage=fsimage
21 rm -rf $testdir $protofile $fsimage
23 if [ -d $testdir ]
24 then
25 echo "dir?"
26 exit 1
29 mkdir -p $testdir $testdir/contents $testdir/modes
31 if [ ! -d $testdir ]
32 then
33 echo "no dir?"
34 exit 1
37 # Make some small & big & bigger files
39 prevf=$testdir/contents/file
40 echo "Test contents 123" >$prevf
41 for double in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
42 do fn=$testdir/contents/fn.$double
43 cat $prevf $prevf >$fn
44 prevf=$fn
45 done
47 # Make some files with various modes & mtimes
49 for many in 0 1 2 3 4 5 6 7 8 9
50 do for m1 in 0 1 2 3 4 5 6 7
51 do for m2 in 0 1 2 3 4 5 6 7
52 do for m3 in 0 1 2 3 4 5 6 7
54 mode=${m1}${m2}${m3}
55 fn=$testdir/modes/m${mode}${many}
56 echo "$many $m1 $m2 $m3 $mode" > $fn
57 chmod $mode $fn
58 done
59 done
60 done
61 done
63 # Make an MFS filesystem image out of it
65 BS=4096
66 BLOCKS=15000
67 INODES=6000
68 dd if=/dev/zero seek=$BLOCKS of=$fsimage count=1 bs=$BS >/dev/null 2>&1
70 # -s keeps modes
71 /usr/sbin/mkproto -s -b $BLOCKS -i $INODES $testdir >$protofile
73 /sbin/mkfs.mfs -T 1 -b $BLOCKS -i $INODES $fsimage $protofile >/dev/null 2>&1
74 sum="`sha1 $fsimage | awk '{ print $4 }'`"
76 if [ $sum != $expect ]
77 then
78 echo sum $sum is not expected $expect
79 exit 1
82 echo ok
84 exit 0