yaffs Added more tests to direct/timothy_tests/quicktests
authorTimothy Manning <tfhmanning@gmail.com>
Sun, 28 Nov 2010 22:42:41 +0000 (11:42 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Sun, 28 Nov 2010 22:44:17 +0000 (11:44 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c [moved from direct/timothy_tests/quick_tests/test_yaffs_fstat_EROFS.c with 64% similarity]
direct/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.h [moved from direct/timothy_tests/quick_tests/test_yaffs_fstat_EROFS.h with 84% similarity]
direct/timothy_tests/quick_tests/test_yaffs_link_EROFS.c
direct/timothy_tests/quick_tests/test_yaffs_link_EROFS.h
direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.h [new file with mode: 0644]

index a6148379c812f49158a9b0194610a3f1a4e5402a..9ea838e27228ef3279cffbe777a2d14ad470710c 100644 (file)
@@ -65,15 +65,15 @@ TESTFILES =         quick_tests.o lib.o \
                test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP_dir.o test_yaffs_access_ELOOP.o test_yaffs_access_EROFS.o \
                test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o test_yaffs_stat_ENOENT2.o test_yaffs_stat_ELOOP.o \
                test_yaffs_stat_ELOOP_dir.o\
-               test_yaffs_fstat.o test_yaffs_fstat_EBADF.o test_yaffs_fstat_EROFS.o \
+               test_yaffs_fstat.o test_yaffs_fstat_EBADF.o  \
                test_yaffs_close_EBADF.o\
                test_yaffs_chmod.o test_yaffs_chmod_ENOENT.o test_yaffs_chmod_ENOTDIR.o test_yaffs_chmod_EINVAL.o \
                test_yaffs_chmod_ENOENT2.o test_yaffs_chmod_ELOOP_dir.o test_yaffs_chmod_ELOOP.o test_yaffs_chmod_EROFS.o \
                test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EROFS.o test_yaffs_fchmod_EINVAL.o\
-               test_yaffs_fsync.o test_yaffs_fsync_EBADF.o \
+               test_yaffs_fsync.o test_yaffs_fsync_EBADF.o test_yaffs_fsync_EROFS.o \
                test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o test_yaffs_fdatasync_EROFS.o\
                test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o test_yaffs_mkdir_ENOENT.o \
-               test_yaffs_mkdir_ELOOP_dir.o \
+               test_yaffs_mkdir_ELOOP_dir.o test_yaffs_mkdir_EROFS.o \
                test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \
                test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o test_yaffs_symlink_ENOENT.o \
                test_yaffs_symlink_ENOENT2.o test_yaffs_symlink_ELOOP_dir.o \
@@ -88,7 +88,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_inodecount.o test_yaffs_inodecount_EINVAL.o \
                test_yaffs_link.o test_yaffs_link_ENOENT.o test_yaffs_link_EEXIST.o test_yaffs_link_ENOTDIR.o \
                test_yaffs_link_ENOTDIR2.o test_yaffs_link_ENOENT2.o test_yaffs_link_ENOENT3.o test_yaffs_link_ENOENT3.o \
-               test_yaffs_link_ENOENT4.o test_yaffs_link_ELOOP_dir.o \
+               test_yaffs_link_ENOENT4.o test_yaffs_link_ELOOP_dir.o test_yaffs_link_EROFS.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_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \
index 60df32263f2c267d5c1521e17f351bdb197dba2f..246093e7ac28eb89ec082884eb454c022a05906a 100644 (file)
@@ -98,7 +98,7 @@
 
 #include "test_yaffs_fstat.h"
 #include "test_yaffs_fstat_EBADF.h"
-#include "test_yaffs_fstat_EROFS.h"
+
 
 #include "test_yaffs_chmod.h"
 #include "test_yaffs_chmod_ENOENT.h"
 
 #include "test_yaffs_fsync.h"
 #include "test_yaffs_fsync_EBADF.h"
+#include "test_yaffs_fsync_EROFS.h"
 
 #include "test_yaffs_fdatasync.h"
 #include "test_yaffs_fdatasync_EBADF.h"
 #include "test_yaffs_mkdir_ENOTDIR.h"
 #include "test_yaffs_mkdir_ENOENT.h"
 #include "test_yaffs_mkdir_ELOOP_dir.h"
+#include "test_yaffs_mkdir_EROFS.h"
 
 
 #include "test_yaffs_symlink.h"
 #include "test_yaffs_link_ENOENT3.h"
 #include "test_yaffs_link_ENOENT4.h"
 #include "test_yaffs_link_ELOOP_dir.h"
-
+#include "test_yaffs_link_EROFS.h"
 
 #include "test_yaffs_rmdir.h"
 #include "test_yaffs_rmdir_EBUSY.h"
@@ -279,7 +281,6 @@ test_template test_list[]={
 
        {test_yaffs_fstat,test_yaffs_fstat_clean,"test_yaffs_fstat"},
        {test_yaffs_fstat_EBADF,test_yaffs_fstat_EBADF_clean,"test_yaffs_fstat_EBADF"},
-       {test_yaffs_fstat_EROFS,test_yaffs_fstat_EROFS_clean,"test_yaffs_fstat_EROFS"},
 
        {test_yaffs_ftruncate,test_yaffs_ftruncate_clean,"test_yaffs_ftruncate"},
        {test_yaffs_ftruncate_EBADF,test_yaffs_ftruncate_EBADF_clean,"test_yaffs_ftruncate_EBADF"},
@@ -311,6 +312,7 @@ test_template test_list[]={
 
        {test_yaffs_fsync,test_yaffs_fsync_clean,"test_yaffs_fsync"},
        {test_yaffs_fsync_EBADF,test_yaffs_fsync_EBADF_clean,"test_yaffs_fsync_EBADF"},
+       {test_yaffs_fsync_EROFS,test_yaffs_fsync_EROFS_clean,"test_yaffs_fsync_EROFS"},
 
        {test_yaffs_fdatasync,test_yaffs_fdatasync_clean,"test_yaffs_fdatasync"},
        {test_yaffs_fdatasync_EBADF,test_yaffs_fdatasync_EBADF_clean,"test_yaffs_fdatasync_EBADF"},
@@ -321,6 +323,7 @@ test_template test_list[]={
        {test_yaffs_mkdir_ENOTDIR,test_yaffs_mkdir_ENOTDIR_clean,"test_yaffs_mkdir_ENOTDIR"},
        {test_yaffs_mkdir_ENOENT,test_yaffs_mkdir_ENOENT_clean,"test_yaffs_mkdir_ENOENT"},
        {test_yaffs_mkdir_ELOOP_dir,test_yaffs_mkdir_ELOOP_dir_clean,"test_yaffs_mkdir_ELOOP_dir"},
+       {test_yaffs_mkdir_EROFS,test_yaffs_mkdir_EROFS_clean,"test_yaffs_mkdir_EROFS"},
 
        {test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"},
        {test_yaffs_symlink_ENOTDIR,test_yaffs_symlink_ENOTDIR_clean,"test_yaffs_symlink_ENOTDIR"},
@@ -367,6 +370,7 @@ test_template test_list[]={
        {test_yaffs_link_ENOENT3,test_yaffs_link_ENOENT3_clean,"test_yaffs_link_ENOENT3"},
        {test_yaffs_link_ENOENT4,test_yaffs_link_ENOENT4_clean,"test_yaffs_link_ENOENT4"},
        {test_yaffs_link_ELOOP_dir,test_yaffs_link_ELOOP_dir_clean,"test_yaffs_link_ELOOP_dir"},
+       {test_yaffs_link_EROFS,test_yaffs_link_EROFS_clean,"test_yaffs_link_EROFS"},
 
        {test_yaffs_rmdir,test_yaffs_rmdir_clean,"test_yaffs_rmdir"},
        {test_yaffs_rmdir_EBUSY,test_yaffs_rmdir_EBUSY_clean,"test_yaffs_rmdir_EBUSY"},
similarity index 64%
rename from direct/timothy_tests/quick_tests/test_yaffs_fstat_EROFS.c
rename to direct/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.c
index cf90933d5ce680ecf2647431d410851ec761087e..97757faea1ec206cf15d0c45e9f0210bcf0cfa34 100644 (file)
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_fstat_EROFS.h"
+#include "test_yaffs_fsync_EROFS.h"
 
 static int handle = -1;
 
-int test_yaffs_fstat_EROFS(void)
+int test_yaffs_fsync_EROFS(void)
 {
        int output = 0;
-       struct yaffs_stat stat;
        int error_code = 0;
+
        EROFS_setup();
        handle = test_yaffs_open();
-       output = yaffs_fstat(handle , &stat);
-       if (output < 0){
-               error_code = yaffs_get_error();
-               if (abs(error_code) == EROFS){
+       output = yaffs_fsync(handle);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EROFS){
                        return 1;
                } else {
-                       print_message("different error than expected\n", 2);
+                       print_message("different error than expected\n",2);
                        return -1;
                }
        } else {
-               print_message("file statted with EROFS set.(which is a bad thing)\n", 2 );
+               print_message("file synced with EROFS set.(which is a bad thing)\n",2);
                return -1;
        }
 }
 
-int test_yaffs_fstat_EROFS_clean(void)
+
+int test_yaffs_fsync_EROFS_clean(void)
 {
        int output=1;
        if (handle >= 0) {
@@ -45,3 +46,4 @@ int test_yaffs_fstat_EROFS_clean(void)
        }
        return (EROFS_clean() && output);
 }
+
similarity index 84%
rename from direct/timothy_tests/quick_tests/test_yaffs_fstat_EROFS.h
rename to direct/timothy_tests/quick_tests/test_yaffs_fsync_EROFS.h
index f382bdeb9ff5d1323064fd53535a44de04433cdf..0e8ef42699d98abbae9a82ca1e5d9c4cc31cdec9 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __test_yaffs_fstat_EROFS_h__
-#define __test_yaffs_fstat_EROFS_h__
+#ifndef __test_yaffs_fsync_EROFS_h__
+#define __test_yaffs_fsync_EROFS_h__
 
 #include "lib.h"
 #include "yaffsfs.h"
 #include "test_yaffs_open.h"
 
-int test_yaffs_fstat_EROFS(void);
-int test_yaffs_fstat_EROFS_clean(void); 
+int test_yaffs_fsync_EROFS(void);
+int test_yaffs_fsync_EROFS_clean(void);
 
 #endif
index 31c0900b19072c2b92dfe379d568876c94756934..bfbd48b0c22f8a8bb715b2cb35934f7d05f9de1c 100644 (file)
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_link_ELOOP_dir.h"
+#include "test_yaffs_link_EROFS.h"
 
 
 
-int test_yaffs_link_ELOOP_dir(void)
+int test_yaffs_link_EROFS(void)
 {
        int output=0;   
        int error =0;
 
-       if (set_up_ELOOP()<0){
-               print_message("failed to setup symlinks\n",2);
-               return -1;
-       }
+       EROFS_setup();
 
-       output = yaffs_link(ELOOP_PATH "/file",HARD_LINK_PATH);
+       output = yaffs_link(FILE_PATH,HARD_LINK_PATH);
        if (output<0){
                error=yaffs_get_error();
-               if (abs(error)==ELOOP){
+               if (abs(error)==EROFS){
                        return 1;
                } else {
                        print_message("different error than expected\n",2);
                        return -1;
                }
        } else {
-               print_message("created a hard link to a non-existing-dir (which is a bad thing)\n",2);
+               print_message("created a hard link with EROFS set (which is a bad thing)\n",2);
                return -1;      
        }
 }
 
 
-int test_yaffs_link_ELOOP_dir_clean(void)
+int test_yaffs_link_EROFS_clean(void)
 {
        int output=0;   
        int error =0;
@@ -50,13 +47,13 @@ int test_yaffs_link_ELOOP_dir_clean(void)
                error=yaffs_get_error();
                if (abs(error)==ENOENT){
                        //if the file does not exist then the error should be ENOENT.
-                       return 1;
+                       return EROFS_clean();
                } else {
                        print_message("different error than expected\n",2);
                        return -1;
                }
        } else {
-               return 1;       /* the file failed to open so there is no need to close it */
+               return EROFS_clean();   /* the file failed to open so there is no need to close it */
        }
 }
 
index cfdb1303130cddf9467c6589eba90e4896e4d94d..8ce4bcd7d78d0b0782eba5f1a761c43136fdd687 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __test_yaffs_link_ELOOP_dir_h__
-#define __test_yaffs_link_ELOOP_dir_h__
+#ifndef __test_yaffs_link_EROFS_h__
+#define __test_yaffs_link_EROFS_h__
 
 #include "lib.h"
 #include "yaffsfs.h"
 
-int test_yaffs_link_ELOOP_dir(void);
-int test_yaffs_link_ELOOP_dir_clean(void);
+int test_yaffs_link_EROFS(void);
+int test_yaffs_link_EROFS_clean(void);
 
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.c
new file mode 100644 (file)
index 0000000..6e83eb4
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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_lseek_EROFS.h"
+
+int handle=-1;
+
+int test_yaffs_lseek_EROFS(void)
+{
+
+       int error_code = 0;
+       int output = 0;
+       EROFS_setup();
+
+       handle = test_yaffs_open();
+       if (handle < 0){
+               print_message("failed to open file\n", 2);
+               return -1;
+       }
+
+       output = yaffs_lseek(handle, 0, 20);
+
+       if (output < 0){
+               error_code = yaffs_get_error();
+               if (abs(error_code) == EROFS){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n", 2);
+                       return -1;
+               }
+       } else {
+               print_message("lseeked with EROFS set (which is a bad thing)\n", 2);
+               return -1;
+       }
+}
+
+int test_yaffs_lseek_EROFS_clean(void)
+{
+       if (handle >= 0){
+               return yaffs_close(handle);
+       } else {
+               return 1; /* no handle was opened so there is no need to close a handle */
+       }       
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EROFS.h
new file mode 100644 (file)
index 0000000..ec1881b
--- /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_lseek_EROFS_h__
+#define __test_yaffs_lseek_EROFS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_lseek_EROFS(void);
+int test_yaffs_lseek_EROFS_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.c
new file mode 100644 (file)
index 0000000..70bbfaf
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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_EROFS.h"
+
+static int output = -1;
+
+int test_yaffs_mkdir_EROFS(void)
+{
+       int error_code = 0;
+
+       EROFS_setup();
+
+       output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
+       if (output < 0){
+               error_code = yaffs_get_error();
+               if (abs(error_code) == EROFS){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n", 2);
+                       return -1;
+               }
+       } else {
+               print_message("created a new directory with EROFS set (which is a bad thing)\n", 2);
+               return -1;
+       }
+}
+
+
+int test_yaffs_mkdir_EROFS_clean(void)
+{
+       int output2 = 1;
+       if (output >= 0){
+               output2= yaffs_rmdir(DIR_PATH);
+       } 
+       return (EROFS_clean() && output2);
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EROFS.h
new file mode 100644 (file)
index 0000000..23ad51d
--- /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_EROFS_h__
+#define __test_yaffs_mkdir_EROFS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mkdir_EROFS(void);
+int test_yaffs_mkdir_EROFS_clean(void);
+
+#endif