X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=yaffsdev.c;h=c44715b32f9d062b2bf69578ef37a0c8666d0a10;hb=572f34a1cc2b7bddbd8d66f64be95ba158703a2e;hp=3fb6a62e39ee13af9795f1a2b961e71dde0c84b8;hpb=f40b8435a109889e57bc37743ac7eb6badf1dd95;p=yaffs%2F.git diff --git a/yaffsdev.c b/yaffsdev.c index 3fb6a62..c44715b 100644 --- a/yaffsdev.c +++ b/yaffsdev.c @@ -27,8 +27,13 @@ #include #include +#include +#include + +unsigned yaffs_traceMask = 0xFFFFFFFF; + yaffs_Device device; @@ -313,15 +318,60 @@ void TestTime(yaffs_Device *dev) x = yaffs_RenameObject(yaffs_Root(dev),"Name1",NULL,"Rename"); - for(i = 0; i < 100000; i+=20) +// Write a file with overwrite, then read it back and save outside yaffs +// This is to test that write caching works. + + for(i = 0; i < 100; i++) { + unsigned char x[500]; - b++; - if(b & 1) - written = yaffs_WriteDataToFile(f,testStr,i,strlen(testStr)); - else - written = yaffs_WriteDataToFile(f,testStr2,i,strlen(testStr2)); + memset(x,i,500); + + written = yaffs_WriteDataToFile(f,x,i*500,500); + } + + for(i = 0; i < 100; i++) + { + unsigned char x; + + x = i+5; + + written = yaffs_WriteDataToFile(f,&x,i*500 + 2,1); } + + + { + int h; + + h = open("bork",O_RDWR | O_CREAT | O_TRUNC,0666); + for(i = 0; i < 100; i++) + { + unsigned char x[500]; + + yaffs_ReadDataFromFile(f,x,i*500,500); + write(h,x,500); + } + close(h); + + + } + +// Big write to fill disk + + written = 1; + for(i = 0; i < 1000000 && written > 0; i++) + { + unsigned char x[500]; + + memset(x,i,500); + + written = yaffs_WriteDataToFile(f,x,i*500,500); + } + if(written <= 0) + { + printf("YAFFS full\n"); + } + // some short reads for(i = 1000; i < 50000; i+=2) { @@ -587,7 +637,7 @@ int main(int argc,char *argv[]) int nBlocks; #if YAFFS_FILEEM - nBlocks =(32 * 1024 * 1024) / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK) ; + nBlocks =(4 * 1024 * 1024) / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK) ; device.writeChunkToNAND = yaffs_FEWriteChunkToNAND; device.readChunkFromNAND = yaffs_FEReadChunkFromNAND; device.eraseBlockInNAND = yaffs_FEEraseBlockInNAND; @@ -616,7 +666,7 @@ int main(int argc,char *argv[]) // yaffs_GutsTest(); - TestTimeBigDeletes(&device); + TestTime(&device); printf("Cache hits %d\n",device.cacheHits); printf("Retired blocks %d\n",device.nRetiredBlocks);