Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
authorCharles Manning <cdhmanning@gmail.com>
Fri, 18 Jan 2013 02:17:53 +0000 (15:17 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Fri, 18 Jan 2013 02:17:53 +0000 (15:17 +1300)
61 files changed:
direct/test-framework/timothy_tests/quick_tests/Makefile
direct/test-framework/timothy_tests/quick_tests/lib.c
direct/test-framework/timothy_tests/quick_tests/lib.h
direct/test-framework/timothy_tests/quick_tests/quick_tests.c
direct/test-framework/timothy_tests/quick_tests/quick_tests.h
direct/test-framework/timothy_tests/quick_tests/test_yaffs_access.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_access_EACCES.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_access_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_fdatasync_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_flush_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_link.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EEXIST.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR2.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_mount.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EACCES.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EROFS.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c
direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_EROFS.c

index ac6943109da5a6f2f43fd50387e2180995751e51..431c883c788ed677ab79101cd6d4762e2af3fa2d 100644 (file)
@@ -78,7 +78,8 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.o test_yaffs_rename_dir_to_file.o \
                test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o  test_yaffs_rename_ELOOP_dir.o test_yaffs_rename_EROFS.o \
                test_yaffs_rename_ENAMETOOLONG.o test_yaffs_rename_ENAMETOOLONG2.o test_yaffs_rename_NULL.o test_yaffs_rename_NULL2.o \
-               test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o \
+               test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o test_yaffs_rename_to_null_file.o \
+               test_yaffs_rename_file_over_file.o test_yaffs_rename_dir_over_dir.o test_yaffs_rename_full_dir_over_dir.o test_yaffs_rename_ENOTEMPTY.o \
                test_yaffs_lstat_NULL.o \
                test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o \
                test_yaffs_dup.o test_yaffs_dup_EBADF.o 
index 50723c3e1e6efbb907f64e836757706e51479a4e..4edc19e59367caa498e5b14e94f389a5d59b1fa1 100644 (file)
@@ -37,6 +37,7 @@ int get_exit_on_error(void)
 int EROFS_setup(void)
 {
        int output= -1;
+       
        output=yaffs_remount(YAFFS_MOUNT_POINT,1,1);
        if (output<0){
                print_message("failed to remount yaffs\n",2);
@@ -125,9 +126,58 @@ void join_paths(char *path1,char *path2,char *new_path )
 void print_message(char *message,char print_level)
 {
        if (print_level <= PRINT_LEVEL){
-               printf(message);
+               printf("%s",message);
        }
 }
-       
 
+/*same as forcing the rmdir of a directory*/
+int delete_dir(char *dir_name)
+{
+       char message[200];
+       yaffs_DIR *d;
+       struct yaffs_dirent *de;
+       struct yaffs_stat s;
+       char str[100];
+       d = yaffs_opendir(dir_name);
+       //printf("%s\n",dir_name);
+       if(!d)
+       {
+               sprintf(message,"\nfailed to open dir %s \n was trying to delete this",dir_name);
+               print_message(message,1);
+
+               
+               get_error();
+               return -1;
+    }
+    
+    while((de = yaffs_readdir(d)) != NULL) {
+               //stats the file
+               sprintf(str,"%s/%s",dir_name,de->d_name);
+               yaffs_lstat(str,&s);
+               
+               if ((s.st_mode & S_IFMT) == S_IFDIR){
+                       //it is a directory. call the function recursivly.
+                       delete_dir(str);
+                       yaffs_rmdir(str);
+               }else{
+                       yaffs_unlink(str);
+               }
+       }
+       yaffs_rmdir(dir_name);
+       yaffs_closedir(d);
+       return 1;
+}
+
+void get_error(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(message,1);
+       sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
+       print_message(message,1);
+}
 
index c7d67d28ebb095ea359be04a1da8154497c1a5f8..5e36ca05687e6a7b8cf9a948eca08c596d0badcf 100644 (file)
 
 
 #define YAFFS_MOUNT_POINT "/yaffs2/"
-#define FILE_NAME "foo"
+#define FILE_NAME "test_dir/foo"
 #define FILE_SIZE 10
 
 #define FILE_MODE (S_IREAD | S_IWRITE)
 #define FILE_SIZE_TRUNCATED 100
 #define FILE_TEXT "file foo "  /* keep space at end of string */
 #define FILE_TEXT_NBYTES 10
+#define TEST_DIR "/yaffs2/test_dir"
+#define DIR_PATH "/yaffs2/test_dir/new_directory"
+#define DIR_PATH2 "/yaffs2/test_dir/new_directory2"
+#define DIR_PATH2_FILE "/yaffs2/test_dir/new_directory2/foo"
+#define SYMLINK_PATH "/yaffs2/test_dir/sym_foo"
 
-#define DIR_PATH "/yaffs2/new_directory"
+#define HARD_LINK_PATH "/yaffs2/test_dir/hard_link"
 
-#define SYMLINK_PATH "/yaffs2/sym_foo"
+#define NODE_PATH "/yaffs2/test_dir/node"
 
-#define HARD_LINK_PATH "/yaffs2/hard_link"
+#define RENAME_PATH "/yaffs2/test_dir/foo2"
 
-#define NODE_PATH "/yaffs2/node"
+#define RENAME_DIR_PATH "/yaffs2/test_dir/dir2"
 
-#define RENAME_PATH "/yaffs2/foo2"
+#define ELOOP_PATH "/yaffs2/test_dir/ELOOP"
+#define ELOOP2_PATH "/yaffs2/test_dir/ELOOP2"
 
-#define RENAME_DIR_PATH "/yaffs2/dir2"
-
-#define ELOOP_PATH "/yaffs2/ELOOP"
-#define ELOOP2_PATH "/yaffs2/ELOOP2"
-
-#define RMDIR_PATH "/yaffs2/RM_DIR"
+#define RMDIR_PATH "/yaffs2/test_dir/RM_DIR"
 
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
-#define FILE_PATH "/yaffs2/foo"
+#define FILE_PATH "/yaffs2/test_dir/foo"
+#define FILE_PATH2 "/yaffs2/test_dir/foo2"
 
 void join_paths(char *path1,char *path2,char *new_path );
 void print_message(char *message,char print_level);
@@ -58,4 +60,6 @@ int get_exit_on_error(void);
 int set_up_ELOOP(void);
 int EROFS_setup(void);
 int EROFS_clean(void);
+int delete_dir(char *dir_name);
+void get_error(void);
 #endif
index a3f6463304d3ec866645db8e413ee90fb8dd83ee..c083d03b80a4888d5cf3bd63b0a8e30b4cddc169 100644 (file)
@@ -50,14 +50,15 @@ int main(int argc, char *argv[])
        }       
        /*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];
+       unsigned 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);   
@@ -77,9 +78,11 @@ void logical_run_of_tests(void)
 void run_test(int x)
 {
        int output=0;
+       int y= 0;
        char message[200];
        message[0]='\0';
 
+       yaffs_mkdir(TEST_DIR,S_IWRITE | S_IREAD);
        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);
@@ -92,7 +95,7 @@ void run_test(int x)
                num_of_tests_pass++;
        } else {
                /*test is assumed to have failed*/
-               //printf("test failed\n");
+               printf("test failed\n");
                sprintf(message,"test: %s failed\n",test_list[x].name_of_test);
                print_message(message,1);               
                num_of_tests_failed ++; 
@@ -121,12 +124,18 @@ void run_test(int x)
                sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test);
                print_message(message,3);
        }
