Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
authorCharles Manning <cdhmanning@gmail.com>
Tue, 14 Dec 2010 22:45:30 +0000 (11:45 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 14 Dec 2010 22:45:30 +0000 (11:45 +1300)
34 files changed:
direct/timothy_tests/handle_tests/Makefile [new file with mode: 0644]
direct/timothy_tests/handle_tests/handle_test.c [new file with mode: 0644]
direct/timothy_tests/handle_tests/handle_test.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/Makefile [new file with mode: 0644]
direct/timothy_tests/mirror_tests/current_bugs.txt [new file with mode: 0644]
direct/timothy_tests/mirror_tests/lib.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/lib.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_open.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_open.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_truncate.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_truncate.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/mirror_tests.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/mirror_tests.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_open.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_open.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_truncate.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_truncate.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_read.c
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_rename.c
direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c
direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c
direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c
direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c
direct/timothy_tests/quick_tests/test_yaffs_rmdir.c
direct/timothy_tests/quick_tests/test_yaffs_rmdir_EBUSY.c
direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_rmdir_NULL.c
direct/timothy_tests/quick_tests/test_yaffs_stat.c
direct/timothy_tests/quick_tests/test_yaffs_write_big_file.c

diff --git a/direct/timothy_tests/handle_tests/Makefile b/direct/timothy_tests/handle_tests/Makefile
new file mode 100644 (file)
index 0000000..6ad275c
--- /dev/null
@@ -0,0 +1,113 @@
+# Makefile for YAFFS direct stress tests
+#
+#
+# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
+#
+# Copyright (C) 2003-2010 Aleph One Ltd.
+#
+#
+# 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.
+#
+# NB Warning this Makefile does not include header dependencies.
+#
+# $Id: Makefile,v 1.7 2010-02-25 22:34:47 charles Exp $
+
+#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
+
+CFLAGS =      -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2  
+CFLAGS +=     -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
+CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing 
+#CFLAGS +=    -fno-strict-aliasing
+CFLAGS +=    -O0
+CFLAGS +=    -Wextra -Wpointer-arith
+#CFLAGS +=    -DCONFIG_YAFFS_VALGRIND_TEST
+
+#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
+#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
+
+
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
+                yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+                yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
+                yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
+                yaffs_checkptrw.o  yaffs_qsort.o\
+                yaffs_nameval.o yaffs_attribs.o \
+                yaffs_norif1.o  ynorsim.o  \
+                yaffs_allocator.o \
+                yaffs_bitmap.o \
+                yaffs_yaffs1.o \
+                yaffs_yaffs2.o \
+                yaffs_verify.o \
+                yaffs_error.o
+
+#               yaffs_checkptrwtest.o\
+
+TESTFILES =    handle_test.o 
+
+
+                 
+
+YAFFSTESTOBJS  = $(COMMONTESTOBJS) $(TESTFILES)
+
+
+ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS)
+
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
+          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
+          yaffs_nameval.c yaffs_nameval.h \
+          yaffs_trace.h yaffs_attribs.h \
+          yaffs_allocator.c yaffs_allocator.h \
+          yaffs_yaffs1.c yaffs_yaffs1.h \
+          yaffs_yaffs2.c yaffs_yaffs2.h \
+          yaffs_bitmap.c yaffs_bitmap.h \
+          yaffs_verify.c yaffs_verify.h
+
+YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
+                      yaffsfs.h ydirectenv.h \
+                      yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
+                      yaffs_nandemul2k.h yaffs_list.h \
+                      yaffs_attribs.c yaffs_osglue.h \
+                      yaffs_nandif.c yaffs_nandif.h yportenv.h \
+                      yaffs_hweight.h yaffs_hweight.c \
+                      yaffs_error.c
+
+
+DIRECTEXTRASYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
+                       yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
+                       yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
+                       ynorsim.h ynorsim.c yaffs_osglue.c
+
+SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS)
+#all: directtest2k boottest
+
+all: handle_test
+
+$(ALLOBJS): %.o: %.c
+       gcc -c $(CFLAGS) -o $@ $<
+
+$(PYTONOSYMLINKS):
+       ln -s ../../python/$@ $@
+
+$(YAFFSSYMLINKS):
+       ln -s ../../../$@ $@
+
+$(YAFFSDIRECTSYMLINKS):
+       ln -s ../../$@ $@
+
+$(DIRECTEXTRASYMLINKS):
+       ln -s ../../basic-test/$@ $@
+
+
+handle_test: $(SYMLINKS) $(ALLOBJS)
+       gcc $(CFLLAG) -o $@ $(ALLOBJS)
+
+
+
+clean:
+       rm -f handle_test  $(ALLOBJS) core $(SYMLINKS) 
diff --git a/direct/timothy_tests/handle_tests/handle_test.c b/direct/timothy_tests/handle_tests/handle_test.c
new file mode 100644 (file)
index 0000000..6182abf
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "handle_test.h"
+
+int random_seed;
+int simulate_power_failure = 0;
+
+int main()
+{
+       
+       int test_batch = 1000000;
+       int output =0;
+       unsigned int total_number_of_tests_run=0;
+       yaffs_start_up();
+       yaffs_mount("yaffs2");
+
+       printf("running tests\n");
+
+       output=dup_test();
+       printf("dup test: %d\n ",output);
+
+       while (1){
+               output = open_close_handle_test(test_batch);
+               if (output>=0){
+                       total_number_of_tests_run ++;
+               } else {
+                       get_error();
+                       return -1;
+               }
+               printf("total number of tests = %d\n",(total_number_of_tests_run*test_batch));
+       }
+
+
+       return 0;
+}
+int dup_test(void){
+       int handle = -1;
+       int handle2 = -1;
+       int output =-1;
+
+       handle =open_handle();
+       if (handle<0){
+               printf("error: failed to open handle\n");
+               return -1;
+       }
+       handle2=yaffs_dup(handle);
+       if (handle2<0){
+               printf("error: failed to open handle2\n");
+               return -1;
+       }
+       
+       output=yaffs_lseek(handle,20,SEEK_SET);
+       if (output >= 0) {
+               output = yaffs_lseek(handle,0,SEEK_CUR);
+               if (output = 20){
+                       printf("dup is working\n");
+                       return 1;
+               } else if (output <0){
+                       printf("failed to lseek the second time\n");
+                       return -1;
+               } else {
+                       printf("lseek position is diffrent than expected\n");
+                       return -1;
+               }
+       } else {
+               printf("failed to lseek the first time\n");
+               return -1;
+       }
+
+}
+
+int open_close_handle_test(int num_of_tests)
+{
+       int handle_number=open_handle();
+       int handle=0;
+       int x =0;
+       int output=0;
+       yaffs_close(handle_number);
+       for (x=0;x<num_of_tests;x++){
+               handle=open_handle();
+               if (handle != handle_number){
+                       printf("handle number changed\n");
+                       printf("test number= %d\n",x);
+                       printf("expected number = %d\n",handle_number);
+                       printf("handle_number = %d\n",handle);
+                       return -1;
+               }
+               output=yaffs_close(handle);
+               if (output <0){
+                       printf("failed to close file\n");
+                       return -1;
+               }
+       }
+       return 1;
+}
+
+void get_error(void)
+{
+       int error_code=0;
+       error_code=yaffs_get_error();
+       printf("yaffs_error code %d\n",error_code);
+       printf("error is : %s\n",yaffs_error_to_str(error_code));
+}
+
+int open_handle(void)
+{
+       return yaffs_open(FILE_PATH,O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
+}
+
diff --git a/direct/timothy_tests/handle_tests/handle_test.h b/direct/timothy_tests/handle_tests/handle_test.h
new file mode 100644 (file)
index 0000000..3ab2510
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __handle_test_h__
+#define __handle_test_h__
+
+#include <stdio.h>
+#include "yaffsfs.h"
+
+#define FILE_PATH "/yaffs2/foo"
+
+int open_close_handle_test(int num_of_tests);
+int open_handle(void);
+void get_error(void);
+#endif
diff --git a/direct/timothy_tests/mirror_tests/Makefile b/direct/timothy_tests/mirror_tests/Makefile
new file mode 100644 (file)
index 0000000..d252e4b
--- /dev/null
@@ -0,0 +1,115 @@
+# Makefile for YAFFS direct stress tests
+#
+#
+# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
+#
+# Copyright (C) 2003-2010 Aleph One Ltd.
+#
+#
+# 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.
+#
+# NB Warning this Makefile does not include header dependencies.
+#
+# $Id: Makefile,v 1.7 2010-02-25 22:34:47 charles Exp $
+
+#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
+
+CFLAGS =      -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2  
+CFLAGS +=     -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
+CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing 
+#CFLAGS +=    -fno-strict-aliasing
+CFLAGS +=    -O0
+CFLAGS +=    -Wextra -Wpointer-arith
+#CFLAGS +=    -DCONFIG_YAFFS_VALGRIND_TEST
+
+#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
+#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
+
+
+COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
+                yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+                yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
+                yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
+                yaffs_checkptrw.o  yaffs_qsort.o\
+                yaffs_nameval.o yaffs_attribs.o \
+                yaffs_norif1.o  ynorsim.o  \
+                yaffs_allocator.o \
+                yaffs_bitmap.o \
+                yaffs_yaffs1.o \
+                yaffs_yaffs2.o \
+                yaffs_verify.o \
+                yaffs_error.o
+
+#               yaffs_checkptrwtest.o\
+
+TESTFILES =    mirror_tests.o lib.o\
+               linux_test_open.o yaffs_test_open.o\
+               linux_test_truncate.o yaffs_test_truncate.o
+
+
+                 
+
+YAFFSTESTOBJS  = $(COMMONTESTOBJS) $(TESTFILES)
+
+
+ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS)
+
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
+          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
+          yaffs_nameval.c yaffs_nameval.h \
+          yaffs_trace.h yaffs_attribs.h \
+          yaffs_allocator.c yaffs_allocator.h \
+          yaffs_yaffs1.c yaffs_yaffs1.h \
+          yaffs_yaffs2.c yaffs_yaffs2.h \
+          yaffs_bitmap.c yaffs_bitmap.h \
+          yaffs_verify.c yaffs_verify.h
+
+YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
+                      yaffsfs.h ydirectenv.h \
+                      yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
+                      yaffs_nandemul2k.h yaffs_list.h \
+                      yaffs_attribs.c yaffs_osglue.h \
+                      yaffs_nandif.c yaffs_nandif.h yportenv.h \
+                      yaffs_hweight.h yaffs_hweight.c \
+                      yaffs_error.c
+
+
+DIRECTEXTRASYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
+                       yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
+                       yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
+                       ynorsim.h ynorsim.c yaffs_osglue.c
+
+SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS)
+#all: directtest2k boottest
+
+all: mirror_tests
+
+$(ALLOBJS): %.o: %.c
+       gcc -c $(CFLAGS) -o $@ $<
+
+$(PYTONOSYMLINKS):
+       ln -s ../../python/$@ $@
+
+$(YAFFSSYMLINKS):
+       ln -s ../../../$@ $@
+
+$(YAFFSDIRECTSYMLINKS):
+       ln -s ../../$@ $@
+
+$(DIRECTEXTRASYMLINKS):
+       ln -s ../../basic-test/$@ $@
+
+
+mirror_tests: $(SYMLINKS) $(ALLOBJS)
+       gcc $(CFLLAG) -o $@ $(ALLOBJS)
+
+
+
+clean:
+       rm -f mirror_tests  $(ALLOBJS) core $(SYMLINKS) 
diff --git a/direct/timothy_tests/mirror_tests/current_bugs.txt b/direct/timothy_tests/mirror_tests/current_bugs.txt
new file mode 100644 (file)
index 0000000..523fd3b
--- /dev/null
@@ -0,0 +1,3 @@
+
+BUGS
+       In yaffs having a pathname "yaffs2/tests//.." appears to create a file called ".." unstead of going back a directory.
diff --git a/direct/timothy_tests/mirror_tests/lib.c b/direct/timothy_tests/mirror_tests/lib.c
new file mode 100644 (file)
index 0000000..1a9d6ac
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "lib.h"
+
+static int EXIT_ON_ERROR = 1;
+static int  PRINT_LEVEL = 2;   //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3  
+                       //0 just prints the number of tests passed and failed.
+                       //1 is the basic print level. it will print the details of a failed test.
+                       //2 will print if a test passes and cleans. 
+void set_print_level(int new_level)
+{
+       PRINT_LEVEL=new_level;
+}
+
+void set_exit_on_error(int num)
+{
+       EXIT_ON_ERROR=num;
+}
+
+int get_exit_on_error(void)
+{
+       return EXIT_ON_ERROR;
+}
+
+void display_error(void)
+{
+       
+}
+
+void  generate_random_string(char *ptr,int length_of_str){
+       unsigned int x;
+       unsigned int length=((rand() %(length_of_str-3))+3);    /*creates a int with the number of charecters been between 1 and 51*/           
+       char letter='\0';
+       strcpy(ptr,"");
+       //printf("generating string\n");
+       //printf("string length is %d\n",length);
+       for (x=0; x <= (length-2) &&length>2 ; x++)
+       {
+               //printf("x=%d\n",x);   
+               /* keep generating a charecter until the charecter is legal*/
+               while((letter=='\0' )||(letter=='/')||(letter=='\\')){
+                       letter=(rand() % 125-59)+58;    /*generate a number between 32 and 126 and uses it as a charecter (letter) */
+               }       
+               ptr[x]=letter;
+               //printf("charecter generated is %c\n",ptr[x]);
+       }
+       ptr[x+1]='\0';  /*adds NULL charecter to turn it into a string*/
+       
+}
+
+void join_paths(char *path1,char *path2,char *new_path )
+{
+       char message[100];
+       print_message(3,"joining paths\n");
+       sprintf(message,"path1: %s\n",path1);
+       print_message(3,message);
+       sprintf(message,"path2: %s\n",path2);
+       print_message(3,message);
+       strcpy(new_path,"");
+       //strcat(new_path,path1);       /*since all functions have this then pull it out*/
+       if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
+               /*paths are compatiable. concatanate them. note -2 is because of \0*/  
+               strcat(new_path,path1);
+               strcat(new_path,path2);         
+               //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
+               //strcpy(new_path,strcat(path1,path2)); 
+               //return new_path;
+       } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
+               /*paths are compatiable. concatanate them*/  
+               strcat(new_path,path1);
+               strcat(new_path,path2);         
+
+       } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
+                       /*need to add a "/". */  
+               strcat(new_path,path1);
+               strcat(new_path,"/");
+               strcat(new_path,path2);
+
+       } else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
+               /*need to remove a "/". */
+               /*yaffs does not mind the extra slash. */               
+               strcat(new_path,path1);
+               strcat(new_path,path2);
+
+       } else {
+               //error 
+               //return -1;
+       }
+}
+
+void print_message(char print_level,char *message)
+{
+       if (print_level <= PRINT_LEVEL){
+               printf(message);
+       }
+}
+       
+
+
diff --git a/direct/timothy_tests/mirror_tests/lib.h b/direct/timothy_tests/mirror_tests/lib.h
new file mode 100644 (file)
index 0000000..99c2763
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef _lib_h__
+#define _lib_h__
+
+#include <stdio.h>
+#include <string.h>
+#include "yaffsfs.h"
+
+
+typedef struct arg_temp2{
+       char char1;
+       char char2;
+       char string1[100];
+       char string2[100];
+       int int1;
+       int int2;
+} arg_temp;
+
+
+typedef struct test_dir_temp
+{
+       int type_of_test; //used to tell if it is LINUX of YAFFS
+       char root_path[200];
+} test_dir;
+test_dir yaffs_struct,linux_struct;
+
+
+
+void generate_random_string(char *ptr,int length_of_str);
+void join_paths(char *path1,char *path2,char *new_path );
+void print_message(char print_level, char *message);
+void set_print_level(int new_level);
+void set_exit_on_error(int num);
+int get_exit_on_error(void);
+void display_error(void);
+
+#endif
diff --git a/direct/timothy_tests/mirror_tests/linux_test_open.c b/direct/timothy_tests/mirror_tests/linux_test_open.c
new file mode 100644 (file)
index 0000000..0f90039
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "linux_test_open.h"
+
+int linux_test_open(arg_temp *args_struct)
+{
+       char path[250];
+       char message[150];
+       int output;
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output= open(path,args_struct->char1 & (O_TRUNC|O_EXCL|O_CREAT|O_APPEND) ,args_struct->char2& (S_IREAD|S_IWRITE));
+       if (output>=0){
+               output=close(output);
+               if (output<0) {
+                       print_message(3,"failed to close handle\n");
+                       return -1;
+               } else {
+                       return 1;
+               }
+       } else {
+               print_message(3,"failed to open file\n");
+               return -1;
+       }
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_open.h b/direct/timothy_tests/mirror_tests/linux_test_open.h
new file mode 100644 (file)
index 0000000..40d3492
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __linux_test_open_h__
+#define __linux_test_open_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "lib.h"
+
+int linux_test_open(arg_temp *args_struct);
+#endif
diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.c b/direct/timothy_tests/mirror_tests/linux_test_truncate.c
new file mode 100644 (file)
index 0000000..8cdaace
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "linux_test_truncate.h"
+
+int linux_test_truncate(arg_temp *args_struct)
+{
+       char path[200];
+       char message[200];
+       int output=0;
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output=truncate(path,args_struct->int1);
+       return output;
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.h b/direct/timothy_tests/mirror_tests/linux_test_truncate.h
new file mode 100644 (file)
index 0000000..219c96d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __linux_test_truncate_h__
+#define __linux_test_truncate_h__
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int linux_test_truncate(arg_temp *args_struct);
+
+#endif
diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.c b/direct/timothy_tests/mirror_tests/mirror_tests.c
new file mode 100644 (file)
index 0000000..a022e4d
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "mirror_tests.h"
+
+int random_seed;
+int simulate_power_failure = 0;
+
+int num_of_random_tests=1;
+
+
+
+typedef struct test_list_temp2{
+       char *test_name;
+       int (*test_pointer)(arg_temp *args_struct);
+}test_list_temp;
+
+typedef struct test_temp2 {
+       int num_of_tests;
+       test_list_temp test_list[];
+}test_temp;
+
+test_temp yaffs_tests={
+       2,
+       {{"yaffs_test_open",yaffs_test_open},
+       {"yaffs_test_truncate",yaffs_test_truncate}
+       }
+};
+
+test_temp linux_tests={
+       2,
+       {{"linux_test_open",linux_test_open},
+       {"linux_test_truncate",linux_test_truncate}
+       }
+};
+
+
+int main(int argc, char *argv[])
+{
+       char message[100];
+       int x;
+//     yaffs_tests.num_of_tests=(sizeof(yaffs_tests)/sizeof(test_temp));
+//     linux_tests.num_of_tests=(sizeof(linux_tests)/sizeof(test_temp));
+
+       init(argc,argv);
+       print_message(1,"running mirror_tests\n");
+       sprintf(message,"linux_root_path: %s\n",linux_struct.root_path);
+       print_message(3,message);
+       sprintf(message,"yaffs_root_path: %s\n",yaffs_struct.root_path);
+       print_message(3,message);
+       sprintf(message,"linux_num_of_tests: %d\n",linux_tests.num_of_tests);
+       print_message(3,message);
+       sprintf(message,"yaffs_num_of_tests: %d\n",yaffs_tests.num_of_tests);
+       print_message(3,message);
+       for (x=0;x<num_of_random_tests;x++){
+               run_random_test();
+       }
+       yaffs_unmount("yaffs2");
+       return 0;
+}
+
+void init(int argc, char *argv[])
+{
+       char dir[200];
+       dir[0]='\0';
+       int x=-1;
+       char message[100];
+       
+       srand((unsigned)time(NULL));
+       linux_struct.type_of_test =LINUX;
+       yaffs_struct.type_of_test =YAFFS;
+
+       sprintf(message,"current absolute path is: %s\n",getcwd(dir,200));
+       print_message(3,message);
+       strcpy(dir,getcwd(dir,200));
+
+       strcat(dir,"/test/");
+       printf("dir: %s\n",dir);
+       strcpy(linux_struct.root_path,dir);
+       strcpy(yaffs_struct.root_path,"yaffs2/test/");  
+
+
+       for (x=0;x<argc;x++){
+               if (strcmp(argv[x],"-h")==0){
+                       printf("mirror_tests help\n");
+                       printf("arguments:\n");
+                       printf("\t-yaffs_path [PATH] //sets the path for yaffs.\n");
+                       printf("\t-linux_path [PATH] //sets the path for linux.\n");
+                       printf("\t-p [NUMBER] //sets the print level for mirror_tests.\n");
+                       printf("\t-v //verbose mode everything is printed\n");
+                       printf("\t-q //quiet mode nothing is printed.\n");
+                       printf("\t-n [number] //sets the number of random tests to run.\n");
+                       printf("\t-s [number] //seeds rand with the number\n");
+                       exit(0);
+               } else if (strcmp(argv[x],"-yaffs_path")==0){
+                       strcpy(yaffs_struct.root_path, argv[x+1]);
+               } else if (strcmp(argv[x],"-linux_path")==0){
+                       strcpy(linux_struct.root_path, argv[x+1]);
+               } else if (strcmp(argv[x],"-p")==0){
+                       set_print_level(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-v")==0){
+                       set_print_level(5);
+               } else if (strcmp(argv[x],"-q")==0){
+                       set_print_level(-1);
+               } else if (strcmp(argv[x],"-n")==0){
+                       num_of_random_tests=atoi(argv[x+1]);
+               } else if (strcmp(argv[x],"-n")==0){
+                       //srand(atoi(argv[x+1]));
+               }
+       }
+
+       yaffs_start_up();
+       print_message(message,"\nmounting yaffs\n");
+       x=yaffs_mount("yaffs2");
+       if (x<0) {
+               print_message(3,"failed to mount yaffs\n");
+               get_error_yaffs();
+       } else {
+               print_message(3,"mounted yaffs\n");
+       }
+
+
+       print_message(3,"\nmaking linux test dir\n");
+       x=mkdir(linux_struct.root_path,0777);
+       if (x<0) {
+               print_message(1,"failed to make dir\n");
+               get_error_linux();
+       } else {
+               print_message(3,"made dir\n");
+       }
+
+       print_message(3,"\nmaking yaffs test dir\n");
+       x=yaffs_mkdir(yaffs_struct.root_path,0777);
+       if (x<0) {
+               print_message(1,"failed to make dir\n");
+               get_error_yaffs();
+       } else {
+               print_message(3,"made dir\n");
+       }
+}
+
+int run_random_test(void)
+{
+       int x=-1;
+       int id=0;
+       int test_id=-1;
+       int num_of_tests=1;
+       char message[100];
+       arg_temp args_struct;
+       for (x=0;x<num_of_tests;x++) {
+               errno=0;
+               yaffs_set_error(0);
+               test_id = select_test_id(yaffs_tests.num_of_tests);
+               sprintf(message,"running test_id %d\n",test_id);
+               print_message(3,message);
+               generate_random_numbers(&args_struct);
+               run_yaffs_test(test_id, &args_struct);
+               run_linux_test(test_id, &args_struct);
+               if      ((abs(yaffs_get_error())!=abs(errno)) &&
+                       (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
+                       (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
+                       ){
+                       print_message(2,"\ndiffrence in returned errors######################################\n");
+                       get_error_yaffs();
+                       get_error_linux();
+                       if (get_exit_on_error()){ 
+                               exit(0);
+                       }
+               }
+       }
+       compare_linux_and_yaffs(); 
+}
+
+int select_test_id(int test_len)
+{
+       int id=0;
+       //printf("test_len = %d\n",test_len);
+       id=(rand() % test_len );
+       //printf("id %d\n",id);
+       return id;
+
+}
+
+int compare_linux_and_yaffs(void)
+{
+//     generate_array_of_objects_in_yaffs(); 
+//     generate_array_of_objects_in_linux();
+       //first do a check to see if both sides have the same objects on both sides. 
+       //then stat all of the files and compare size and mode
+       //read the text of each file and compare them.
+       
+       //show the diffrences by printing them. 
+
+}
+
+void generate_random_numbers(arg_temp *args_struct)
+{
+       char string[51];
+       args_struct->char1= (rand() % 255);
+       args_struct->char2= (rand() % 255);
+       args_struct->int1= (rand() % 100000);
+       args_struct->int2= (rand() % 100000);
+       generate_random_string(string,50);
+       strcpy(args_struct->string1, string);
+       generate_random_string(string,50);
+       strcpy(args_struct->string2, string);
+}
+
+void run_yaffs_test(int id,arg_temp *args_struct)
+{
+       char message[200];
+       int output =0;
+       print_message(3,"\n");
+       //printf("id = %d\n",id);
+       sprintf(message,"running_test %s\n",yaffs_tests.test_list[id].test_name);
+       print_message(3,message);
+       output=yaffs_tests.test_list[id].test_pointer(args_struct);
+       if (output<0) {
+               sprintf(message,"test_failed %s\n",yaffs_tests.test_list[id].test_name);
+               print_message(3,message);
+       } else {
+               print_message(3,"test_passed\n");
+       }
+}
+
+void run_linux_test(int id,arg_temp *args_struct)
+{
+       char message[200];
+       int output =0;
+       print_message(3,"\n");
+       //printf("id = %d\n",id);
+       sprintf(message,"running_test %s\n",linux_tests.test_list[id].test_name);
+       print_message(3,message);
+       output=linux_tests.test_list[id].test_pointer(args_struct);
+       if (output<0) {
+               sprintf(message,"test_failed %s\n",linux_tests.test_list[id].test_name);
+               print_message(3,message);
+       } else {
+               print_message(3,"test_passed\n");
+       }
+}
+
+void get_error_yaffs(void)
+{
+       int error_code=0;
+       char message[30];
+       message[0]='\0';
+
+       error_code=yaffs_get_error();
+       sprintf(message,"yaffs_error code %d\n",error_code);
+       print_message(1,message);
+       sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
+       print_message(1,message);
+}
+
+void get_error_linux(void)
+{
+       int error_code=0;
+       char message[30];
+       message[0]='\0';
+
+       error_code=errno;
+       sprintf(message,"linux_error code %d\n",error_code);
+       print_message(1,message);
+       strcpy(message,"error code");
+       sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
+       //perror(message);      
+       print_message(1,message);
+}
+
diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.h b/direct/timothy_tests/mirror_tests/mirror_tests.h
new file mode 100644 (file)
index 0000000..0ae4be5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __mirror_tests_h__
+#define __mirror_tests_h__
+
+#include <stdio.h>
+#include <unistd.h>    //used for getting the current directory. 
+#include <string.h>
+#include <errno.h>
+#include "yaffsfs.h"
+#include "lib.h"
+#include <time.h>
+
+#include "linux_test_open.h"
+#include "yaffs_test_open.h"
+#include "linux_test_truncate.h"
+#include "yaffs_test_truncate.h"
+
+
+#define LINUX 1
+#define YAFFS 2
+
+
+
+
+
+void init(int argc, char *argv[]);
+int run_random_test(void);
+int compare_linux_and_yaffs(void);
+void get_error_yaffs(void);
+void get_error_linux(void);
+int select_test_id(int test_len);
+void generate_random_numbers(arg_temp *args_struct);
+void run_yaffs_test(int id,arg_temp *args_struct);
+void run_linux_test(int id,arg_temp *args_struct);
+//void generate_array_of_objects_in_yaffs(void); 
+//void generate_array_of_objects_in_linux(void);
+
+#endif
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_open.c b/direct/timothy_tests/mirror_tests/yaffs_test_open.c
new file mode 100644 (file)
index 0000000..87a824b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "yaffs_test_open.h"
+
+int yaffs_test_open(arg_temp *args_struct)
+{
+       char path[200];
+       char message[100];
+       int output=0;
+       join_paths(yaffs_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output=yaffs_open(path,args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND),args_struct->char2&(S_IREAD|S_IWRITE));
+       if (output>=0){
+               output= yaffs_close(output);
+               if (output<0) {
+                       print_message(3,"failed to close handle\n");
+                       return -1;
+               } else {
+                       return 1;
+               }
+       } else {
+               print_message(3,"failed to open file\n");
+               return -1;
+       }
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_open.h b/direct/timothy_tests/mirror_tests/yaffs_test_open.h
new file mode 100644 (file)
index 0000000..f9e4224
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __yaffs_test_open_h__
+#define __yaffs_test_open_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_open(arg_temp *args_struct);
+
+#endif
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c
new file mode 100644 (file)
index 0000000..688d66e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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 Timothy Manning <timothy@yaffs.net>
+ *
+ * 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 "yaffs_test_truncate.h"
+
+int yaffs_test_truncate(arg_temp *args_struct)
+{
+       char path[200];
+       char message[200];
+       int output=0;
+       join_paths(yaffs_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output=yaffs_truncate(path,args_struct->int1);
+       return output;
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h
new file mode 100644 (file)
index 0000000..cf19013
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __yaffs_test_truncate_h__
+#define __yaffs_test_truncate_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_truncate(arg_temp *args_struct);
+
+#endif
index d757584d56285698ed4007a49527d65024744005..1744392688be0dea7fbcf4c5a0fb4bab50baaf26 100644 (file)
@@ -246,7 +246,7 @@ test_yaffs_write_EROFS.c
 
 Tests to add
 
-
+       test_yaffs_rename a file over its self.
 
        test_yaffs_readlink
        test_yaffs_readlink_ENOENT
index f8b6d749c6173b989b4284537cdd11732ee830be..72376b598778c89dd346f7df3e9e2ede49a94e6d 100644 (file)
@@ -45,6 +45,8 @@
 #define ELOOP_PATH "/yaffs2/ELOOP"
 #define ELOOP2_PATH "/yaffs2/ELOOP2"
 
+#define RMDIR_PATH "/yaffs2/RM_DIR"
+
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
 
index 244b8b0cf729953532b707bf9663059ad8c1049a..0e34ea7a2d6ef301c66b07f920e85656c448fcea 100644 (file)
@@ -20,69 +20,93 @@ int simulate_power_failure = 0;
 
 
 
-
+static int number_of_random_tests=0;
 static unsigned int num_of_tests_pass=0;
 static unsigned int num_of_tests_failed=0;
 static unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_template));
 
-int main(int argc, char *argv[]){
-       int output=0;
-       char message[30];
-       message[0]='\0';
-       unsigned int x=0;
+int main(int argc, char *argv[])
+{
+       int x=0;
 
        init_quick_tests(argc, argv);
+       logical_run_of_tests();
+       for (x=0;x<number_of_random_tests;x ++){
+               run_random_test_loop();
+       }       
+       /*this is where the loop should break to*/
+       quit_quick_tests(0);
+}
+
+
+void run_random_test_loop(void)
+{
+       int id=0;
+       int x=0;
+       int run_list[total_number_of_tests];
+       for (x=0;x<total_number_of_tests;x++){ 
+               id = (rand() % (total_number_of_tests-1));
+               run_test(id);   
+       }
+}
+
+void logical_run_of_tests(void)
+{
+       unsigned int x=0;
        print_message("\n\nrunning quick tests for yaffs\n\n", 0);
 
        for (x=0;x<total_number_of_tests;x++){
-       /*      output=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
-               printf("yaffs_open %d \n",output);
-               printf("yaffs_close %d \n",yaffs_close(output));
-       */      yaffs_set_error(0);     /*reset the last error to 0 */
-               //printf("foo exists %d\n",test_yaffs_open());
-               sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
-               print_message(message,3);
-               output=test_list[x].p_function();       /*run test*/
-               if (output>=0){
-                       /*test has passed*/
-                       sprintf(message,"\ttest %s passed\n",test_list[x].name_of_test);
-                       print_message(message,3); 
-                       num_of_tests_pass++;
-               } else {
-                       /*test is assumed to have failed*/
-                       //printf("test failed\n");
-                       sprintf(message,"test: %s failed\n",test_list[x].name_of_test);
-                       print_message(message,1);               
-                       num_of_tests_failed ++; 
-               
-                       get_error();
-                       print_message("\n\n",1);
-                       if (get_exit_on_error()){       
-                               quit_quick_tests(1);
-                       }
+               run_test(x);
+       }
+}
 
+void run_test(int x)
+{
+       int output=0;
+       char message[200];
+       message[0]='\0';
+
+       yaffs_set_error(0);     /*reset the last error to 0 */
+       //printf("foo exists %d\n",test_yaffs_open());
+       sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
+       print_message(message,3);
+       output=test_list[x].p_function();       /*run test*/
+       if (output>=0){
+               /*test has passed*/
+               sprintf(message,"\ttest %s passed\n",test_list[x].name_of_test);
+               print_message(message,3); 
+               num_of_tests_pass++;
+       } else {
+               /*test is assumed to have failed*/
+               //printf("test failed\n");
+               sprintf(message,"test: %s failed\n",test_list[x].name_of_test);
+               print_message(message,1);               
+               num_of_tests_failed ++; 
+       
+               get_error();
+               print_message("\n\n",1);
+               if (get_exit_on_error()){       
+                       quit_quick_tests(1);
                }
-               output=0;
-               output=test_list[x].p_function_clean(); /*clean the test*/
-               if (output <0){
-                       /* if the test failed to clean it's self then */
-                       sprintf(message,"test: %s failed to clean\n",test_list[x].name_of_test);
-                       print_message(message,1);               
-                       num_of_tests_failed ++; 
-                       num_of_tests_pass--;
-                       get_error();
-                       printf("\n\n");
-                       if (get_exit_on_error()){
-                               quit_quick_tests(1);
-                       }
-                       
-               } else {
-                       sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test);
-                       print_message(message,3);
+       }
+       output=0;
+       output=test_list[x].p_function_clean(); /*clean the test*/
+       if (output <0){
+               /* if the test failed to clean it's self then */
+               sprintf(message,"test: %s failed to clean\n",test_list[x].name_of_test);
+               print_message(message,1);               
+               num_of_tests_failed ++; 
+               num_of_tests_pass--;
+               get_error();
+               printf("\n\n");
+               if (get_exit_on_error()){
+                       quit_quick_tests(1);
                }
+               
+       } else {
+               sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test);
+               print_message(message,3);
        }
-       /*this is where the loop should break to*/
-       quit_quick_tests(0);
 }
 
 void quit_quick_tests(int exit_code)
@@ -122,6 +146,7 @@ void init_quick_tests(int argc, char *argv[])
                        printf("-v will print all messages\n");
                        printf("-q quiet mode only the number of tests passed and failed will be printed\n");
                        printf("-t [number] set yaffs_trace to number\n");
+                       printf("-r [number] sets the number of random loops to run after the the test has run\n");
                        exit(0);
                } else if (0==strcmp(argv[x],"-c")) {
                        set_exit_on_error(0);
@@ -131,6 +156,8 @@ void init_quick_tests(int argc, char *argv[])
                        trace = atoi(argv[x+1]);
                }  else if (0==strcmp(argv[x],"-v")) {
                        set_print_level(5);
+               } else if (0==strcmp(argv[x],"-r")) {
+                       number_of_random_tests=atoi(argv[x+1]);
                }
 
        }
index bee341c930fc7d700a020a4e9883d4cb7de31ec8..50d17dcf711d551b746c081cce7818183d8b2cb1 100644 (file)
@@ -510,7 +510,10 @@ test_template test_list[]={
 
        };
 
+void logical_run_of_tests(void);
 void init_quick_tests(int argc, char *argv[]);
 void quit_quick_tests(int exit_code);
 void get_error(void);
+void run_random_test_loop(void);
+void run_test(int x);
 #endif
index 48e98260ff15d500f041acfbd94fab982fd0bda0..98e3b3bab2f5bbb797db52c2bad4cd1ebe7e5a86 100644 (file)
@@ -17,19 +17,14 @@ static int handle=-1;
 
 int test_yaffs_read(void)
 {
-       char text[20] = "\0";
+       char text[2000] = "\0";
        int output=0;
 
        handle = test_yaffs_open();
        if (handle>=0){
                output=yaffs_read(handle, text, FILE_TEXT_NBYTES);
-               if (output>0){ 
-                       if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
-                               return 1;
-                       } else {
-                               print_message("returned text does not match the the expected text that should be in the file\n", 2);
-                               return -1;
-                       }
+               if (output>=0){ 
+                       return 1;
                } else{
                        print_message("error reading file\n", 2);
                        return -1;
index c5b5455ef9a548338d70907dbf415ae0340c0d2e..873f0127171a4d46f8112faefcd432e56c3afd20 100644 (file)
@@ -113,7 +113,7 @@ int test_yaffs_read_EINVAL_init(void)
                return -1;
        }
        
-       strcat(file_name,YAFFS_MOUNT_POINT);
+       strcpy(file_name,YAFFS_MOUNT_POINT);
        for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
                file_name[x]='a';
        }
index 509bb9a83b44ba90ed47537bf9924bf48346aed2..cc55fb139d085fd439aeac2c29216bd058805a68 100644 (file)
@@ -34,10 +34,10 @@ int test_yaffs_rename(void)
 int test_yaffs_rename_clean(void)
 {
        int output = 0;
-       if (0 ==  yaffs_access(RENAME_PATH,0)) {
-               output = yaffs_rename(RENAME_PATH,FILE_PATH);
+       if (0 ==  yaffs_access(FILE_PATH,0)) {
+               output = test_yaffs_open();
                if (output < 0) {
-                       print_message("failed to rename the file\n",2);
+                       print_message("failed to open a new file\n",2);
                        return -1;
                }
        }
index 5c7a2547dbc378e36b05aabfbd1d27f403bad9f7..d6eb84c7515cf02a5df1122642de72e9fdf9e0f3 100644 (file)
 int test_yaffs_rename_dir(void)
 {
        int output=0;
-       int error_code =0;
 
-       if (0 !=  yaffs_access(FILE_PATH,0)) {
-               output = test_yaffs_open();
+
+       if (0 !=  yaffs_access(DIR_PATH,0)) {
+               output = yaffs_mkdir(DIR_PATH,S_IREAD|S_IWRITE);
                if (output < 0) {
                        print_message("failed to create file\n",2);
                        return -1;
index 637f758de4db9be49e00056db93036ba069c7f8a..9b15fa5f31aa1206b046a25321d22f8501cb2ead 100644 (file)
@@ -36,6 +36,14 @@ int test_yaffs_rename_dir(void)
 int test_yaffs_rename_dir_clean(void)
 {
        int output = 0;
+       if (0 ==  yaffs_access("/yaffs2/new_directory/file",0)) {
+               output = yaffs_unlink("/yaffs2/new_directory/file");
+               if (output < 0) {
+                       print_message("failed to remove file\n",2);
+                       return -1;
+               }
+       }
+
        if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
                output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH);
                if (output < 0) {
index d87b8ab6adebeea7f7d60201c1b60d65790fcfbf..cea18f0175ca5c9790ec4255e924123d235e9bad 100644 (file)
@@ -21,7 +21,14 @@ int test_yaffs_rename_dir_to_file(void)
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output= yaffs_mkdir(DIR_PATH,(S_IREAD | S_IWRITE));
                if (output<0) {
-                       print_message("failed to create directory\n",2);
+                       print_message("failed to remove directory\n",2);
+                       return -1;
+               }
+       }
+       if (0 !=  yaffs_access(RENAME_PATH,0)) {
+               output= yaffs_mkdir(RENAME_PATH,(S_IREAD | S_IWRITE));
+               if (output<0) {
+                       print_message("failed to remove file\n",2);
                        return -1;
                }
        }
index b756b3e1e9a896f72cc8999e9b1b0c26d4b7ae4c..8954828fc06e4d08a33778add0dc4b479547a104 100644 (file)
@@ -52,6 +52,11 @@ int test_yaffs_rename_file_to_dir_clean(void)
                        print_message("failed to unlink the file\n",2);
                        return -1;
                }
+               output = test_yaffs_open();
+               if (output < 0) {
+                       print_message("failed to open a new\n",2);
+                       return -1;
+               }
        }
        return 1;
 
index fe0e09f6d67e6e1118012f97cc8553f556bec6b5..2fd79820c8cad82dbac89c3593e3a3f9b43b1572 100644 (file)
 int test_yaffs_rmdir(void)
 {
        int output=0;
-       if (0 !=  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
+       if (0 !=  yaffs_access(RMDIR_PATH,0)) {
+               output = yaffs_mkdir(RMDIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
                        print_message("failed to create directory\n",2);
                        return -1;
                }
        }
-       return yaffs_rmdir(DIR_PATH);
+       return yaffs_rmdir(RMDIR_PATH);
 }
 
 
index 1b7e53eac41b7abf0ca3cfc7febeb45b4312491d..14949a857127201032e7b4a5c8c08b98a4505bc1 100644 (file)
@@ -19,13 +19,7 @@ int test_yaffs_rmdir_EBUSY(void)
        int output=0;
        int error_code =0;
 
-       if (0 !=  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
-               if (output < 0) {
-                       print_message("failed to create directory\n",2);
-                       return -1;
-               }
-       }
+
        output = yaffs_rmdir("/yaffs2/");
        if (output<0){ 
                error_code=yaffs_get_error();
@@ -45,13 +39,7 @@ int test_yaffs_rmdir_EBUSY(void)
 int test_yaffs_rmdir_EBUSY_clean(void)
 {
        int output = 0;
-       if (0 ==  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_rmdir(DIR_PATH);
-               if (output < 0) {
-                       print_message("failed to remove the directory\n",2);
-                       return -1;
-               }
-       }
+
        return 1;
 
 }
index a3e581e374720d56329fb7b8ca20ba88e00a1db6..1aec8575de1ec2c128fc52e625dc0ec7c934b3b0 100644 (file)
@@ -19,13 +19,6 @@ int test_yaffs_rmdir_ENOENT(void)
        int output=0;
        int error_code =0;
 
-       if (0 !=  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
-               if (output < 0) {
-                       print_message("failed to create directory\n",2);
-                       return -1;
-               }
-       }
        output = yaffs_rmdir("/yaffs2/non-existing-dir/");
        if (output<0){ 
                error_code=yaffs_get_error();
@@ -45,14 +38,6 @@ int test_yaffs_rmdir_ENOENT(void)
 int test_yaffs_rmdir_ENOENT_clean(void)
 {
        int output = 0;
-       if (0 ==  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_rmdir(DIR_PATH);
-               if (output < 0) {
-                       print_message("failed to remove the directory\n",2);
-                       return -1;
-               }
-       }
        return 1;
-
 }
 
index 2a833b0b9531fec7094e53c25e0d80bcf662b016..7b092c8b5f8e3b1ffaac544fc24ed2783bfa4084 100644 (file)
@@ -19,13 +19,6 @@ int test_yaffs_rmdir_NULL(void)
        int output=0;
        int error_code =0;
 
-       if (0 !=  yaffs_access(DIR_PATH,0)) {
-               output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
-               if (output < 0) {
-                       print_message("failed to create directory\n",2);
-                       return -1;
-               }
-       }
        output = yaffs_rmdir(NULL);
        if (output<0){ 
                error_code=yaffs_get_error();
index 8244333b880d7b67a47b3e5108fef82a07d2039a..838df1eaceb72b92030ed873bcca7d644f94c126 100644 (file)
@@ -19,40 +19,9 @@ int test_yaffs_stat(void)
        int mode=0;
        int size=0;
        message[0]='\0';
+       struct yaffs_stat stat;
 
-       mode =yaffs_test_stat_mode();   
-       if (mode>=0){
-               if (FILE_MODE == (FILE_MODE & mode)){
-                       mode=1;
-               } else {
-                       print_message("mode did not match expected file mode\n",2);
-                       return -1;
-               }
-       } else {
-               mode =-1;
-       }
-
-       size=yaffs_test_stat_size();
-       if (size >=0){
-               if (size==FILE_SIZE){
-                       size=1;
-               } else {
-                       sprintf(message,"file size %d, expected file size %d\n",size,FILE_SIZE);
-                       print_message(message,2);
-                       print_message("mode did not match expected file mode\n",2);
-                       return -1;
-               }
-       } else {
-               size =-1;
-       }       
-
-
-       if ((mode>0) && (size>0)){
-               return 1;
-       } else {
-               /* one of the tests failed*/
-               return -1;
-       }
+       return yaffs_stat(FILE_PATH, &stat);
 }
 
 int test_yaffs_stat_clean(void)
index 829204c78fd9c94aef467bd89c5b45d97852defa..a17dd8944a63cc391e7e3ef09b1a7e56204d96d4 100644 (file)
@@ -38,7 +38,7 @@ int test_yaffs_write_big_file(void)
                return -1;
        }
        
-       strcat(file_name,YAFFS_MOUNT_POINT);
+       strcpy(file_name,YAFFS_MOUNT_POINT);
        for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
                file_name[x]='a';
        }