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 9737cdba04ba99c38698101624225021acc7f274..36a8b510e7a4bc33968ff91490a52efcde803e94 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_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 f2a99421fd3ade216ebe63998343a1608f89cf06..e5a3e260f5d549053271eece162f833e31d0454c 100644 (file)
@@ -52,6 +52,9 @@ Tests made
        test_yaffs_read_EBADF
        test_yaffs_read_EINVAL
 
        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
 
        test_yaffs_stat
        test_yaffs_stat_ENOENT
@@ -103,13 +106,10 @@ Tests to add
        test_yaffs_readlink_ELOOP
        test_yaffs_readlink_ENAMETOOLONG
 
        test_yaffs_readlink_ELOOP
        test_yaffs_readlink_ENAMETOOLONG
 
-       test_yaffs_mkdir
+       
        test_yaffs_mkdir_EACCES
        test_yaffs_mkdir_EACCES
-       test_yaffs_mkdir_EEXISTS
        test_yaffs_mkdir_ELOOP
        test_yaffs_mkdir_ENAMETOOLONG
        test_yaffs_mkdir_ELOOP
        test_yaffs_mkdir_ENAMETOOLONG
-       test_yaffs_mkdir_ENOENT
-       test_yaffs_mkdir_ENOTDIR
        test_yaffs_mkdir_EROFS
 
        test_yaffs_symlink
        test_yaffs_mkdir_EROFS
 
        test_yaffs_symlink
index ccada1d776efe8b707163a97a6ad0605e2059194..534df7c270cd1e55a3c27be7057a7109b96d7442 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 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.
 
 
        Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors.
index 51b5794602bc9abf167e7eb04843c81be5f53133..b12c04f55da6d4d4a0c5cb411a4a61fe01ecc940 100644 (file)
 #define FILE_TEXT "file foo "  /* keep space at end of string */
 #define FILE_TEXT_NBYTES 10
 
 #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"
 
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
 
index 47d8c893f2c363dfdd0790fb9bbe9e2f9ddf6fd8..00b66839670b761223be211f855989a28c065941 100644 (file)
 #include "test_yaffs_fdatasync_EBADF.h"
 
 #include "test_yaffs_mkdir.h"
 #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"
 
 #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_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 aedaa8024b5dd4f2bec1db0fee472b5c86b91b09..a0b29b776cf529315f58c499a3b586b88dd47532 100644 (file)
 
 #include "test_yaffs_mkdir.h"
 
 
 #include "test_yaffs_mkdir.h"
 
-static int handle = 0;
+static int output = -1;
 
 int test_yaffs_mkdir(void)
 {
 
 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)
 {
 }
 
 
 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 */
                return yaffs_rmdir("/yaffs2/new_directory/");
        } else {
                return 1;       /* the file failed to open so there is no need to close it */
similarity index 62%
rename from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c
rename to direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c
index 99483930f824ea73dde86a1c10bddba6df08af17..939c2149b4779d7d2df7b4a8423f737359a20109 100644 (file)
  * published by the Free Software Foundation.
  */
 
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_mkdir_EEXISTS.h"
+#include "test_yaffs_mkdir_EEXIST.h"
 
 static int output = -1;
 
 
 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();
        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);
                        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){
 {
        if (output >= 0){
-               return yaffs_rmdir("/yaffs2/new_directory/");
+               return yaffs_rmdir(DIR_PATH);
        } else {
                return 1;       
        }
        } else {
                return 1;       
        }
similarity index 78%
rename from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h
rename to direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.h
index 16d5bfe33220ee048bb2f0ce7bed0c272c4c5cdb..9b5b3382b860d3e16064223c01bfefcd501f9a64 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
  * 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"
 
 
 #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
 
 #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