Tweaks to nor stress simulation. Save random seed so that we can do better debugging
[yaffs2.git] / direct / nor_stress.c
index 0eaaf1bd0f23419dcd9cedd77b92396e7c1a0c06..b3704583a184ffc7f4f5b03f0285ee48783acd82 100644 (file)
@@ -48,8 +48,8 @@ static void FatalError(void)
 
 static void UpdateCounter(const char *name, unsigned *val,  int initialise)
 {
-  int inh;
-  int outh;
+  int inh=-1;
+  int outh=-1;
   unsigned x[2];
   int nread = 0;
   int nwritten = 0;
@@ -139,6 +139,9 @@ static void dump_directory_tree_worker(const char *dname,int recursive)
 
                        if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
                                dump_directory_tree_worker(str,1);
+                               
+                        if(s.st_ino > 10000)
+                          FatalError();
                                                        
                }
                
@@ -287,10 +290,11 @@ static int yVerifyFile(const char *fName)
        return retval;
 }
 
-static unsigned long next = 1;
+extern int random_seed;
+
 int myrand(void) {
-  next = next * 1103515245 + 12345;
-  return((unsigned)(next/65536) % 32768);
+  random_seed = random_seed * 1103515245 + 12345;
+  return((unsigned)(random_seed/65536) % 32768);
 }
 
 static void DoUpdateMainFile(void)
@@ -341,13 +345,16 @@ void NorStressTestRun(const char *prefix)
   dump_directory_tree(fullPathName);
   
   UpdateCounter(fullPowerUpName,&powerUps,0);
+  dump_directory_tree(fullPathName);
   
   while(1){
     UpdateCounter(fullStartName, &cycleStarts,0);
+    dump_directory_tree(fullPathName);
     DoVerifyMainFile();
     DoUpdateMainFile();
     dump_directory_tree(fullPathName);
   
     UpdateCounter(fullEndName,&cycleEnds,0);
+    dump_directory_tree(fullPathName);
   }
 }