Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / tests / testisofs.sh
blobf1ab021ebddefc739313150de2e309612765492a
1 # Create and verify a simple ISO filesystem
3 #!/bin/sh
5 set -e
7 echo -n "isofs test "
9 # Somehow timezones mess up the timestamp comparison, so unset the timezone for
10 # now. TODO: sort out if this is actually a bug or simply expected behavior.
11 unset TZ
13 # testing ISO 9660 Level 3 compliance isn't possible for the time being
14 # (not possible to store a >4GB ISO file into a ramdisk)
15 testLevel3=0
16 testRockRidge=1
18 ramdev=/dev/ram
19 mp=/mnt
20 testdir=isofstest
21 fsimage=isofsimage
22 contents=CONTENTS
23 out1=v1
24 out2=v2
25 excludes=excludes
27 create_contents_level3() {
28 # >4GB file
29 seq 1 1000000000 > $testdir/HUGEFILE
32 create_contents_rockridge() {
33 # long filenames
34 mkdir -p $testdir/rockridge/longnames
35 echo "this is a test" > $testdir/rockridge/longnames/azertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopaz
36 echo "this is a test" > $testdir/rockridge/longnames/azertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopaze
37 echo "this is a test" > $testdir/rockridge/longnames/azertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazer
39 # devices
40 mkdir -p $testdir/rockridge/devices
41 CURLOC=$(pwd)
42 cd $testdir/rockridge/devices && MAKEDEV -s
43 cd $CURLOC
45 # symbolic links
46 mkdir -p $testdir/rockridge/symlinks
47 ln -s . $testdir/rockridge/symlinks/cur_dir
48 ln -s .. $testdir/rockridge/symlinks/parent_dir
49 ln -s / $testdir/rockridge/symlinks/root_dir
50 ln -s /mnt $testdir/rockridge/symlinks/root_mnt_dir
51 ln -s ../../rockridge $testdir/rockridge/symlinks/rockridge_dir
52 ln -s ../../rockridge/symlinks $testdir/rockridge/symlinks/symlinks_dir
53 ln -s ../../rockridge/symlinks/../symlinks $testdir/rockridge/symlinks/symlinks_dir_bis
54 ln -s cur_dir $testdir/rockridge/symlinks/to_cur_dir
55 ln -s rockridge_dir $testdir/rockridge/symlinks/to_rockridge_dir
57 # deep directory tree
58 mkdir -p $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think
59 mkdir -p $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/yes
60 mkdir -p $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/no
61 echo "I agree." > $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/yes/awnser1
62 echo "Yes, totally." > $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/yes/awnser2
63 echo "Nah." > $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/no/awnser1
64 echo "Meh." > $testdir/rockridge/deep_dirs/this/is/a/ridiculously/deep/directory/hierarchy/dont/you/think/no/awnser2
66 # permissions
67 mkdir -p $testdir/rockridge/permissions
68 for u in $(seq 0 7); do
69 for g in $(seq 0 7); do
70 for o in $(seq 0 7); do
71 echo "$u$g$o" > $testdir/rockridge/permissions/mode-$u$g$o
72 chmod $u$g$o $testdir/rockridge/permissions/mode-$u$g$o
73 done
74 done
75 done
76 echo "uid-gid test" > $testdir/rockridge/permissions/uid-1-gid-2
77 chown 1:2 $testdir/rockridge/permissions/uid-1-gid-2
78 echo "uid-gid test" > $testdir/rockridge/permissions/uid-128-gid-256
79 chown 128:256 $testdir/rockridge/permissions/uid-128-gid-256
80 echo "uid-gid test" > $testdir/rockridge/permissions/uid-12345-gid-23456
81 chown 12345:23456 $testdir/rockridge/permissions/uid-12345-gid-23456
84 create_contents_base() {
85 # simple file
86 echo $(date) > $testdir/DATE
88 # big file
89 seq 1 100000 > $testdir/BIGFILE
91 # lots of files in a directory
92 mkdir $testdir/BIGDIR
93 for i in $(seq 1 250); do
94 HASH=$(cksum -a SHA1 <<EOF
96 EOF
98 FILE=$(echo $HASH | cut -c 1-30 | sed -e "y/abcdef/ABCDEF/")
99 echo $HASH > $testdir/BIGDIR/$FILE
100 done
102 # lots of directories
103 mkdir $testdir/SUBDIRS
104 for i in $(seq 1 1000); do
105 HASH=$(cksum -a SHA1 <<EOF
109 DIR1=$(echo $HASH | cut -c 1-2 | sed -e "y/abcdef/ABCDEF/")
110 DIR2=$(echo $HASH | cut -c 3-4 | sed -e "y/abcdef/ABCDEF/")
111 FILE=$(echo $HASH | cut -c 5-12 | sed -e "y/abcdef/ABCDEF/")
112 mkdir -p $testdir/SUBDIRS/$DIR1/$DIR2
113 echo $HASH > $testdir/SUBDIRS/$DIR1/$DIR2/$FILE
114 done
117 rm -rf $testdir $fsimage $out1 $out2 $excludes
119 if [ -d $testdir ]
120 then
121 echo "dir?"
122 exit 1
125 mkdir -p $testdir
127 if [ ! -d $testdir ]
128 then
129 echo "no dir?"
130 exit 1
133 # make some small & big & bigger files
134 OPTIONS=
135 create_contents_base
136 if [ "$testLevel3" -eq 1 ]
137 then
138 create_contents_level3
140 if [ "$testRockRidge" -eq 1 ]
141 then
142 create_contents_rockridge
143 OPTIONS="-o rockridge"
144 else
145 # fixups for the fact that bare ISO 9660 isn't POSIX enough
146 # for mtree
147 # fix permissions
148 find $testdir -exec chmod 555 {} ";"
151 # make image
152 /usr/sbin/makefs -t cd9660 $OPTIONS $fsimage $testdir
154 # umount previous things
155 umount $ramdev >/dev/null 2>&1 || true
156 umount $mp >/dev/null 2>&1 || true
158 # mount it on a RAM disk
159 ramdisk $(expr $(wc -c < $fsimage) / 1024) $ramdev >/dev/null 2>&1
160 cat < $fsimage > $ramdev
161 mount -t isofs $ramdev $mp >/dev/null 2>&1
163 # compare contents
164 if [ "$testRockRidge" -eq 1 ]
165 then
166 # get rid of root directory time
167 echo 'RR_MOVED' >$excludes
168 /usr/sbin/mtree -c -p $testdir | sed -e "s/\. *type=dir.*/\. type=dir/" | /usr/sbin/mtree -p $mp -X $excludes
169 else
170 # fixups for the fact that bare ISO 9660 isn't POSIX enough
171 # for mtree
172 # get rid of time
173 /usr/sbin/mtree -c -p $testdir | sed -e "s/time=[0-9]*.[0-9]*//" | /usr/sbin/mtree -p $mp
176 umount $ramdev >/dev/null 2>&1
178 # cleanup
179 rm -rf $testdir $fsimage $out1 $out2 $excludes
181 echo ok
183 exit 0