Mercurial > yaffs-ecoscentric
changeset 256:3bd2a4e3262f
Improve test harness for yaffs2 mode
| author | charles |
|---|---|
| date | Fri, 16 Jan 2009 00:47:00 +0000 |
| parents | 467bb4a77339 |
| children | cb6f501bd6c2 |
| files | direct/tests/Makefile direct/tests/yaffs_test.c direct/yaffs_fileem2k.c direct/yaffs_fileem2k.h direct/yaffscfg2k.c |
| diffstat | 5 files changed, 133 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/direct/tests/Makefile +++ b/direct/tests/Makefile @@ -34,6 +34,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc. yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \ yaffs_checkptrw.o yaffs_qsort.o\ yaffs_norif1.o ynorsim.o nor_stress.o yaffs_fsx.o + # yaffs_checkptrwtest.o\ YAFFSTESTOBJS = $(COMMONTESTOBJS) yaffs_test.o @@ -52,7 +53,8 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c YAFFSDIRECTSYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffs_fileem2k.h yaffsfs.h yaffs_malloc.h yaffs_ramdisk.h ydirectenv.h \ yaffscfg.h yaffs_fileem.c yaffs_flashif.c yaffs_ramdisk.c yaffs_ramem2k.c\ - yaffs_norif1.c yaffs_norif1.h ynorsim.c ynorsim.h + yaffs_norif1.c yaffs_norif1.h ynorsim.c ynorsim.h \ + yaffs_nandif.c yaffs_nandif.h SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS)
--- a/direct/tests/yaffs_test.c +++ b/direct/tests/yaffs_test.c @@ -101,7 +101,7 @@ int main(int argc, char **argv) simulate_power_failure = 0; NorStressTestInitialise(mount_point); } else if(do_upgrade){ - printf("Running stress on %s with seed %d\n",argv[1],random_seed); + printf("Running stress on %s with seed %d\n",mount_point,random_seed); NorStressTestRun(mount_point,n_cycles,do_fsx); } else if(do_fsx){ yaffs_fsx_main(mount_point,n_cycles);
--- a/direct/yaffs_fileem2k.c +++ b/direct/yaffs_fileem2k.c @@ -33,7 +33,6 @@ const char *yaffs_flashif2_c_version = " #include "yaffs_fileem2k.h" #include "yaffs_packedtags2.h" -//#define SIMULATE_FAILURES #define REPORT_ERROR 0 @@ -52,7 +51,7 @@ typedef struct #define MAX_HANDLES 20 -#define BLOCKS_PER_HANDLE 8000 +#define BLOCKS_PER_HANDLE (32*8) typedef struct { @@ -64,6 +63,30 @@ static yflash_Device filedisk; int yaffs_testPartialWrite = 0; +extern int random_seed; +extern int simulate_power_failure; +static int initialised = 0; +static int remaining_ops; +static int nops_so_far; + +int ops_multiplier; + + +static void yflash2_MaybePowerFail(void) +{ + + nops_so_far++; + + + remaining_ops--; + if(simulate_power_failure && + remaining_ops < 1){ + printf("Simulated power failure after %d operations\n",nops_so_far); + exit(0); + } +} + + @@ -118,7 +141,11 @@ static int CheckInit(void) initialised = 1; - memset(dummyBuffer,0xff,sizeof(dummyBuffer)); + + srand(random_seed); + remaining_ops = (rand() % 1000) * 2; + memset(dummyBuffer,0xff,sizeof(dummyBuffer)); + filedisk.nBlocks = SIZE_IN_MB * BLOCKS_PER_MB; @@ -179,24 +206,25 @@ int yflash2_WriteChunkWithTagsToNAND(yaf } else { - + /* First do a write of a partial page */ + int n_partials; + int bpos; + if(data) { pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE; h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))]; - lseek(h,pos,SEEK_SET); - nRead = read(h, localBuffer,dev->nDataBytesPerChunk); - for(i = error = 0; i < dev->nDataBytesPerChunk && !error; i++){ - if(REPORT_ERROR && localBuffer[i] != 0xFF){ - printf("nand simulation: chunk %d data byte %d was %0x2\n", - chunkInNAND,i,localBuffer[i]); - error = 1; - } + + memcpy(localBuffer,data, dev->nDataBytesPerChunk); + + n_partials = rand()%20; + + for(i = 0; i < n_partials; i++){ + bpos = rand() % dev->nDataBytesPerChunk; + + localBuffer[bpos] |= (1 << (rand() & 7)); } - - for(i = 0; i < dev->nDataBytesPerChunk; i++) - localBuffer[i] &= data[i]; if(REPORT_ERROR && memcmp(localBuffer,data,dev->nDataBytesPerChunk)) printf("nand simulator: data does not match\n"); @@ -208,14 +236,85 @@ int yflash2_WriteChunkWithTagsToNAND(yaf close(h); exit(1); } + + + if(written != dev->nDataBytesPerChunk) return YAFFS_FAIL; + } + yflash2_MaybePowerFail(); + + if(tags) + { + pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE + PAGE_DATA_SIZE ; + h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))]; -#ifdef SIMULATE_FAILURES - if((chunkInNAND >> 6) == 100) - written = 0; + lseek(h,pos,SEEK_SET); + + if( 0 && dev->isYaffs2) + { + + written = write(h,tags,sizeof(yaffs_ExtendedTags)); + if(written != sizeof(yaffs_ExtendedTags)) return YAFFS_FAIL; + } + else + { + yaffs_PackedTags2 pt; + yaffs_PackTags2(&pt,tags); + __u8 * ptab = (__u8 *)&pt; - if((chunkInNAND >> 6) == 110) - written = 0; -#endif + nRead = read(h,localBuffer,sizeof(pt)); + for(i = error = 0; REPORT_ERROR && i < sizeof(pt) && !error; i++){ + if(localBuffer[i] != 0xFF){ + printf("nand simulation: chunk %d oob byte %d was %0x2\n", + chunkInNAND,i,localBuffer[i]); + error = 1; + } + } + + for(i = 0; i < sizeof(pt); i++) + localBuffer[i] &= ptab[i]; + + n_partials = rand()% sizeof(pt); + + for(i = 0; i < n_partials; i++){ + bpos = rand() % sizeof(pt); + + localBuffer[bpos] |= (1 << (rand() & 7)); + } + + if(REPORT_ERROR && memcmp(localBuffer,&pt,sizeof(pt))) + printf("nand sim: tags corruption\n"); + + lseek(h,pos,SEEK_SET); + + written = write(h,localBuffer,sizeof(pt)); + if(written != sizeof(pt)) return YAFFS_FAIL; + } + } + + //yflash2_MaybePowerFail(); + + /* Next do the whole write */ + if(data) + { + pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE; + h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))]; + + + memset(localBuffer,0xFF, PAGE_SIZE); + for(i = 0; i < dev->nDataBytesPerChunk; i++){ + localBuffer[i] &= data[i]; + } + + if(REPORT_ERROR && memcmp(localBuffer,data,dev->nDataBytesPerChunk)) + printf("nand simulator: data does not match\n"); + + lseek(h,pos,SEEK_SET); + written = write(h,localBuffer,dev->nDataBytesPerChunk); + + if(yaffs_testPartialWrite){ + close(h); + exit(1); + } if(written != dev->nDataBytesPerChunk) return YAFFS_FAIL; @@ -261,6 +360,8 @@ int yflash2_WriteChunkWithTagsToNAND(yaf if(written != sizeof(pt)) return YAFFS_FAIL; } } + + yflash2_MaybePowerFail(); } return YAFFS_OK;
--- a/direct/yaffs_fileem2k.h +++ b/direct/yaffs_fileem2k.h @@ -18,7 +18,7 @@ #if 1 -#define SIZE_IN_MB 128 +#define SIZE_IN_MB 32 //#define SIZE_IN_MB 8000 #define PAGE_DATA_SIZE (2048) #define PAGE_SPARE_SIZE (64)
--- a/direct/yaffscfg2k.c +++ b/direct/yaffscfg2k.c @@ -34,9 +34,7 @@ unsigned yaffs_traceMask = YAFFS_TRACE_ERROR | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE | - YAFFS_TRACE_CHECKPOINT | YAFFS_TRACE_BAD_BLOCKS | - YAFFS_TRACE_VERIFY | 0; @@ -167,21 +165,19 @@ int yaffs_StartUp(void) m18_1Dev.deinitialiseNAND = ynorif1_DeinitialiseNAND; - // /flash (yaffs2) + // /yaffs2 // Set this puppy up to use // the file emulation space as - // 2kpage/64chunk per block/128MB device + // 2kpage/64chunk per block + // memset(&flashDev,0,sizeof(flashDev)); - flashDev.totalBytesPerChunk = 512; + flashDev.totalBytesPerChunk = 2048; flashDev.nChunksPerBlock = 64; flashDev.nReservedBlocks = 5; - flashDev.inbandTags = 1; - //flashDev.checkpointStartBlock = 1; - //flashDev.checkpointEndBlock = 20; + flashDev.inbandTags = 0; flashDev.startBlock = 0; - flashDev.endBlock = 200; // Make it smaller - //flashDev.endBlock = yflash_GetNumberOfBlocks()-1; + flashDev.endBlock = yflash2_GetNumberOfBlocks()-1; flashDev.isYaffs2 = 1; flashDev.wideTnodesDisabled=0; flashDev.nShortOpCaches = 10; // Use caches @@ -193,27 +189,6 @@ int yaffs_StartUp(void) flashDev.markNANDBlockBad = yflash2_MarkNANDBlockBad; flashDev.queryNANDBlock = yflash2_QueryNANDBlock; - // /ram2k - // Set this puppy up to use - // the file emulation space as - // 2kpage/64chunk per block/128MB device - memset(&ram2kDev,0,sizeof(ram2kDev)); - - ram2kDev.totalBytesPerChunk = nandemul2k_GetBytesPerChunk(); - ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock(); - ram2kDev.nReservedBlocks = 5; - ram2kDev.startBlock = 0; // First block after /boot - //ram2kDev.endBlock = 127; // Last block in 16MB - ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB - ram2kDev.isYaffs2 = 1; - ram2kDev.nShortOpCaches = 10; // Use caches - ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat. - ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND; - ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND; - ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND; - ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND; - ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad; - ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock; yaffs_initialise(yaffsfs_config);
