yaffs More tests added to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Thu, 25 Nov 2010 23:28:21 +0000 (12:28 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Thu, 25 Nov 2010 23:28:21 +0000 (12:28 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/lib.c
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h [new file with mode: 0644]

index e0bbdf944b5cc7b8e054c1c3ab6d03742b4d197e..70750a1b174ccb706e00e7e4117e75c1e566d304 100644 (file)
@@ -58,7 +58,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_read.o test_yaffs_read_EBADF.o test_yaffs_read_EINVAL.o\
                test_yaffs_lseek.o test_yaffs_lseek_EBADF.o test_yaffs_lseek_EINVAL.o test_yaffs_lseek_big_file.o \
                test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o \
-               test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP.o \
+               test_yaffs_access_ENOENT2.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_fstat.o test_yaffs_fstat_EBADF.o \
                test_yaffs_close_EBADF.o\
index f79bc79eca409ac2bbeaec4ec1a2d44a392a485d..bbeb0d77eb72688d05b3d804d5072d2524a28bcb 100644 (file)
@@ -28,6 +28,9 @@ test_yaffs_fchmod_EINVAL.c
 test_yaffs_fdatasync.c
 test_yaffs_fdatasync_EBADF.c
 
+test_yaffs_flush
+test_yaffs_flush_EBADF 
+
 test_yaffs_freespace.c
 test_yaffs_freespace_EINVAL.c
 
@@ -187,7 +190,6 @@ Tests to add
 
        
        test_yaffs_mkdir_EACCES
-       test_yaffs_mkdir_ELOOP
        test_yaffs_mkdir_ENAMETOOLONG
        test_yaffs_mkdir_EROFS
 
@@ -238,9 +240,6 @@ Tests to add
        test_yaffs_dup
        test_yaffs_dup_EBADF            
 
-       test_yaffs_flush
-       test_yaffs_flush_EBADF  
-       
        test_yaffs_fchmod_EACCES
        test_yaffs_fchmod_ELOOP
 
index bc004043d11b33b87006fbe941feac8e220ac166..e29764565337d63412b29e24768985b74c8930d8 100644 (file)
@@ -34,6 +34,29 @@ int get_exit_on_error(void)
 }
 
 
+int EROFS_setup(void)
+{
+       int output= -1;
+       output=yaffs_remount(YAFFS_MOUNT_POINT,1,1);
+       if (output<0){
+               print_message("failed to remount yaffs\n",2);
+               return -1;
+       }
+       return 1;
+}
+
+int EROFS_clean(void)
+{
+       int output=-1;
+       output= yaffs_remount(YAFFS_MOUNT_POINT,1,0);
+       if (output<0){
+               print_message("failed to remount yaffs\n",2);
+               return -1;
+       }
+       return 1;
+}
+
+
 int set_up_ELOOP(void){
        int output1=1;
        int output2=1;
index f24e3aaf22edd62b21b78a1e6a281f81e728d938..fdb28fead0a90ea25ef45b1d343c847a1e33d2e6 100644 (file)
@@ -21,7 +21,7 @@
 #include "yaffsfs.h"
 
 
-#define ELOOP 10       //the error code ELOOP is not defined yet so I'm making a stand in.
+
 
 
 #define YAFFS_MOUNT_POINT "/yaffs2/"
@@ -57,4 +57,6 @@ void set_print_level(int new_level);
 void set_exit_on_error(int num);
 int get_exit_on_error(void);
 int set_up_ELOOP(void);
+int EROFS_setup(void);
+int EROFS_clean(void);
 #endif
index e7a6b149661c3b508c0eb72672e5fc98b3bca643..2e5fee310e2f18b97588c014b0d9214504b1b782 100644 (file)
@@ -82,6 +82,7 @@
 #include "test_yaffs_access_ENOENT.h"
 #include "test_yaffs_access_ENOENT2.h"
 #include "test_yaffs_access_ELOOP.h"
+#include "test_yaffs_access_EROFS.h"
 
 #include "test_yaffs_stat.h"
 #include "test_yaffs_stat_ENOENT.h"
@@ -98,6 +99,7 @@
 #include "test_yaffs_chmod_EINVAL.h"
 #include "test_yaffs_chmod_ENOENT2.h"
 #include "test_yaffs_chmod_ELOOP.h"
+#include "test_yaffs_chmod_EROFS.h"
 
 #include "test_yaffs_fchmod.h"
 #include "test_yaffs_fchmod_EBADF.h"
@@ -226,6 +228,7 @@ test_template test_list[]={
        {test_yaffs_access_ENOENT,test_yaffs_access_ENOENT_clean,"test_yaffs_access_ENOENT"},
        {test_yaffs_access_ENOENT2,test_yaffs_access_ENOENT2_clean,"test_yaffs_access_ENOENT2"},
        {test_yaffs_access_ELOOP,test_yaffs_access_ELOOP_clean,"test_yaffs_access_ELOOP"},
+       {test_yaffs_access_EROFS,test_yaffs_access_EROFS_clean,"test_yaffs_access_EROFS"},
 
        {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"},
        {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"},
@@ -277,6 +280,8 @@ test_template test_list[]={
        {test_yaffs_chmod_ENOTDIR,test_yaffs_chmod_ENOTDIR_clean,"test_yaffs_chmod_ENOTDIR"},
        {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"},
        {test_yaffs_chmod_ELOOP,test_yaffs_chmod_ELOOP_clean,"test_yaffs_chmod_ELOOP"},
+       {test_yaffs_chmod_EROFS,test_yaffs_chmod_EROFS_clean,"test_yaffs_chmod_EROFS"},
+
        {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"},
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c
new file mode 100644 (file)
index 0000000..5944ec1
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_access_EROFS.h"
+
+int test_yaffs_access_EROFS(void)
+{
+       int output=0;
+       int error=0;
+       if (EROFS_setup() < 0 ){
+               return -1;
+       }
+
+       output= yaffs_access(FILE_PATH,R_OK |W_OK);
+       if (output<0){
+               error=yaffs_get_error();
+               if ( abs(error)== EROFS){
+                       return 1;
+               } else {
+                       print_message("error does not match expected error\n",2);
+                       return -1;
+               }
+       } else{
+               print_message("accessed an existing file with the file system mounted as read only (which is a bad thing)\n",2);
+
+               return -1;
+       }
+}
+
+int test_yaffs_access_EROFS_clean(void)
+{
+       return EROFS_clean();
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h
new file mode 100644 (file)
index 0000000..ebf91fb
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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__access_EROFS_h__
+#define __test_yaffs_access_EROFS_h__
+#include "lib.h"
+#include "yaffsfs.h"
+int test_yaffs_access_EROFS(void);
+int test_yaffs_access_EROFS_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c
new file mode 100644 (file)
index 0000000..fef37e5
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_chmod_EROFS.h"
+
+int test_yaffs_chmod_EROFS(void)
+{
+       int error=0;
+       int output;
+
+       EROFS_setup();
+
+       output = yaffs_chmod(FILE_PATH,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 setup (which is a bad thing)\n",2);
+               return -1;
+       }
+
+}
+
+int test_yaffs_chmod_EROFS_clean(void)
+{
+       return test_yaffs_chmod() | EROFS_clean();
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h
new file mode 100644 (file)
index 0000000..9b3f2d3
--- /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_chmod_EROFS_h__
+#define __test_yaffs_chmod_EROFS_h__
+       
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_chmod.h"
+
+int test_yaffs_chmod_EROFS(void);      
+int test_yaffs_chmod_EROFS_clean(void);
+
+#endif