yaffs Added more tests to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 24 Nov 2010 04:13:22 +0000 (17:13 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 24 Nov 2010 04:13:22 +0000 (17:13 +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.h
direct/timothy_tests/quick_tests/test_yaffs_flush.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_flush.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rename_EEXISTS.c

index 557516f08158c3fb173351118cd4620bfdbc3dbd..e0bbdf944b5cc7b8e054c1c3ab6d03742b4d197e 100644 (file)
@@ -88,7 +88,8 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \
                test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.o test_yaffs_rename_dir_to_file.o \
                test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o test_yaffs_rename_ELOOP.o\
-               test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o 
+               test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o \
+               test_yaffs_flush.o test_yaffs_flush_EBADF.o
 
 
                  
index 010a82a24d7008a9ee77a6911396d74a4127f635..f79bc79eca409ac2bbeaec4ec1a2d44a392a485d 100644 (file)
@@ -6,12 +6,14 @@ Tests made
 
 test_yaffs_access.c
 test_yaffs_access_EINVAL.c
+test_yaffs_access_ELOOP.c
 test_yaffs_access_ENOENT2.c
 test_yaffs_access_ENOENT.c
 test_yaffs_access_ENOTDIR.c
 
 test_yaffs_chmod.c
 test_yaffs_chmod_EINVAL.c
+test_yaffs_chmod_ELOOP.c
 test_yaffs_chmod_ENOENT2.c
 test_yaffs_chmod_ENOENT.c
 test_yaffs_chmod_ENOTDIR.c
@@ -47,6 +49,7 @@ test_yaffs_link.c
 test_yaffs_link_EEXIST.c
 test_yaffs_link_ENOENT2.c
 test_yaffs_link_ENOENT3.c
+test_yaffs_link_ENOENT4.c
 test_yaffs_link_ENOENT.c
 test_yaffs_link_ENOTDIR2.c
 test_yaffs_link_ENOTDIR.c
@@ -56,9 +59,9 @@ test_yaffs_lseek.c
 test_yaffs_lseek_EBADF.c
 test_yaffs_lseek_EINVAL.c
 
-test_yaffs_lstat
-test_yaffs_lstat_ENOENT
-test_yaffs_lstat_ENOTDIR
+test_yaffs_lstat.c
+test_yaffs_lstat_ENOENT.c
+test_yaffs_lstat_ENOTDIR.c
 
 test_yaffs_mkdir.c
 test_yaffs_mkdir_EEXIST.c
@@ -80,6 +83,7 @@ test_yaffs_open_EEXIST.c
 test_yaffs_open_EINVAL2.c
 test_yaffs_open_EINVAL.c
 test_yaffs_open_EISDIR.c
+test_yaffs_open_ELOOP.c
 test_yaffs_open_ENAMETOOLONG.c
 test_yaffs_open_ENOENT.c
 test_yaffs_open_ENOTDIR.c
@@ -95,18 +99,27 @@ test_yaffs_remount_force_off_read_only_on.c
 test_yaffs_remount_force_on_read_only_off.c
 test_yaffs_remount_force_on_read_only_on.c
 
-test_yaffs_rename
-test_yaffs_rename_ENOENT
-test_yaffs_rename_ENOTDIR
-test_yaffs_rename_EINVAL
+test_yaffs_rename.c
+test_yaffs_rename_dir.c
+test_yaffs_rename_dir_ENOENT2.c
+test_yaffs_rename_dir_ENOENT.c
+test_yaffs_rename_dir_not_empty.c
+test_yaffs_rename_dir_to_file.c
+test_yaffs_rename_EEXISTS.c
+test_yaffs_rename_EINVAL.c
+test_yaffs_rename_ELOOP.c
+test_yaffs_rename_ENOENT.c
+test_yaffs_rename_ENOTDIR.c
+test_yaffs_rename_file_to_dir.c
 
 test_yaffs_rmdir.c
-test_yaffs_rmdir_EBUSY
-test_yaffs_rmdir_EINVAL
-test_yaffs_rmdir_ENOENT
-test_yaffs_rmdir_ENOTDIR
+test_yaffs_rmdir_EBUSY.c
+test_yaffs_rmdir_EINVAL.c
+test_yaffs_rmdir_ENOENT.c
+test_yaffs_rmdir_ENOTDIR.c
 
 test_yaffs_stat.c
+test_yaffs_stat_ELOOP.c
 test_yaffs_stat_ENOENT2.c
 test_yaffs_stat_ENOENT.c
 test_yaffs_stat_ENOTDIR.c
@@ -123,10 +136,11 @@ test_yaffs_sync_ENODEV.c
 test_yaffs_totalspace.c
 test_yaffs_totalspace_EINVAL.c
 
-test_yaffs_truncate.c
 test_yaffs_truncate_big_file.c
+test_yaffs_truncate.c
 test_yaffs_truncate_EINVAL.c
 test_yaffs_truncate_EISDIR.c
+test_yaffs_truncate_ELOOP.c
 test_yaffs_truncate_ENOENT2.c
 test_yaffs_truncate_ENOENT.c
 test_yaffs_truncate_ENOTDIR.c
@@ -143,29 +157,27 @@ test_yaffs_unmount2_EINVAL.c
 test_yaffs_unmount2_ENODEV.c
 test_yaffs_unmount2_with_handle_open_and_forced_mode_off.c
 test_yaffs_unmount2_with_handle_open_and_forced_mode_on.c
-
 test_yaffs_unmount.c
 test_yaffs_unmount_EBUSY.c
 test_yaffs_unmount_ENAMETOOLONG.c
 test_yaffs_unmount_ENODEV.c
 
-test_yaffs_write.c
 test_yaffs_write_big_file.c
+test_yaffs_write.c
 test_yaffs_write_EBADF.c
 
-       
 
 Tests to add
        test_yaffs_fchmod_EACCES
 
        test_yaffs_chmod_EACCES
-       test_yaffs_chmod_ELOOP
+
        test_yaffs_chmod_ENAMETOOLONG
 
        
        test_yaffs_lstat_EACCES
        test_yaffs_lstat_ENAMETOOLONG
-       test_yaffs_lstat_ELOOP
+
 
        test_yaffs_readlink
        test_yaffs_readlink_ENOENT
@@ -181,7 +193,6 @@ Tests to add
 
 
        test_yaffs_symlink_EACCES
-       test_yaffs_symlink_ELOOP
        test_yaffs_symlink_ENAMETOOLONG
        test_yaffs_symlink_EROFS
 
@@ -207,8 +218,6 @@ Tests to add
 
        test_yaffs_link_EACCES
 
-       test_yaffs_link_ELOOP
-
        test_yaffs_link_ENAMETOOLONG
        test_yaffs_link_EPERM
        test_yaffs_link_EROFS
@@ -217,12 +226,11 @@ Tests to add
        test_yaffs_rmdir_EACCES
        test_yaffs_rmdir_ENOTEMPTY
        test_yaffs_rmdir_EROFS
-       test_yaffs_emdir_ELOOP
+
 
 
 
        test_yaffs_rename_EACCES
-       test_yaffs_rename_ELOOP
        test_yaffs_rename_EMLINK
        test_yaffs_rename_EEXISTS or EPERM
        test_yaffs_rename_EROFS
@@ -242,9 +250,9 @@ Tests to add
        test_yaffs_open_ELOOP   
        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_stat_ELOOP
+       
+
        test_yaffs_stat_EACCES
        test_yaffs_stat_ENAMETOOLONG
 
@@ -266,14 +274,13 @@ Tests to add
        test_yaffs_pwrite_EINVAL
 
        test_yaffs_unlink_EACCES
-       test_yaffs_unlink_ELOOP
+
        test_yaffs_unlink_ENOMEM
 
        test_yaffs_stat_EACCES
        test_yaffs_stat_ELOOP
 
        test_yaffs_access_EACCESS
-       test_yaffs_access_ELOOP
        test_yaffs_access_ENAMETOOLONG
        test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
 
@@ -281,14 +288,13 @@ Tests to add
 
 
        test_yaffs_truncate_EACCES
-       test_yaffs_truncate_ELOOP
        test_yaffs_truncate_ENAMETOOLONG
        Add a truncate function for truncating a file size to -1.
 
        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? 
@@ -300,7 +306,9 @@ Tests to add
        Change the mode of the lost and found dir to read only.
 
 Tests which do not exist in yaffs:
-       
+       test_yaffs_close        //This function has already been called by the time this test is reached, 
+                               //so there is no point in testing it.
+
        test_yaffs_link_EMLINK          //should not happen on yaffs
        test_yaffs_link_ELOOP
        
index 036ea4596d6fc25e75aada2f55dd2daf25d50dbb..e7a6b149661c3b508c0eb72672e5fc98b3bca643 100644 (file)
 #include "test_yaffs_lstat_ENOENT.h"
 #include "test_yaffs_lstat_ENOTDIR.h"
 
+#include "test_yaffs_flush.h"
+#include "test_yaffs_flush_EBADF.h"
+
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
 #include "lib.h"
@@ -352,7 +355,10 @@ test_template test_list[]={
 
        {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"},
        {test_yaffs_lstat_ENOENT,test_yaffs_lstat_ENOENT_clean,"test_yaffs_lstat_ENOENT"},
-       {test_yaffs_lstat_ENOTDIR,test_yaffs_lstat_ENOTDIR_clean,"test_yaffs_lstat_ENOTDIR"}
+       {test_yaffs_lstat_ENOTDIR,test_yaffs_lstat_ENOTDIR_clean,"test_yaffs_lstat_ENOTDIR"},
+
+       {test_yaffs_flush,test_yaffs_flush_clean,"test_yaffs_flush"},
+       {test_yaffs_flush_EBADF,test_yaffs_flush_EBADF_clean,"test_yaffs_flush_EBADF"}
 
        };
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_flush.c b/direct/timothy_tests/quick_tests/test_yaffs_flush.c
new file mode 100644 (file)
index 0000000..de5ccde
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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_flush.h"
+
+static int handle =-1;
+
+int test_yaffs_flush(void)
+{
+       int output=0;
+       handle = test_yaffs_open();
+       output =yaffs_flush(handle);
+       
+}
+
+
+int test_yaffs_flush_clean(void)
+{
+       return yaffs_close(handle);
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_flush.h b/direct/timothy_tests/quick_tests/test_yaffs_flush.h
new file mode 100644 (file)
index 0000000..f1fccea
--- /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_flush_h__
+#define __test_yaffs_flush_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_close.h"
+
+int test_yaffs_flush(void);
+int test_yaffs_flush_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.c
new file mode 100644 (file)
index 0000000..9daf090
--- /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_flush_EBADF.h"
+
+
+
+int test_yaffs_flush_EBADF(void)
+{
+       int output=0;
+       int error =0;
+       output = yaffs_flush(-1);
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==EBADF){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n",2);
+                       return -1;
+               }
+       } else {
+               print_message("flushed a bad handle (which is a bad thing)\n",2);
+               return -1;
+       }
+
+}
+
+
+int test_yaffs_flush_EBADF_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_flush_EBADF.h
new file mode 100644 (file)
index 0000000..f88d003
--- /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_flush_EBADF_h__
+#define __test_yaffs_flush_EBADF_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_close.h"
+
+int test_yaffs_flush_EBADF(void);
+int test_yaffs_flush_EBADF_clean(void);
+
+#endif
index d9d1666a844750688327b65e600399ddf14ebcf2..432be36c72c8bf6ee117e3fc9e75fd5331445a77 100644 (file)
@@ -60,6 +60,13 @@ int test_yaffs_rename_EEXISTS(void)
 int test_yaffs_rename_EEXISTS_clean(void)
 {
        int output = 0;
+       if (0 ==  yaffs_access("/yaffs2/dir2/file",0) ) {
+               output = yaffs_unlink("/yaffs2/dir2/file");
+               if (output < 0) {
+                       print_message("failed to remove the file\n",2);
+                       return -1;
+               }
+       }
        if (0 ==  yaffs_access(RENAME_PATH,0) && 0 != yaffs_access(DIR_PATH,0)) {
                output = yaffs_rename(RENAME_PATH,FILE_PATH);
                if (output < 0) {
@@ -67,6 +74,7 @@ int test_yaffs_rename_EEXISTS_clean(void)
                        return -1;
                }
        }
+       
        return 1;
 
 }