Added lseek() to chkfile test.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2795 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6b104a6c69
commit
f9b5fdcd4d
3 changed files with 38 additions and 13 deletions
|
@ -10,7 +10,11 @@ static FILE* file;
|
||||||
|
|
||||||
int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
|
int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
|
||||||
{
|
{
|
||||||
DEBUGF("[Reading block 0x%lx, %d]\n", start, count);
|
if ( count > 1 )
|
||||||
|
DEBUGF("[Reading %d blocks: 0x%lx to 0x%lx]\n",
|
||||||
|
count, start, start+count-1);
|
||||||
|
else
|
||||||
|
DEBUGF("[Reading block 0x%lx, %d]\n", start, count);
|
||||||
|
|
||||||
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
|
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
|
||||||
perror("fseek");
|
perror("fseek");
|
||||||
|
@ -26,7 +30,11 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
|
||||||
|
|
||||||
int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
|
int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
|
||||||
{
|
{
|
||||||
DEBUGF("[Writing block 0x%lx, %d]\n", start, count);
|
if ( count > 1 )
|
||||||
|
DEBUGF("[Writing %d blocks: 0x%lx to 0x%lx]\n",
|
||||||
|
count, start, start+count-1);
|
||||||
|
else
|
||||||
|
DEBUGF("[Writing block 0x%lx]\n", start);
|
||||||
|
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
panicf("Writing on sector 0!\n");
|
panicf("Writing on sector 0!\n");
|
||||||
|
|
|
@ -125,9 +125,9 @@ int dbg_mkfile(char* name, int num)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dbg_chkfile(char* name)
|
int dbg_chkfile(char* name, int size)
|
||||||
{
|
{
|
||||||
char text[8192];
|
char text[81920];
|
||||||
int i;
|
int i;
|
||||||
int x=0;
|
int x=0;
|
||||||
int block=0;
|
int block=0;
|
||||||
|
@ -136,6 +136,13 @@ int dbg_chkfile(char* name)
|
||||||
DEBUGF("Failed opening file\n");
|
DEBUGF("Failed opening file\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size) {
|
||||||
|
lseek(fd, size*512, SEEK_SET);
|
||||||
|
x = size * 1024 / 16;
|
||||||
|
LDEBUGF("Check base is %x\n",x);
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int rc = read(fd, text, sizeof text);
|
int rc = read(fd, text, sizeof text);
|
||||||
DEBUGF("read %d bytes\n",rc);
|
DEBUGF("read %d bytes\n",rc);
|
||||||
|
@ -343,8 +350,12 @@ int dbg_cmd(int argc, char *argv[])
|
||||||
|
|
||||||
if (!strcasecmp(cmd, "chkfile"))
|
if (!strcasecmp(cmd, "chkfile"))
|
||||||
{
|
{
|
||||||
if (arg1)
|
if (arg1) {
|
||||||
return dbg_chkfile(arg1);
|
if (arg2)
|
||||||
|
return dbg_chkfile(arg1, atoi(arg2));
|
||||||
|
else
|
||||||
|
return dbg_chkfile(arg1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -34,22 +34,27 @@ runtests() {
|
||||||
echo ---Test: create a 10K file
|
echo ---Test: create a 10K file
|
||||||
try mkfile /apa.txt 10
|
try mkfile /apa.txt 10
|
||||||
check
|
check
|
||||||
try chkfile /apa.txt
|
try chkfile /apa.txt 10
|
||||||
|
|
||||||
echo ---Test: create a 1K file
|
echo ---Test: create a 1K file
|
||||||
try mkfile /bpa.txt 1
|
try mkfile /bpa.txt 1
|
||||||
check
|
check
|
||||||
try chkfile /bpa.txt
|
try chkfile /bpa.txt 1
|
||||||
|
|
||||||
echo ---Test: create a 40K file
|
echo ---Test: create a 40K file
|
||||||
try mkfile /cpa.txt 40
|
try mkfile /cpa.txt 40
|
||||||
check
|
check
|
||||||
try chkfile /cpa.txt
|
try chkfile /cpa.txt 40
|
||||||
|
|
||||||
|
echo ---Test: create a 400K file
|
||||||
|
try mkfile /dpa.txt 400
|
||||||
|
check
|
||||||
|
try chkfile /dpa.txt 400
|
||||||
|
|
||||||
echo ---Test: truncate previous 40K file to 20K
|
echo ---Test: truncate previous 40K file to 20K
|
||||||
try mkfile /cpa.txt 20
|
try mkfile /cpa.txt 20
|
||||||
check
|
check
|
||||||
try chkfile /cpa.txt
|
try chkfile /cpa.txt 20
|
||||||
|
|
||||||
echo ---Test: truncate previous 20K file to 0K
|
echo ---Test: truncate previous 20K file to 0K
|
||||||
try mkfile /cpa.txt 0
|
try mkfile /cpa.txt 0
|
||||||
|
@ -59,14 +64,15 @@ runtests() {
|
||||||
try chkfile /bpa.txt
|
try chkfile /bpa.txt
|
||||||
|
|
||||||
LOOP=50
|
LOOP=50
|
||||||
|
SIZE=50
|
||||||
|
|
||||||
echo ---Test: create $LOOP 40k 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 40
|
try mkfile /rockbox.$i $SIZE
|
||||||
check
|
check
|
||||||
try chkfile /rockbox.$i
|
try chkfile /rockbox.$i $SIZE
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue