projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffs Add multi and single version Linux glue code
[yaffs2.git]
/
direct
/
tests
/
nor_stress.c
diff --git
a/direct/tests/nor_stress.c
b/direct/tests/nor_stress.c
index 5676159e4045db946b20410346d1cc4e3639cf3b..6f6b4ce583c74fee117a81d5fe041b3a98510797 100644
(file)
--- a/
direct/tests/nor_stress.c
+++ b/
direct/tests/nor_stress.c
@@
-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"
#include "nor_stress.h"
@@
-7,6
+21,7
@@
#include <stdio.h>
#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)
#if 1
#define FSX_INIT(mount_pt) do{ if(interleave_fsx) yaffs_fsx_init(mount_pt); } while(0)
@@
-27,12
+42,16
@@
do { \
#endif
#endif
+void (*ext_fatal)(void) = NULL;
+
static unsigned powerUps;
static unsigned cycleStarts;
static unsigned cycleEnds;
static int interleave_fsx;
static unsigned powerUps;
static unsigned cycleStarts;
static unsigned cycleEnds;
static int interleave_fsx;
+static int no_verification;
+
char fullPathName[100];
char fullPowerUpName[100];
char fullStartName[100];
char fullPathName[100];
char fullPowerUpName[100];
char fullStartName[100];
@@
-68,13
+87,24
@@
void MakeFullNames(const char *prefix)
MakeName(fullTempMainName,prefix,"tmp-main");
}
MakeName(fullTempMainName,prefix,"tmp-main");
}
-static void FatalError(
void
)
+static void FatalError(
int lineNo
)
{
{
- printf("Integrity error\n");
+ printf("Integrity error %d\n",lineNo);
+
+ if(fuzz_test)
+ return;
+
+ if(ext_fatal)
+ ext_fatal();
+
while(1){
sleep(1);
}
}
while(1){
sleep(1);
}
}
+void print_stat(const char *str, struct yaffs_stat *st)
+{
+ printf("%s inode %d\n",str,st->st_ino);
+}
static void UpdateCounter(const char *name, unsigned *val, int initialise)
{
static void UpdateCounter(const char *name, unsigned *val, int initialise)
{
@@
-96,11
+126,12
@@
static void UpdateCounter(const char *name, unsigned *val, int initialise)
yaffs_close(inh);
}
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());
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();
+ FatalError(
__LINE__
);
}
x[0]++;
}
x[0]++;
@@
-109,12
+140,23
@@
static void UpdateCounter(const char *name, unsigned *val, int initialise)
FSX();
outh = yaffs_open(fullTempCounterName, O_RDWR | O_TRUNC | O_CREAT, S_IREAD | S_IWRITE);
FSX();
outh = yaffs_open(fullTempCounterName, O_RDWR | O_TRUNC | O_CREAT, S_IREAD | S_IWRITE);
+
if(outh >= 0){
if(outh >= 0){
+ struct yaffs_stat tmpstat, oldstat, tmpfstat;
FSX();
FSX();
+ yaffs_fstat(outh,&tmpfstat);
+ printf("\n\n\n*** Writing file %s inode %d\n",fullTempCounterName,tmpfstat.st_ino);
nwritten = yaffs_write(outh,x,sizeof(x));
FSX();
yaffs_close(outh);
FSX();
nwritten = yaffs_write(outh,x,sizeof(x));
FSX();
yaffs_close(outh);
FSX();
+
+ printf("About to rename %s to %s\n",fullTempCounterName,name);
+ yaffs_stat(fullTempCounterName,&tmpstat);
+ yaffs_stat(name,&oldstat);
+ print_stat("old stat",&oldstat);
+ print_stat("new stat",&tmpstat);
+ print_stat("new fstat",&tmpfstat);
yaffs_rename(fullTempCounterName,name);
FSX();
}
yaffs_rename(fullTempCounterName,name);
FSX();
}
@@
-122,7
+164,7
@@
static void UpdateCounter(const char *name, unsigned *val, int initialise)
if(nwritten != sizeof(x)){
printf("Error writing counter %s handle %d, x[0] %u x[1] %u\n",
name, inh, x[0], x[1]);
if(nwritten != sizeof(x)){
printf("Error writing counter %s handle %d, x[0] %u x[1] %u\n",
name, inh, x[0], x[1]);
- FatalError();
+ FatalError(
__LINE__
);
}
*val = x[0];
}
*val = x[0];
@@
-139,6
+181,8
@@
static void dump_directory_tree_worker(const char *dname,int recursive)
yaffs_dirent *de;
struct yaffs_stat s;
char str[1000];
yaffs_dirent *de;
struct yaffs_stat s;
char str[1000];
+ int error_line = 0;
+ int nentries;
d = yaffs_opendir(dname);
d = yaffs_opendir(dname);
@@
-148,15
+192,22
@@
static void dump_directory_tree_worker(const char *dname,int recursive)
}
else
{
}
else
{
+ nentries = 0;
while((de = yaffs_readdir(d)) != NULL)
{
strcpy(str,dname);
strcat(str,"/");
strcat(str,de->d_name);
while((de = yaffs_readdir(d)) != NULL)
{
strcpy(str,dname);
strcat(str,"/");
strcat(str,de->d_name);
+ nentries++;
yaffs_lstat(str,&s);
yaffs_lstat(str,&s);
- printf("%s inode %d obj %x length %d mode %X ",str,s.st_ino,de->d_dont_use,(int)s.st_size,s.st_mode);
+ printf("%s inode %ld %d obj %x length %d mode %X ",str, de->d_ino, s.st_ino,de->d_dont_use,(int)s.st_size,s.st_mode);\
+ if(de->d_ino != s.st_ino){
+ printf(" \n\n!!!! HEY inode mismatch\n\n");
+ error_line = __LINE__;
+ }
+
switch(s.st_mode & S_IFMT)
{
case S_IFREG: printf("data file"); break;
switch(s.st_mode & S_IFMT)
{
case S_IFREG: printf("data file"); break;
@@
-176,10
+227,18
@@
static void dump_directory_tree_worker(const char *dname,int recursive)
dump_directory_tree_worker(str,1);
if(s.st_ino > 10000)
dump_directory_tree_worker(str,1);
if(s.st_ino > 10000)
-
FatalError()
;
+
error_line = __LINE__
;
}
}
+ if(strstr(dname,"lost+found") && nentries >0){
+ printf("\n\n!!! HEY lost+found not empty, had %d entries\n\n\n",nentries);
+ error_line = __LINE__;
+ }
+
+ if(error_line && !no_verification)
+ FatalError(error_line);
+
yaffs_closedir(d);
}
yaffs_closedir(d);
}
@@
-204,12
+263,15
@@
static int yWriteFile(const char *fname, unsigned sz32)
int h;
int r;
int i;
int h;
int r;
int i;
+ struct yaffs_stat st;
unsigned checksum = 0;
unsigned checksum = 0;
- printf("Writing file %s\n",fname);
FSX();
h = yaffs_open(fname,O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
FSX();
h = yaffs_open(fname,O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+ yaffs_fstat(h,&st);
+ printf("\n\n\n**** Open writing file %s inode %d\n",fname, st.st_ino);
+
FSX();
if(h < 0){
FSX();
if(h < 0){
@@
-245,6
+307,7
@@
static int yWriteFile(const char *fname, unsigned sz32)
FSX();
yaffs_close(h);
FSX();
yaffs_close(h);
+ printf("File closed\n");
return 0;
WRITE_ERROR:
return 0;
WRITE_ERROR:
@@
-265,6
+328,8
@@
static int yVerifyFile(const char *fName)
int i;
int retval = 0;
int i;
int retval = 0;
+ if(no_verification)
+ return 0;
printf("Verifying file %s\n",fName);
printf("Verifying file %s\n",fName);
@@
-337,8
+402,9
@@
static void DoUpdateMainFile(void)
result = yWriteFile(fullTempMainName,sz32);
FSX();
result = yWriteFile(fullTempMainName,sz32);
FSX();
- if(result)
- FatalError();
+ if(!no_verification && result)
+ FatalError(__LINE__);
+ printf("Raname file %s to %s\n",fullTempMainName,fullMainName);
yaffs_rename(fullTempMainName,fullMainName);
FSX();
}
yaffs_rename(fullTempMainName,fullMainName);
FSX();
}
@@
-346,9
+412,11
@@
static void DoUpdateMainFile(void)
static void DoVerifyMainFile(void)
{
int result;
static void DoVerifyMainFile(void)
{
int result;
+ if(no_verification)
+ return;
result = yVerifyFile(fullMainName);
if(result)
result = yVerifyFile(fullMainName);
if(result)
- FatalError();
+ FatalError(
__LINE__
);
}
}
@@
-366,10
+434,14
@@
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;
interleave_fsx = do_fsx;
+ no_verification = skip_verification;
+
MakeFullNames(prefix);
MakeFullNames(prefix);
+ dump_directory_tree(fullPathName);
FSX_INIT(prefix);
dump_directory_tree(fullPathName);
FSX_INIT(prefix);
dump_directory_tree(fullPathName);