diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/test/fat/ata-sim.c | 4 | ||||
-rw-r--r-- | firmware/test/fat/main.c | 70 | ||||
-rw-r--r-- | firmware/test/fat/test.sh | 77 |
3 files changed, 90 insertions, 61 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c index 63abc58084..aac7fba0f4 100644 --- a/firmware/test/fat/ata-sim.c +++ b/firmware/test/fat/ata-sim.c | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | static FILE* file; | 9 | static FILE* file; |
10 | 10 | ||
11 | int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | 11 | int ata_read_sectors(unsigned long start, int count, void* buf) |
12 | { | 12 | { |
13 | if ( count > 1 ) | 13 | if ( count > 1 ) |
14 | DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n", | 14 | DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n", |
@@ -28,7 +28,7 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | |||
28 | return 0; | 28 | return 0; |
29 | } | 29 | } |
30 | 30 | ||
31 | int ata_write_sectors(unsigned long start, unsigned char count, void* buf) | 31 | int ata_write_sectors(unsigned long start, int count, void* buf) |
32 | { | 32 | { |
33 | if ( count > 1 ) | 33 | if ( count > 1 ) |
34 | DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n", | 34 | DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n", |
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index 520454541f..9c1b983925 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c | |||
@@ -331,40 +331,47 @@ int dbg_append(char* name) | |||
331 | int dbg_test(char* name) | 331 | int dbg_test(char* name) |
332 | { | 332 | { |
333 | int x=0; | 333 | int x=0; |
334 | int size, fd, rc; | 334 | int j; |
335 | char buf[4096]; | 335 | int fd; |
336 | char text[BUFSIZE+1]; | ||
336 | 337 | ||
337 | fd = open(name,O_RDWR); | 338 | for (j=0; j<5; j++) { |
338 | if (fd<0) { | 339 | int num = 40960; |
339 | DEBUGF("Failed opening file\n"); | ||
340 | return -1; | ||
341 | } | ||
342 | 340 | ||
343 | size = lseek(fd, -1024, SEEK_END); | 341 | fd = open(name,O_WRONLY|O_CREAT|O_APPEND); |
344 | size &= ~7; | 342 | if (fd<0) { |
345 | DEBUGF("File is %d bytes\n", size); | 343 | DEBUGF("Failed opening file\n"); |
346 | x = size / CHUNKSIZE; | 344 | return -1; |
347 | LDEBUGF("Check base is %x (%d)\n",x,size); | 345 | } |
348 | 346 | ||
349 | rc = read(fd, buf, sizeof buf); | 347 | while ( num ) { |
350 | if ( rc < 0 ) | 348 | int rc, i; |
351 | panicf("Failed reading data\n"); | 349 | int len = num > BUFSIZE ? BUFSIZE : num; |
352 | if ( rc == 0 ) | ||
353 | DEBUGF("EOF\n"); | ||
354 | 350 | ||
355 | rc = read(fd, buf, sizeof buf); | 351 | for (i=0; i<len/CHUNKSIZE; i++ ) |
356 | if ( rc < 0 ) | 352 | sprintf(text+i*CHUNKSIZE,"%c%06x,",name[1],x++); |
357 | panicf("Failed reading data\n"); | ||
358 | if ( rc == 0 ) | ||
359 | DEBUGF("EOF\n"); | ||
360 | 353 | ||
361 | rc = write(fd, buf, sizeof buf); | 354 | rc = write(fd, text, len); |
362 | if ( rc < 0 ) | 355 | if ( rc < 0 ) { |
363 | panicf("Failed writing data\n"); | 356 | DEBUGF("Failed writing data\n"); |
364 | if ( rc == 0 ) | 357 | return -1; |
365 | DEBUGF("Nothing written!\n"); | 358 | } |
359 | else | ||
360 | if ( rc == 0 ) { | ||
361 | DEBUGF("No space left\n"); | ||
362 | return -2; | ||
363 | } | ||
364 | else | ||
365 | DEBUGF("wrote %d bytes\n",rc); | ||
366 | 366 | ||
367 | return close(fd); | 367 | num -= len; |
368 | } | ||
369 | |||
370 | if (close(fd) < 0) | ||
371 | return -1; | ||
372 | } | ||
373 | |||
374 | return 0; | ||
368 | } | 375 | } |
369 | 376 | ||
370 | int dbg_dump(char* name, int offset) | 377 | int dbg_dump(char* name, int offset) |
@@ -511,6 +518,7 @@ int dbg_cmd(int argc, char *argv[]) | |||
511 | " wrtest <file>\n" | 518 | " wrtest <file>\n" |
512 | " append <file>\n" | 519 | " append <file>\n" |
513 | " test <file>\n" | 520 | " test <file>\n" |
521 | " ren <file> <newname>\n" | ||
514 | ); | 522 | ); |
515 | return -1; | 523 | return -1; |
516 | } | 524 | } |
@@ -615,6 +623,12 @@ int dbg_cmd(int argc, char *argv[]) | |||
615 | return dbg_trunc(arg1, atoi(arg2)); | 623 | return dbg_trunc(arg1, atoi(arg2)); |
616 | } | 624 | } |
617 | 625 | ||
626 | if (!strcasecmp(cmd, "ren")) | ||
627 | { | ||
628 | if (arg1 && arg2) | ||
629 | return rename(arg1, arg2); | ||
630 | } | ||
631 | |||
618 | return 0; | 632 | return 0; |
619 | } | 633 | } |
620 | 634 | ||
diff --git a/firmware/test/fat/test.sh b/firmware/test/fat/test.sh index 7d9435b85d..6a26e7ff59 100644 --- a/firmware/test/fat/test.sh +++ b/firmware/test/fat/test.sh | |||
@@ -15,8 +15,9 @@ check() { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | try() { | 17 | try() { |
18 | echo COMMAND: fat $1 $2 $3 >> $RESULT | 18 | echo COMMAND: fat $1 "$2" "$3" |
19 | ./fat $1 $2 $3 2>> $RESULT | 19 | echo COMMAND: fat $1 "$2" "$3" >> $RESULT |
20 | ./fat $1 "$2" "$3" 2>> $RESULT | ||
20 | RETVAL=$? | 21 | RETVAL=$? |
21 | [ $RETVAL -ne 0 ] && fail | 22 | [ $RETVAL -ne 0 ] && fail |
22 | } | 23 | } |
@@ -26,6 +27,10 @@ buildimage() { | |||
26 | mount -o loop $IMAGE $MOUNT | 27 | mount -o loop $IMAGE $MOUNT |
27 | echo "Filling it with /etc files" | 28 | echo "Filling it with /etc files" |
28 | find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \; | 29 | find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \; |
30 | for i in `seq 1 120`; | ||
31 | do | ||
32 | echo apa > "$MOUNT/very $i long test filename so we can make sure they.work" | ||
33 | done | ||
29 | mkdir $MOUNT/dir | 34 | mkdir $MOUNT/dir |
30 | umount $MOUNT | 35 | umount $MOUNT |
31 | } | 36 | } |
@@ -34,53 +39,63 @@ runtests() { | |||
34 | rm $RESULT | 39 | rm $RESULT |
35 | 40 | ||
36 | echo ---Test: create a 10K file | 41 | echo ---Test: create a 10K file |
37 | try mkfile /apa.txt 10 | 42 | try mkfile "/really long filenames rock" 10 |
38 | try mkfile /dir/apa.txt 10 | 43 | check |
44 | try mkfile /dir/apa.monkey.me.now 10 | ||
39 | check | 45 | check |
40 | try chkfile /apa.txt 10 | 46 | try chkfile "/really long filenames rock" 10 |
41 | try chkfile /dir/apa.txt 8 | 47 | try chkfile /dir/apa.monkey.me.now 8 |
42 | 48 | ||
43 | echo ---Test: create a 1K file | 49 | echo ---Test: create a 1K file |
44 | try mkfile /bpa.txt 1 | 50 | try mkfile /bpa.rock 1 |
45 | check | 51 | check |
46 | try chkfile /bpa.txt 1 | 52 | try chkfile /bpa.rock 1 |
47 | 53 | ||
48 | echo ---Test: create a 40K file | 54 | echo ---Test: create a 40K file |
49 | try mkfile /cpa.txt 40 | 55 | try mkfile /cpa.rock 40 |
50 | check | 56 | check |
51 | try chkfile /cpa.txt 40 | 57 | try chkfile /cpa.rock 40 |
52 | 58 | ||
53 | echo ---Test: create a 400K file | 59 | echo ---Test: create a 400K file |
54 | try mkfile /dpa.txt 400 | 60 | try mkfile /dpa.rock 400 |
61 | check | ||
62 | try chkfile /dpa.rock 400 | ||
63 | |||
64 | echo ---Test: create a 1200K file | ||
65 | try mkfile /epa.rock 1200 | ||
55 | check | 66 | check |
56 | try chkfile /dpa.txt 400 | 67 | try chkfile /epa.rock 1200 |
57 | 68 | ||
58 | echo ---Test: truncate previous 40K file to 20K | 69 | echo ---Test: rewrite first 20K of a 40K file |
59 | try mkfile /cpa.txt 20 | 70 | try mkfile /cpa.rock 20 |
60 | check | 71 | check |
61 | try chkfile /cpa.txt 20 | 72 | try chkfile /cpa.rock 20 |
62 | 73 | ||
63 | echo ---Test: truncate previous 20K file to 0K | 74 | echo ---Test: rewrite first sector of 40K file |
64 | try mkfile /cpa.txt 0 | 75 | try mkfile /cpa.rock 0 |
65 | check | 76 | check |
66 | try chkfile /cpa.txt | 77 | try chkfile /cpa.rock |
67 | try chkfile /apa.txt | 78 | try chkfile /apa.rock |
68 | try chkfile /bpa.txt | 79 | try chkfile /bpa.rock |
69 | 80 | ||
70 | LOOP=50 | 81 | LOOP=50 |
71 | SIZE=70 | 82 | SIZE=700 |
83 | |||
84 | try del "/really long filenames rock" | ||
72 | 85 | ||
73 | echo ---Test: create $LOOP $SIZE k files | 86 | echo ---Test: create $LOOP $SIZE k files |
74 | for i in `seq 1 $LOOP`; | 87 | for i in `seq 1 $LOOP`; |
75 | do | 88 | do |
76 | echo ---Test: $i/$LOOP --- | 89 | echo ---Test: $i/$LOOP --- |
77 | try mkfile /rockbox.$i $SIZE | 90 | try mkfile "/rockbox rocks.$i" $SIZE |
91 | check | ||
92 | try chkfile "/rockbox rocks.$i" $SIZE | ||
78 | check | 93 | check |
79 | try chkfile /rockbox.$i $SIZE | 94 | try del "/rockbox rocks.$i" |
80 | check | 95 | check |
81 | try del /rockbox.$i | 96 | try mkfile "/rockbox rocks.$i" $SIZE |
82 | check | 97 | check |
83 | try mkfile /rockbox.$i $SIZE | 98 | try ren "/rockbox rocks.$i" "$i is a new long filename!" |
84 | check | 99 | check |
85 | done | 100 | done |
86 | 101 | ||
@@ -90,20 +105,20 @@ echo "Building test image (4 sector/cluster)" | |||
90 | buildimage 4 | 105 | buildimage 4 |
91 | runtests | 106 | runtests |
92 | 107 | ||
93 | echo "Building test image (128 sectors/cluster)" | ||
94 | buildimage 128 | ||
95 | runtests | ||
96 | |||
97 | echo "Building test image (32 sectors/cluster)" | 108 | echo "Building test image (32 sectors/cluster)" |
98 | buildimage 32 | 109 | buildimage 32 |
99 | runtests | 110 | runtests |
100 | 111 | ||
112 | echo "Building test image (1 sector/cluster)" | ||
113 | buildimage 1 | ||
114 | runtests | ||
115 | |||
101 | echo "Building test image (8 sectors/cluster)" | 116 | echo "Building test image (8 sectors/cluster)" |
102 | buildimage 8 | 117 | buildimage 8 |
103 | runtests | 118 | runtests |
104 | 119 | ||
105 | echo "Building test image (1 sector/cluster)" | 120 | echo "Building test image (128 sectors/cluster)" |
106 | buildimage 1 | 121 | buildimage 128 |
107 | runtests | 122 | runtests |
108 | 123 | ||
109 | echo "== Test completed sucessfully ==" | 124 | echo "== Test completed sucessfully ==" |