very minor code police. also fix a possible but unlikely missed cpu_boost(false)
[Rockbox.git] / firmware / test / fat / test.sh
blob921a0c80bf4ac712ae5360668897893aa46c7324
1 #!/bin/sh
3 IMAGE=disk.img
4 MOUNT=/mnt/dummy
5 RESULT=result.txt
7 fail() {
8 echo "!! Test failed. Look in $RESULT for test logs."
9 chmod a+rw $RESULT
10 exit
13 check() {
14 /sbin/dosfsck -r $IMAGE | tee -a $RESULT
15 [ $RETVAL -ne 0 ] && fail
18 try() {
19 echo COMMAND: fat $1 "$2" "$3"
20 echo COMMAND: fat $1 "$2" "$3" >> $RESULT
21 ./fat $1 "$2" "$3" 2>> $RESULT
22 RETVAL=$?
23 [ $RETVAL -ne 0 ] && fail
26 buildimage() {
27 /sbin/mkdosfs -F 32 -s $1 $IMAGE > /dev/null
28 mount -o loop $IMAGE $MOUNT
29 echo "Filling it with /etc files"
30 find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \;
31 for i in `seq 1 120`;
33 echo apa > "$MOUNT/very $i long test filename so we can make sure they.work"
34 done
35 umount $MOUNT
38 runtests() {
39 rm $RESULT
41 echo ---Test: create a long name directory in the root
42 try mkdir "/very long subdir name"
43 check
44 try mkdir "/very long subdir name/apa.monkey.me.now"
45 check
47 echo ---Test: create a directory called "dir"
48 try mkdir "/dir"
49 check
51 echo ---Test: create a 10K file
52 try mkfile "/really long filenames rock" 10
53 check
55 try mkfile /dir/apa.monkey.me.now 10
56 check
57 try chkfile "/really long filenames rock" 10
58 try chkfile /dir/apa.monkey.me.now 8
60 echo ---Test: create a 1K file
61 try mkfile /bpa.rock 1
62 check
63 try chkfile /bpa.rock 1
65 echo ---Test: create a 40K file
66 try mkfile /cpa.rock 40
67 check
68 try chkfile /cpa.rock 40
70 echo ---Test: create a 400K file
71 try mkfile /dpa.rock 400
72 check
73 try chkfile /dpa.rock 400
75 echo ---Test: create a 1200K file
76 try mkfile /epa.rock 1200
77 check
78 try chkfile /epa.rock 1200
80 echo ---Test: rewrite first 20K of a 40K file
81 try mkfile /cpa.rock 20
82 check
83 try chkfile /cpa.rock 20
85 echo ---Test: rewrite first sector of 40K file
86 try mkfile /cpa.rock 0
87 check
88 try chkfile /cpa.rock
89 try chkfile /bpa.rock
91 LOOP=50
92 SIZE=700
94 try del "/really long filenames rock"
96 echo ---Test: create $LOOP $SIZE k files
97 for i in `seq 1 $LOOP`;
99 echo ---Test: $i/$LOOP ---
100 try mkfile "/rockbox rocks.$i" $SIZE
101 check
102 try chkfile "/rockbox rocks.$i" $SIZE
103 check
104 try del "/rockbox rocks.$i"
105 check
106 try mkfile "/rockbox rocks.$i" $SIZE
107 check
108 try ren "/rockbox rocks.$i" "/$i is a new long filename!"
109 check
110 done
114 echo "--------------------------------------"
115 echo "Building test image (4 sector/cluster)"
116 echo "--------------------------------------"
117 buildimage 4
118 runtests
120 echo "---------------------------------------"
121 echo "Building test image (32 sectors/cluster)"
122 echo "---------------------------------------"
123 buildimage 32
124 runtests
126 echo "--------------------------------------"
127 echo "Building test image (1 sector/cluster)"
128 echo "--------------------------------------"
129 buildimage 1
130 runtests
132 echo "--------------------------------------"
133 echo "Building test image (8 sectors/cluster)"
134 echo "--------------------------------------"
135 buildimage 8
136 runtests
138 echo "----------------------------------------"
139 echo "Building test image (128 sectors/cluster)"
140 echo "----------------------------------------"
141 buildimage 128
142 runtests
144 echo "== Test completed successfully =="
145 chmod a+rw $RESULT