yaffs Yet more tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 22:47:15 +0000 (11:47 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 9 Nov 2010 01:02:35 +0000 (14:02 +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_lseek.c
direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h [new file with mode: 0644]

index 91ece44..6aeb346 100644 (file)
@@ -55,7 +55,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_truncate_EFBIG.o\
                test_yaffs_write.o \
                test_yaffs_read.o \
-               test_yaffs_lseek.o \
+               test_yaffs_lseek.o test_yaffs_lseek_EBADF.o test_yaffs_lseek_EINVAL.o test_yaffs_lseek_EFBIG.o \
                test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o\
                test_yaffs_stat.o \
                test_yaffs_close_EBADF.o
index 3b32b43..203f401 100644 (file)
@@ -19,8 +19,12 @@ Tests made
        test_yaffs_ftruncate
        test_yaffs_ftruncate_EBADF
        test_yaffs_ftruncate_ENIVAL
+       test_yaffs_ftruncate_EFBIG
 
        test_yaffs_lseek
+       test_yaffs_lseek_EBADF
+       test_yaffs_lseek_EINVAL
+       test_yaffs_lseek_EFBIG
 
        test_yaffs_open
        test_yaffs_open_EEXIST
@@ -29,7 +33,7 @@ Tests made
        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_open_EINVAL2 //the function open has two modes which can be set, so two tests modes are needed.
 
        test_yaffs_read
        test_yaffs_stat
@@ -70,8 +74,8 @@ Tests to add
        test_yaffs_open_ELOOP   //Too many symbolic links were encountered in resolving pathname
        test yaffs_open_running_out_of_handles error
 
-       test_yaffs_close        //This function has already been called by the time this test is reached. 
-
+       test_yaffs_close        //This function has already been called by the time this test is reached.
+       
        test_yaffs_unlink_EACCES
        test_yaffs_unlink_ELOOP
        test_yaffs_unlink_ENOMEM
@@ -81,20 +85,20 @@ Tests to add
        test_yaffs_access_ENAMETOOLONG
        test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
 
-       test_yaffs_ftruncate_EACCES
-       test_yaffs_ftruncate_EFBIG
-       test_yaffs_ftruncate_EISDIR
-       test_yaffs_ftruncate_ELOOP
-       test_yaffs_ftruncate_ENOENT
-       test_yaffs_ftruncate_ENOTDIR
+       test_yaffs_ftruncate_EACCES     
+       test_yaffs_ftruncate_EISDIR     //
+       test_yaffs_ftruncate_ELOOP      //
+       test_yaffs_ftruncate_ENOENT     //
+       test_yaffs_ftruncate_ENOTDIR    //
 
        test_yaffs_truncate_EACCES
        test_yaffs_truncate_ELOOP
        test_yaffs_truncate_ENAMETOOLONG
        add a truncate function for truncating a file size to -1.
 
-
-       check to see if an error code is generated when there isn't an error.
+       What happens if a handle is opened to a file and the file is then deleted?
+       Check to see if yaffs generates an error code for no reason.
+       What happens when a file is opened with no modes set?
 
 
 How to add a test
index 24ed8ca..be27d78 100644 (file)
@@ -29,6 +29,9 @@ Current BUGS
        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.)  
 
+       Bug with lseeking to a very large size (size =100000000000000000000000000000000000000) without causing an error.
+       Should cause the error EINVAL.
+
 
 Current WARNINGS
        
index 3d5dc6a..d05167b 100644 (file)
@@ -49,6 +49,7 @@
 #include "test_yaffs_ftruncate_EINVAL.h"
 #include "test_yaffs_ftruncate_EFBIG.h"
 
+
 #include "test_yaffs_truncate.h"
 #include "test_yaffs_truncate_ENOTDIR.h"
 #include "test_yaffs_truncate_EISDIR.h"
 
 #include "test_yaffs_write.h"
 #include "test_yaffs_read.h"
+
 #include "test_yaffs_lseek.h"
+#include "test_yaffs_lseek_EBADF.h"
+#include "test_yaffs_lseek_EINVAL.h"
+#include "test_yaffs_lseek_EFBIG.h"
 
 #include "test_yaffs_access.h"
 #include "test_yaffs_access_EINVAL.h"
@@ -115,6 +120,10 @@ test_template test_list[]={
 
 
        {test_yaffs_lseek,test_yaffs_lseek_clean,"test_yaffs_lseek"},
+       {test_yaffs_lseek_EBADF,test_yaffs_lseek_EBADF_clean,"test_yaffs_lseek_EBADF"},
+       {test_yaffs_lseek_EINVAL,test_yaffs_lseek_EINVAL_clean,"test_yaffs_lseek_EINVAL"},
+       {test_yaffs_lseek_EFBIG,test_yaffs_lseek_EFBIG_clean,"test_yaffs_lseek_EFBIG"},
+
        {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
        {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
 
index 588635e..98809c0 100644 (file)
 static int handle=0;
 int test_yaffs_lseek(void){
        handle=test_yaffs_open();
-       char text[20]="\0";
        int output=0;
        if (handle>=0){
-               if (0==yaffs_lseek(handle, 0, SEEK_SET)){
+               output=yaffs_lseek(handle, 0, SEEK_SET);
+               if (output==0){
                        return 1;
                }
                else {
-                       printf("lseek returned a different position to the expeced position\n");
+                       if (output<0){
+                               printf("lseek failed to seek\n");
+                       }
+                       else {
+                               printf("lseek returned a different position to the expeced position\n");
+                               return -1;
+                       }
                }
        }
        else {
@@ -34,6 +40,14 @@ int test_yaffs_lseek(void){
 }
 
 int test_yaffs_lseek_clean(void){
-       return yaffs_close(handle);     
+       if (handle>=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1; /* no handle was opened so there is no need to close a handle */
+       }
+
 }
 
+
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c
new file mode 100644 (file)
index 0000000..06d9764
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_lseek_EBADF.h"
+
+
+int test_yaffs_lseek_EBADF(void){
+       int error_code=0;
+       int output=yaffs_lseek(-1, 0, SEEK_SET);
+       if (output<0){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==EBADF){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("lseeked to a negative position\n");
+       }
+}
+
+int test_yaffs_lseek_EBADF_clean(void){
+       return 1;       
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h
new file mode 100644 (file)
index 0000000..1530760
--- /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_lseek_EBADF_h__
+#define __test_yaffs_lseek_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_lseek_EBADF(void);
+int test_yaffs_lseek_EBADF_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c
new file mode 100644 (file)
index 0000000..4822499
--- /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_lseek_EFBIG.h"
+
+static int handle=0;
+
+int test_yaffs_lseek_EFBIG(void){
+       handle=test_yaffs_open();
+       int error_code=0;
+       int output=yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
+
+       if (output<0){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("lseeked to a very large size (which is a bad thing)\n");
+               return -1;
+       }
+}
+
+int test_yaffs_lseek_EFBIG_clean(void){
+       if (handle>=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return -1; /* no handle was opened so there is no need to close a handle */
+       }       
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h
new file mode 100644 (file)
index 0000000..656a369
--- /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_lseek_EFBIG_h__
+#define __test_yaffs_lseek_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_lseek_EFBIG(void);
+int test_yaffs_lseek_EFBIG_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c
new file mode 100644 (file)
index 0000000..173e1b5
--- /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_lseek_EINVAL.h"
+
+int handle=0;
+
+int test_yaffs_lseek_EINVAL(void){
+       handle=test_yaffs_open();
+       int error_code=0;
+       int output=yaffs_lseek(handle, 0, -1);
+
+       if (output<0){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("lseeked to a negative position (which is a bad thing)\n");
+               return -1;
+       }
+}
+
+int test_yaffs_lseek_EINVAL_clean(void){
+       if (handle>=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1; /* no handle was opened so there is no need to close a handle */
+       }       
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h
new file mode 100644 (file)
index 0000000..5795c4b
--- /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_lseek_EINVAL_h__
+#define __test_yaffs_lseek_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_lseek_EINVAL(void);
+int test_yaffs_lseek_EINVAL_clean(void);
+
+#endif