yaffs More tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 16 Nov 2010 02:02:51 +0000 (15:02 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 16 Nov 2010 02:02:51 +0000 (15:02 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
12 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/lib.h
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_mkdir.c
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c [moved from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c with 62% similarity]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.h [moved from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h with 78% similarity]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_symlink.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_symlink.h [new file with mode: 0644]

index 9737cdb..36a8b51 100644 (file)
@@ -64,8 +64,9 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o\
                test_yaffs_fsync.o test_yaffs_fsync_EBADF.o \
                test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o \
-               test_yaffs_mkdir.o \
-               test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o
+               test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o \
+               test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \
+               test_yaffs_symlink.o
 
                  
 
index f2a9942..e5a3e26 100644 (file)
@@ -52,6 +52,9 @@ Tests made
        test_yaffs_read_EBADF
        test_yaffs_read_EINVAL
 
+       test_yaffs_mkdir
+       test_yaffs_mkdir_EEXISTS
+       test_yaffs_mkdir_ENOTDIR
 
        test_yaffs_stat
        test_yaffs_stat_ENOENT
@@ -103,13 +106,10 @@ Tests to add
        test_yaffs_readlink_ELOOP
        test_yaffs_readlink_ENAMETOOLONG
 
-       test_yaffs_mkdir
+       
        test_yaffs_mkdir_EACCES
-       test_yaffs_mkdir_EEXISTS
        test_yaffs_mkdir_ELOOP
        test_yaffs_mkdir_ENAMETOOLONG
-       test_yaffs_mkdir_ENOENT
-       test_yaffs_mkdir_ENOTDIR
        test_yaffs_mkdir_EROFS
 
        test_yaffs_symlink
index ccada1d..534df7c 100644 (file)
@@ -33,6 +33,8 @@ Current BUGS
                Bug when trying to chmod a file in a non-existing directory. The error 
                returned is ENOENT, it should be ENOTDIR 
 
+               Bug when trying to mkdir on top of a non-existing directory. The error 
+               returned is ENOENT, it should be ENOTDIR. yaffs_mkdir should never return ENOENT.
 
 
        Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors.
index 51b5794..b12c04f 100644 (file)
 #define FILE_TEXT "file foo "  /* keep space at end of string */
 #define FILE_TEXT_NBYTES 10
 
+#define DIR_PATH "/yaffs2/new_directory/"
+
+#define SYMLINK_PATH "/yaffs2/sym_foo"
+
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
 
index 47d8c89..00b6683 100644 (file)
 #include "test_yaffs_fdatasync_EBADF.h"
 
 #include "test_yaffs_mkdir.h"
+#include "test_yaffs_mkdir_EEXIST.h"
+#include "test_yaffs_mkdir_ENOTDIR.h"
+
+#include "test_yaffs_symlink.h"
 
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
@@ -199,7 +203,11 @@ test_template test_list[]={
        {test_yaffs_fdatasync,test_yaffs_fdatasync_clean,"test_yaffs_fdatasync"},
        {test_yaffs_fdatasync_EBADF,test_yaffs_fdatasync_EBADF_clean,"test_yaffs_fdatasync_EBADF"},
 
-       {test_yaffs_mkdir,test_yaffs_mkdir_clean,"test_yaffs_mkdir"}
+       {test_yaffs_mkdir,test_yaffs_mkdir_clean,"test_yaffs_mkdir"},
+       {test_yaffs_mkdir_EEXIST,test_yaffs_mkdir_EEXIST_clean,"test_yaffs_mkdir_EEXIST"},
+       {test_yaffs_mkdir_ENOTDIR,test_yaffs_mkdir_ENOTDIR_clean,"test_yaffs_mkdir_ENOTDIR"},
+
+       {test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"}
 
 
 
index aedaa80..a0b29b7 100644 (file)
 
 #include "test_yaffs_mkdir.h"
 
-static int handle = 0;
+static int output = -1;
 
 int test_yaffs_mkdir(void)
 {
-       handle = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
-       return handle;
+       output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+       return output;
 }
 
 
 int test_yaffs_mkdir_clean(void)
 {
-       if (handle >= 0){
+       if (output >= 0){
                return yaffs_rmdir("/yaffs2/new_directory/");
        } else {
                return 1;       /* the file failed to open so there is no need to close it */
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_mkdir_EEXISTS.h"
+#include "test_yaffs_mkdir_EEXIST.h"
 
 static int output = -1;
 
-int test_yaffs_mkdir_EEXISTS(void)
+int test_yaffs_mkdir_EEXIST(void)
 {
-       output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
-       if (output <0) {
-               print_message("filed to create the directory the first time\n",2);
-               return -1;
+       int error_code = 0;
+       
+       if (0==yaffs_access(DIR_PATH,0)){
+               /* if the file exists  then the file does not need to be created the first time*/
+               
+       } else {
+       
+               output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
+               if (output <0) {
+                       print_message("failed to create the directory the first time\n",2);
+                       return -1;
+               }
        }
+
        output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
        if (output < 0){
                error_code = yaffs_get_error();
-               if (abs(error_code) == EEXISTS){
+               if (abs(error_code) == EEXIST){
                        return 1;
                } else {
                        print_message("different error than expected\n", 2);
@@ -38,10 +47,10 @@ int test_yaffs_mkdir_EEXISTS(void)
 }
 
 
-int test_yaffs_mkdir_EEXISTS_clean(void)
+int test_yaffs_mkdir_EEXIST_clean(void)
 {
        if (output >= 0){
-               return yaffs_rmdir("/yaffs2/new_directory/");
+               return yaffs_rmdir(DIR_PATH);
        } else {
                return 1;       
        }
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __test_yaffs_mkdir_EEXISTS_h__
-#define __test_yaffs_mkdir_EEXISTS_h__
+#ifndef __test_yaffs_mkdir_EEXIST_h__
+#define __test_yaffs_mkdir_EEXIST_h__
 
 #include "lib.h"
 #include "yaffsfs.h"
 
-int test_yaffs_mkdir_EEXISTS(void);
-int test_yaffs_mkdir_EEXISTS_clean(void);
+int test_yaffs_mkdir_EEXIST(void);
+int test_yaffs_mkdir_EEXIST_clean(void);
 
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c
new file mode 100644 (file)
index 0000000..4b36abc
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_mkdir_ENOTDIR.h"
+
+static int output = -1;
+
+int test_yaffs_mkdir_ENOTDIR(void)
+{
+       int error_code = 0;
+       
+
+       output = yaffs_mkdir("/non_existing_directory/new_directory/",O_CREAT | O_RDWR);
+       if (output < 0){
+               error_code = yaffs_get_error();
+               if (abs(error_code) == ENOTDIR){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n", 2);
+                       return -1;
+               }
+       } else {
+               print_message("created a new directory on top of an non-existing directory (which is a bad thing)\n", 2);
+               return -1;
+       }
+}
+
+
+int test_yaffs_mkdir_ENOTDIR_clean(void)
+{
+       if (output >= 0){
+               return yaffs_rmdir(DIR_PATH);
+       } else {
+               return 1;       
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.h
new file mode 100644 (file)
index 0000000..570b406
--- /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_mkdir_ENOTDIR_h__
+#define __test_yaffs_mkdir_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mkdir_ENOTDIR(void);
+int test_yaffs_mkdir_ENOTDIR_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink.c b/direct/timothy_tests/quick_tests/test_yaffs_symlink.c
new file mode 100644 (file)
index 0000000..570136e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_symlink.h"
+
+static int output = 0;
+
+int test_yaffs_symlink(void)
+{
+       output = yaffs_symlink(FILE_PATH,SYMLINK_PATH);
+       return output;
+}
+
+
+int test_yaffs_symlink_clean(void)
+{
+       if (output >= 0){
+               return yaffs_unlink(SYMLINK_PATH);
+       } else {
+               return 1;       /* the file failed to open so there is no need to close it */
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink.h b/direct/timothy_tests/quick_tests/test_yaffs_symlink.h
new file mode 100644 (file)
index 0000000..e41bfeb
--- /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_symlink_h__
+#define __test_yaffs_symlink_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_symlink(void);
+int test_yaffs_symlink_clean(void);
+
+#endif