diff options
Diffstat (limited to 'firmware/test/fat')
-rw-r--r-- | firmware/test/fat/test.sh | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/firmware/test/fat/test.sh b/firmware/test/fat/test.sh new file mode 100644 index 0000000000..0b00d765c2 --- /dev/null +++ b/firmware/test/fat/test.sh | |||
@@ -0,0 +1,81 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | IMAGE=disk.img | ||
4 | MOUNT=/mnt/dummy | ||
5 | |||
6 | fail() { | ||
7 | echo "!! Test failed. Look in result.txt for test log." | ||
8 | exit | ||
9 | } | ||
10 | |||
11 | check() { | ||
12 | /sbin/dosfsck -r $IMAGE | tee -a result.txt | ||
13 | [ $RETVAL -ne 0 ] && fail | ||
14 | } | ||
15 | |||
16 | try() { | ||
17 | ./fat $1 $2 $3 2> result.txt | ||
18 | RETVAL=$? | ||
19 | [ $RETVAL -ne 0 ] && fail | ||
20 | } | ||
21 | |||
22 | buildimage() { | ||
23 | umount $MOUNT | ||
24 | /sbin/mkdosfs -F 32 -s $1 disk.img >/dev/null | ||
25 | mount -o loop $IMAGE $MOUNT | ||
26 | echo "Filling it with /etc files" | ||
27 | find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \; | ||
28 | } | ||
29 | |||
30 | runtests() { | ||
31 | |||
32 | echo ---Test: create a 10K file | ||
33 | try mkfile /apa.txt 10 | ||
34 | check | ||
35 | try chkfile /apa.txt | ||
36 | |||
37 | echo ---Test: create a 1K file | ||
38 | try mkfile /bpa.txt 1 | ||
39 | check | ||
40 | try chkfile /bpa.txt | ||
41 | |||
42 | echo ---Test: create a 40K file | ||
43 | try mkfile /cpa.txt 40 | ||
44 | check | ||
45 | try chkfile /cpa.txt | ||
46 | |||
47 | echo ---Test: truncate previous 40K file to 20K | ||
48 | try mkfile /cpa.txt 20 | ||
49 | check | ||
50 | try chkfile /cpa.txt | ||
51 | |||
52 | echo ---Test: truncate previous 20K file to 0K | ||
53 | try mkfile /cpa.txt 0 | ||
54 | check | ||
55 | try chkfile /cpa.txt | ||
56 | |||
57 | echo ---Test: create 20 1k files | ||
58 | for i in `seq 1 10`; | ||
59 | do | ||
60 | echo -n $i | ||
61 | try mkfile /rockbox.$i | ||
62 | check | ||
63 | done | ||
64 | |||
65 | } | ||
66 | |||
67 | echo "Building test image A (2 sectors/cluster)" | ||
68 | buildimage 2 | ||
69 | runtests | ||
70 | |||
71 | echo "Building test image B (8 sectors/cluster)" | ||
72 | buildimage 8 | ||
73 | runtests | ||
74 | |||
75 | echo "Building test image B (1 sector/cluster)" | ||
76 | buildimage 1 | ||
77 | runtests | ||
78 | |||
79 | umount $MOUNT | ||
80 | |||
81 | echo "-- Test complete --" | ||