yaffs Added more tests to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 23 Nov 2010 23:01:00 +0000 (12:01 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 23 Nov 2010 23:01:00 +0000 (12:01 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
13 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/current_bugs.txt
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_mkdir.c
direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c
direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.h [new file with mode: 0644]

index 7e4f7b3..813c60f 100644 (file)
@@ -86,7 +86,8 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_rmdir.o test_yaffs_rmdir_EBUSY.o test_yaffs_rmdir_EINVAL.o test_yaffs_rmdir_ENOENT.o \
                test_yaffs_rmdir_ENOTDIR.o \
                test_yaffs_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \
-               test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.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
 
 
                  
index 17c52f3..7b80533 100644 (file)
@@ -3,15 +3,9 @@ Made by Timothy Manning <timothy@yaffs.net> on 08/11/2010
 
 
 Current BUGS 
-
-       BUG with trying to rmdir /yaffs2/ the error returned is ENOTEMPTY. 
-       But the error that should be returned is EBUSY.
-
-       BUG with trying to rmdir /yaffs2/. the error returned is ENOENT. 
-       But the error that should be returned is EINVAL.
-
-       BUG with having slashes on the end of the second path passed into the rename function.
-       The function returns ENOENT. but should be returning other errors.
+       Bug with test_yaffs_rename_dir it does not return an error code.
+       
+       Bug with test_yaffs_rename_EEXIST should be giving the bug EEXIST but instead gives ENOENT. 
 
 Current WARNINGS
        
index d52b974..9a74a08 100644 (file)
@@ -30,7 +30,7 @@
 #define FILE_TEXT "file foo "  /* keep space at end of string */
 #define FILE_TEXT_NBYTES 10
 
-#define DIR_PATH "/yaffs2/new_directory/"
+#define DIR_PATH "/yaffs2/new_directory"
 
 #define SYMLINK_PATH "/yaffs2/sym_foo"
 
index 91403e3..1aca5cb 100644 (file)
 #include "test_yaffs_rename_dir.h"
 #include "test_yaffs_rename_dir_ENOENT.h"
 #include "test_yaffs_rename_dir_ENOENT2.h"
+#include "test_yaffs_rename_dir_to_file.h"
+#include "test_yaffs_rename_file_to_dir.h"
+#include "test_yaffs_rename_EEXISTS.h"
 
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
@@ -324,7 +327,10 @@ test_template test_list[]={
        {test_yaffs_rename_EINVAL,test_yaffs_rename_EINVAL_clean,"test_yaffs_rename_EINVAL"},
        {test_yaffs_rename_dir,test_yaffs_rename_dir_clean,"test_yaffs_rename_dir"},
        {test_yaffs_rename_dir_ENOENT,test_yaffs_rename_dir_ENOENT_clean,"test_yaffs_rename_dir_ENOENT"},
-       {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"}
+       {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"},
+       {test_yaffs_rename_dir_to_file,test_yaffs_rename_dir_to_file_clean,"test_yaffs_rename_dir_to_file"},
+       {test_yaffs_rename_file_to_dir,test_yaffs_rename_file_to_dir_clean,"test_yaffs_rename_file_to_dir"},
+       {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"}
        };
 
 void init_quick_tests(int argc, char *argv[]);
index a0b29b7..3427b23 100644 (file)
 
 #include "test_yaffs_mkdir.h"
 
-static int output = -1;
+
 
 int test_yaffs_mkdir(void)
 {
-       output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+       int output=-1;
+       if (0==yaffs_access(DIR_PATH,0)) {
+               output=yaffs_rmdir(DIR_PATH);
+               if (output<0) {
+                       print_message("the directory already exists and cannot be removed.\n",2);
+                       return -1;
+               }
+       }
+       output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
        return output;
 }
 
 
 int test_yaffs_mkdir_clean(void)
 {
-       if (output >= 0){
-               return yaffs_rmdir("/yaffs2/new_directory/");
+       if (0==yaffs_access(DIR_PATH,0)) {
+               return yaffs_rmdir(DIR_PATH);
        } else {
-               return 1;       /* the file failed to open so there is no need to close it */
+               return 1;       
        }
 }
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c
new file mode 100644 (file)
index 0000000..b1df21d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_rename_EEXISTS.h"
+
+
+int test_yaffs_rename_EEXISTS(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;
+               }
+       }
+       if (0 !=  yaffs_access(RENAME_DIR_PATH,0)) {
+               output = yaffs_mkdir(RENAME_DIR_PATH,S_IWRITE | S_IREAD);
+               if (output < 0) {
+                       error_code=yaffs_get_error();
+                       if (abs(error_code)!=EEXIST){
+                               print_message("failed to create second directory\n",2);
+                               return -1;
+                       }
+               }
+       }
+       output= yaffs_open("/yaffs2/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;
+       }
+       output = yaffs_rename(DIR_PATH , RENAME_DIR_PATH);
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EEXIST){
+                       return 1;
+               } else {
+                       print_message("returned error does not match the the expected error\n",2);
+                       return -1;
+               }
+       } else{
+               print_message("removed /yaffs2/ directory (which is a bad thing)\n",2);
+               return -1;
+       }       
+}
+
+
+int test_yaffs_rename_EEXISTS_clean(void)
+{
+       int output = 0;
+       if (0 ==  yaffs_access(RENAME_PATH,0) && 0 != yaffs_access(DIR_PATH,0)) {
+               output = yaffs_rename(RENAME_PATH,FILE_PATH);
+               if (output < 0) {
+                       print_message("failed to remove the directory\n",2);
+                       return -1;
+               }
+       }
+       return 1;
+
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.h
new file mode 100644 (file)
index 0000000..9924d31
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_rename_EEXISTS_h__
+#define __test_yaffs_rename_EEXISTS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_EEXISTS(void);
+int test_yaffs_rename_EEXISTS_clean(void);
+
+#endif
index 5a1f675..716d7dc 100644 (file)
@@ -20,7 +20,6 @@ int test_yaffs_rename_EINVAL(void)
        int error_code =0;
 
        if (0 !=  yaffs_access(DIR_PATH,0)) {
-               printf("dir does not exist\n");
                output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
                if (output < 0) {
                        print_message("failed to create directory\n",2);
index 323a0e7..5c7a254 100644 (file)
@@ -27,7 +27,6 @@ int test_yaffs_rename_dir(void)
                }
        }
        output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH);
-       printf("output %d\n",output);
        return output;  
 }
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.c
new file mode 100644 (file)
index 0000000..d87b8ab
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_rename_dir_to_file.h"
+
+
+int test_yaffs_rename_dir_to_file(void)
+{
+       int output=0;
+
+       if (0 !=  yaffs_access(DIR_PATH,0)) {
+               output= yaffs_mkdir(DIR_PATH,(S_IREAD | S_IWRITE));
+               if (output<0) {
+                       print_message("failed to create directory\n",2);
+                       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);
+               return -1;
+       } else{
+               return 1;
+       }       
+
+}
+
+
+int test_yaffs_rename_dir_to_file_clean(void)
+{
+       int output = 0;
+       if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
+               output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH);
+               if (output < 0) {
+                       print_message("failed to rename the file\n",2);
+                       return -1;
+               }
+       }
+       return 1;
+
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_to_file.h
new file mode 100644 (file)
index 0000000..b68bd5c
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_rename_dir_to_file_h__
+#define __test_yaffs_rename_dir_to_file_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_rename_dir_to_file(void);
+int test_yaffs_rename_dir_to_file_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.c
new file mode 100644 (file)
index 0000000..182fb0d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_rename_file_to_dir.h"
+
+
+int test_yaffs_rename_file_to_dir(void)
+{
+       int output=0;
+
+       if (0 !=  yaffs_access(FILE_PATH,0)) {
+               output = test_yaffs_open();
+               if (output < 0) {
+                       print_message("failed to create file\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);
+               return -1;
+       } else{
+               return 1;
+       }       
+
+}
+
+
+int test_yaffs_rename_file_to_dir_clean(void)
+{
+       int output = 0;
+       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;
+               }
+       }
+       return 1;
+
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_file_to_dir.h
new file mode 100644 (file)
index 0000000..a5c8136
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_rename_file_to_dir_h__
+#define __test_yaffs_rename_file_to_dir_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_rename_file_to_dir(void);
+int test_yaffs_rename_file_to_dir_clean(void);
+
+#endif