yaffs Chasing a bug in yaffsfs.
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 17 Nov 2010 00:09:36 +0000 (13:09 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 17 Nov 2010 00:09:36 +0000 (13:09 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
17 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_mknode.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mknode.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount2.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount2.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_big_file.c
direct/timothy_tests/quick_tests/test_yaffs_unlink.c

index 00ef9f1..94614fb 100644 (file)
@@ -66,7 +66,9 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o \
                test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o \
                test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \
-               test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o
+               test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o test_yaffs_symlink_ENOENT.o \
+               test_yaffs_mount2.o
+
 
                  
 
index a1cb4b7..41efeee 100644 (file)
@@ -62,6 +62,8 @@ Tests made
 
        test_yaffs_symlink
        test_yaffs_symlink_ENOTDIR
+       test_yaffs_symlink_EEXISTS
+       test_yaffs_symlink_ENOENT       //if there is a slash on the end of new path
 
        test_yaffs_fstat
        test_yaffs_fstat_EBADF
@@ -117,12 +119,12 @@ Tests to add
 
 
        test_yaffs_symlink_EACCES
-       test_yaffs_symlink_EEXISTS
        test_yaffs_symlink_ELOOP
        test_yaffs_symlink_ENAMETOOLONG
-       test_yaffs_symlink_ENOENT       //if there is a slash on the end
        test_yaffs_symlink_EROFS
 
+       
+       //the yaffs_mknod function does not exist in yaffsfs, so these tests will be ignored.
        test_yaffs_mknod
        test_yaffs_mknod_EACCES
        test_yaffs_mknod_EEXIST
index b12c04f..2906312 100644 (file)
@@ -34,6 +34,8 @@
 
 #define SYMLINK_PATH "/yaffs2/sym_foo"
 
+#define NODE_PATH "/yaffs2/node"
+
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
 
index d74714d..f127be7 100644 (file)
@@ -35,7 +35,9 @@ int main(int argc, char *argv[]){
        print_message("\n\nrunning quick tests for yaffs\n\n", 0);
 
        for (x=0;x<total_number_of_tests;x++){
-               //printf("x %d\n",x);
+               output=test_yaffs_open();
+               printf("yaffs_open = %d\n",output);
+               printf("yaffs_open_clean = %d\n",yaffs_close(output));
                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 c483d8f..16776c1 100644 (file)
 #include "test_yaffs_symlink.h"
 #include "test_yaffs_symlink_ENOTDIR.h"
 #include "test_yaffs_symlink_EEXIST.h"
+#include "test_yaffs_symlink_ENOENT.h"
 
+#include "test_yaffs_mount2.h"
 
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
@@ -166,7 +168,7 @@ test_template test_list[]={
 
        {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
        {test_yaffs_write_EBADF,test_yaffs_write_EBADF_clean,"test_yaffs_write_EBADF"},
-       {test_yaffs_write_big_file,test_yaffs_write_big_file_clean,"test_yaffs_write_big_file"},
+//     {test_yaffs_write_big_file,test_yaffs_write_big_file_clean,"test_yaffs_write_big_file"},
 
        {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
        {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
@@ -212,7 +214,12 @@ test_template test_list[]={
 
        {test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"},
        {test_yaffs_symlink_ENOTDIR,test_yaffs_symlink_ENOTDIR_clean,"test_yaffs_symlink_ENOTDIR"},
-       {test_yaffs_symlink_EEXIST,test_yaffs_symlink_EEXIST_clean,"test_yaffs_symlink_EEXIST"}
+       {test_yaffs_symlink_EEXIST,test_yaffs_symlink_EEXIST_clean,"test_yaffs_symlink_EEXIST"},
+       {test_yaffs_symlink_ENOENT,test_yaffs_symlink_ENOENT_clean,"test_yaffs_symlink_ENOENT"},
+
+       {test_yaffs_mount2,test_yaffs_mount2_clean,"test_yaffs_mount2"}
+
+
 
 
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mknode.c b/direct/timothy_tests/quick_tests/test_yaffs_mknode.c
new file mode 100644 (file)
index 0000000..5c6c5ca
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_mknode.h"
+
+static int output = 0;
+
+int test_yaffs_mknode(void)
+{
+       output = yaffs_mknod(NODE_PATH,S_IREAD | S_IWRITE);
+       return output;
+}
+
+
+int test_yaffs_mknode_clean(void)
+{
+       if (output >= 0){
+               return yaffs_unlink(NODE_PATH);
+       } else {
+               return 1;       /* the file failed to open so there is no need to close it */
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mknode.h b/direct/timothy_tests/quick_tests/test_yaffs_mknode.h
new file mode 100644 (file)
index 0000000..7699141
--- /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_mknode_h__
+#define __test_yaffs_mknode_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mknode(void);
+int test_yaffs_mknode_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount2.c b/direct/timothy_tests/quick_tests/test_yaffs_mount2.c
new file mode 100644 (file)
index 0000000..52728b7
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_mount2.h"
+
+int test_yaffs_mount2(void)
+{
+       int output = -1;
+       printf("closing handle again %d\n",yaffs_close(0));
+       output= yaffs_unmount(YAFFS_MOUNT_POINT);
+       if (output < 0) {
+               print_message("failed to unmount current_mountpoint\n",2);
+               return -1;
+       }
+
+       output = yaffs_mount2(YAFFS_MOUNT_POINT,255);
+       return output;
+}
+
+int test_yaffs_mount2_clean(void)
+{
+       return 1;       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount2.h b/direct/timothy_tests/quick_tests/test_yaffs_mount2.h
new file mode 100644 (file)
index 0000000..4db4342
--- /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_mount2__
+#define __test_yaffs_mount2__
+
+#include "yaffsfs.h"
+#include "lib.h"
+#include "test_yaffs_unmount.h"
+
+int test_yaffs_mount2(void);
+int test_yaffs_mount2_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.c
new file mode 100644 (file)
index 0000000..64129b1
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_symlink_ENOENT.h"
+
+static int output = 0;
+
+int test_yaffs_symlink_ENOENT(void)
+{
+       int error_code = 0;
+       output = yaffs_symlink(FILE_PATH,"/yaffs2//");
+       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("created a symlink in a non-existing directory (which is a bad thing)\n",2);
+               return -1;
+       }       
+
+}
+
+int test_yaffs_symlink_ENOENT_clean(void)
+{
+       if (output >= 0){
+               return yaffs_unlink(SYMLINK_PATH);
+       } else {
+               return 1;       /* the file failed to open so there is no need to close it */
+       }
+}
+
+
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOENT.h
new file mode 100644 (file)
index 0000000..b6dc53d
--- /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_symlink_ENOENT_h__
+#define __test_yaffs_symlink_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_symlink_ENOENT(void);
+int test_yaffs_symlink_ENOENT_clean(void);
+
+#endif
index f56045a..26c70a1 100644 (file)
  */
 
 #include "test_yaffs_truncate_EINVAL.h"
-static int handle=-1;
+
 
 int test_yaffs_truncate_EINVAL(void)
 {
        int error=0;
        int output=0;
-       handle=test_yaffs_open();
-       if (handle>=0){
-               output= yaffs_truncate("/yaffs2/foo",-1 );
-               if (output<0){
-                       error=yaffs_get_error();
-                       if (abs(error)==EINVAL){
-                               return 1;
-                       } else {
-                               print_message("received a different error than expected\n",2);
-                               return -1;
-                       }
-               } else{
-                       print_message("truncated a file with a bad mode set.\n",2);
+
+       output= yaffs_truncate("/yaffs2/foo",-1 );
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==EINVAL){
+                       return 1;
+               } else {
+                       print_message("received a different error than expected\n",2);
                        return -1;
                }
-                       
-       } else {
-               print_message("error opening file",2);
+       } else{
+               print_message("truncated a file with a bad mode set.\n",2);
                return -1;
        }
+                       
+
 }
 
 int test_yaffs_truncate_EINVAL_clean(void)
index cfd1d82..b6bd10f 100644 (file)
@@ -18,26 +18,22 @@ int test_yaffs_truncate_EISDIR(void)
 {
        int error = 0;
        int output = 0;
-       handle = test_yaffs_open();
-       if (handle>=0){
-               output = yaffs_truncate("/yaffs2/",10);
-               if (output < 0){
-                       error = yaffs_get_error();
-                       if (abs(error) == EISDIR){
-                               return 1;
-                       } else {
-                               print_message("received a different error than expected\n",2);
-                               return -1;
-                       }
-               } else{
-                       print_message("truncated a directory\n",2);
+
+
+       output = yaffs_truncate("/yaffs2/",10);
+       if (output < 0){
+               error = yaffs_get_error();
+               if (abs(error) == EISDIR){
+                       return 1;
+               } else {
+                       print_message("received a different error than expected\n",2);
                        return -1;
                }
-                       
-       } else {
-               print_message("error opening file\n",2);
-               return 1;
+       } else{
+               print_message("truncated a directory\n",2);
+               return -1;
        }
+
 }
 
 int test_yaffs_truncate_EISDIR_clean(void)
index 72d7314..21b2873 100644 (file)
  */
 
 #include "test_yaffs_truncate_ENOENT.h"
-static int handle = -1;
+
 
 int test_yaffs_truncate_ENOENT(void)
 {
        int error=0;
        int output=0;
 
-       handle=test_yaffs_open();
-       if (handle>=0){
-               output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
-               if (output<0){
-                       error=yaffs_get_error();
-                       if (abs(error)==ENOENT){
-                               return 1;
-                       } else {
-                               print_message("received a different error than expected\n",2);
-                               return -1;
-                       }
-               } else{
-                       print_message("truncated a nonexisting file\n",2);
+
+       output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==ENOENT){
+                       return 1;
+               } else {
+                       print_message("received a different error than expected\n",2);
                        return -1;
-               }               
-       } else {
-               print_message("error opening file",2);
+               }
+       } else{
+               print_message("truncated a nonexisting file\n",2);
                return -1;
-       }
+       }               
+
 }
 
 int test_yaffs_truncate_ENOENT_clean(void)
index c2414db..d8ef155 100644 (file)
 
 #include "test_yaffs_truncate_ENOTDIR.h"
 
-static int handle = -1;
+
 
 int test_yaffs_truncate_ENOTDIR(void)
 {
        int error=0;
        int output=0;
-       handle=test_yaffs_open();
-       if (handle>=0){
-               output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
-               if (output<0){
-                       error=yaffs_get_error();
-                       if (abs(error)==ENOTDIR){
-                               return 1;
-                       } else {
-                               print_message("received a different error than expected\n",2);
-                               return -1;
-                       }
-               } else{
-                       print_message("truncated a nonexisting file\n",2);
+
+
+       output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==ENOTDIR){
+                       return 1;
+               } else {
+                       print_message("received a different error than expected\n",2);
                        return -1;
                }
-                       
-       } else {
-               print_message("error opening file\n",2);
+       } else{
+               print_message("truncated a nonexisting file\n",2);
                return -1;
        }
 }
index 270bf49..7ec30cf 100644 (file)
  */
 
 #include "test_yaffs_truncate_big_file.h"
-static int handle = -1;
+
 
 int test_yaffs_truncate_big_file(void)
 {
        int error=0;
        int output=0;
-       handle=test_yaffs_open();
-       if (handle>=0){
-               output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
-               if (output<0){
-                       error=yaffs_get_error();
-                       if (abs(error)==EINVAL){        /*in yaffs EINVAL is used instead of big_file */
-                               return 1;
-                       } else {
-                               print_message("received a different error than expected\n",2);
-                               return -1;
-                       }
-               } else{
-                       print_message("truncated a file to a massive size\n",2);
+
+       output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==EINVAL){        /*in yaffs EINVAL is used instead of big_file */
+                       return 1;
+               } else {
+                       print_message("received a different error than expected\n",2);
                        return -1;
                }
-                       
-       } else {
-               print_message("error opening file\n",2);
+       } else{
+               print_message("truncated a file to a massive size\n",2);
                return -1;
        }
+                       
+
 }
 
 int test_yaffs_truncate_big_file_clean(void)
index 75cf7c0..4436da6 100644 (file)
@@ -26,5 +26,5 @@ int test_yaffs_unlink(void)
 
 int test_yaffs_unlink_clean(void)
 {
-       return test_yaffs_open();
+       return test_yaffs_open()||test_yaffs_open_clean();
 }