Add more test scripts to automate running tests.
authorCharles Manning <cdhmanning@gmail.com>
Thu, 25 Mar 2010 00:48:41 +0000 (13:48 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 25 Mar 2010 03:01:37 +0000 (16:01 +1300)
direct/tests/README
direct/tests/manage_nand_test.sh [new file with mode: 0755]
direct/tests/manage_nor_test.sh [new file with mode: 0755]
yaffs_guts.c

index 72a349cec657651e78262533ba32e4305331ead0..c4976c2846ce8998e305f4c89df9304137648339 100644 (file)
@@ -10,3 +10,48 @@ If anyone knows otherwise, please contact me: manningc2@actrix.gen.nz
 
 I find it best to run these tests in a ramfs to make them run faster (and
 not pound the disk).
+
+A quick word about running some of these tests...
+
+
+There are two tests, one simulating nor and the other nand, labelled
+
+*nor*.sh and *nand*.sh
+
+These can be run in the local directory as follows:
+$ ./init_fw_update_test_nand.sh
+$ ./run_fw_update_test_nand.sh
+
+NB These create simulation files in the current directory, so only one
+instance can be run in a directory.
+
+The number of iterations can be set by adding a numerical parameter
+
+$ ./init_fw_update_test_nand.sh
+$ ./run_fw_update_test_nand.sh 5000
+
+Since the test creates snapshot files between each iteration the test is
+relatively slow if run against a hard disk. Far better to run against a ram
+disk
+
+$ mkdir xxx
+$ mount -t tmpfs none xxx
+$ cd xxx
+$ cp ../*sh .
+$ ln -s ../yaffs_test yaffs_test
+$ ./init_fw_update_test_nand.sh
+$ ./run_fw_update_test_nand.sh
+
+The above is also wrapped in a script called manage_nor_test.sh which
+creates all the above. The managed_nor_test.sh script accepts an optional
+parameter to specify an instance name. Named instances will create named
+directories.
+
+If you want to run multuiple instances then it is easy to do so with 
+xterm as follows:
+
+$ xterm  -e "`pwd`/manage_nor_test.sh  1"&
+$ xterm  -e "`pwd`/manage_nor_test.sh  2"&
+$ xterm  -e "`pwd`/manage_nor_test.sh  3"&
+...
+
diff --git a/direct/tests/manage_nand_test.sh b/direct/tests/manage_nand_test.sh
new file mode 100755 (executable)
index 0000000..0d02f13
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+dir_id=-none
+[ -z $1 ] || dir_id=$1
+
+RUNDIR=`pwd`/tmpnand$dir_id
+mkdir $RUNDIR
+sudo mount -t tmpfs none $RUNDIR
+sudo chmod a+wr $RUNDIR
+cd $RUNDIR
+cp ../*sh .
+ln -s ../yaffs_test yaffs_test
+
+./init_fw_update_test_nand.sh
+./run_fw_update_test_nand.sh
+
diff --git a/direct/tests/manage_nor_test.sh b/direct/tests/manage_nor_test.sh
new file mode 100755 (executable)
index 0000000..e1c94d5
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+dir_id=-none
+[ -z $1 ] || dir_id=$1
+
+RUNDIR=`pwd`/tmpnor$dir_id
+mkdir $RUNDIR
+sudo mount -t tmpfs none $RUNDIR
+sudo chmod a+wr $RUNDIR
+cd $RUNDIR
+cp ../*sh .
+ln -s ../yaffs_test yaffs_test
+
+./init_fw_update_test_nor.sh
+./run_fw_update_test_nor.sh
+
index 523bfb722b8afc31bd36f4e1ededd9805234460d..feade2aff1044b208adf2647a924f374d79b52b4 100644 (file)
@@ -2943,6 +2943,10 @@ static void yaffs_BlockBecameDirty(yaffs_Device *dev, int blockNo)
 
        bi->blockState = YAFFS_BLOCK_STATE_DIRTY;
 
+       /* If this is the block being garbage collected then stop gc'ing this block */
+       if(blockNo == dev->gcBlock)
+               dev->gcBlock = -1;
+
        if (!bi->needsRetiring) {
                yaffs_InvalidateCheckpoint(dev);
                erasedOk = yaffs_EraseBlockInNAND(dev, blockNo);
@@ -3215,12 +3219,6 @@ static int yaffs_GarbageCollectBlock(yaffs_Device *dev, int block,
        
        bi->hasShrinkHeader = 0;        /* clear the flag so that the block can erase */
 
-       /* Take off the number of soft deleted entries because
-        * they're going to get really deleted during GC.
-        */
-       if(dev->gcChunk == 0) /* first time through for this block */
-               dev->nFreeChunks -= bi->softDeletions;
-
        dev->isDoingGC = 1;
 
        if (isCheckpointBlock ||
@@ -3300,6 +3298,13 @@ static int yaffs_GarbageCollectBlock(yaffs_Device *dev, int block,
                                         * No need to copy this, just forget about it and
                                         * fix up the object.
                                         */
+                                        
+                                       /* Free chunks already includes softdeleted chunks.
+                                        * How ever this chunk is going to soon be really deleted
+                                        * which will increment free chunks.
+                                        * We have to decrement free chunks so this works out properly.
+                                        */
+                                       dev->nFreeChunks--;
 
                                        object->nDataChunks--;
 
@@ -3420,8 +3425,14 @@ static int yaffs_GarbageCollectBlock(yaffs_Device *dev, int block,
 
 
 
-       /* If the gc completed then clear the current gcBlock so that we find another. */
-       if (bi->blockState != YAFFS_BLOCK_STATE_COLLECTING) {
+       if (bi->blockState == YAFFS_BLOCK_STATE_COLLECTING) {
+               /*
+                * The gc did not complete. Set block state back to FULL
+                * because checkpointing does not restore gc.
+                */
+               bi->blockState = YAFFS_BLOCK_STATE_FULL;
+       } else {
+               /* The gc completed. */
                chunksAfter = yaffs_GetErasedChunks(dev);
                if (chunksBefore >= chunksAfter) {
                        T(YAFFS_TRACE_GC,