yaffs Added some more tests to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 1 Dec 2010 00:51:27 +0000 (13:51 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 1 Dec 2010 00:51:27 +0000 (13:51 +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_dup.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_dup.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.h [new file with mode: 0644]

index dbefa93..22a772d 100644 (file)
@@ -99,13 +99,15 @@ TESTFILES =         quick_tests.o lib.o \
                test_yaffs_link_ENAMETOOLONG2.o test_yaffs_link_NULL.o test_yaffs_link_NULL2.o \
                test_yaffs_rmdir.o test_yaffs_rmdir_EBUSY.o test_yaffs_rmdir_EINVAL.o test_yaffs_rmdir_ENOENT.o \
                test_yaffs_rmdir_ENOTDIR.o test_yaffs_rmdir_ELOOP_dir.o test_yaffs_rmdir_EROFS.o test_yaffs_rmdir_ENAMETOOLONG.o \
+               test_yaffs_rmdir_ENOTEMPTY.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_dir.o test_yaffs_rename_EROFS.o \
                test_yaffs_rename_ENAMETOOLONG.o test_yaffs_rename_ENAMETOOLONG2.o test_yaffs_rename_NULL.o test_yaffs_rename_NULL2.o \
                test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o \
                test_yaffs_lstat_NULL.o \
-               test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o 
+               test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o \
+               test_yaffs_dup.o test_yaffs_dup_EBADF.o
 
 
                  
index 851315c..d757584 100644 (file)
@@ -31,6 +31,9 @@ test_yaffs_close.c
 test_yaffs_close_EBADF.c
 test_yaffs_close_NULL.c
 
+test_yaffs_dup.c
+test_yaffs_dup_EBADF.c 
+
 test_yaffs_fchmod.c
 test_yaffs_fchmod_EBADF.c
 test_yaffs_fchmod_EINVAL.c
@@ -250,11 +253,8 @@ Tests to add
        test_yaffs_readlink_ENOTDIR
        test_yaffs_readlink_ELOOP
 
-
        test_yaffs_mount2_with read only set
 
-
-
        test_yaffs_remount_force_off_read_only_on
        test_yaffs_remount_force_on_read_only_on
 
@@ -266,23 +266,17 @@ Tests to add
 
        test_yaffs_closedir
 
-
        test_yaffs_link_EPERM
 
        test_yaffs_rmdir_ENOTEMPTY
 
        test_yaffs_rename_EMLINK
-       test_yaffs_rename_EEXISTS or EPERM
-
-       test_yaffs_dup
-       test_yaffs_dup_EBADF            
+       test_yaffs_rename_EEXISTS or EPERM      
 
        test_yaffs_open_ENOSPC
 
        test yaffs_open_running_out_of_handles error
 
-
-
        test_yaffs_read_big_file
        test what happens if you read off the end of the file?
 
@@ -295,17 +289,14 @@ Tests to add
        test_yaffs_write_EINVAL
        What happens when you run out of space?
        
-       test_yaffs_write_EBADF
-       test_yaffs_write
+
        test_yaffs_pwrite_big_file
        test_yaffs_pwrite_EINVAL
 
        test_yaffs_unlink_ENOMEM
 
-
        test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
 
-
        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?
index 7b80533..a8a88c4 100644 (file)
@@ -3,9 +3,7 @@ Made by Timothy Manning <timothy@yaffs.net> on 08/11/2010
 
 
 Current BUGS 
-       Bug with test_yaffs_rename_dir it does not return an error code.
-       
-       Bug with test_yaffs_rename_EEXIST should be giving the bug EEXIST but instead gives ENOENT. 
+
 
 Current WARNINGS
        
index e046eec..78ec211 100644 (file)
 #include "test_yaffs_rmdir_ELOOP_dir.h"
 #include "test_yaffs_rmdir_EROFS.h"
 #include "test_yaffs_rmdir_ENAMETOOLONG.h"
+#include "test_yaffs_rmdir_ENOTEMPTY.h"
 
 #include "test_yaffs_rename.h"
 #include "test_yaffs_rename_ENOENT.h"
 #include "test_yaffs_flush_EBADF.h"
 #include "test_yaffs_flush_EROFS.h"
 
+#include "test_yaffs_dup.h"
+#include "test_yaffs_dup_EBADF.h"
 
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
@@ -472,6 +475,7 @@ test_template test_list[]={
        {test_yaffs_rmdir_ELOOP_dir,test_yaffs_rmdir_ELOOP_dir_clean,"test_yaffs_rmdir_ELOOP_dir"},
        {test_yaffs_rmdir_EROFS,test_yaffs_rmdir_EROFS_clean,"test_yaffs_rmdir_EROFS"},
        {test_yaffs_rmdir_ENAMETOOLONG,test_yaffs_rmdir_ENAMETOOLONG_clean,"test_yaffs_rmdir_ENAMETOOLONG"},
+       {test_yaffs_rmdir_ENOTEMPTY,test_yaffs_rmdir_ENOTEMPTY_clean,"test_yaffs_rmdir_ENOTEMPTY"},
 
        {test_yaffs_stat_ELOOP_dir,test_yaffs_stat_ELOOP_dir_clean,"test_yaffs_stat_ELOOP_dir"},
 
@@ -502,7 +506,8 @@ test_template test_list[]={
        {test_yaffs_flush_EBADF,test_yaffs_flush_EBADF_clean,"test_yaffs_flush_EBADF"},
        {test_yaffs_flush_EROFS,test_yaffs_flush_EROFS_clean,"test_yaffs_flush_EROFS"},
 
-
+       {test_yaffs_dup,test_yaffs_dup_clean,"test_yaffs_dup"},
+       {test_yaffs_dup_EBADF,test_yaffs_dup_EBADF_clean,"test_yaffs_dup_EBADF"},
 
        };
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_dup.c b/direct/timothy_tests/quick_tests/test_yaffs_dup.c
new file mode 100644 (file)
index 0000000..07ef59d
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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_dup.h"
+
+static int handle = -1;
+static int handle2 = -1;
+int test_yaffs_dup(void)
+{
+       handle = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+       if (handle >=0){
+               handle2 =yaffs_dup(handle);
+               return handle2;
+       }
+       
+}
+
+
+int test_yaffs_dup_clean(void)
+{
+       int output1=1;
+       int output2=1;
+       if (handle >= 0){
+               output1= yaffs_close(handle);
+       } 
+       if (handle2 >= 0){
+               output2 =yaffs_close(handle2);
+       }
+       return (output1 && output2);    
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_dup.h b/direct/timothy_tests/quick_tests/test_yaffs_dup.h
new file mode 100644 (file)
index 0000000..170203d
--- /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_dup_h__
+#define __test_yaffs_dup_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_dup(void);
+int test_yaffs_dup_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.c
new file mode 100644 (file)
index 0000000..f919744
--- /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_dup_EBADF.h"
+
+
+int test_yaffs_dup_EBADF(void)
+{
+       int error_code= -1;
+       int output =yaffs_dup(-1);
+       if (output < 0){
+               error_code = yaffs_get_error();
+               if (abs(error_code) == EBADF){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n", 2);
+                       return -1;
+               }
+       } else {
+               print_message("non existant handle duplicated.(which is a bad thing)\n", 2 );
+               return -1;
+       }
+}
+
+
+int test_yaffs_dup_EBADF_clean(void)
+{
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_dup_EBADF.h
new file mode 100644 (file)
index 0000000..7cfc1f1
--- /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_dup_EBADF_h__
+#define __test_yaffs_dup_EBADF_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_dup_EBADF(void);
+int test_yaffs_dup_EBADF_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c b/direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.c
new file mode 100644 (file)
index 0000000..60b6cca
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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_rmdir_ENOTEMPTY.h"
+
+
+int test_yaffs_rmdir_ENOTEMPTY(void)
+{
+       int output=0;
+       int error_code =0;
+
+       if (0 !=  yaffs_access(DIR_PATH,0)) {
+               output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
+               if (output < 0) {
+                       print_message("failed to create directory\n",2);
+                       return -1;
+               }
+       }
+       if (0 !=  yaffs_access("/yaffs2/new_directory/dir",0)) {
+               output = yaffs_mkdir("/yaffs2/new_directory/dir",S_IWRITE | S_IREAD);
+               if (output < 0) {
+                       print_message("failed to create directory\n",2);
+                       return -1;
+               }
+       }
+       output = yaffs_rmdir(DIR_PATH);
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOTEMPTY){
+                       return 1;
+               } else {
+                       print_message("returned error does not match the the expected error\n",2);
+                       return -1;
+               }
+       } else{
+               print_message("removed /yaffs2/ directory (which is a bad thing)\n",2);
+               return -1;
+       }       
+}
+
+
+int test_yaffs_rmdir_ENOTEMPTY_clean(void)
+{
+       int output = -1;
+       int output2 = -1;
+       if (0 ==  yaffs_access("/yaffs2/new_directory/dir",0)) {
+               output = yaffs_rmdir("/yaffs2/new_directory/dir");
+               if (output < 0) {
+                       print_message("failed to remove the directory\n",2);
+                       output=1;
+               }
+       }
+       if (0 ==  yaffs_access(DIR_PATH,0)) {
+               output = yaffs_rmdir(DIR_PATH);
+               if (output < 0) {
+                       print_message("failed to remove the directory\n",2);
+                       output2=1;
+               }
+       }
+       return (output && output2);
+
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.h b/direct/timothy_tests/quick_tests/test_yaffs_rmdir_ENOTEMPTY.h
new file mode 100644 (file)
index 0000000..2c1688a
--- /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_rmdir_ENOTEMPTY_h__
+#define __test_yaffs_rmdir_ENOTEMPTY_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rmdir_ENOTEMPTY(void);
+int test_yaffs_rmdir_ENOTEMPTY_clean(void);
+
+#endif