yaffs Get fuzz tester to run further
[yaffs2.git] / direct / tests / nor_stress.c
index 28fbb2d6015fca8e00f188c82d3692b19e753878..3802837130d997e1f34840ddcdc2b3c470fb9094 100644 (file)
@@ -1,3 +1,17 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
 #include "nor_stress.h"
 
 
@@ -7,6 +21,7 @@
 #include <stdio.h>
 
 
+extern int fuzz_test;
 
 #if 1
 #define FSX_INIT(mount_pt) do{ if(interleave_fsx) yaffs_fsx_init(mount_pt); } while(0)
@@ -35,6 +50,8 @@ static unsigned cycleEnds;
 
 static int interleave_fsx;
 
+static int no_verification;
 char fullPathName[100];
 char fullPowerUpName[100];
 char fullStartName[100];
@@ -73,6 +90,10 @@ void MakeFullNames(const char *prefix)
 static void FatalError(int lineNo)
 {
   printf("Integrity error %d\n",lineNo);
+
+  if(fuzz_test)
+       return;
+
   if(ext_fatal)
        ext_fatal();
        
@@ -105,8 +126,9 @@ static void UpdateCounter(const char *name, unsigned *val,  int initialise)
       yaffs_close(inh);
     }
 
-    if(nread != sizeof(x) ||
-       x[0] + 1 != x[1]){
+    if(!no_verification &&
+      (nread != sizeof(x) ||
+       x[0] + 1 != x[1])){
       printf("Error reading counter %s handle %d, x[0] %u x[1] %u last error %d\n",
               name, inh, x[0], x[1],yaffsfs_GetLastError());
       FatalError(__LINE__);
@@ -206,7 +228,7 @@ static void dump_directory_tree_worker(const char *dname,int recursive)
                                                        
                }
                
-               if(error_line)
+               if(error_line && !no_verification)
                        FatalError(error_line);
                
                yaffs_closedir(d);
@@ -298,6 +320,8 @@ static int yVerifyFile(const char *fName)
        int i;
        int retval = 0;
 
+       if(no_verification)
+               return 0;
 
         printf("Verifying file %s\n",fName);
                
@@ -370,7 +394,7 @@ static void DoUpdateMainFile(void)
         
        result = yWriteFile(fullTempMainName,sz32);
        FSX();
-       if(result)
+       if(!no_verification && result)
            FatalError(__LINE__);
        printf("Raname file %s to %s\n",fullTempMainName,fullMainName);
        yaffs_rename(fullTempMainName,fullMainName);
@@ -380,6 +404,8 @@ static void DoUpdateMainFile(void)
 static void DoVerifyMainFile(void)
 {
         int result;
+       if(no_verification)
+               return;
        result = yVerifyFile(fullMainName);
        if(result)
            FatalError(__LINE__);
@@ -400,10 +426,12 @@ void NorStressTestInitialise(const char *prefix)
 }
 
 
-void NorStressTestRun(const char *prefix, int n_cycles, int do_fsx)
+void NorStressTestRun(const char *prefix, int n_cycles, int do_fsx, int skip_verification)
 {
 
   interleave_fsx = do_fsx;
+  no_verification = skip_verification;
   MakeFullNames(prefix);
   dump_directory_tree(fullPathName);
   FSX_INIT(prefix);