yaffs Still trying to find the bug.
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 17 Nov 2010 02:10:17 +0000 (15:10 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 17 Nov 2010 02:10:17 +0000 (15:10 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_sync_ENOTDIR.c

index dca2eed4698683065a9a3913029a0a0608c0c672..0604e1d79162ee03ff4e32a41032b8b8b181a8e3 100644 (file)
@@ -69,7 +69,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o test_yaffs_symlink_ENOENT.o \
                test_yaffs_mount2.o \
                test_yaffs_unmount2.o \
-               test_yaffs_sync.o
+               test_yaffs_sync.o test_yaffs_sync_ENOTDIR.o test_yaffs_sync_ENOENT.o
 
 
                  
index 5033e126b9f8efd42a519b7bad92170bf7c9060a..398512a78a70e6312d7dcbc31a89c670b615c4e4 100644 (file)
@@ -67,6 +67,9 @@ Tests made
        test_yaffs_symlink_EEXISTS
        test_yaffs_symlink_ENOENT       //if there is a slash on the end of new path
 
+       test_yaffs_sync
+       test_yaffs_sync_ENOTDIR
+
        test_yaffs_fstat
        test_yaffs_fstat_EBADF
 
@@ -161,9 +164,8 @@ Tests to add
        test_yaffs_remount2_ENODEV
        test_yaffs_remount2_EINVAL
 
-       test_yaffs_sync
+
        test_yaffs_sync_ENOENT
-       test_yaffs_sync_ENOTDIR
 
        test_yaffs_freespace
        test_yaffs_freespace_ENOENT
index f127be7f2b044b37ed60f2cee1e64c23ea43dee8..115525b476a802e82770b550e3b40383408757c8 100644 (file)
@@ -37,7 +37,8 @@ int main(int argc, char *argv[]){
        for (x=0;x<total_number_of_tests;x++){
                output=test_yaffs_open();
                printf("yaffs_open = %d\n",output);
-               printf("yaffs_open_clean = %d\n",yaffs_close(output));
+               printf("yaffs_close handle 0 = %d\n",yaffs_close(output));
+               //printf("yaffs_close handle 1#################################### =%d\n",yaffs_close(1));
                yaffs_set_error(0);     /*reset the last error to 0 */
                sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
                print_message(message,3);
index 0a6cf06db470ee5638de2103a2cc52a442f84b55..14d7dbc6d13bde1813624899c950fb71accedcff 100644 (file)
 #include "test_yaffs_unmount2.h"
 
 #include "test_yaffs_sync.h"
+#include "test_yaffs_sync_ENOTDIR.h"
+#include "test_yaffs_sync_ENOENT.h"
+
 
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
@@ -225,7 +228,9 @@ test_template test_list[]={
 
        {test_yaffs_unmount2,test_yaffs_unmount2_clean,"test_yaffs_unmount2"},
 
-       {test_yaffs_sync,test_yaffs_sync_clean,"test_yaffs_sync"}
+       {test_yaffs_sync,test_yaffs_sync_clean,"test_yaffs_sync"},
+       {test_yaffs_sync_ENOTDIR,test_yaffs_sync_ENOTDIR_clean,"test_yaffs_sync_ENOTDIR"},
+       {test_yaffs_sync_ENOENT,test_yaffs_sync_ENOENT_clean,"test_yaffs_sync_ENOENT"}
 
 
 
index e3ce96667c53ac0113d892cb88f4ee3752c9515e..27120b21c313a8074ea5a7e594522c7819558887 100644 (file)
@@ -19,7 +19,8 @@ static char *file_name = NULL;
 int test_yaffs_read_EINVAL(void)
 {
        int error_code = 0;
-       handle=test_yaffs_open();
+       handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+       printf("newly opend handle = %d handle\n",handle);
        char text[2000000]="\0";
        int output=0;   
        
@@ -59,10 +60,33 @@ int test_yaffs_read_EINVAL_clean(void)
 {
        int output=0;
        if (handle>=0){
-               output=test_yaffs_read_EINVAL_init_clean();
+               if(file_name){
+                       free(file_name);
+                       file_name = NULL;
+               }
+
+               
+               output= yaffs_truncate(FILE_PATH,FILE_SIZE );   
+               if (output>=0){
+                       output=test_yaffs_write();
+                       if (output<0){
+                               print_message("failed to write to file\n",2);
+                               return -1;
+                       } else {
+                               output=test_yaffs_write_clean();
+                               if (output<0){
+                                       print_message("failed to clean the write_to_file function\n",2);
+                               }
+                       }
+               } else {
+                       print_message("failed to truncate file\n",2);
+                       return -1;
+               }
+
                if(output>=0){
                        output=yaffs_close(handle);
                        if (output>=0){
+                               printf("closed the file, handle %d\n",handle);
                                return 1;
                        } else {
                                print_message("could not close the handle\n",2);
@@ -74,6 +98,7 @@ int test_yaffs_read_EINVAL_clean(void)
                }
        } else {
                print_message("no open handle\n",2);
+               return -1;      
        }
 }
 
@@ -115,28 +140,4 @@ int test_yaffs_read_EINVAL_init(void)
        
 }
 
-int test_yaffs_read_EINVAL_init_clean(void)
-{
-       int output=1;
-       if(file_name){
-               free(file_name);
-               file_name = NULL;
-       }
-
-       
-       output= yaffs_truncate(FILE_PATH,FILE_SIZE );   
-       if (output>=0){
-               output=test_yaffs_write();
-               if (output>=0){
-                       return 1;
-               } else {
-                       print_message("failed to write to file\n",2);
-                       return -1;
-               }
-       } else {
-               print_message("failed to truncate file\n",2);
-               return -1;
-       }
-
-}
 
index ee559276343c73b9061ca54c282f35350379b3d9..df25d55b06574fefb8ad5502541b9d755ae1f07d 100644 (file)
 
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_yaffs_open.h"
-#include "test_yaffs_write.h"
-#include "test_yaffs_truncate.h"
+//#include "test_yaffs_open.h"
+//#include "test_yaffs_write.h"
+//#include "test_yaffs_truncate.h"
 
 
 int test_yaffs_read_EINVAL(void);
 int test_yaffs_read_EINVAL_clean(void);
 int test_yaffs_read_EINVAL_init(void);
-int test_yaffs_read_EINVAL_init_clean(void);
+
 
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c
new file mode 100644 (file)
index 0000000..2f1792d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_sync_ENOENT.h"
+
+
+int test_yaffs_sync_ENOENT(void)
+{
+       int error_code=-1;
+       int output = yaffs_sync("yaffs2/non-existing-file");
+       
+       if (output<0){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOENT){
+                       return 1;
+               } else {
+                       print_message("returned error does not match the the expected error\n",2);
+                       return -1;
+               }
+       } else {
+               print_message("synced a file in a non-existing directory (which is a bad thing)\n",2);
+               return -1;
+       }       
+
+
+}
+
+
+int test_yaffs_sync_ENOENT_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h
new file mode 100644 (file)
index 0000000..55cf61b
--- /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_sync_ENOENT_h__
+#define __test_yaffs_sync_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_sync_ENOENT(void);
+int test_yaffs_sync_ENOENT_clean(void);
+
+#endif
index 97fb2b14daeb33bdaacc7ab3d79a23d6937f2206..0961af20c6789c595289e62670ea6c90a44a578f 100644 (file)
@@ -16,7 +16,9 @@
 
 int test_yaffs_sync_ENOTDIR(void)
 {
+       int error_code=-1;
        int output = yaffs_sync("non-existing-dir/foo");
+       
        if (output<0){
                error_code=yaffs_get_error();
                if (abs(error_code)==ENOTDIR){