diff options
Diffstat (limited to 'firmware/test/fat/test16.sh')
-rwxr-xr-x | firmware/test/fat/test16.sh | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/firmware/test/fat/test16.sh b/firmware/test/fat/test16.sh new file mode 100755 index 0000000000..bc12fd837c --- /dev/null +++ b/firmware/test/fat/test16.sh | |||
@@ -0,0 +1,135 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | IMAGE=disk.img | ||
4 | MOUNT=/mnt/dummy | ||
5 | DIR=$MOUNT/q | ||
6 | RESULT=result.txt | ||
7 | |||
8 | fail() { | ||
9 | echo "!! Test failed $RETVAL. Look in $RESULT for test logs." | ||
10 | chmod a+rw $RESULT | ||
11 | exit | ||
12 | } | ||
13 | |||
14 | check() { | ||
15 | /sbin/dosfsck -r $IMAGE | tee -a $RESULT | ||
16 | [ $RETVAL -ne 0 ] && fail | ||
17 | } | ||
18 | |||
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 | ||
25 | } | ||
26 | |||
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`; | ||
34 | do | ||
35 | echo apa > "$DIR/very $i long test filename so we can make sure they.work"; | ||
36 | done; | ||
37 | umount $MOUNT; | ||
38 | } | ||
39 | |||
40 | runtests() { | ||
41 | rm $RESULT | ||
42 | |||
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 | ||
48 | |||
49 | echo ---Test: create a directory called "dir" | ||
50 | try mkdir "/dir" | ||
51 | check | ||
52 | |||
53 | echo ---Test: create a 10K file | ||
54 | try mkfile "/really long filenames rock" 10 | ||
55 | check | ||
56 | |||
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 | ||
61 | |||
62 | echo ---Test: create a 1K file | ||
63 | try mkfile /bpa.rock 1 | ||
64 | check | ||
65 | try chkfile /bpa.rock 1 | ||
66 | |||
67 | echo ---Test: create a 40K file | ||
68 | try mkfile /cpa.rock 40 | ||
69 | check | ||
70 | try chkfile /cpa.rock 40 | ||
71 | |||
72 | echo ---Test: create a 400K file | ||
73 | try mkfile /dpa.rock 400 | ||
74 | check | ||
75 | try chkfile /dpa.rock 400 | ||
76 | |||
77 | echo ---Test: create a 1200K file | ||
78 | try mkfile /epa.rock 1200 | ||
79 | check | ||
80 | try chkfile /epa.rock 1200 | ||
81 | |||
82 | echo ---Test: rewrite first 20K of a 40K file | ||
83 | try mkfile /cpa.rock 20 | ||
84 | check | ||
85 | try chkfile /cpa.rock 20 | ||
86 | |||
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 | ||
92 | |||
93 | LOOP=25 | ||
94 | SIZE=700 | ||
95 | |||
96 | try del "/really long filenames rock" | ||
97 | |||
98 | echo ---Test: create $LOOP $SIZE k files | ||
99 | for i in `seq 1 $LOOP`; | ||
100 | do | ||
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 | ||
113 | |||
114 | } | ||
115 | |||
116 | echo "--------------------------------------" | ||
117 | echo "Building test image (4 sector/cluster)" | ||
118 | echo "--------------------------------------" | ||
119 | buildimage 4 | ||
120 | runtests | ||
121 | |||
122 | echo "--------------------------------------" | ||
123 | echo "Building test image (8 sectors/cluster)" | ||
124 | echo "--------------------------------------" | ||
125 | buildimage 8 | ||
126 | runtests | ||
127 | |||
128 | echo "----------------------------------------" | ||
129 | echo "Building test image (64 sectors/cluster)" | ||
130 | echo "----------------------------------------" | ||
131 | buildimage 16 | ||
132 | runtests | ||
133 | |||
134 | echo "== Test completed successfully ==" | ||
135 | chmod a+rw $RESULT | ||