yaffs Added another test to direct/timothy_tests/quick_tests
authorTimothy Manning <tfhmanning@gmail.com>
Sun, 28 Nov 2010 23:13:51 +0000 (12:13 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Sun, 28 Nov 2010 23:13:51 +0000 (12:13 +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_open_EROFS.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EROFS.h [new file with mode: 0644]

index 9ea838e27228ef3279cffbe777a2d14ad470710c..8d25cd9cedee312c78b9a2cc4b5e52ebdaefe225 100644 (file)
@@ -50,7 +50,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_unmount.o test_yaffs_unmount_ENODEV.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \
                test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o \
                test_yaffs_open_ENAMETOOLONG.o test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o test_yaffs_open_ELOOP.o \
                test_yaffs_unmount.o test_yaffs_unmount_ENODEV.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \
                test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o \
                test_yaffs_open_ENAMETOOLONG.o test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o test_yaffs_open_ELOOP.o \
-               test_yaffs_open_ELOOP_dir.o \
+               test_yaffs_open_ELOOP_dir.o test_yaffs_open_EROFS.o \
                test_yaffs_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o \
                test_yaffs_unlink_ENOTDIR.o test_yaffs_unlink_ENOENT2.o test_yaffs_unlink_ELOOP_dir.o \
                test_yaffs_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_big_file.o \
                test_yaffs_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o \
                test_yaffs_unlink_ENOTDIR.o test_yaffs_unlink_ENOENT2.o test_yaffs_unlink_ELOOP_dir.o \
                test_yaffs_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_big_file.o \
index 246093e7ac28eb89ec082884eb454c022a05906a..336a1d7bfe317e8185143b9a5ebd21966ac63244 100644 (file)
@@ -37,6 +37,7 @@
 #include "test_yaffs_open_EINVAL2.h"
 #include "test_yaffs_open_ELOOP.h"
 #include "test_yaffs_open_ELOOP_dir.h"
 #include "test_yaffs_open_EINVAL2.h"
 #include "test_yaffs_open_ELOOP.h"
 #include "test_yaffs_open_ELOOP_dir.h"
+#include "test_yaffs_open_EROFS.h"
 
 #include "test_yaffs_close_EBADF.h"
 
 
 #include "test_yaffs_close_EBADF.h"
 
@@ -237,6 +238,7 @@ test_template test_list[]={
        {test_yaffs_open_EINVAL2,test_yaffs_open_EINVAL2_clean,"test_yaffs_open_EINVAL2"},
        {test_yaffs_open_ELOOP,test_yaffs_open_ELOOP_clean,"test_yaffs_open_ELOOP"},
        {test_yaffs_open_ELOOP_dir,test_yaffs_open_ELOOP_dir_clean,"test_yaffs_open_ELOOP_dir"},
        {test_yaffs_open_EINVAL2,test_yaffs_open_EINVAL2_clean,"test_yaffs_open_EINVAL2"},
        {test_yaffs_open_ELOOP,test_yaffs_open_ELOOP_clean,"test_yaffs_open_ELOOP"},
        {test_yaffs_open_ELOOP_dir,test_yaffs_open_ELOOP_dir_clean,"test_yaffs_open_ELOOP_dir"},
+       {test_yaffs_open_EROFS,test_yaffs_open_EROFS_clean,"test_yaffs_open_EROFS"},
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EROFS.c
new file mode 100644 (file)
index 0000000..5b85563
--- /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_open_EROFS.h"
+
+static int handle = -1;
+
+int test_yaffs_open_EROFS(void)
+{
+       int error_code = 0;
+       yaffs_unlink(FILE_PATH);
+       EROFS_setup();
+
+       handle = yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
+       if (handle == -1){
+               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("non existant file opened.(which is a bad thing)\n",2);
+               return -1;
+       }
+}
+
+int test_yaffs_open_EROFS_clean(void)
+{
+       int output =1;
+       if (handle >=0){
+               handle= yaffs_close(handle);
+       } 
+       return (EROFS_clean() && output);
+       
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EROFS.h
new file mode 100644 (file)
index 0000000..da82256
--- /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_open_EROFS_h__
+#define __test_yaffs_open_EROFS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EROFS(void);
+int test_yaffs_open_EROFS_clean(void);
+
+#endif