From: Charles Manning Date: Fri, 18 Jan 2013 02:17:53 +0000 (+1300) Subject: Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2 X-Git-Tag: aleph1-release~62^2~1 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=fa6e2de81382a23a7a99de6a8832f26c371c9520;hp=7d4b7d916729a7c0e9e4c2cbf708c2769620fd0d Merge branch 'master' of ssh://aleph1.co.uk/home/aleph1/git/yaffs2 --- diff --git a/direct/test-framework/timothy_tests/quick_tests/Makefile b/direct/test-framework/timothy_tests/quick_tests/Makefile index ac69431..431c883 100644 --- a/direct/test-framework/timothy_tests/quick_tests/Makefile +++ b/direct/test-framework/timothy_tests/quick_tests/Makefile @@ -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 diff --git a/direct/test-framework/timothy_tests/quick_tests/lib.c b/direct/test-framework/timothy_tests/quick_tests/lib.c index 50723c3..4edc19e 100644 --- a/direct/test-framework/timothy_tests/quick_tests/lib.c +++ b/direct/test-framework/timothy_tests/quick_tests/lib.c @@ -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); +} diff --git a/direct/test-framework/timothy_tests/quick_tests/lib.h b/direct/test-framework/timothy_tests/quick_tests/lib.h index c7d67d2..5e36ca0 100644 --- a/direct/test-framework/timothy_tests/quick_tests/lib.h +++ b/direct/test-framework/timothy_tests/quick_tests/lib.h @@ -22,33 +22,35 @@ #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 diff --git a/direct/test-framework/timothy_tests/quick_tests/quick_tests.c b/direct/test-framework/timothy_tests/quick_tests/quick_tests.c index a3f6463..c083d03 100644 --- a/direct/test-framework/timothy_tests/quick_tests/quick_tests.c +++ b/direct/test-framework/timothy_tests/quick_tests/quick_tests.c @@ -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=0){ /* there were no errors */ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c index 4587315..86155b2 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c @@ -16,7 +16,11 @@ 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(); diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c index fd8af69..cff0503 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c @@ -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); diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c index 250ebc6..d0df070 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c @@ -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; } diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fdatasync_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fdatasync_EROFS.c index bad5f01..6aee590 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fdatasync_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fdatasync_EROFS.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_flush_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_flush_EROFS.c index 41a7450..61138df 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_flush_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_flush_EROFS.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c index 729fad1..8a656be 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c @@ -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 { diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link.c index 7aa8aab..dc70bde 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link.c @@ -18,6 +18,10 @@ 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; } diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EEXIST.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EEXIST.c index 18a540b..e97d3bb 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EEXIST.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EEXIST.c @@ -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); diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR.c index 62c8065..0d54023 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR2.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR2.c index 32d1e0b..15f6f87 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR2.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_ENOTDIR2.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EROFS.c index da4abd6..d3ab40e 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_link_EROFS.c @@ -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); diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c index 665ff9f..5dfa1bb 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c index 2d94fa4..5c99800 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c index c417bb3..709e3ed 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mount.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mount.c index 42f12ba..d1e4d57 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mount.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_mount.c @@ -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; } diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EACCES.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EACCES.c index c3d9a71..c333c3f 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EACCES.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EACCES.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c index 922f431..4e5a2a4 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c index c1f6c90..7729369 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c index 4ec6a74..6b0fc98 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c index 101c458..75bf704 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c index c5e2a26..82d29bb 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c index a430577..d1bb6bd 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTDIR.c index 7252638..210a08b 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTDIR.c @@ -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 index 0000000..a13ee8a --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c @@ -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 + * + * 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 index 0000000..10b634d --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h @@ -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 + * + * 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 diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EROFS.c index 768a2d6..f9821d2 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_EROFS.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir.c index 70e3db7..18a28e6 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c index f86b705..059e0b9 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c index a47e2c5..2e2cb28 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c @@ -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; } diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c index 9b37209..bc6f01f 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c @@ -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 index 0000000..1a46919 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c @@ -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 + * + * 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 index 0000000..e1ebd15 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h @@ -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 + * + * 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 diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c index b191dbb..5fabdd2 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c @@ -13,32 +13,35 @@ #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 index 0000000..70652d6 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c @@ -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 + * + * 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 index 0000000..ce99b00 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h @@ -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 + * + * 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 diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c index efc87d0..fec2bf0 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c @@ -16,48 +16,42 @@ 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 index 0000000..64317ce --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c @@ -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 + * + * 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 index 0000000..dfee3cd --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h @@ -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 + * + * 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 index 0000000..ba04a4f --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c @@ -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 + * + * 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 index 0000000..0858ecf --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h @@ -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 + diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTDIR.c index 45f5685..412bd3d 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c index 6b8c046..5d881b0 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c @@ -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; diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat.c index f3aa8f7..5b5cd31 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat.c @@ -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); } diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c index c6773d3..ce22805 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c index 680f0aa..9bb9bb6 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c index 6e6ef40..b535039 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c index a2d010f..ce621a0 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EROFS.c index 2840a67..6b4b526 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_truncate_EROFS.c @@ -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 ); diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink.c index f45b595..cffdb25 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink.c @@ -15,6 +15,10 @@ 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*/ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c index e75d121..89bace3 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c @@ -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){ diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_EROFS.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_EROFS.c index 7e1d602..152ef39 100644 --- a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_EROFS.c +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_unlink_EROFS.c @@ -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);