1
0
Fork 0
forked from len0rd/rockbox

Fat test code, for the archives.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2911 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-12-03 14:00:33 +00:00
parent c032e65034
commit f6cb6163b9
3 changed files with 92 additions and 63 deletions

View file

@ -8,7 +8,7 @@
static FILE* file; static FILE* file;
int ata_read_sectors(unsigned long start, unsigned char count, void* buf) int ata_read_sectors(unsigned long start, int count, void* buf)
{ {
if ( count > 1 ) if ( count > 1 )
DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n", 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)
return 0; return 0;
} }
int ata_write_sectors(unsigned long start, unsigned char count, void* buf) int ata_write_sectors(unsigned long start, int count, void* buf)
{ {
if ( count > 1 ) if ( count > 1 )
DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n", DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n",

View file

@ -331,40 +331,47 @@ int dbg_append(char* name)
int dbg_test(char* name) int dbg_test(char* name)
{ {
int x=0; int x=0;
int size, fd, rc; int j;
char buf[4096]; int fd;
char text[BUFSIZE+1];
fd = open(name,O_RDWR); for (j=0; j<5; j++) {
if (fd<0) { int num = 40960;
DEBUGF("Failed opening file\n");
return -1;
}
size = lseek(fd, -1024, SEEK_END); fd = open(name,O_WRONLY|O_CREAT|O_APPEND);
size &= ~7; if (fd<0) {
DEBUGF("File is %d bytes\n", size); DEBUGF("Failed opening file\n");
x = size / CHUNKSIZE; return -1;
LDEBUGF("Check base is %x (%d)\n",x,size); }
rc = read(fd, buf, sizeof buf); while ( num ) {
if ( rc < 0 ) int rc, i;
panicf("Failed reading data\n"); int len = num > BUFSIZE ? BUFSIZE : num;
if ( rc == 0 )
DEBUGF("EOF\n");
rc = read(fd, buf, sizeof buf); for (i=0; i<len/CHUNKSIZE; i++ )
if ( rc < 0 ) sprintf(text+i*CHUNKSIZE,"%c%06x,",name[1],x++);
panicf("Failed reading data\n");
if ( rc == 0 )
DEBUGF("EOF\n");
rc = write(fd, buf, sizeof buf); rc = write(fd, text, len);
if ( rc < 0 ) if ( rc < 0 ) {
panicf("Failed writing data\n"); DEBUGF("Failed writing data\n");
if ( rc == 0 ) return -1;
DEBUGF("Nothing written!\n"); }
else
if ( rc == 0 ) {
DEBUGF("No space left\n");
return -2;
}
else
DEBUGF("wrote %d bytes\n",rc);
return close(fd); num -= len;
}
if (close(fd) < 0)
return -1;
}
return 0;
} }
int dbg_dump(char* name, int offset) int dbg_dump(char* name, int offset)
@ -511,6 +518,7 @@ int dbg_cmd(int argc, char *argv[])
" wrtest <file>\n" " wrtest <file>\n"
" append <file>\n" " append <file>\n"
" test <file>\n" " test <file>\n"
" ren <file> <newname>\n"
); );
return -1; return -1;
} }
@ -615,6 +623,12 @@ int dbg_cmd(int argc, char *argv[])
return dbg_trunc(arg1, atoi(arg2)); return dbg_trunc(arg1, atoi(arg2));
} }
if (!strcasecmp(cmd, "ren"))
{
if (arg1 && arg2)
return rename(arg1, arg2);
}
return 0; return 0;
} }

View file

