summaryrefslogtreecommitdiff
path: root/firmware/test
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-10-31 19:06:14 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-10-31 19:06:14 +0000
commit6b104a6c69e3e77f399cdd34ac35648b492b3d75 (patch)
tree3d8c6a4be325a62199e03dc92933c2339e465dfd /firmware/test
parent08356fb50a70bc44e598ff49ab61bd149060a668 (diff)
downloadrockbox-6b104a6c69e3e77f399cdd34ac35648b492b3d75.tar.gz
rockbox-6b104a6c69e3e77f399cdd34ac35648b492b3d75.zip
Improved tests.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2794 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test')
-rw-r--r--firmware/test/fat/ata-sim.c14
-rw-r--r--firmware/test/fat/main.c13
-rw-r--r--firmware/test/fat/test.sh28
3 files changed, 30 insertions, 25 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index 661cc79a1f..10bc3d9dc5 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -10,28 +10,23 @@ static FILE* file;
10 10
11int ata_read_sectors(unsigned long start, unsigned char count, void* buf) 11int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
12{ 12{
13 int i; 13 DEBUGF("[Reading block 0x%lx, %d]\n", start, count);
14 for (i=0; i<count; i++ )
15 DEBUGF("[Reading block 0x%lx]\n",start+i);
16 14
17 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 15 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
18 perror("fseek"); 16 perror("fseek");
19 return -1; 17 return -1;
20 } 18 }
21 if(!fread(buf,BLOCK_SIZE,count,file)) { 19 if(!fread(buf,BLOCK_SIZE,count,file)) {
22 printf("Failed reading %d blocks starting at block 0x%lx\n",count,start); 20 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf );
23 perror("fread"); 21 perror("fread");
24 panicf("Disk error\n"); 22 panicf("Disk error\n");
25 return -2;
26 } 23 }
27 return 0; 24 return 0;
28} 25}
29 26
30int ata_write_sectors(unsigned long start, unsigned char count, void* buf) 27int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
31{ 28{
32 int i; 29 DEBUGF("[Writing block 0x%lx, %d]\n", start, count);
33 for (i=0; i<count; i++ )
34 DEBUGF("[Writing block 0x%lx]\n",start+i);
35 30
36 if (start == 0) 31 if (start == 0)
37 panicf("Writing on sector 0!\n"); 32 panicf("Writing on sector 0!\n");
@@ -39,11 +34,10 @@ int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
39 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 34 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
40 perror("fseek"); 35 perror("fseek");
41 return -1; 36 return -1;
42 panicf("Disk error\n");
43 } 37 }
44 if(!fwrite(buf,BLOCK_SIZE,count,file)) { 38 if(!fwrite(buf,BLOCK_SIZE,count,file)) {
39 DEBUGF("ata_write_sectors(0x%x, 0x%x, 0x%x)\n", start, count, buf );
45 perror("fwrite"); 40 perror("fwrite");
46 return -2;
47 panicf("Disk error\n"); 41 panicf("Disk error\n");
48 } 42 }
49 return 0; 43 return 0;
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c
index 0259be410b..ab71308abb 100644
--- a/firmware/test/fat/main.c
+++ b/firmware/test/fat/main.c
@@ -99,17 +99,26 @@ int dbg_mkfile(char* name, int num)
99 } 99 }
100 num *= 1024; 100 num *= 1024;
101 while ( num ) { 101 while ( num ) {
102 int rc;
102 int len = num > sizeof text ? sizeof text : num; 103 int len = num > sizeof text ? sizeof text : num;
103 104
104 for (i=0; i<len/CHUNKSIZE; i++ ) 105 for (i=0; i<len/CHUNKSIZE; i++ )
105 sprintf(text+i*CHUNKSIZE,"%c%06x,",name[1],x++); 106 sprintf(text+i*CHUNKSIZE,"%c%06x,",name[1],x++);
106 107
107 if (write(fd, text, len) < 0) { 108 rc = write(fd, text, len);
109 if ( rc < 0 ) {
108 DEBUGF("Failed writing data\n"); 110 DEBUGF("Failed writing data\n");
109 return -1; 111 return -1;
110 } 112 }
113 else
114 if ( rc == 0 ) {
115 DEBUGF("No space left\n");
116 break;
117 }
118 else
119 DEBUGF("wrote %d bytes\n",rc);
120
111 num -= len; 121 num -= len;
112 DEBUGF("wrote %d bytes\n",len);
113 } 122 }
114 123
115 close(fd); 124 close(fd);
diff --git a/firmware/test/fat/test.sh b/firmware/test/fat/test.sh
index 476b0e4542..2f58b3cb81 100644
--- a/firmware/test/fat/test.sh
+++ b/firmware/test/fat/test.sh
@@ -58,35 +58,37 @@ runtests() {
58 try chkfile /apa.txt 58 try chkfile /apa.txt
59 try chkfile /bpa.txt 59 try chkfile /bpa.txt
60 60
61 echo ---Test: create 10 1k files 61 LOOP=50
62 for i in `seq 1 10`; 62
63 echo ---Test: create $LOOP 40k files
64 for i in `seq 1 $LOOP`;
63 do 65 do
64 echo ---Test: $i/10 --- 66 echo ---Test: $i/$LOOP ---
65 try mkfile /rockbox.$i 67 try mkfile /rockbox.$i 40
66 check 68 check
67 try chkfile /bpa.txt 69 try chkfile /rockbox.$i
68 done 70 done
69 71
70} 72}
71 73
72echo "Building test image (1 sector/cluster)" 74echo "Building test image (128 sectors/cluster)"
73buildimage 1 75buildimage 128
74runtests 76runtests
75 77
76echo "Building test image (4 sector/cluster)" 78echo "Building test image (32 sectors/cluster)"
77buildimage 4 79buildimage 32
78runtests 80runtests
79 81
80echo "Building test image (8 sectors/cluster)" 82echo "Building test image (8 sectors/cluster)"
81buildimage 8 83buildimage 8
82runtests 84runtests
83 85
84echo "Building test image (32 sectors/cluster)" 86echo "Building test image (4 sector/cluster)"
85buildimage 32 87buildimage 4
86runtests 88runtests
87 89
88echo "Building test image (128 sectors/cluster)" 90echo "Building test image (1 sector/cluster)"
89buildimage 128 91buildimage 1
90runtests 92runtests
91 93
92echo "== Test completed sucessfully ==" 94echo "== Test completed sucessfully =="