yaffs Yet more tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 9 Nov 2010 03:32:03 +0000 (16:32 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 9 Nov 2010 03:32:03 +0000 (16:32 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
21 files changed:
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_EFBIG.c
direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_read.c
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_stat.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c
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_unlink_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_write.c

index 07b2948a7df135c4c73bec706cbc6dd994524bb0..85aa36bda9647aee2e9fc514d055c2db3e79e29f 100644 (file)
@@ -46,7 +46,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
 
 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_unmount.o test_yaffs_unmount_ENOENT.o test_yaffs_unmount_ENAMETOOLONG.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\
@@ -54,7 +54,7 @@ TESTFILES =   quick_tests.o lib.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_read_EBADF.o \
+               test_yaffs_read.o test_yaffs_read_EBADF.o test_yaffs_read_EINVAL.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 \
index cc5b036a7096942a3d27ba622a3db03532e01283..58536c97fe6b8d65b76648290478a9fcf701cef5 100644 (file)
@@ -10,7 +10,7 @@ Tests made
        test_yaffs_mount_EBUSY          //called when trying to mount a new mount point with a mount point already mounted.
 
        test_yaffs_access
-       test_yaffs_access_ENIVAL        //when the mode is incorrect.
+       test_yaffs_access_ENIVAL
        test_yaffs_access_ENOTDIR
        test_yaffs_access_ENOENT
 
@@ -37,6 +37,7 @@ Tests made
 
        test_yaffs_read
        test_yaffs_read_EBADF
+       test_yaffs_read_EINVAL
 
        test_yaffs_stat
 
@@ -55,9 +56,12 @@ Tests made
        test_yaffs_unlink_ENOENT
 
        test_yaffs_unmount
+       test_yaffs_unmount_ENOENT
+       test_yaffs_unmount_ENAMETOOLONG
+
        test_yaffs_write
 
-       add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog". 
+       
 
 Tests to add
        test_yaffs_mount_EACCES         //Cannot be generated with yaffs.
@@ -66,10 +70,9 @@ Tests to add
        test_yaffs_mount_EMFILE         //Cannot be generated with yaffs.
        test_yaffs_mount_ENOTDIR        //Cannot be generated with yaffs.
 
-       test_yaffs_umount_ENODEV
-       test_yaffs_umount_ENAMETOOLONG
-       test_yaffs_umount_ENOENT
-       test_yaffs_umount_EBUSY
+       test_yaffs_umount_ENODEV        //Cannot be generated with yaffs.
+       test_yaffs_umount_ENOENT        //Cannot be generated with yaffs.
+       test_yaffs_umount_EBUSY         //when files are open and yaffs is unmounted.
 
        test_yaffs_open_EACCES
        test_yaffs_open_ENOSPC
@@ -78,11 +81,20 @@ Tests to add
 
        test_yaffs_close        //This function has already been called by the time this test is reached.
        
-
-       test_yaffs_read_EINVAL  //test exists but is not finshed yet. 
+       test_yaffs_stat_EBADF
+       test_yaffs_stat_ELOOP
+       test_yaffs_stat_EACCES
+       test_yaffs_stat_ENAMETOOLONG
+       test_yaffs_stat_ENOTDIR
+        
        test_yaffs_read_EISDIR          //Cannot be generated with yaffs.
        test what happens if you read off the end of the file?
 
+       test_yaffs_write_EBADF
+       test_yaffs_write_EFBIG
+       test_yaffs_write_EINVAL
+       What happens when you run out of space?
+
        test_yaffs_unlink_EACCES
        test_yaffs_unlink_ELOOP
        test_yaffs_unlink_ENOMEM
@@ -106,7 +118,10 @@ Tests to add
        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?
+       Add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog". 
+       What happens when yaffs is unmounted twice?
 
+       What happens when open a handle, unmount yaffs and then try to use the handle? 
 
 How to add a test
        First create the test .c and .h file.
index da09048c10dc587f3c17ed3d8892fe9c4577b526..f2a81c9a4dd23258a2a9098d9add7b68eaafb143 100644 (file)
@@ -15,6 +15,9 @@ Current BUGS
                ENODEV. yaffs_mount should be returning ENAMETOOLONG.
                When the name is passed into the yaffs_mount function the length of the
                mount point decreases from around 10000000 to 200. This needs to be investigated.
+               
+               Bug with unmounting a too long non-existing mountpoint. 
+               The error returned is ENODEV. It should be ENAMETOOLONG.
 
 
        ENOTDIR ERRORS
@@ -30,12 +33,24 @@ Current BUGS
        Bug with lseeking to a very large size (size =100000000000000000000000000000000000000) without causing an error.
        Should cause the error EINVAL.
 
+       Bug with unmounting a non-existing mountpoint. The function returns ENODEV 
+       but should be returning EINVAL.
+       
+       Bug with reading -1 bytes of a file without an error (test is in test_yaffs_read_EINVAL).
+       It should return EINVAL.
+
+       Unmount2 forcing the unmount needs to break the handles so they return EBADF.
+
 
 Current WARNINGS
        
-       <<WHAT FUNCTIONS>>
        WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. 
-       some function return EBADF instead.
+       But some function return EBADF instead.
+       Functions which return ENOTDIR: open, close, access, unlink, lseek, write, read
+
+       Functions which return ENOENT: access, stat
+       
+
 
        WARNING-the function yaffs_open does not check the mode passed to it. 
        This means that yaffs open does not return EINVAL if a bad mode is passed to it.
index 9a0adc24b53beadc46a766abf284548f74640f4c..b1fb094dc3c8541eb4940786ca243cd1b7c51611 100644 (file)
@@ -24,6 +24,8 @@
 #include "test_yaffs_mount_EBUSY.h"
 
 #include "test_yaffs_unmount.h"
+#include "test_yaffs_unmount_ENOENT.h"
+#include "test_yaffs_unmount_ENAMETOOLONG.h"
 
 #include "test_yaffs_open.h"
 #include "test_yaffs_open_EISDIR.h"
@@ -61,6 +63,7 @@
 
 #include "test_yaffs_read.h"
 #include "test_yaffs_read_EBADF.h"
+#include "test_yaffs_read_EINVAL.h"
 
 #include "test_yaffs_lseek.h"
 #include "test_yaffs_lseek_EBADF.h"
@@ -89,14 +92,16 @@ typedef struct test {
 
 
 test_template test_list[]={
-       {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
+/*     {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
        {test_yaffs_mount_ENODEV,test_yaffs_mount_ENODEV_clean,"test_yaffs_mount_ENODEV"},
        {test_yaffs_mount_ENAMETOOLONG,test_yaffs_mount_ENAMETOOLONG_clean,"test_yaffs_mount_ENAMETOOLONG"},
        {test_yaffs_mount_ENOENT,test_yaffs_mount_ENOENT_clean,"test_yaffs_mount_ENOENT"},
        {test_yaffs_mount_EBUSY,test_yaffs_mount_EBUSY_clean,"test_yaffs_mount_EBUSY"},
 
        {test_yaffs_unmount,test_yaffs_unmount_clean,"test_yaffs_unmount"},
-
+       {test_yaffs_unmount_ENOENT,test_yaffs_unmount_ENOENT_clean,"test_yaffs_unmount_ENOENT"},
+       {test_yaffs_unmount_ENAMETOOLONG,test_yaffs_unmount_ENAMETOOLONG_clean,"test_yaffs_unmount_ENAMETOOLONG"},
+*/
        {test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"},
        {test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"},
        {test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"},
@@ -130,6 +135,7 @@ test_template test_list[]={
 
        {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
        {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
+       {test_yaffs_read_EINVAL,test_yaffs_read_EINVAL_clean,"test_yaffs_read_EINVAL"},
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
 
index 4822499d217eeef56c14d3404736022408a76c7c..5a001bb6f1f204661a6186e6cc791ecd31c00c09 100644 (file)
 
 #include "test_yaffs_lseek_EFBIG.h"
 
-static int handle=0;
+static int handle=-1;
 
 int test_yaffs_lseek_EFBIG(void){
        handle=test_yaffs_open();
        int error_code=0;
-       int output=yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
+       int output=0;
+
+       if (handle<0){
+               printf("failed to open file\n");
+               return -1;
+       }
+       
+       yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
 
        if (output<0){
                error_code=yaffs_get_error();
index 173e1b5d04ed8169cedf11e5ad12c0d736b252b5..b03914e87279808b9fe0212320c099195de99b59 100644 (file)
 
 #include "test_yaffs_lseek_EINVAL.h"
 
-int handle=0;
+int handle=-1;
 
 int test_yaffs_lseek_EINVAL(void){
        handle=test_yaffs_open();
        int error_code=0;
-       int output=yaffs_lseek(handle, 0, -1);
+       int output=0;
+
+       if (handle<0){
+               printf("failed to open file\n");
+               return -1;
+       }
+       
+
+       output=yaffs_lseek(handle, 0, -1);
 
        if (output<0){
                error_code=yaffs_get_error();
index 2bc2aba6c964eed2ea0ac0a042e32917c0045618..a5157d24f7d4064c603dea33fc023e3de18cfdfc 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "test_yaffs_read.h"
 
-static int handle=0;
+static int handle=-1;
 
 int test_yaffs_read(void){
        handle=test_yaffs_open();
@@ -46,5 +46,10 @@ int test_yaffs_read(void){
 }
 
 int test_yaffs_read_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 */
+       }       
 }
index 7e7d43ef2a0e82339bcbb5296fbb36f5a32372ec..f11e3adbf8b6f4432d44ed54ad761637fdce8548 100644 (file)
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_read_EBADF.h"
+#include "test_yaffs_read_EINVAL.h"
 
 static int handle=0;
 
-int test_yaffs_read_EBADF(void){
+int test_yaffs_read_EINVAL(void){
+       int error_code=0;
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
-       //printf("handle %d\n",handle);
+
        if (handle>=0){
-               output=yaffs_read(-1, text, FILE_TEXT_NBYTES);
-               //printf("yaffs_test_read output: %d\n",output);
-               //printf("text in file is: '%s' expected text is '%s'\n",text,FILE_TEXT);
+               output=yaffs_read(handle, text, -1);
+
                if (output<0){ 
-                       if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
+                       error_code=yaffs_get_error();
+                       if (abs(error_code)== EINVAL){
                                return 1;
                        }
                        else {
-                               printf("returned error does not match the the expected error\n");
+                               printf("different error than expected\n");
                                return -1;
                        }
                }
@@ -45,6 +46,11 @@ int test_yaffs_read_EBADF(void){
        
 }
 
-int test_yaffs_read_EBADF_clean(void){
-       return yaffs_close(handle);
+int test_yaffs_read_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 */
+       }       
 }
index 845148f51f58e7b2658cc302b689a2a1110e2ef3..b9650580f0c52e712da6c9e5d9c98afdac6c6a8d 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __test_yaffs_read_EBADF_h__
-#define __test_yaffs_read_EBADF_h__
+#ifndef __test_yaffs_read_EINVAL_h__
+#define __test_yaffs_read_EINVAL_h__
 #include "lib.h"
 #include "yaffsfs.h"
 #include "test_yaffs_open.h"
 
 
-int test_yaffs_read_EBADF(void);
-int test_yaffs_read_EBADF_clean(void);
+int test_yaffs_read_EINVAL(void);
+int test_yaffs_read_EINVAL_clean(void);
 #endif
index f99ab7f62eab44d61dea45a6cbe16de341e264d9..d379944d769b4e27d61c1411b71a86edb4fd8aa0 100644 (file)
@@ -17,28 +17,38 @@ int test_yaffs_stat(void){
        int mode=0;
        int size=0;
        mode =yaffs_test_stat_mode();
-/*     printf("\nmode %o\n",mode);
-       printf("expected mode %o \n",FILE_MODE);
-       printf("anding together %o\n",FILE_MODE & mode);
-       printf("%d\n",FILE_MODE == (FILE_MODE & mode));
-*/     if (FILE_MODE == (FILE_MODE & mode)){
-               mode=1;
+       
+       if (mode>=0){
+       
+               if (FILE_MODE == (FILE_MODE & mode)){
+                       mode=1;
+               }
+               else {
+                       printf("mode did not match expected file mode\n");
+                       return -1;
+               }
        }
        else {
-               printf("mode did not match expected file mode\n");
-               return -1;
+               mode =-1;
        }
+
        size=yaffs_test_stat_size();
-       if (size==FILE_SIZE){
-               size=1;
+       if (size >=0){
+               if (size==FILE_SIZE){
+                       size=1;
+               }
+               else {
+                       printf("file size %d, expected file size %d\n",size,FILE_SIZE);
+                       printf("mode did not match expected file mode\n");
+                       return -1;
+               }
        }
        else {
-               printf("file size %d, expected file size %d\n",size,FILE_SIZE);
-               printf("mode did not match expected file mode\n");
-               return -1;
-       }
-       
-       if (mode && size){
+               size =-1;
+       }       
+
+
+       if ((mode>0) && (size>0)){
                return 1;
        }
        else {
@@ -61,7 +71,7 @@ int yaffs_test_stat_mode(void){
                return stat.st_mode;    
        }
        else {
-               printf("failed to stat file\n") ;
+               printf("failed to stat file mode\n") ;
                return -1;
        }
 }
@@ -74,7 +84,7 @@ int yaffs_test_stat_size(void){
                return stat.st_size;    
        }
        else {
-               printf("failed to stat file\n") ;
+               printf("failed to stat file size\n") ;
                return -1;
        }
 }
index 7ea85da00f06f532eec93151a8cb21b868d6379b..0fc79af6ead130e0a13166748c51bf11d8efdc0a 100644 (file)
@@ -26,7 +26,7 @@ int test_yaffs_truncate_EFBIG(void){
                                return 1;
                        }
                        else {
-                               printf("recieved a different error than expected\n");
+                               printf("received a different error than expected\n");
                                return -1;
                        }
                }
index bec53dea41247da9576f1cd0037cacb0013f5dd2..7c8fd9d19b15eafc4020cac63022c962f9d7ac50 100644 (file)
@@ -26,7 +26,7 @@ int test_yaffs_truncate_EINVAL(void){
                                return 1;
                        }
                        else {
-                               printf("recieved a different error than expected\n");
+                               printf("received a different error than expected\n");
                                return -1;
                        }
                }
index 051e1a7795b225904ebb0165a33c0511644b89da..5fa4601a4fc88594bdbaa0db5e3449874ea2a70e 100644 (file)
@@ -26,7 +26,7 @@ int test_yaffs_truncate_EISDIR(void){
                                return 1;
                        }
                        else {
-                               printf("recieved a different error than expected\n");
+                               printf("received a different error than expected\n");
                                return -1;
                        }
                }
index 6258aeae97eae36e98593111b5486e08053b0d48..7d264e5203382c5d173afa896fac082d63462d15 100644 (file)
@@ -26,7 +26,7 @@ int test_yaffs_truncate_ENOENT(void){
                                return 1;
                        }
                        else {
-                               printf("recieved a different error than expected\n");
+                               printf("received a different error than expected\n");
                                return -1;
                        }
                }
index 2cc71b502af30ae480526b1685d5f90b9026511f..bda51ef15d32ad394b9f7cd74b845557d2c5db40 100644 (file)
@@ -26,7 +26,7 @@ int test_yaffs_truncate_ENOTDIR(void){
                                return 1;
                        }
                        else {
-                               printf("recieved a different error than expected\n");
+                               printf("received a different error than expected\n");
                                return -1;
                        }
                }
index c5184a5f0863e4a3ec53a8c14c7ecd1c9b0daada..8f255431b9ea0feff9048369a3739cc73a61a912 100644 (file)
@@ -14,7 +14,7 @@
 #include "test_yaffs_unlink_ENAMETOOLONG.h"
 
 
-static int handle=0;
+
 int test_yaffs_unlink_ENAMETOOLONG(void){
        int output=0;
        int error_code=0;
@@ -45,15 +45,9 @@ int test_yaffs_unlink_ENAMETOOLONG(void){
                printf("directory unlinked opened.(which is a bad thing)\n");
                return -1;
        }
-       /* the program should not get here but the compiler is complaining */
-       return -1;
 }
+
 int test_yaffs_unlink_ENAMETOOLONG_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*/
-       }
+       return 1;
 }
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c
new file mode 100644 (file)
index 0000000..1af5761
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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_unmount_ENAMETOOLONG.h"
+
+
+
+
+int test_yaffs_unmount_ENAMETOOLONG(void){
+       int output=0;
+       int x;
+       int error_code=0;
+       int file_name_length=1000000;
+       char file_name[file_name_length];
+
+
+
+       for (x=0; x<file_name_length -1; x++){
+               file_name[x]='a';
+       }
+       file_name[file_name_length-2]='\0';
+       
+       //printf("file name: %s\n",file_name);
+
+
+       output=yaffs_unmount(file_name);
+
+       if (output<0){
+               error_code=yaffs_get_error();
+               if (abs(error_code)== ENAMETOOLONG){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("mounted a too long mount point name.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+
+int test_yaffs_unmount_ENAMETOOLONG_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.h
new file mode 100644 (file)
index 0000000..f337671
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_unmount_ENAMETOOLONG_h__
+#define __test_yaffs_unmount_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_mount.h"
+#include "test_yaffs_unmount.h"
+
+
+int test_yaffs_unmount_ENAMETOOLONG(void);
+int test_yaffs_unmount_ENAMETOOLONG_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c
new file mode 100644 (file)
index 0000000..5eb853c
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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_mount_ENOENT.h"
+
+
+int test_yaffs_unmount_ENOENT(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       
+       
+
+       output=yaffs_unmount("/non_existaint_mount_point/");
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant mount point unmounted.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_unmount_ENOENT_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h
new file mode 100644 (file)
index 0000000..9c4c2cc
--- /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_unmount_ENOENT_h__
+#define __test_yaffs_unmount_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_unmount.h"
+#include "test_yaffs_mount.h"
+
+int test_yaffs_unmount_ENOENT(void);
+int test_yaffs_unmount_ENOENT_clean(void);
+#endif
index dbd17e592b91421c2a4b9bd7b4d296a55fda6b1e..cd5a61ffec468a8fd6189f9ae5ec968a23643eb5 100644 (file)
@@ -27,5 +27,10 @@ int test_yaffs_write(void){
 }
 
 int test_yaffs_write_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 */
+       }       
 }