+       /* close all open handles */
+       for (y=0; y<100;y++){
+               yaffs_close(y);
+       }
+       delete_dir(TEST_DIR);
 }
 
 void quit_quick_tests(int exit_code)
 {
-       char message[30];
-       message[0]='\0';        
+       /*char message[30];
+       message[0]='\0';
+       */      
        if (num_of_tests_pass==total_number_of_tests &&  num_of_tests_failed==0){
                printf("\t OK --all tests passed\n");
        }
@@ -135,24 +144,12 @@ void quit_quick_tests(int exit_code)
        exit(exit_code);
 }
 
-void get_error(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(message,1);
-       sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
-       print_message(message,1);
-}
 
 void init_quick_tests(int argc, char *argv[])
 {
        int trace=0;
        int new_option;
-       int x=0;        
+       //int x=0;      
        do{
                new_option=getopt_long(argc,argv,short_options,long_options,NULL);              
                if (new_option=='h'){
index 99675634fe4bf5d9efee96e6f666de833dad0a7e..324d3c4139a99574861bea1e6418fd2e8c378689 100644 (file)
@@ -84,7 +84,7 @@
 
 #include "test_yaffs_read.h"
 #include "test_yaffs_read_EBADF.h"
-#include "test_yaffs_read_EINVAL.h"
+//#include "test_yaffs_read_EINVAL.h"
 
 #include "test_yaffs_lseek.h"
 #include "test_yaffs_lseek_EBADF.h"
 #include "test_yaffs_rename_ENAMETOOLONG2.h"
 #include "test_yaffs_rename_NULL.h"
 #include "test_yaffs_rename_NULL2.h"
+#include "test_yaffs_rename_file_over_file.h"
+#include "test_yaffs_rename_dir_over_dir.h"
+#include "test_yaffs_rename_to_null_file.h"
+#include "test_yaffs_rename_full_dir_over_dir.h"
+#include "test_yaffs_rename_ENOTEMPTY.h"
 
 #include "test_yaffs_lstat.h"
 #include "test_yaffs_lstat_ENOENT.h"
@@ -334,7 +339,7 @@ test_template test_list[]={
 
        {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
        {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
-       {test_yaffs_read_EINVAL,test_yaffs_read_EINVAL_clean,"test_yaffs_read_EINVAL"},
+//     {test_yaffs_read_EINVAL,test_yaffs_read_EINVAL_clean,"test_yaffs_read_EINVAL"},
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
        {test_yaffs_stat_ENOENT,test_yaffs_stat_ENOENT_clean,"test_yaffs_stat_ENOENT"},
@@ -495,6 +500,11 @@ test_template test_list[]={
        {test_yaffs_rename_ENAMETOOLONG2,test_yaffs_rename_ENAMETOOLONG2_clean,"test_yaffs_rename_ENAMETOOLONG2"},
        {test_yaffs_rename_NULL,test_yaffs_rename_NULL_clean,"test_yaffs_rename_NULL"},
        {test_yaffs_rename_NULL2,test_yaffs_rename_NULL2_clean,"test_yaffs_rename_NULL2"},
+       {test_yaffs_rename_to_null_file,test_yaffs_rename_to_null_file_clean,"test_yaffs_rename_to_null_file"},
+       {test_yaffs_rename_file_over_file,test_yaffs_rename_file_over_file_clean,"test_yaffs_rename_file_over_file"},
+       {test_yaffs_rename_dir_over_dir,test_yaffs_rename_dir_over_dir_clean,"test_yaffs_rename_dir_over_dir"},
+       {test_yaffs_rename_full_dir_over_dir,test_yaffs_rename_full_dir_over_dir_clean,"test_yaffs_rename_full_dir_over_dir"},
+       {test_yaffs_rename_ENOTEMPTY,test_yaffs_rename_ENOTEMPTY_clean,"test_yaffs_rename_ENOTEMPTY"},
 
        {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"},
        {test_yaffs_lstat_ENOENT,test_yaffs_lstat_ENOENT_clean,"test_yaffs_lstat_ENOENT"},
index 1e516bc60d40525559bf488d1e449048c614e352..23b8c035f4e227c3e90f971b517e7838757b7898 100644 (file)
 
 int test_yaffs_access(void)
 {
-               return yaffs_access(FILE_PATH,0);
+
+       if (-1==yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       return yaffs_access(FILE_PATH,0);
 }
 
 int test_yaffs_access_clean(void)
index 1cbd0a60022cce21bc0965787e2863d35819ac00..f48813041755f777cf800aa402a95d9bf2defe29 100644 (file)
@@ -17,6 +17,10 @@ int test_yaffs_access_EACCES(void)
 {
        int output=0;
        int error=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }
        output=yaffs_chmod(FILE_PATH,S_IREAD);
        if (output<0){
                print_message("failed to chmod file\n",2);
index afd3e07c2ab9bc33627a5f9930cf1c8396a533d4..a9718a8ba3edccec07165f718d2b5b33793322e7 100644 (file)
@@ -19,8 +19,11 @@ int test_yaffs_access_ENOTDIR(void)
 {
        int output=0;
        int error_code=0;
-       
-       output=yaffs_access("/yaffs2/foo/file",0);
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output=yaffs_access("/yaffs2/test_dir/foo/file",0);
        if (output==-1){
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 056033783ef7a8bec627cb741b1f97e1e3b1d122..bf223e050b339f416de3928c3d2cf6fa5fe52b1d 100644 (file)
@@ -17,6 +17,10 @@ int test_yaffs_access_EROFS(void)
 {
        int output=0;
        int error=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }
        if (EROFS_setup() < 0 ){
                return -1;
        }
index 7259fcbdcf6818aaa28ab29393dfec53e8070324..9a8cac90d4db1255f136cc4b403417347e15864f 100644 (file)
 
 int test_yaffs_chmod(void)
 {
-       int output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE);
+       int output=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       
+       output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE);
 
        if (output>=0){
                /* there were no errors */
index 458731579885855d94331a2717824c004cb94a41..86155b20e70aec2907d28f3a21fd86286a9073d3 100644 (file)
 int test_yaffs_chmod_ENOTDIR(void)
 {
        int error=0;
-       int output=yaffs_chmod("/yaffs2/foo/file",S_IREAD|S_IWRITE);
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       int output=yaffs_chmod("/yaffs2/test_dir/foo/file",S_IREAD|S_IWRITE);
 
        if (output<0){
                error=yaffs_get_error();
index fd8af69e4f2b14551711e565578363fa4cb410ae..cff0503bf99712d5081bb31151a91b1ef9330c65 100644 (file)
@@ -17,7 +17,10 @@ int test_yaffs_chmod_EROFS(void)
 {
        int error=0;
        int output;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
 
        output = yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE);
index 250ebc68a716e924297d8bb4f0bebef7dc8be578..d0df0703e552231ffe0fba44fd7196dbc6f50c60 100644 (file)
@@ -18,6 +18,10 @@ int test_yaffs_fchmod_EROFS(void)
 {
        int error = 0;
        int output = 0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (EROFS_setup() < 0 ){
                return -1;
        }
index bad5f0171772323b38c412d56227cce2329b89a3..6aee5902194a7dbf7927f788c8aeaa72da8438e3 100644 (file)
@@ -19,6 +19,10 @@ int test_yaffs_fdatasync_EROFS(void)
 {
        int output = 0;
        int error_code = 0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
        handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
        if (handle<0){
index 41a74505880614fb3854c6ceb7a79d3506e7414e..61138df673430616ae1f949df9a7ed49a12f9821 100644 (file)
@@ -19,6 +19,10 @@ int test_yaffs_flush_EROFS(void)
 {
        int output=0;
        int error =0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
        handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
        if (handle<0){
index 729fad1a6d2e93822d41f827ff1236e6a1e49723..8a656becf90c49b1f692504e767d847a4c30f4aa 100644 (file)
@@ -19,7 +19,10 @@ int test_yaffs_fsync_EROFS(void)
 {
        int output = 0;
        int error_code = 0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
        handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
        if (handle<0){
@@ -29,6 +32,7 @@ int test_yaffs_fsync_EROFS(void)
        output = yaffs_fsync(handle);
        if (output==-1){
                error_code=yaffs_get_error();
+
                if (abs(error_code)==EROFS){
                        return 1;
                } else {
index 7aa8aab1dfaff7eba633f7c1b62b496469a73d0b..dc70bdee5ab4234de8ee3c0406ae9a869d433fd6 100644 (file)
 int test_yaffs_link(void)
 {
        int output=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        output = yaffs_link(FILE_PATH,HARD_LINK_PATH);
        return output;
 }
index 18a540b004f7ece8a246a3bef0074dc06b739e56..e97d3bb336b24793ab3bf1331fe3d36c8b3ce3e9 100644 (file)
@@ -19,7 +19,10 @@ int test_yaffs_link_EEXIST(void)
 {
        int output=0;   
        int error =0;
-       
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        output = yaffs_link(FILE_PATH,HARD_LINK_PATH);
        if (output<0){
                print_message("failed to create the first hard link\n",2);
index 62c8065a51b47aed91aee83aa417465045b150f7..0d54023a44143a7ee84937fcd89d4dba1248d74d 100644 (file)
@@ -19,7 +19,11 @@ int test_yaffs_link_ENOTDIR(void)
 {
        int output=0;   
        int error =0;
-       output = yaffs_link("/yaffs2/foo/file",HARD_LINK_PATH);
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_link("/yaffs2/test_dir/foo/file",HARD_LINK_PATH);
        if (output<0){
                error=yaffs_get_error();
                if (abs(error)==ENOTDIR){
index 32d1e0b2d3bc7e0a827a9acdf6e747c541f2647c..15f6f874c8e78f054bc3568f7735e0cb55ee947b 100644 (file)
@@ -19,7 +19,11 @@ int test_yaffs_link_ENOTDIR2(void)
 {
        int output=0;   
        int error =0;
-       output = yaffs_link(FILE_PATH,"yaffs2/foo/hard_link");
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_link(FILE_PATH,"yaffs2/test_dir/foo/hard_link");
        if (output<0){
                error=yaffs_get_error();
                if (abs(error)==ENOTDIR){
index da4abd6b1b195513be4b1d2bd4b8bd42df22215c..d3ab40edb0209f0b4d7a704cb9aac98adcc315fe 100644 (file)
@@ -19,7 +19,10 @@ int test_yaffs_link_EROFS(void)
 {
        int output=0;   
        int error =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
 
        output = yaffs_link(FILE_PATH,HARD_LINK_PATH);
index 665ff9faa56b9b26d1b3b7746c17b9ec2ae87c2f..5dfa1bb9c9a29349659b5027eaaccc824d52c856 100644 (file)
@@ -40,7 +40,7 @@ int test_yaffs_lstat_ENOTDIR(void)
                }
        }
        
-       output =yaffs_lstat("yaffs2/foo/dir",&stat);
+       output =yaffs_lstat("yaffs2/test_dir/foo/dir",&stat);
        if (output<0){
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 2d94fa4d60753e8d267495332dc2a070f1c055ea..5c99800b43c0ef691f50fb615a7656b9ef19a562 100644 (file)
@@ -19,19 +19,12 @@ int test_yaffs_mkdir_EEXIST(void)
 {
        int error_code = 0;
        
-       if (0==yaffs_access(DIR_PATH,0)){
-               /* if the file exists  then the file does not need to be created the first time*/
-               
-       } else {
-       
-               output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
-               if (output <0) {
-                       print_message("failed to create the directory the first time\n",2);
-                       return -1;
-               }
+       output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
+       if (output <0) {
+               print_message("failed to create the directory the first time\n",2);
+               return -1;
        }
-
-       output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+       output = yaffs_mkdir("/yaffs2/test_dir/new_directory/",O_CREAT | O_RDWR);
        if (output < 0){
                error_code = yaffs_get_error();
                if (abs(error_code) == EEXIST){
index c417bb372d26e64f8bcd38241c552018e3f4972b..709e3edd03cd00187641429a7b31a53efe8130f1 100644 (file)
@@ -19,8 +19,11 @@ int test_yaffs_mkdir_ENOTDIR(void)
 {
        int error_code = 0;
        
-
-       output = yaffs_mkdir("/yaffs2/foo/new_directory/",O_CREAT | O_RDWR);
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_mkdir("/yaffs2/test_dir/foo/new_directory/",O_CREAT | O_RDWR);
        if (output < 0){
                error_code = yaffs_get_error();
                if (abs(error_code) == ENOTDIR){
index 42f12ba2506adbd5469e41634bb6708bf91580e2..d1e4d575ae53d136dd2048e671fed57b23121932 100644 (file)
@@ -17,6 +17,8 @@ int test_yaffs_mount(void)
 {
        int output = 0;
        output = yaffs_mount(YAFFS_MOUNT_POINT);
+       yaffs_mkdir(TEST_DIR,S_IWRITE | S_IREAD);
+
        return output;
 }
 
index c3d9a71957d43a9aebbb35d2db8dd00a5452856d..c333c3f90bedcccd9f190b8b0ddde68a8c937096 100644 (file)
@@ -20,7 +20,10 @@ int test_yaffs_open_EACCES(void)
        int error_code=0;
        int output =-1;
        if (yaffs_access(FILE_PATH,0)!=0){
-               output=yaffs_close(test_yaffs_open());
+               
+               handle = yaffs_open(FILE_PATH, O_CREAT | O_RDWR, FILE_MODE);
+
+               output=yaffs_close(handle);
                if (output<0){
                        print_message("failed to open file\n",2);
                        return -1;
index 922f4312a566e057e35abfa2361792572ead026e..4e5a2a497b4ede65fb87b5a876501891d87efc8b 100644 (file)
@@ -18,6 +18,7 @@ static int handle = -1;
 int test_yaffs_open_EEXIST(void)
 {
        int error_code = 0;
+       handle = yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
 
        handle = yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
        if (handle == -1){
index c1f6c90fd8ab71bd053acd577acf380f43205506..7729369ea333d56486b7801039fb1ac4f48e05de 100644 (file)
@@ -18,6 +18,7 @@ static int handle = -1;
 int test_yaffs_open_EINVAL(void)
 {
        int error_code = 0;
+       handle = yaffs_open(FILE_PATH, O_CREAT | O_RDWR, FILE_MODE);
 
        handle=yaffs_open(FILE_PATH, 255,FILE_MODE);
        if (handle == -1){
index 4ec6a7467fbfaa54c8c7b2cda0cdb8762b909109..6b0fc98cfebb56d4c639e92ec2cc6840ea80ba6f 100644 (file)
@@ -18,8 +18,9 @@ static int handle = -1;
 int test_yaffs_open_ENOTDIR(void)
 {
        int error_code=0;
+       handle = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
 
-       handle=yaffs_open("/yaffs2/foo/file", O_TRUNC| O_RDWR,FILE_MODE );
+       handle=yaffs_open("/yaffs2/test_dir/foo/file", O_TRUNC| O_RDWR,FILE_MODE );
        if (handle <0){
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 101c458a4bd6bf68b7dbe3f94dd8fc5453c448c9..75bf7048b5456da124041a02f110479a0a11c5ec 100644 (file)
@@ -11,6 +11,8 @@
  * published by the Free Software Foundation.
  */
 
+/*this is no longer relevent because it is not possiable to read -1 bytes*/
+
 #include "test_yaffs_read_EINVAL.h"
 
 static int handle = -1;
@@ -19,10 +21,14 @@ static char *file_name = NULL;
 int test_yaffs_read_EINVAL(void)
 {
        int error_code = 0;
-       handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
        char text[2000000];
        int output=0;   
-       
+       /*if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }*/
+       handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+
        if (handle<0){
                print_message("could not open file\n",2);
                return -1;
index c5e2a261bc10f8b32893c147c4997fa1d00cf608..82d29bb012473ac28cb3f66de54a8b941d8f1dee 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_rename_EEXISTS(void)
 {
        int output=0;
        int error_code =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
@@ -36,7 +39,7 @@ int test_yaffs_rename_EEXISTS(void)
                        }
                }
        }
-       output= yaffs_open("/yaffs2/dir2/file",O_CREAT | O_RDWR, FILE_MODE);
+       output= yaffs_open("/yaffs2/test_dir/dir2/file",O_CREAT | O_RDWR, FILE_MODE);
        if (output<0){
                print_message("failed to open file in the second directory\n",2);
                return -1;
index a430577a4552553898a9513c6afca373b965b7bc..d1bb6bd90b120268c4a5f1ad685dfda30ecc7199 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_rename_EINVAL(void)
 {
        int output=0;
        int error_code =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
@@ -26,7 +29,7 @@ int test_yaffs_rename_EINVAL(void)
                        return -1;
                }
        }
-       output = yaffs_rename(DIR_PATH , "/yaffs2/new_directory/dir/");
+       output = yaffs_rename(DIR_PATH , "/yaffs2/test_dir/new_directory/dir/");
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==EINVAL){
index 7252638792be14821ff557df67ceaff7e03e86f7..210a08bafe5a33392d69176e16bdafde961d05e8 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_rename_ENOTDIR(void)
 {
        int output=0;
        int error_code =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
@@ -26,7 +29,7 @@ int test_yaffs_rename_ENOTDIR(void)
                        return -1;
                }
        }
-       output = yaffs_rename("yaffs2/foo/file" , RENAME_PATH);
+       output = yaffs_rename("yaffs2/test_dir/foo/file" , RENAME_PATH);
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c
new file mode 100644 (file)
index 0000000..a13ee8a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_ENOTEMPTY.h"
+
+int  test_yaffs_rename_ENOTEMPTY(void)
+{
+
+       int output=0;
+       int error_code =0;
+
+       if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir\n",1);
+               return -1;
+       }
+       if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir2\n",1);
+               return -1;
+       }
+       if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_rename( DIR_PATH,DIR_PATH2 );
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOTEMPTY){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n",2);
+                       return -1;
+               }
+               print_message("could not rename a directory over a nonempty directory (which is a bad thing)\n",2);
+               return -1;
+       } 
+               
+       return 1;
+
+}
+
+
+int  test_yaffs_rename_ENOTEMPTY_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h
new file mode 100644 (file)
index 0000000..10b634d
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_ENOTEMPTY_H__
+#define __TEST_YAFFS_RENAME_ENOTEMPTY_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_ENOTEMPTY(void);
+int test_yaffs_rename_ENOTEMPTY_clean(void);
+
+#endif
index 768a2d6c9ae7535ac98d8b7195d60f157e88d550..f9821d2297f4bc819b9a639f00a494f1d7d72709 100644 (file)
@@ -18,6 +18,10 @@ int test_yaffs_rename_EROFS(void)
 {
        int output=0;
        int error_code =0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        EROFS_setup();
        output = yaffs_rename(FILE_PATH , RENAME_PATH);
        if (output<0){ 
index 70e3db7a495d84d9f9a146cec7ace8a52b24adeb..18a28e6bb1c626b3cfde4c10acc10db80dacf2fb 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "test_yaffs_rename_dir.h"
 
-
+/*creates a new directory and renames it*/
 int test_yaffs_rename_dir(void)
 {
        int output=0;
index f86b705b7d685654f7a57382045eb0fae746a792..059e0b9ef32b9044283541a9c5acd59492ead726 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "test_yaffs_rename_dir_ENOENT.h"
 
-
+/*tries to rename a nonexisting directory */
 int test_yaffs_rename_dir_ENOENT(void)
 {
        int output=0;
index a47e2c563d07a3e036f5f0160378c7afb0f7d34e..2e2cb281b0b588e780db3c671eb16552d9f5ec28 100644 (file)
@@ -20,13 +20,13 @@ int test_yaffs_rename_dir_ENOENT2(void)
        int error_code =0;
 
        if (0 !=  yaffs_access(DIR_PATH,0)) {
-               output = mkdir(DIR_PATH,S_IREAD | S_IWRITE);
+               output = yaffs_mkdir(DIR_PATH,S_IREAD | S_IWRITE);
                if (output < 0) {
                        print_message("failed to create dir\n",2);
                        return -1;
                }
        }
-       output = yaffs_rename( DIR_PATH , "/yaffs2/nonexisting-dir/dir");
+       output = yaffs_rename( DIR_PATH , "/yaffs2/test_dir/nonexisting-dir/dir");
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOENT){
@@ -36,7 +36,7 @@ int test_yaffs_rename_dir_ENOENT2(void)
                        return -1;
                }
        } else{
-               print_message("removed /yaffs2/ directory (which is a bad thing)\n",2);
+               print_message("removed /yaffs2/test_dir/ directory (which is a bad thing)\n",2);
                return -1;
        }       
 
index 9b37209fd835119c098a2faa92e130b1ed6d84e9..bc6f01f55b7de101132dd195b670ea80d8732033 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "test_yaffs_rename_dir.h"
 
-
+/*tests renaming a non empty file */
 int test_yaffs_rename_dir(void)
 {
        int output=0;
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c
new file mode 100644 (file)
index 0000000..1a46919
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_dir_over_dir.h"
+
+int  test_yaffs_rename_dir_over_dir(void)
+{
+
+       int output=0;
+       int error_code =0;
+
+       if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir\n",1);
+               return -1;
+       }
+       if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir2\n",1);
+               return -1;
+       }
+       output = yaffs_rename(DIR_PATH ,DIR_PATH2 );
+       if (output<0){ 
+               print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2);
+               return -1;
+       } 
+               
+       return 1;
+
+}
+
+
+int  test_yaffs_rename_dir_over_dir_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h
new file mode 100644 (file)
index 0000000..e1ebd15
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_DIR_OVER_DIR_H__
+#define __TEST_YAFFS_RENAME_DIR_OVER_DIR_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_dir_over_dir(void);
+int test_yaffs_rename_dir_over_dir_clean(void);
+
+#endif
index b191dbb9d18839ec4febbcb0fa830e733ebfd9cb..5fabdd227cc5c3582ce11bc35cb343cf6a0aabb7 100644 (file)
 
 #include "test_yaffs_rename_dir_to_file.h"
 
-
+/*tries to rename a directory over an existing file */
 int test_yaffs_rename_dir_to_file(void)
 {
        int output=0;
-
+       int error_code=0;
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output= yaffs_mkdir(DIR_PATH,(S_IREAD | S_IWRITE));
                if (output<0) {
-                       print_message("failed to remove directory\n",2);
+                       print_message("failed to create 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);
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_rename( DIR_PATH , FILE_PATH);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOTDIR){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n",2);
                        return -1;
                }
-       }
-       output = yaffs_rename( DIR_PATH , RENAME_PATH);
-       if (output<0){ 
-               print_message("failed to rename a file over an empty directory\n",2);
+       } else {
+               print_message("renamed a directory over file.(which is a bad thing)\n",2);
                return -1;
-       } else{
-               return 1;
-       }       
+       }
 
 }
 
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c
new file mode 100644 (file)
index 0000000..70652d6
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_file_over_file.h"
+
+int  test_yaffs_rename_file_over_file(void)
+{
+
+       int output=0;
+       int error_code =0;
+
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       if (yaffs_close(yaffs_open(FILE_PATH2,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_rename(FILE_PATH ,FILE_PATH2 );
+       if (output<0){ 
+               print_message("could not rename a file over a file (which is a bad thing)\n",2);
+               return -1;
+       } 
+               
+       return 1;
+
+}
+
+
+int  test_yaffs_rename_file_over_file_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h
new file mode 100644 (file)
index 0000000..ce99b00
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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 __test_yaffs_RENAME_FILE_OVER_FILE_H__
+#define __test_yaffs_RENAME_FILE_OVER_FILE_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_file_over_file(void);
+int test_yaffs_rename_file_over_file_clean(void);
+
+#endif
index efc87d0f2405c031e10a5f4e284b4d1618632405..fec2bf0693c88b20cae8ccd18f40404270ad2363 100644 (file)
 
 int test_yaffs_rename_file_to_dir(void)
 {
+
        int output=0;
+       int error_code=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
 
-       if (0 !=  yaffs_access(FILE_PATH,0)) {
-               output = test_yaffs_open();
+       if (0 !=  yaffs_access(RENAME_DIR_PATH,0)) {
+               output = yaffs_mkdir(RENAME_DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
-                       print_message("failed to create file\n",2);
+                       print_message("failed to create directory\n",2);
                        return -1;
-               } else {
-                       output = yaffs_close(output);
-                       if (output < 0) {
-                               print_message("failed to close file\n",2);
-                               return -1;
-                       }
                }
        }
-       output = yaffs_rename( "/yaffs2/foo" , RENAME_DIR_PATH);
-       if (output<0){ 
-               print_message("failed to rename a file over an empty directory\n",2);
+       output=yaffs_rename(FILE_PATH,RENAME_DIR_PATH);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EISDIR){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n",2);
+                       return -1;
+               }
+       } else {
+               print_message("renamed a file over a directory (which is a bad thing)\n",2);
                return -1;
-       } else{
-               return 1;
-       }       
+       }
+       return 1;
 
 }
 
 
 int test_yaffs_rename_file_to_dir_clean(void)
 {
-       int output = 0;
-       test_yaffs_open();
-       if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
-               output = yaffs_unlink(RENAME_DIR_PATH);
-               if (output < 0) {
-                       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;
 
 }
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c
new file mode 100644 (file)
index 0000000..64317ce
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_full_dir_over_dir.h"
+
+int  test_yaffs_rename_full_dir_over_dir(void)
+{
+
+       int output=0;
+       int error_code =0;
+
+       if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir\n",1);
+               return -1;
+       }
+       if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+               print_message("failed to create dir2\n",1);
+               return -1;
+       }
+       if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_rename( DIR_PATH2,DIR_PATH );
+       if (output<0){ 
+               print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2);
+               return -1;
+       } 
+               
+       return 1;
+
+}
+
+
+int  test_yaffs_rename_full_dir_over_dir_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h
new file mode 100644 (file)
index 0000000..dfee3cd
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_FULL_DIR_OVER_DIR_H__
+#define __TEST_YAFFS_RENAME_FULL_DIR_OVER_DIR_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_full_dir_over_dir(void);
+int test_yaffs_rename_full_dir_over_dir_clean(void);
+
+#endif
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c
new file mode 100644 (file)
index 0000000..ba04a4f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_to_null_file.h"
+
+int  test_yaffs_rename_to_null_file(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_rename(FILE_PATH , NULL);
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EFAULT){
+                       return 1;
+               } else {
+                       print_message("returned error does not match the the expected error\n",2);
+                       return -1;
+               }
+       } else{
+               print_message("renamed to null path (which is a bad thing)\n",2);
+               return -1;
+       }       
+}
+
+
+int  test_yaffs_rename_to_null_file_clean(void)
+{
+       return 1;
+}
diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h
new file mode 100644 (file)
index 0000000..0858ecf
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __test_yaffs_rename_NULL3_h__
+#define __test_yaffs_rename_NULL3_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_to_null_file(void);
+int test_yaffs_rename_to_null_file_clean(void);
+
+#endif
+
index 45f5685886f25a1f18291df17d45539a6ffda15f..412bd3d90f90cfee21dafca91628fb99f3f3f89c 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_rmdir_ENOTDIR(void)
 {
        int output=0;
        int error_code =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
@@ -26,7 +29,7 @@ int test_yaffs_rmdir_ENOTDIR(void)
                        return -1;
                }
        }
-       output = yaffs_rmdir("/yaffs2/foo/dir/");
+       output = yaffs_rmdir("/yaffs2/test_dir/foo/dir/");
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 6b8c046a0d7fee12bee6d68f8d050520ca080a2a..5d881b00ef7e5ad2acc2988b9cf113278814d4ce 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_rmdir_ENOTEMPTY(void)
 {
        int output=0;
        int error_code =0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
        if (0 !=  yaffs_access(DIR_PATH,0)) {
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
@@ -26,8 +29,8 @@ int test_yaffs_rmdir_ENOTEMPTY(void)
                        return -1;
                }
        }
-       if (0 !=  yaffs_access("/yaffs2/new_directory/dir",0)) {
-               output = yaffs_mkdir("/yaffs2/new_directory/dir",S_IWRITE | S_IREAD);
+       if (0 !=  yaffs_access("/yaffs2/test_dir/new_directory/dir",0)) {
+               output = yaffs_mkdir("/yaffs2/test_dir/new_directory/dir",S_IWRITE | S_IREAD);
                if (output < 0) {
                        print_message("failed to create directory\n",2);
                        return -1;
@@ -53,8 +56,8 @@ int test_yaffs_rmdir_ENOTEMPTY_clean(void)
 {
        int output = -1;
        int output2 = -1;
-       if (0 ==  yaffs_access("/yaffs2/new_directory/dir",0)) {
-               output = yaffs_rmdir("/yaffs2/new_directory/dir");
+       if (0 ==  yaffs_access("/yaffs2/test_dir/new_directory/dir",0)) {
+               output = yaffs_rmdir("/yaffs2/test_dir/new_directory/dir");
                if (output < 0) {
                        print_message("failed to remove the directory\n",2);
                        output=1;
index f3aa8f75a33bd475fcf4e35270539689905c53d3..5b5cd31c8b0ac34e0ddd8c217ce83382df8b2226 100644 (file)
@@ -20,7 +20,10 @@ int test_yaffs_stat(void)
        int size=0;
        message[0]='\0';
        struct yaffs_stat stat;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file \n",1);
+               return -1;
+       }
        return yaffs_stat(FILE_PATH, &stat);
 }
 
index c6773d32b99ad7c3f260fe8d8e02f578f3cb86e0..ce228057f1592dfcbe26139c91ba026a0a4f7f30 100644 (file)
@@ -20,7 +20,11 @@ int test_yaffs_stat_ENOTDIR(void)
        int output=0;
        char text[100];
        text[0] ='\0';
-       output=yaffs_stat("/yaffs2/foo/file", &stat);;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output=yaffs_stat("/yaffs2/test_dir/foo/file", &stat);;
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 680f0aaab2c5b6473982abfc22bc6ed6ae35a0f3..9bb9bb65e489e07f85e09c03196b59ae80c01c83 100644 (file)
@@ -18,7 +18,11 @@ static int output = 0;
 int test_yaffs_symlink_ENOTDIR(void)
 {
        int error_code = 0;
-       output = yaffs_symlink(FILE_PATH,"yaffs2/foo/sym_link");
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file\n",1);
+               return -1;
+       }
+       output = yaffs_symlink(FILE_PATH,"yaffs2/test_dir/foo/sym_link");
        if (output<0){ 
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 6e6ef405828ce8b21c65ab7c2534e17cc9c1a136..b535039f369259349c3e47a4d3aa58c51f589eae 100644 (file)
@@ -18,8 +18,11 @@ int test_yaffs_truncate_EINVAL(void)
 {
        int error=0;
        int output=0;
-
-       output= yaffs_truncate("/yaffs2/foo",-1 );
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file \n",1);
+               return -1;
+       }
+       output= yaffs_truncate(FILE_PATH,-1 );
        if (output<0){
                error=yaffs_get_error();
                if (abs(error)==EINVAL){
index a2d010f646508deb91b98b7db8bcfbe6bde09247..ce621a0cf83ee7427591043bd52b19698d309227 100644 (file)
@@ -19,9 +19,12 @@ int test_yaffs_truncate_ENOTDIR(void)
 {
        int error=0;
        int output=0;
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file \n",1);
+               return -1;
+       }
 
-
-       output= yaffs_truncate("/yaffs2/foo/file",FILE_SIZE_TRUNCATED );
+       output= yaffs_truncate("/yaffs2/test_dir/foo/file",FILE_SIZE_TRUNCATED );
        if (output<0){
                error=yaffs_get_error();
                if (abs(error)==ENOTDIR){
index 2840a6737e4d57fcbf611394214a2737d49df0ae..6b4b526ce36de9367870779f38e402b08276314b 100644 (file)
@@ -19,7 +19,10 @@ int test_yaffs_truncate_EROFS(void)
 {
        int error=0;
        int output=0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file \n",1);
+               return -1;
+       }
 
        EROFS_setup();
        output= yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
index f45b59592dede94e68d95cf67b3ea91574389768..cffdb25619a27b3820e3bae9e5154b65c2741890 100644 (file)
 
 int test_yaffs_unlink(void)
 {
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }
        int output=yaffs_unlink(FILE_PATH);
        if (output>=0){
                return (-test_yaffs_access());  /*return negative access. we do not want the file to be there*/
index e75d12164e96fb17692c3d2c6725503b332af1c7..89bace3f4ffdf6c4cce12953d10bce73f8e62767 100644 (file)
@@ -18,8 +18,11 @@ int test_yaffs_unlink_ENOTDIR(void)
 {
        int output=0;
        int error_code=0;
-
-       output=yaffs_unlink("/yaffs2/foo/file");
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }
+       output=yaffs_unlink("/yaffs2/test_dir/foo/file");
        if (output==-1){
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){
index 7e1d602feaad6607b482162739e2a9b3ca27e525..152ef3987bc6e5f85b5f26445b1ec62fe2ccb7c6 100644 (file)
@@ -18,7 +18,10 @@ int test_yaffs_unlink_EROFS(void)
 {
 
        int error_code=0;
-
+       if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+               print_message("failed to create file before remounting\n",1);
+               return -1;
+       }
        EROFS_setup();
 
        output=yaffs_unlink(FILE_PATH);