yaffs Added more tests to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 23 Nov 2010 23:52:07 +0000 (12:52 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 23 Nov 2010 23:52:07 +0000 (12:52 +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_lstat.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lstat.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_symlink.c

index 813c60f..bafcbc1 100644 (file)
@@ -87,7 +87,8 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_rmdir_ENOTDIR.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_file_to_dir.o test_yaffs_rename_EEXISTS.o \
+               test_yaffs_lstat.o
 
 
                  
index c6d316b..3479aa5 100644 (file)
@@ -183,37 +183,13 @@ Tests to add
        test_yaffs_symlink_ENAMETOOLONG
        test_yaffs_symlink_EROFS
 
-       
-       //the yaffs_mknod function does not exist in yaffsfs, so these tests will not be added.
-       test_yaffs_mknod
-       test_yaffs_mknod_EACCES
-       test_yaffs_mknod_EEXIST
-       test_yaffs_mknod_EINVAL
-       test_yaffs_mknod_ELOOP
-       test_yaffs_mknod_ENAMETOOLONG
-       test_yaffs_mknod_ENOENT
-       test_yaffs_mknod_ENOTDIR
-       test_yaffs_mknod_EROFS
-
-
-       test_yaffs_mount2_EINVAL        //cannot happen in yaffs since the mode is not checked.
-       test_yaffs_mount2_ENOTDIR       //cannot be generated in yaffs.
-       test_yaffs_mount2_ENOENT        //cannot be generated in yaffs.
        test_yaffs_mount2_ENAMETOOLONG
        test_yaffs_mount2_with read only set
 
-
-
-       test_yaffs_unmount2_ENOENT      //cannot be generated in yaffs.
-       test_yaffs_unmount2_ENOTDIR     //cannot be generated in yaffs.
        test_yaffs_unmount2_ENAMETOOLONG
-       
 
        test_yaffs_remount_force_off_read_only_on
        test_yaffs_remount_force_on_read_only_on
-       test_yaffs_remount_ENOENT       //cannot be generated in yaffs
-       test_yaffs_remount_ENOTDIR      //cannot be generated in yaffs
-
 
        test_yaffs_freespace_ENAMETOOLONG
        test_yaffs_totalspace_ENAMETOOLONG
@@ -227,11 +203,10 @@ Tests to add
 
        test_yaffs_closedir
 
-
        test_yaffs_link_EACCES
 
        test_yaffs_link_ELOOP
-       test_yaffs_link_EMLINK          //should not happen on yaffs
+
        test_yaffs_link_ENAMETOOLONG
        test_yaffs_link_EPERM
        test_yaffs_link_EROFS
@@ -242,16 +217,13 @@ Tests to add
        test_yaffs_rmdir_EROFS
 
 
-       what happens if a file is renamed into a dir.
-       //need to do rename for directories.
-       //what happens if the dir or file is renamed over an existing dir or file 
+
        test_yaffs_rename_EACCES
        test_yaffs_rename_ELOOP
        test_yaffs_rename_EMLINK
        test_yaffs_rename_EEXISTS or EPERM
        test_yaffs_rename_EROFS
 
-
        test_yaffs_dup
        test_yaffs_dup_EBADF            
 
@@ -273,8 +245,6 @@ Tests to add
        test_yaffs_stat_EACCES
        test_yaffs_stat_ENAMETOOLONG
 
-        
-
        test_yaffs_read_big_file
        test what happens if you read off the end of the file?
 
@@ -322,6 +292,32 @@ Tests to add
 
        What happens when a mount point is mounted using mount2 with read only mode set and then a file is chmoded? 
 
+
+Tests which do not exist in yaffs:
+       
+       test_yaffs_link_EMLINK          //should not happen on yaffs
+       
+       //the yaffs_mknod function does not exist in yaffsfs, so these tests will not be added.
+       test_yaffs_mknod
+       test_yaffs_mknod_EACCES
+       test_yaffs_mknod_EEXIST
+       test_yaffs_mknod_EINVAL
+       test_yaffs_mknod_ELOOP
+       test_yaffs_mknod_ENAMETOOLONG
+       test_yaffs_mknod_ENOENT
+       test_yaffs_mknod_ENOTDIR
+       test_yaffs_mknod_EROFS
+
+       test_yaffs_mount2_EINVAL        //cannot happen in yaffs since the mode is not checked.
+       test_yaffs_mount2_ENOTDIR       //cannot be generated in yaffs.
+       test_yaffs_mount2_ENOENT        //cannot be generated in yaffs.
+
+       test_yaffs_remount_ENOENT       //cannot be generated in yaffs
+       test_yaffs_remount_ENOTDIR      //cannot be generated in yaffs
+
+       test_yaffs_unmount2_ENOENT      //cannot be generated in yaffs.
+       test_yaffs_unmount2_ENOTDIR     //cannot be generated in yaffs.
+
 How to add a test
        First create the test .c and .h file.
        The file name and test function name should be the same. 
index 1aca5cb..3f55512 100644 (file)
 #include "test_yaffs_rename_file_to_dir.h"
 #include "test_yaffs_rename_EEXISTS.h"
 
+#include "test_yaffs_lstat.h"
+
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
 #include "lib.h"
@@ -330,7 +332,8 @@ test_template test_list[]={
        {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"},
        {test_yaffs_rename_dir_to_file,test_yaffs_rename_dir_to_file_clean,"test_yaffs_rename_dir_to_file"},
        {test_yaffs_rename_file_to_dir,test_yaffs_rename_file_to_dir_clean,"test_yaffs_rename_file_to_dir"},
-       {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"}
+       {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"},
+       {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"}
        };
 
 void init_quick_tests(int argc, char *argv[]);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat.c b/direct/timothy_tests/quick_tests/test_yaffs_lstat.c
new file mode 100644 (file)
index 0000000..1d1ecbd
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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_lstat.h"
+
+
+int test_yaffs_lstat(void)
+{
+       int output = -1;
+       struct yaffs_stat stat;
+       if (0 != yaffs_access(FILE_PATH,0)){
+               output=test_yaffs_open();
+               if (output>=0){
+                       output = yaffs_close(output);
+                       if (output<0){
+                               print_message("failed to close file\n",2);
+                               return -1;
+                       }
+               } else {
+                       print_message("failed to open file\n",2);
+                       return -1;
+               }
+       }
+       if (0 != yaffs_access(SYMLINK_PATH,0)){
+               output=yaffs_symlink(FILE_PATH,SYMLINK_PATH);
+               if (output<0){
+                       print_message("failed to open file\n",2);
+                       return -1;
+               }
+       }
+       
+       output =yaffs_lstat(SYMLINK_PATH,&stat);
+       return output;
+}
+
+
+int test_yaffs_lstat_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat.h b/direct/timothy_tests/quick_tests/test_yaffs_lstat.h
new file mode 100644 (file)
index 0000000..b460df2
--- /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_lstat_h__
+#define __test_yaffs_lstat_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_lstat(void);
+int test_yaffs_lstat_clean(void);
+
+#endif
index 570136e..ddebec1 100644 (file)
@@ -17,6 +17,13 @@ static int output = 0;
 
 int test_yaffs_symlink(void)
 {
+       if (0 == yaffs_access(SYMLINK_PATH,0)){
+               output=yaffs_unlink(SYMLINK_PATH);
+               if (output<0){
+                       print_message("failed to unlink symlink\n",2);
+                       return -1;
+               }
+       }
        output = yaffs_symlink(FILE_PATH,SYMLINK_PATH);
        return output;
 }