yaffs More tests added to quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 21:03:00 +0000 (10:03 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 21:03:00 +0000 (10:03 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
14 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c

index 4db44306eea8a1d04a0eab86ccee677b42545abc..91ece44fafdf3db210b981dd1271afa6cd2b7939 100644 (file)
@@ -50,7 +50,7 @@ TESTFILES =   quick_tests.o lib.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_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\
-               test_yaffs_ftruncate.o \
+               test_yaffs_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_EFBIG.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 \
index 0a669e3e5e9327373568a063c78c6e7bf298c8af..3b32b43395dbf5ea61493f4cf57a4e3408b1d589 100644 (file)
@@ -15,7 +15,11 @@ Tests made
        test_yaffs_access_ENOENT
 
        test_yaffs_close_EBADF
+
        test_yaffs_ftruncate
+       test_yaffs_ftruncate_EBADF
+       test_yaffs_ftruncate_ENIVAL
+
        test_yaffs_lseek
 
        test_yaffs_open
@@ -47,6 +51,7 @@ Tests made
        test_yaffs_unmount
        test_yaffs_write
 
+       add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog". 
 
 Tests to add
        test_yaffs_mount_EACCES         //Cannot be generated with yaffs.
@@ -78,7 +83,6 @@ Tests to add
 
        test_yaffs_ftruncate_EACCES
        test_yaffs_ftruncate_EFBIG
-       test_yaffs_ftruncate_ENIVAL
        test_yaffs_ftruncate_EISDIR
        test_yaffs_ftruncate_ELOOP
        test_yaffs_ftruncate_ENOENT
index 1f6a935cfc90af888d7bcd607760d9d833aae8d7..e057f1237fa331b0acf849b38c0fb4fb8489e037 100644 (file)
@@ -41,6 +41,7 @@ int main(){
                output=test_list[x].p_function();       /*run test*/
                if (output>=0){
                        /*test has passed*/
+                       printf("\ttest %s passed\n",test_list[x].name_of_test); 
                        num_of_tests_pass++;
                }
                else {
index decc191a997a2b8f79dfa85abb0445a6c07a5791..3d5dc6ab166422cebcde03320f6677927c6b6c6f 100644 (file)
@@ -45,6 +45,9 @@
 #include "test_yaffs_unlink_ENOENT.h"
 
 #include "test_yaffs_ftruncate.h"
+#include "test_yaffs_ftruncate_EBADF.h"
+#include "test_yaffs_ftruncate_EINVAL.h"
+#include "test_yaffs_ftruncate_EFBIG.h"
 
 #include "test_yaffs_truncate.h"
 #include "test_yaffs_truncate_ENOTDIR.h"
@@ -117,7 +120,11 @@ test_template test_list[]={
 
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
+
        {test_yaffs_ftruncate,test_yaffs_ftruncate_clean,"test_yaffs_ftruncate"},
+       {test_yaffs_ftruncate_EBADF,test_yaffs_ftruncate_EBADF_clean,"test_yaffs_ftruncate_EBADF"},
+       {test_yaffs_ftruncate_EINVAL,test_yaffs_ftruncate_EINVAL_clean,"test_yaffs_ftruncate_EINVAL"},
+       {test_yaffs_ftruncate_EFBIG,test_yaffs_ftruncate_EFBIG_clean,"test_yaffs_ftruncate_EFBIG"},
 
        {test_yaffs_truncate,test_yaffs_truncate_clean,"test_yaffs_truncate"},
        {test_yaffs_truncate_ENOTDIR,test_yaffs_truncate_ENOTDIR_clean,"test_yaffs_truncate_ENOTDIR"},
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c
new file mode 100644 (file)
index 0000000..e308906
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_ftruncate_EBADF.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EBADF(void){
+       int output=0;
+       int error_code=0;
+       output= yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED );
+       if (output<0){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+               if (abs(error_code)== EBADF){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant file truncated.(which is a bad thing)\n");
+               return -1;
+       }
+}
+
+int test_yaffs_ftruncate_EBADF_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h
new file mode 100644 (file)
index 0000000..631150d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_ftruncate_EBADF_h__
+#define __test_yaffs_ftruncate_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EBADF(void);
+int test_yaffs_ftruncate_EBADF_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c
new file mode 100644 (file)
index 0000000..3c99f1b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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_ftruncate_EFBIG.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EFBIG(void){
+       int output=0;
+       int error_code=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output=yaffs_ftruncate(handle,10000000000000000000000000000000);
+               if (output<0){
+                       error_code=yaffs_get_error();
+                       //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+                       if (abs(error_code)== EINVAL){  /* yaffs uses the error EINVAL instead of EFBIG */
+                               return 1;
+                       }
+                       else {
+                               printf("different error than expected\n");
+                               return -1;
+                       }
+               }
+               else {
+                       printf("file truncated to a very large size.(which is a bad thing)\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+
+       
+       
+}
+
+int test_yaffs_ftruncate_EFBIG_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h
new file mode 100644 (file)
index 0000000..0e10046
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_ftruncate_EFBIG_h__
+#define __test_yaffs_ftruncate_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EFBIG(void);
+int test_yaffs_ftruncate_EFBIG_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c
new file mode 100644 (file)
index 0000000..9a47c39
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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_ftruncate_EINVAL.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EINVAL(void){
+       int output=0;
+       int error_code=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output=yaffs_ftruncate(handle,-1 );
+               if (output<0){
+                       error_code=yaffs_get_error();
+                       //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+                       if (abs(error_code)== EINVAL){
+                               return 1;
+                       }
+                       else {
+                               printf("different error than expected\n");
+                               return -1;
+                       }
+               }
+               else {
+                       printf("file truncated to a negative size.(which is a bad thing)\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+
+       
+       
+}
+
+int test_yaffs_ftruncate_EINVAL_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h
new file mode 100644 (file)
index 0000000..d95bdb8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_ftruncate_EINVAL_h__
+#define __test_yaffs_ftruncate_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EINVAL(void);
+int test_yaffs_ftruncate_EINVAL_clean(void); 
+#endif
index 5a2ec4d172b9820a68d3632d9da8d3b9743354b7..17c5912ea116043063c9455a20d76ea24e2bc888 100644 (file)
@@ -42,7 +42,7 @@ int test_yaffs_open_EINVAL_clean(void){
                return yaffs_close(handle);
        }
        else {
-               return -1;      /* the file failed to open so there is no need to close it*/
+               return 1;       /* the file failed to open so there is no need to close it*/
        }
 }
 
index d86e081ff9215ff06a6a3085355f9f583cdcc797..b15156fa8a364690fd5edb6ae63604eedcc96a2f 100644 (file)
@@ -32,12 +32,11 @@ int test_yaffs_open_EISDIR(void){
                        return -1;
                }
        }
-       else if (output >=0){
+       else {
                printf("non existant directory opened.(which is a bad thing)\n");
                return -1;
        }
-       /* the program should not get here but the compiler is complaining */
-       return -1;
+
 }
 int test_yaffs_open_EISDIR_clean(void){
        if (handle >=0){
index dd7cc86b61bf6854078ab68a35210fe2c5ff9c9d..7ea85da00f06f532eec93151a8cb21b868d6379b 100644 (file)
@@ -22,7 +22,7 @@ int test_yaffs_truncate_EFBIG(void){
                output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
                if (output<0){
                        error=yaffs_get_error();
-                       if (abs(error)==EINVAL){
+                       if (abs(error)==EINVAL){        /*in yaffs EINVAL is used instead of EFBIG */
                                return 1;
                        }
                        else {
index 1fcfafeb7b9700c024d89f96986201973880ef9e..bec53dea41247da9576f1cd0037cacb0013f5dd2 100644 (file)
@@ -43,5 +43,5 @@ int test_yaffs_truncate_EINVAL(void){
 }
 
 int test_yaffs_truncate_EINVAL_clean(void){
-       return -1;
+       return 1;
 }