very minor code police. also fix a possible but unlikely missed cpu_boost(false)
[Rockbox.git] / firmware / test / fat / test16.sh
blob5a1c13150c4ec00bdca609526ba045cbccf55061
1 #!/bin/sh
3 IMAGE=disk.img
4 MOUNT=/mnt/dummy
5 DIR=$MOUNT/q
6 RESULT=result.txt
8 fail() {
9 echo "!! Test failed $RETVAL. Look in $RESULT for test logs."
10 chmod a+rw $RESULT
11 exit
14 check() {
15 /sbin/dosfsck -r $IMAGE | tee -a $RESULT
16 [ $RETVAL -ne 0 ] && fail
19 try() {
20 echo COMMAND: fat $1 "$2" "$3"
21 echo COMMAND: fat $1 "$2" "$3" >> $RESULT
22 ./fat $1 "$2" "$3" 2>> $RESULT
23 RETVAL=$?
24 [ $RETVAL -ne 0 ] && fail
27 buildimage() {
28 /sbin/mkdosfs -F 16 -s $1 $IMAGE > /dev/null;
29 mount -o loop,fat=16 $IMAGE $MOUNT;
30 echo "Filling it with /etc files";
31 mkdir $DIR;
32 find /etc -type f -maxdepth 1 -exec cp {} $DIR \;
33 for i in `seq 1 120`;
35 echo apa > "$DIR/very $i long test filename so we can make sure they.work";
36 done;
37 umount $MOUNT;
40 runtests() {
41 rm $RESULT
43 echo ---Test: create a long name directory in the root
44 try mkdir "/very long subdir name"
45 check
46 try mkdir "/very long subdir name/apa.monkey.me.now"
47 check
49 echo ---Test: create a directory called "dir"
50 try mkdir "/dir"
51 check
53 echo ---Test: create a 10K file
54 try mkfile "/really long filenames rock" 10
55 check
57 try mkfile /dir/apa.monkey.me.now 10
58 check
59 try chkfile "/really long filenames rock" 10
60 try chkfile /dir/apa.monkey.me.now 8
62 echo ---Test: create a 1K file
63 try mkfile /bpa.rock 1
64 check
65 try chkfile /bpa.rock 1
67 echo ---Test: create a 40K file
68 try mkfile /cpa.rock 40
69 check
70 try chkfile /cpa.rock 40
72 echo ---Test: create a 400K file
73 try mkfile /dpa.rock 400
74 check
75 try chkfile /dpa.rock 400
77 echo ---Test: create a 1200K file
78 try mkfile /epa.rock 1200
79 check
80 try chkfile /epa.rock 1200
82 echo ---Test: rewrite first 20K of a 40K file
83 try mkfile /cpa.rock 20
84 check
85 try chkfile /cpa.rock 20
87 echo ---Test: rewrite first sector of 40K file
88 try mkfile /cpa.rock 0
89 check
90 try chkfile /cpa.rock
91 try chkfile /bpa.rock
93 LOOP=25
94 SIZE=700
96 try del "/really long filenames rock"
98 echo ---Test: create $LOOP $SIZE k files
99 for i in `seq 1 $LOOP`;
101 echo ---Test: $i/$LOOP ---
102 try mkfile "/q/rockbox rocks.$i" $SIZE
103 check
104 try chkfile "/q/rockbox rocks.$i" $SIZE
105 check
106 try del "/q/rockbox rocks.$i"
107 check
108 try mkfile "/q/rockbox rocks.$i" $SIZE
109 check
110 try ren "/q/rockbox rocks.$i" "/q/$i is a new long filename!"
111 check
112 done
116 echo "--------------------------------------"
117 echo "Building test image (4 sector/cluster)"
118 echo "--------------------------------------"
119 buildimage 4
120 runtests
122 echo "--------------------------------------"
123 echo "Building test image (8 sectors/cluster)"
124 echo "--------------------------------------"
125 buildimage 8
126 runtests
128 echo "----------------------------------------"
129 echo "Building test image (64 sectors/cluster)"
130 echo "----------------------------------------"
131 buildimage 64
132 runtests
134 echo "== Test completed successfully =="
135 chmod a+rw $RESULT