yaffs Added a test to direct/timothy_tests/quick_test
authorTimothy Manning <tfhmanning@gmail.com>
Fri, 26 Nov 2010 04:17:38 +0000 (17:17 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Fri, 26 Nov 2010 04:17:38 +0000 (17:17 +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_fchmod_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h [new file with mode: 0644]

index f948b01455aeeca69b4ddb0c9a3ea8850d55aafb..252c635809d78e817225fc1257019cb466703062 100644 (file)
@@ -67,7 +67,7 @@ TESTFILES =   quick_tests.o lib.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_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.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_fdatasync.o test_yaffs_fdatasync_EBADF.o \
                test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o test_yaffs_mkdir_ENOENT.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_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o test_yaffs_mkdir_ENOENT.o \
index 1f128611ca93d28d348af370aa2d2532db28fe8a..876ff400b4e15798c7a35609bd216c44064fd647 100644 (file)
 #include "test_yaffs_fchmod.h"
 #include "test_yaffs_fchmod_EBADF.h"
 #include "test_yaffs_fchmod_EINVAL.h"
 #include "test_yaffs_fchmod.h"
 #include "test_yaffs_fchmod_EBADF.h"
 #include "test_yaffs_fchmod_EINVAL.h"
+#include "test_yaffs_fchmod_EROFS.h"
 
 #include "test_yaffs_fsync.h"
 #include "test_yaffs_fsync_EBADF.h"
 
 #include "test_yaffs_fsync.h"
 #include "test_yaffs_fsync_EBADF.h"
@@ -300,6 +301,7 @@ test_template test_list[]={
        {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_EINVAL,test_yaffs_fchmod_EINVAL_clean,"test_yaffs_fchmod_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_EINVAL,test_yaffs_fchmod_EINVAL_clean,"test_yaffs_fchmod_EINVAL"},
+       {test_yaffs_fchmod_EROFS,test_yaffs_fchmod_EROFS_clean,"test_yaffs_fchmod_EROFS"},
 
        {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,test_yaffs_fsync_clean,"test_yaffs_fsync"},
        {test_yaffs_fsync_EBADF,test_yaffs_fsync_EBADF_clean,"test_yaffs_fsync_EBADF"},
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c
new file mode 100644 (file)
index 0000000..0d733fa
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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_fchmod_EROFS.h"
+static int handle = -1;
+
+int test_yaffs_fchmod_EROFS(void)
+{
+       int error = 0;
+       int output = 0;
+       if (EROFS_setup() < 0 ){
+               return -1;
+       }
+       handle = test_yaffs_open();
+
+       if (handle < 0){
+               print_message("failed to open file\n",2);
+               return -1;
+       }
+
+       output = yaffs_fchmod(handle,S_IREAD|S_IWRITE);
+
+       if (output<0){
+               error=yaffs_get_error();
+               if (abs(error)==EROFS){
+                       return 1;
+               } else {
+                       print_message("different error than expected\n",2);
+                       return -1;
+               }
+       } else {
+               print_message("chmoded with EROFS (which is a bad thing)\n",2);
+               return -1;
+       }
+
+
+}
+
+int test_yaffs_fchmod_EROFS_clean(void)
+{
+       int output =-1;
+       if (handle >= 0) {
+               output= yaffs_close(handle);
+       }
+       return (EROFS_clean() && output);
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h
new file mode 100644 (file)
index 0000000..d360f63
--- /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_fchmod_EROFS_h__
+#define __test_yaffs_fchmod_EROFS_h__
+       
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_fchmod_EROFS(void);     
+int test_yaffs_fchmod_EROFS_clean(void);
+
+#endif