yaffs More quick tests added.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 23:06:54 +0000 (12:06 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 9 Nov 2010 01:02:35 +0000 (14:02 +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/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h [new file with mode: 0644]

index 6aeb346487cc5c311fef0d8bbb640a935b4a3050..cb13baa38d92c2200df11e1ca2ceac87dbc96e27 100644 (file)
@@ -54,7 +54,7 @@ TESTFILES =   quick_tests.o lib.o \
                test_yaffs_truncate.o test_yaffs_truncate_ENOTDIR.o test_yaffs_truncate_EISDIR.o test_yaffs_truncate_ENOENT.o test_yaffs_truncate_EINVAL.o \
                test_yaffs_truncate_EFBIG.o\
                test_yaffs_write.o \
-               test_yaffs_read.o \
+               test_yaffs_read.o test_yaffs_read_EBADF.o \
                test_yaffs_lseek.o test_yaffs_lseek_EBADF.o test_yaffs_lseek_EINVAL.o test_yaffs_lseek_EFBIG.o \
                test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o\
                test_yaffs_stat.o \
index 203f4014a286d711292925c20880680eaa94b1b7..cc5b036a7096942a3d27ba622a3db03532e01283 100644 (file)
@@ -36,6 +36,8 @@ Tests made
        test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests modes are needed.
 
        test_yaffs_read
+       test_yaffs_read_EBADF
+
        test_yaffs_stat
 
        test_yaffs_truncate
@@ -76,6 +78,11 @@ Tests to add
 
        test_yaffs_close        //This function has already been called by the time this test is reached.
        
+
+       test_yaffs_read_EINVAL  //test exists but is not finshed yet. 
+       test_yaffs_read_EISDIR          //Cannot be generated with yaffs.
+       test what happens if you read off the end of the file?
+
        test_yaffs_unlink_EACCES
        test_yaffs_unlink_ELOOP
        test_yaffs_unlink_ENOMEM
@@ -86,10 +93,10 @@ Tests to add
        test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
 
        test_yaffs_ftruncate_EACCES     
-       test_yaffs_ftruncate_EISDIR     //
-       test_yaffs_ftruncate_ELOOP      //
-       test_yaffs_ftruncate_ENOENT     //
-       test_yaffs_ftruncate_ENOTDIR    //
+       test_yaffs_ftruncate_EISDIR     //Cannot be generated with yaffs.
+       test_yaffs_ftruncate_ELOOP      //Cannot be generated with yaffs.
+       test_yaffs_ftruncate_ENOENT     //Cannot be generated with yaffs.
+       test_yaffs_ftruncate_ENOTDIR    //Cannot be generated with yaffs.
 
        test_yaffs_truncate_EACCES
        test_yaffs_truncate_ELOOP
index d05167bfed437c667f571f0e2444f847e7786b08..fd75a739921580cc6820825347c65848547c1aee 100644 (file)
@@ -58,7 +58,9 @@
 #include "test_yaffs_truncate_EFBIG.h"
 
 #include "test_yaffs_write.h"
+
 #include "test_yaffs_read.h"
+#include "test_yaffs_read_EBADF.h"
 
 #include "test_yaffs_lseek.h"
 #include "test_yaffs_lseek_EBADF.h"
@@ -125,8 +127,9 @@ test_template test_list[]={
        {test_yaffs_lseek_EFBIG,test_yaffs_lseek_EFBIG_clean,"test_yaffs_lseek_EFBIG"},
 
        {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
-       {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
 
+       {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
+       {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
 
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c
new file mode 100644 (file)
index 0000000..073f329
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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_read_EBADF.h"
+
+int test_yaffs_read_EBADF(void){
+       int error_code=0;
+       int output=0;
+       char text[100];
+       text[0] ='\0';
+       output=yaffs_read(-1, text, FILE_TEXT_NBYTES);
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==EBADF){
+                       return 1;
+               }
+               else {
+                       printf("returned error does not match the the expected error\n");
+                       return -1;
+               }
+       }
+       else{
+               printf("read a non-existing file (which is a bad thing)\n");
+               return -1;
+       }       
+}
+
+int test_yaffs_read_EBADF_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h
new file mode 100644 (file)
index 0000000..845148f
--- /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_read_EBADF_h__
+#define __test_yaffs_read_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+
+int test_yaffs_read_EBADF(void);
+int test_yaffs_read_EBADF_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c
new file mode 100644 (file)
index 0000000..7e7d43e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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_read_EBADF.h"
+
+static int handle=0;
+
+int test_yaffs_read_EBADF(void){
+       handle=test_yaffs_open();
+       char text[20]="\0";
+       int output=0;
+       //printf("handle %d\n",handle);
+       if (handle>=0){
+               output=yaffs_read(-1, text, FILE_TEXT_NBYTES);
+               //printf("yaffs_test_read output: %d\n",output);
+               //printf("text in file is: '%s' expected text is '%s'\n",text,FILE_TEXT);
+               if (output<0){ 
+                       if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
+                               return 1;
+                       }
+                       else {
+                               printf("returned error does not match the the expected error\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("read a non-existing file (which is a bad thing)\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+       
+}
+
+int test_yaffs_read_EBADF_clean(void){
+       return yaffs_close(handle);
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h
new file mode 100644 (file)
index 0000000..845148f
--- /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_read_EBADF_h__
+#define __test_yaffs_read_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+
+int test_yaffs_read_EBADF(void);
+int test_yaffs_read_EBADF_clean(void);
+#endif