yaffs More quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 16 Nov 2010 00:40:50 +0000 (13:40 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 16 Nov 2010 00:40:50 +0000 (13:40 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
15 files changed:
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_fdatasync.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fdatasync.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fsync.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fsync.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h [new file with mode: 0644]

index a966301..6e298b4 100644 (file)
@@ -61,7 +61,10 @@ TESTFILES =  quick_tests.o lib.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_fchmod.o test_yaffs_fchmod_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
                  
 
 YAFFSTESTOBJS  = $(COMMONTESTOBJS) $(TESTFILES)
index 7ebc1fb..74d512a 100644 (file)
@@ -22,6 +22,12 @@ Tests made
 
        test_yaffs_close_EBADF
 
+       test_yaffs_fdatasync
+       test_yaffs_fdatasync_EBADF
+
+       test_yaffs_fsync
+       test_yaffs_fsync_EBADF  
+
        test_yaffs_ftruncate
        test_yaffs_ftruncate_EBADF
        test_yaffs_ftruncate_ENIVAL
@@ -85,12 +91,6 @@ Tests to add
        test_yaffs_chmod_ELOOP
        test_yaffs_chmod_ENAMETOOLONG
 
-       test_yaffs_fsync
-       test_yaffs_fsync_EBADF  
-
-       test_yaffs_datasync
-       test_yaffs_datasync_EBADF
-
        test_yaffs_lstat
        test_yaffs_lstat_EACCES
        test_yaffs_lstat_ENOTDIR
index 110e3ee..12bd6af 100644 (file)
 #include "test_yaffs_fchmod.h"
 #include "test_yaffs_fchmod_EBADF.h"
 
+#include "test_yaffs_fsync.h"
+#include "test_yaffs_fsync_EBADF.h"
+
+#include "test_yaffs_fdatasync.h"
+#include "test_yaffs_fdatasync_EBADF.h"
+
+#include "test_yaffs_mkdir.h"
+
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
 #include "lib.h"
@@ -181,7 +189,15 @@ test_template test_list[]={
        {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"},
 
        {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"},
-       {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"}
+       {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"},
+
+       {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_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"}
        };
 
 void init_quick_tests(int argc, char *argv[]);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.c b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.c
new file mode 100644 (file)
index 0000000..7711d50
--- /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_fdatasync.h"
+
+static int handle = 0;
+
+int test_yaffs_fdatasync(void)
+{
+       handle = test_yaffs_open();
+       return yaffs_fdatasync(handle);
+}
+
+
+int test_yaffs_fdatasync_clean(void)
+{
+       if (handle >= 0){
+               return yaffs_close(handle);
+       } 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_fdatasync.h b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.h
new file mode 100644 (file)
index 0000000..905e691
--- /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_fdatasync_h__
+#define __test_yaffs_fdatasync_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_fdatasync(void);
+int test_yaffs_fdatasync_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c
new file mode 100644 (file)
index 0000000..edfbb95
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_fdatasync.h"
+
+
+
+int test_yaffs_fdatasync_EBADF(void)
+{
+       int output = 0;
+       int error_code = 0;
+       output = yaffs_fdatasync(-1);
+       if (output==-1){
+               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 file synced.(which is a bad thing)\n",2);
+               return -1;
+       }
+}
+
+
+int test_yaffs_fdatasync_EBADF_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h
new file mode 100644 (file)
index 0000000..d562c56
--- /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_fdatasync_EBADF_h__
+#define __test_yaffs_fdatasync_EBADF_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_fdatasync_EBADF(void);
+int test_yaffs_fdatasync_EBADF_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync.c b/direct/timothy_tests/quick_tests/test_yaffs_fsync.c
new file mode 100644 (file)
index 0000000..cff6ac1
--- /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_fsync.h"
+
+static int handle = 0;
+
+int test_yaffs_fsync(void)
+{
+       handle = test_yaffs_open();
+       return yaffs_fsync(handle);
+}
+
+
+int test_yaffs_fsync_clean(void)
+{
+       if (handle >= 0){
+               return yaffs_close(handle);
+       } 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_fsync.h b/direct/timothy_tests/quick_tests/test_yaffs_fsync.h
new file mode 100644 (file)
index 0000000..cbb9e0f
--- /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_fsync_h__
+#define __test_yaffs_fsync_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_fsync(void);
+int test_yaffs_fsync_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c
new file mode 100644 (file)
index 0000000..3f6e0c2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_fsync.h"
+
+
+
+int test_yaffs_fsync_EBADF(void)
+{
+       int output = 0;
+       int error_code = 0;
+       output = yaffs_fsync(-1);
+       if (output==-1){
+               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 file synced.(which is a bad thing)\n",2);
+               return -1;
+       }
+}
+
+
+int test_yaffs_fsync_EBADF_clean(void)
+{
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.h
new file mode 100644 (file)
index 0000000..fb689bb
--- /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_fsync_EBADF_h__
+#define __test_yaffs_fsync_EBADF_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_fsync_EBADF(void);
+int test_yaffs_fsync_EBADF_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c
new file mode 100644 (file)
index 0000000..aedaa80
--- /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_mkdir.h"
+
+static int handle = 0;
+
+int test_yaffs_mkdir(void)
+{
+       handle = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+       return handle;
+}
+
+
+int test_yaffs_mkdir_clean(void)
+{
+       if (handle >= 0){
+               return yaffs_rmdir("/yaffs2/new_directory/");
+       } 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_mkdir.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.h
new file mode 100644 (file)
index 0000000..b59b454
--- /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_h__
+#define __test_yaffs_mkdir_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mkdir(void);
+int test_yaffs_mkdir_clean(void);
+
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c
new file mode 100644 (file)
index 0000000..9948393
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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_EEXISTS.h"
+
+static int output = -1;
+
+int test_yaffs_mkdir_EEXISTS(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;
+       }
+       output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+       if (output < 0){
+               error_code = yaffs_get_error();
+               if (abs(error_code) == EEXISTS){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n", 2);
+                       return -1;
+               }
+       } else {
+               print_message("lseeked to a negative position (which is a bad thing)\n", 2);
+               return -1;
+       }
+}
+
+
+int test_yaffs_mkdir_EEXISTS_clean(void)
+{
+       if (output >= 0){
+               return yaffs_rmdir("/yaffs2/new_directory/");
+       } else {
+               return 1;       
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h
new file mode 100644 (file)
index 0000000..16d5bfe
--- /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_EEXISTS_h__
+#define __test_yaffs_mkdir_EEXISTS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mkdir_EEXISTS(void);
+int test_yaffs_mkdir_EEXISTS_clean(void);
+
+#endif