diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-10-31 20:40:15 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-10-31 20:40:15 +0000 |
commit | f9b5fdcd4d0a8095d6bc5bb91473de56ab6381c6 (patch) | |
tree | ef58b10083fa86c765c2635d924524ef3bf854d0 /firmware/test/fat | |
parent | 6b104a6c69e3e77f399cdd34ac35648b492b3d75 (diff) | |
download | rockbox-f9b5fdcd4d0a8095d6bc5bb91473de56ab6381c6.tar.gz rockbox-f9b5fdcd4d0a8095d6bc5bb91473de56ab6381c6.zip |
Added lseek() to chkfile test.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2795 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/fat')
-rw-r--r-- | firmware/test/fat/ata-sim.c | 12 | ||||
-rw-r--r-- | firmware/test/fat/main.c | 19 | ||||
-rw-r--r-- | firmware/test/fat/test.sh | 20 |
3 files changed, 38 insertions, 13 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c index 10bc3d9dc5..04cdadb6ce 100644 --- a/firmware/test/fat/ata-sim.c +++ b/firmware/test/fat/ata-sim.c | |||
@@ -10,7 +10,11 @@ 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, unsigned char count, void* buf) |
12 | { | 12 | { |
13 | DEBUGF("[Reading block 0x%lx, %d]\n", start, count); | 13 | if ( count > 1 ) |
14 | DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n", | ||
15 | count, start, start+count-1); | ||
16 | else | ||
17 | DEBUGF("[Reading block 0x%lx, %d]\n", start, count); | ||
14 | 18 | ||
15 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { | 19 | if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { |
16 | perror("fseek"); | 20 | perror("fseek"); |
@@ -26,7 +30,11 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf) | |||
26 | 30 | ||
27 | int ata_write_sectors(unsigned long start, unsigned char count, void* buf) | 31 | int ata_write_sectors(unsigned long start, unsigned char count, void* buf) |
28 | { | 32 | { |
29 | DEBUGF("[Writing block 0x%lx, %d]\n", start, count); | 33 | if ( count > 1 ) |
34 | DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n", | ||
35 | count, start, start+count-1); | ||
36 | else | ||
37 | DEBUGF("[Writing block 0x%lx]\n", start); | ||
30 | 38 | ||
31 | if (start == 0) | 39 | if (start == 0) |
32 | panicf("Writing on sector 0!\n"); | 40 | panicf("Writing on sector 0!\n"); |
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index ab71308abb..68cef1f08c 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c | |||
@@ -125,9 +125,9 @@ int dbg_mkfile(char* name, int num) | |||
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | int dbg_chkfile(char* name) | 128 | int dbg_chkfile(char* name, int size) |
129 | { | 129 | { |
130 | char text[8192]; | 130 | char text[81920]; |
131 | int i; | 131 | int i; |
132 | int x=0; | 132 | int x=0; |
133 | int block=0; | 133 | int block=0; |
@@ -136,6 +136,13 @@ int dbg_chkfile(char* name) | |||
136 | DEBUGF("Failed opening file\n"); | 136 | DEBUGF("Failed opening file\n"); |
137 | return -1; | 137 | return -1; |
138 | } | 138 | } |
139 | |||
140 | if (size) { | ||
141 | lseek(fd, size*512, SEEK_SET); | ||
142 | x = size * 1024 / 16; | ||
143 | LDEBUGF("Check base is %x\n",x); | ||
144 | } | ||
145 | |||
139 | while (1) { | 146 | while (1) { |
140 | int rc = read(fd, text, sizeof text); | 147 | int rc = read(fd, text, sizeof text); |
141 | DEBUGF("read %d bytes\n",rc); | 148 | DEBUGF("read %d bytes\n",rc); |
@@ -343,8 +350,12 @@ int dbg_cmd(int argc, char *argv[]) | |||
343 | 350 | ||
344 | if (!strcasecmp(cmd, "chkfile")) | 351 | if (!strcasecmp(cmd, "chkfile")) |
345 | { | 352 | { |
346 | if (arg1) | 353 | if (arg1) { |
347 | return dbg_chkfile(arg1); | 354 | if (arg2) |
355 | return dbg_chkfile(arg1, atoi(arg2)); | ||
356 | else | ||
357 | return dbg_chkfile(arg1, 0); | ||
358 | } | ||
348 | } | 359 | } |
349 | 360 | ||
350 | return 0; | 361 | return 0; |
diff --git a/firmware/test/fat/test.sh b/firmware/test/fat/test.sh index 2f58b3cb81..f723f69ec3 100644 --- a/firmware/test/fat/test.sh +++ b/firmware/test/fat/test.sh | |||
@@ -34,22 +34,27 @@ runtests() { | |||
34 | echo ---Test: create a 10K file | 34 | echo ---Test: create a 10K file |
35 | try mkfile /apa.txt 10 | 35 | try mkfile /apa.txt 10 |
36 | check | 36 | check |
37 | try chkfile /apa.txt | 37 | try chkfile /apa.txt 10 |
38 | 38 | ||
39 | echo ---Test: create a 1K file | 39 | echo ---Test: create a 1K file |
40 | try mkfile /bpa.txt 1 | 40 | try mkfile /bpa.txt 1 |
41 | check | 41 | check |
42 | try chkfile /bpa.txt | 42 | try chkfile /bpa.txt 1 |
43 | 43 | ||
44 | echo ---Test: create a 40K file | 44 | echo ---Test: create a 40K file |
45 | try mkfile /cpa.txt 40 | 45 | try mkfile /cpa.txt 40 |
46 | check | 46 | check |
47 | try chkfile /cpa.txt | 47 | try chkfile /cpa.txt 40 |
48 | |||
49 | echo ---Test: create a 400K file | ||
50 | try mkfile /dpa.txt 400 | ||
51 | check | ||
52 | try chkfile /dpa.txt 400 | ||
48 | 53 | ||
49 | echo ---Test: truncate previous 40K file to 20K | 54 | echo ---Test: truncate previous 40K file to 20K |
50 | try mkfile /cpa.txt 20 | 55 | try mkfile /cpa.txt 20 |
51 | check | 56 | check |
52 | try chkfile /cpa.txt | 57 | try chkfile /cpa.txt 20 |
53 | 58 | ||
54 | echo ---Test: truncate previous 20K file to 0K | 59 | echo ---Test: truncate previous 20K file to 0K |
55 | try mkfile /cpa.txt 0 | 60 | try mkfile /cpa.txt 0 |
@@ -59,14 +64,15 @@ runtests() { | |||
59 | try chkfile /bpa.txt | 64 | try chkfile /bpa.txt |
60 | 65 | ||
61 | LOOP=50 | 66 | LOOP=50 |
67 | SIZE=50 | ||
62 | 68 | ||
63 | echo ---Test: create $LOOP 40k files | 69 | echo ---Test: create $LOOP $SIZE k files |
64 | for i in `seq 1 $LOOP`; | 70 | for i in `seq 1 $LOOP`; |
65 | do | 71 | do |
66 | echo ---Test: $i/$LOOP --- | 72 | echo ---Test: $i/$LOOP --- |
67 | try mkfile /rockbox.$i 40 | 73 | try mkfile /rockbox.$i $SIZE |
68 | check | 74 | check |
69 | try chkfile /rockbox.$i | 75 | try chkfile /rockbox.$i $SIZE |
70 | done | 76 | done |
71 | 77 | ||
72 | } | 78 | } |