mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 21:55:10 -05:00
FAT test case builds again
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6309 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
70ad08ccab
commit
b99551d1be
5 changed files with 166 additions and 9 deletions
|
|
@ -3,8 +3,9 @@ DRIVERS = ../../drivers
|
||||||
EXPORT = ../../export
|
EXPORT = ../../export
|
||||||
|
|
||||||
INCLUDE = -I$(EXPORT)
|
INCLUDE = -I$(EXPORT)
|
||||||
|
|
||||||
RINCLUDE = -I$(FIRMWARE)/include
|
RINCLUDE = -I$(FIRMWARE)/include
|
||||||
DEFINES = -DTEST_FAT -DDEBUG -DCRT_DISPLAY -DDISK_WRITE
|
DEFINES = -DTEST_FAT -DDEBUG -DCRT_DISPLAY -DDISK_WRITE -DHAVE_FAT16SUPPORT
|
||||||
|
|
||||||
CFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) $(RINCLUDE) -DLITTLE_ENDIAN
|
CFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE) $(RINCLUDE) -DLITTLE_ENDIAN
|
||||||
SIMFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE)
|
SIMFLAGS = -g -Wall $(DEFINES) -I. $(INCLUDE)
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "panic.h"
|
|
||||||
|
|
||||||
#define BLOCK_SIZE 512
|
#define BLOCK_SIZE 512
|
||||||
|
|
||||||
static FILE* file;
|
static FILE* file;
|
||||||
|
|
||||||
|
void panicf( const char *fmt, ... );
|
||||||
|
|
||||||
int ata_read_sectors(unsigned long start, int count, void* buf)
|
int ata_read_sectors(unsigned long start, int count, void* buf)
|
||||||
{
|
{
|
||||||
if ( count > 1 )
|
if ( count > 1 )
|
||||||
|
|
@ -51,10 +52,9 @@ int ata_write_sectors(unsigned long start, int count, void* buf)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ata_init(char* filename)
|
int ata_init(void)
|
||||||
{
|
{
|
||||||
if (!filename)
|
char* filename = "disk.img";
|
||||||
filename = "disk.img";
|
|
||||||
/* check disk size */
|
/* check disk size */
|
||||||
file=fopen(filename,"rb+");
|
file=fopen(filename,"rb+");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
extern int ata_init(char*);
|
|
||||||
extern void ata_read_sectors(int, int, char*);
|
|
||||||
|
|
||||||
void dbg_dump_sector(int sec);
|
void dbg_dump_sector(int sec);
|
||||||
void dbg_dump_buffer(unsigned char *buf, int len, int offset);
|
void dbg_dump_buffer(unsigned char *buf, int len, int offset);
|
||||||
void dbg_console(void);
|
void dbg_console(void);
|
||||||
|
|
||||||
|
void mutex_init(void* l) {}
|
||||||
|
void mutex_lock(void* l) {}
|
||||||
|
void mutex_unlock(void* l) {}
|
||||||
|
|
||||||
void panicf( char *fmt, ...)
|
void panicf( char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -26,6 +27,24 @@ void panicf( char *fmt, ...)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugf(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start( ap, fmt );
|
||||||
|
fprintf(stderr,"DEBUGF: ");
|
||||||
|
vfprintf( stderr, fmt, ap );
|
||||||
|
va_end( ap );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ldebugf(const char* file, int line, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start( ap, fmt );
|
||||||
|
fprintf( stderr, "%s:%d ", file, line );
|
||||||
|
vfprintf( stderr, fmt, ap );
|
||||||
|
va_end( ap );
|
||||||
|
}
|
||||||
|
|
||||||
void dbg_dump_sector(int sec)
|
void dbg_dump_sector(int sec)
|
||||||
{
|
{
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
|
|
@ -660,7 +679,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
srand(clock());
|
srand(clock());
|
||||||
|
|
||||||
if(ata_init("disk.img")) {
|
if(ata_init()) {
|
||||||
DEBUGF("*** Warning! The disk is uninitialized\n");
|
DEBUGF("*** Warning! The disk is uninitialized\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ RESULT=result.txt
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
echo "!! Test failed. Look in $RESULT for test logs."
|
echo "!! Test failed. Look in $RESULT for test logs."
|
||||||
|
chmod a+rw $RESULT
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,3 +143,4 @@ buildimage 128
|
||||||
runtests
|
runtests
|
||||||
|
|
||||||
echo "== Test completed successfully =="
|
echo "== Test completed successfully =="
|
||||||
|
chmod a+rw $RESULT
|
||||||
|
|
|
||||||
135
firmware/test/fat/test16.sh
Executable file
135
firmware/test/fat/test16.sh
Executable file
|
|
@ -0,0 +1,135 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
IMAGE=disk.img
|
||||||
|
MOUNT=/mnt/dummy
|
||||||
|
DIR=$MOUNT/q
|
||||||
|
RESULT=result.txt
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
echo "!! Test failed $RETVAL. Look in $RESULT for test logs."
|
||||||
|
chmod a+rw $RESULT
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
/sbin/dosfsck -r $IMAGE | tee -a $RESULT
|
||||||
|
[ $RETVAL -ne 0 ] && fail
|
||||||
|
}
|
||||||
|
|
||||||
|
try() {
|
||||||
|
echo COMMAND: fat $1 "$2" "$3"
|
||||||
|
echo COMMAND: fat $1 "$2" "$3" >> $RESULT
|
||||||
|
./fat $1 "$2" "$3" 2>> $RESULT
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -ne 0 ] && fail
|
||||||
|
}
|
||||||
|
|
||||||
|
buildimage() {
|
||||||
|
/sbin/mkdosfs -F 16 -s $1 $IMAGE > /dev/null;
|
||||||
|
mount -o loop,fat=16 $IMAGE $MOUNT;
|
||||||
|
echo "Filling it with /etc files";
|
||||||
|
mkdir $DIR;
|
||||||
|
find /etc -type f -maxdepth 1 -exec cp {} $DIR \;
|
||||||
|
for i in `seq 1 120`;
|
||||||
|
do
|
||||||
|
echo apa > "$DIR/very $i long test filename so we can make sure they.work";
|
||||||
|
done;
|
||||||
|
umount $MOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
runtests() {
|
||||||
|
rm $RESULT
|
||||||
|
|
||||||
|
echo ---Test: create a long name directory in the root
|
||||||
|
try mkdir "/very long subdir name"
|
||||||
|
check
|
||||||
|
try mkdir "/very long subdir name/apa.monkey.me.now"
|
||||||
|
check
|
||||||
|
|
||||||
|
echo ---Test: create a directory called "dir"
|
||||||
|
try mkdir "/dir"
|
||||||
|
check
|
||||||
|
|
||||||
|
echo ---Test: create a 10K file
|
||||||
|
try mkfile "/really long filenames rock" 10
|
||||||
|
check
|
||||||
|
|
||||||
|
try mkfile /dir/apa.monkey.me.now 10
|
||||||
|
check
|
||||||
|
try chkfile "/really long filenames rock" 10
|
||||||
|
try chkfile /dir/apa.monkey.me.now 8
|
||||||
|
|
||||||
|
echo ---Test: create a 1K file
|
||||||
|
try mkfile /bpa.rock 1
|
||||||
|
check
|
||||||
|
try chkfile /bpa.rock 1
|
||||||
|
|
||||||
|
echo ---Test: create a 40K file
|
||||||
|
try mkfile /cpa.rock 40
|
||||||
|
check
|
||||||
|
try chkfile /cpa.rock 40
|
||||||
|
|
||||||
|
echo ---Test: create a 400K file
|
||||||
|
try mkfile /dpa.rock 400
|
||||||
|
check
|
||||||
|
try chkfile /dpa.rock 400
|
||||||
|
|
||||||
|
echo ---Test: create a 1200K file
|
||||||
|
try mkfile /epa.rock 1200
|
||||||
|
check
|
||||||
|
try chkfile /epa.rock 1200
|
||||||
|
|
||||||
|
echo ---Test: rewrite first 20K of a 40K file
|
||||||
|
try mkfile /cpa.rock 20
|
||||||
|
check
|
||||||
|
try chkfile /cpa.rock 20
|
||||||
|
|
||||||
|
echo ---Test: rewrite first sector of 40K file
|
||||||
|
try mkfile /cpa.rock 0
|
||||||
|
check
|
||||||
|
try chkfile /cpa.rock
|
||||||
|
try chkfile /bpa.rock
|
||||||
|
|
||||||
|
LOOP=25
|
||||||
|
SIZE=700
|
||||||
|
|
||||||
|
try del "/really long filenames rock"
|
||||||
|
|
||||||
|
echo ---Test: create $LOOP $SIZE k files
|
||||||
|
for i in `seq 1 $LOOP`;
|
||||||
|
do
|
||||||
|
echo ---Test: $i/$LOOP ---
|
||||||
|
try mkfile "/q/rockbox rocks.$i" $SIZE
|
||||||
|
check
|
||||||
|
try chkfile "/q/rockbox rocks.$i" $SIZE
|
||||||
|
check
|
||||||
|
try del "/q/rockbox rocks.$i"
|
||||||
|
check
|
||||||
|
try mkfile "/q/rockbox rocks.$i" $SIZE
|
||||||
|
check
|
||||||
|
try ren "/q/rockbox rocks.$i" "/q/$i is a new long filename!"
|
||||||
|
check
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "--------------------------------------"
|
||||||
|
echo "Building test image (4 sector/cluster)"
|
||||||
|
echo "--------------------------------------"
|
||||||
|
buildimage 4
|
||||||
|
runtests
|
||||||
|
|
||||||
|
echo "--------------------------------------"
|
||||||
|
echo "Building test image (8 sectors/cluster)"
|
||||||
|
echo "--------------------------------------"
|
||||||
|
buildimage 8
|
||||||
|
runtests
|
||||||
|
|
||||||
|
echo "----------------------------------------"
|
||||||
|
echo "Building test image (64 sectors/cluster)"
|
||||||
|
echo "----------------------------------------"
|
||||||
|
buildimage 16
|
||||||
|
runtests
|
||||||
|
|
||||||
|
echo "== Test completed successfully =="
|
||||||
|
chmod a+rw $RESULT
|
||||||
Loading…
Add table
Add a link
Reference in a new issue