yaffs Added some more tests to timothy_tests.
authorTimothy Manning <tfhmanning@gmail.com>
Sun, 12 Dec 2010 23:21:56 +0000 (12:21 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 14 Dec 2010 22:32:30 +0000 (11:32 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
29 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/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/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/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..f26ff4c
--- /dev/null
@@ -0,0 +1,114 @@
+# 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
+
+
+                 
+
+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/lib.c b/direct/timothy_tests/mirror_tests/lib.c
new file mode 100644 (file)
index 0000000..4b9ebd6
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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 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..2e03573
--- /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 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..7817c3a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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[200];
+       char message[100];
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       return open(path,args_struct->char1,args_struct->char2);
+}
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/mirror_tests.c b/direct/timothy_tests/mirror_tests/mirror_tests.c
new file mode 100644 (file)
index 0000000..319eb93
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ * 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;
+
+
+
+
+
+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={
+       0,
+       {{"yaffs_test_open",yaffs_test_open}
+       }
+};
+
+test_temp linux_tests={
+       0,
+       {{"linux_test_open",linux_test_open}
+       }
+};
+
+
+int main(int argc, char *argv[])
+{
+       char message[100];
+
+       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);
+
+               run_random_test();
+       return 0;
+}
+
+void init(int argc, char *argv[])
+{
+       char dir[200];
+       dir[0]='\0';
+       int x=-1;
+       char message[100];
+       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");
+                       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);
+               } 
+       }
+
+       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[15];
+       arg_temp args_struct;
+       for (x=0;x<num_of_tests;x++) {
+               test_id = select_test_id(yaffs_tests.num_of_tests);
+               sprintf(message,"test_id %d\n",test_id);
+               print_message(2,message);
+               generate_random_numbers(&args_struct);
+               run_yaffs_test(id, &args_struct);
+               run_linux_test(id, &args_struct);
+       }
+       compare_linux_and_yaffs(); 
+}
+
+int select_test_id(int test_len)
+{
+       int id=0;
+       id=(rand() % test_len );
+       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)
+{
+       args_struct->char1= (rand() % 255);
+       args_struct->char2= (rand() % 255);
+       args_struct->int1= (rand() % 100000);
+       args_struct->int2= (rand() % 100000);
+       strcpy(args_struct->string1, "apple");
+       strcpy(args_struct->string2, "apple");
+}
+
+void run_yaffs_test(int id,arg_temp *args_struct)
+{
+       char message[30];
+       int output =0;
+       print_message(2,"\n");
+       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(1,message);
+               get_error_yaffs();
+       } else {
+               print_message(3,"test_passed\n");
+       }
+}
+
+void run_linux_test(int id,arg_temp *args_struct)
+{
+       char message[30];
+       int output =0;
+       print_message(2,"\n");
+       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(1,message);
+               get_error_linux();
+       } 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..8c8b820
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 "linux_test_open.h"
+#include "yaffs_test_open.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);
+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..e8b72b4
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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];
+       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,args_struct->char2);
+       if (output>=0){
+               output= yaffs_close(output);
+               if (output<0) {
+                       print_message(1,"failed to close handle\n");
+                       return -1
+               } else {
+                       return 1;
+               }
+       } else {
+               print_message(1,"failed to close handle\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
index d757584..1744392 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 f8b6d74..72376b5 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 244b8b0..0e34ea7 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 bee341c..50d17dc 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 48e9826..98e3b3b 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 c5b5455..873f012 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 509bb9a..cc55fb1 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 5c7a254..d6eb84c 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 637f758..9b15fa5 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 d87b8ab..cea18f0 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 b756b3e..8954828 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 fe0e09f..2fd7982 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 1b7e53e..14949a8 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 a3e581e..1aec857 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 2a833b0..7b092c8 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 8244333..838df1e 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 829204c..a17dd89 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';
        }