@ -15,8 +15,9 @@ check() {
} }
try() { try() {
echo COMMAND: fat $1 $2 $3 >> $RESULT echo COMMAND: fat $1 "$2" "$3"
./fat $1 $2 $3 2>> $RESULT echo COMMAND: fat $1 "$2" "$3" >> $RESULT
./fat $1 "$2" "$3" 2>> $RESULT
RETVAL=$? RETVAL=$?
[ $RETVAL -ne 0 ] && fail [ $RETVAL -ne 0 ] && fail
} }
@ -26,6 +27,10 @@ buildimage() {
mount -o loop $IMAGE $MOUNT mount -o loop $IMAGE $MOUNT
echo "Filling it with /etc files" echo "Filling it with /etc files"
find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \; find /etc -type f -maxdepth 1 -exec cp {} $MOUNT \;
for i in `seq 1 120`;
do
echo apa > "$MOUNT/very $i long test filename so we can make sure they.work"
done
mkdir $MOUNT/dir mkdir $MOUNT/dir
umount $MOUNT umount $MOUNT
} }
@ -34,53 +39,63 @@ runtests() {
rm $RESULT rm $RESULT
echo ---Test: create a 10K file echo ---Test: create a 10K file
try mkfile /apa.txt 10 try mkfile "/really long filenames rock" 10
try mkfile /dir/apa.txt 10
check check
try chkfile /apa.txt 10 try mkfile /dir/apa.monkey.me.now 10
try chkfile /dir/apa.txt 8 check
try chkfile "/really long filenames rock" 10
try chkfile /dir/apa.monkey.me.now 8
echo ---Test: create a 1K file echo ---Test: create a 1K file
try mkfile /bpa.txt 1 try mkfile /bpa.rock 1
check check
try chkfile /bpa.txt 1 try chkfile /bpa.rock 1
echo ---Test: create a 40K file echo ---Test: create a 40K file
try mkfile /cpa.txt 40 try mkfile /cpa.rock 40
check check
try chkfile /cpa.txt 40 try chkfile /cpa.rock 40
echo ---Test: create a 400K file echo ---Test: create a 400K file
try mkfile /dpa.txt 400 try mkfile /dpa.rock 400
check check
try chkfile /dpa.txt 400 try chkfile /dpa.rock 400
echo ---Test: truncate previous 40K file to 20K echo ---Test: create a 1200K file
try mkfile /cpa.txt 20 try mkfile /epa.rock 1200
check check
try chkfile /cpa.txt 20 try chkfile /epa.rock 1200
echo ---Test: truncate previous 20K file to 0K echo ---Test: rewrite first 20K of a 40K file
try mkfile /cpa.txt 0 try mkfile /cpa.rock 20
check check
try chkfile /cpa.txt try chkfile /cpa.rock 20
try chkfile /apa.txt
try chkfile /bpa.txt echo ---Test: rewrite first sector of 40K file
try mkfile /cpa.rock 0
check
try chkfile /cpa.rock
try chkfile /apa.rock
try chkfile /bpa.rock
LOOP=50 LOOP=50
SIZE=70 SIZE=700
try del "/really long filenames rock"
echo ---Test: create $LOOP $SIZE k files echo ---Test: create $LOOP $SIZE k files
for i in `seq 1 $LOOP`; for i in `seq 1 $LOOP`;
do do
echo ---Test: $i/$LOOP --- echo ---Test: $i/$LOOP ---
try mkfile /rockbox.$i $SIZE try mkfile "/rockbox rocks.$i" $SIZE
check check
try chkfile /rockbox.$i $SIZE try chkfile "/rockbox rocks.$i" $SIZE
check check
try del /rockbox.$i try del "/rockbox rocks.$i"
check check
try mkfile /rockbox.$i $SIZE try mkfile "/rockbox rocks.$i" $SIZE
check
try ren "/rockbox rocks.$i" "$i is a new long filename!"
check check
done done
@ -90,20 +105,20 @@ echo "Building test image (4 sector/cluster)"
buildimage 4 buildimage 4
runtests runtests
echo "Building test image (128 sectors/cluster)"
buildimage 128
runtests
echo "Building test image (32 sectors/cluster)" echo "Building test image (32 sectors/cluster)"
buildimage 32 buildimage 32
runtests runtests
echo "Building test image (8 sectors/cluster)"
buildimage 8
runtests
echo "Building test image (1 sector/cluster)" echo "Building test image (1 sector/cluster)"
buildimage 1 buildimage 1
runtests runtests
echo "Building test image (8 sectors/cluster)"
buildimage 8
runtests
echo "Building test image (128 sectors/cluster)"
buildimage 128
runtests
echo "== Test completed sucessfully ==" echo "== Test completed sucessfully =="