yaffs More tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 03:50:06 +0000 (16:50 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 03:50:06 +0000 (16:50 +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/current_bugs.txt
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h [new file with mode: 0644]

index 3567b88..4db4430 100644 (file)
@@ -48,9 +48,11 @@ TESTFILES =  quick_tests.o lib.o \
                test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_ENOENT.o test_yaffs_mount_EBUSY.o \
                test_yaffs_unmount.o\
                test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o test_yaffs_open_ENAMETOOLONG.o \
+               test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o \
                test_yaffs_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\
                test_yaffs_ftruncate.o \
                test_yaffs_truncate.o test_yaffs_truncate_ENOTDIR.o test_yaffs_truncate_EISDIR.o test_yaffs_truncate_ENOENT.o test_yaffs_truncate_EINVAL.o \
+               test_yaffs_truncate_EFBIG.o\
                test_yaffs_write.o \
                test_yaffs_read.o \
                test_yaffs_lseek.o \
index 5134478..8487ac6 100644 (file)
@@ -24,6 +24,8 @@ Tests made
        test_yaffs_open_ENAMETOOLONG
        test_yaffs_open_ENOENT
        test_yaffs_open_ENOTDIR
+       test_yaffs_open_EINVAL
+       test_yaffs_open_EINVAL2 //the function open has to modes which can be set, so two modes are needed.
 
        test_yaffs_read
        test_yaffs_stat
@@ -33,6 +35,7 @@ Tests made
        test_yaffs_truncate_EISDIR
        test_yaffs_truncate_ENOENT
        test_yaffs_truncate_ENIVAL
+       test_yaffs_truncate_EFBIG
 
        test_yaffs_unlink
        test_yaffs_unlink_EISDIR
@@ -80,13 +83,11 @@ Tests to add
        test_yaffs_ftruncate_ELOOP
        test_yaffs_ftruncate_ENOENT
        test_yaffs_ftruncate_ENOTDIR
-       test_yaffs_ftruncate_EPERM
 
        test_yaffs_truncate_EACCES
-       test_yaffs_truncate_EFBIG
        test_yaffs_truncate_ELOOP
        test_yaffs_truncate_ENAMETOOLONG
-       test_yaffs_truncate_EPERM
+
 
        check to see if an error code is generated when there isn't an error.
 
index 3ecd20c..d2b4a48 100644 (file)
@@ -27,6 +27,16 @@ Current BUGS
 
        Bug truncating a file to a size of -1 does not cause an error. 
 
+       BUG truncating a file to a size greater than the maximum file size should 
+       return the error EFBIG. However EFBIG has not been defined in yaffs and 
+       needs to be added. When a file is truncated to a large size 
+       (size =10000000000000000000000000000000000000000000) the truncate 
+       function works without any errors, which is wrong. 
+
+       Bug with opening a file with bad mode. yaffs_open has two modes which 
+       are passed into it. if the modes are set to 255 the open function 
+       does not report any errors. (Also need to try this with modes set to -1.)  
+
 
 Current WARNINGS
        WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. 
index ecde804..decc191 100644 (file)
@@ -31,6 +31,8 @@
 #include "test_yaffs_open_ENOENT.h"
 #include "test_yaffs_open_ENOTDIR.h"
 #include "test_yaffs_open_ENAMETOOLONG.h"
+#include "test_yaffs_open_EINVAL.h"
+#include "test_yaffs_open_EINVAL2.h"
 
 #include "test_yaffs_close_EBADF.h"
 
@@ -49,6 +51,7 @@
 #include "test_yaffs_truncate_EISDIR.h"
 #include "test_yaffs_truncate_ENOENT.h"
 #include "test_yaffs_truncate_EINVAL.h"
+#include "test_yaffs_truncate_EFBIG.h"
 
 #include "test_yaffs_write.h"
 #include "test_yaffs_read.h"
@@ -90,6 +93,8 @@ test_template test_list[]={
        {test_yaffs_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"},
        {test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"},
        {test_yaffs_open_ENAMETOOLONG,test_yaffs_open_ENAMETOOLONG_clean,"test_yaffs_open_ENAMETOOLONG"},
+       {test_yaffs_open_EINVAL,test_yaffs_open_EINVAL_clean,"test_yaffs_open_EINVAL"},
+       {test_yaffs_open_EINVAL2,test_yaffs_open_EINVAL2_clean,"test_yaffs_open_EINVAL2"},
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
@@ -118,7 +123,8 @@ test_template test_list[]={
        {test_yaffs_truncate_ENOTDIR,test_yaffs_truncate_ENOTDIR_clean,"test_yaffs_truncate_ENOTDIR"},
        {test_yaffs_truncate_EISDIR,test_yaffs_truncate_EISDIR_clean,"test_yaffs_truncate_EISDIR"},
        {test_yaffs_truncate_EINVAL,test_yaffs_truncate_EINVAL_clean,"test_yaffs_truncate_EINVAL"},
-       {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"}
+       {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"},
+       {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"}
        };
 
 void init_quick_tests(void);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c
new file mode 100644 (file)
index 0000000..5a2ec4d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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_open_EINVAL.h"
+
+static int handle=0;
+int test_yaffs_open_EINVAL(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_open(FILE_PATH, 255,FILE_MODE);
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
+               if (abs(error_code)== EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf(" file opened with bad mode.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_open_EINVAL_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       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_open_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h
new file mode 100644 (file)
index 0000000..85597da
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_open_EINVAL_h__
+#define __test_yaffs_open_EINVAL_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EINVAL(void);
+int test_yaffs_open_EINVAL_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c
new file mode 100644 (file)
index 0000000..cdab776
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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_open_EINVAL2.h"
+
+static int handle=0;
+int test_yaffs_open_EINVAL2(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_open(FILE_PATH, O_CREAT | O_RDWR ,255);
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
+               if (abs(error_code)== EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf(" file opened with bad mode.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_open_EINVAL2_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       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_open_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h
new file mode 100644 (file)
index 0000000..de35847
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_open_EINVAL2_h__
+#define __test_yaffs_open_EINVAL2_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EINVAL2(void);
+int test_yaffs_open_EINVAL2_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c
new file mode 100644 (file)
index 0000000..dd7cc86
--- /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_truncate_EFBIG.h"
+static int handle=0;
+
+int test_yaffs_truncate_EFBIG(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){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a file to a massive size\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_EFBIG_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h
new file mode 100644 (file)
index 0000000..15f0999
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_truncate_EFBIG_h__
+#define __test_yaffs_truncate_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EFBIG(void);
+int test_yaffs_truncate_EFBIG_clean(void); 
+#endif