yaffs more tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 10 Nov 2010 03:15:33 +0000 (16:15 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 10 Nov 2010 03:15:33 +0000 (16:15 +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/current_bugs.txt
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_fstat.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fstat.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_write_EFBIG.c

index 58dabc0c223ad063581ee4a1c07213eb33f6c167..a22592a6e6842b0f74d0d4d9f94d961097fc7748 100644 (file)
@@ -57,7 +57,8 @@ 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_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 \
+               test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o \
+               test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \
                test_yaffs_close_EBADF.o
                  
 
index 2a5892fa76f55ddb1faf27fbe770a4ee4f1f4e86..b7b17b0990dce98de031af82976531f6020d595c 100644 (file)
@@ -41,6 +41,11 @@ Tests made
 
 
        test_yaffs_stat
+       test_yaffs_stat_ENOENT
+       test_yaffs_stat_ENOTDIR
+
+       test_yaffs_fstat
+       test_yaffs_fstat_EBADF
 
        test_yaffs_truncate
        test_yaffs_truncate_ENOTDIR
@@ -102,6 +107,9 @@ Tests to add
        test_yaffs_unlink_ELOOP
        test_yaffs_unlink_ENOMEM
 
+       test_yaffs_stat_EACCES
+       test_yaffs_stat_ELOOP
+
        test_yaffs_access_EACCESS
        test_yaffs_access_ELOOP
        test_yaffs_access_ENAMETOOLONG
@@ -116,7 +124,7 @@ Tests to add
        test_yaffs_truncate_EACCES
        test_yaffs_truncate_ELOOP
        test_yaffs_truncate_ENAMETOOLONG
-       add a truncate function for truncating a file size to -1.
+       Add a truncate function for truncating a file size to -1.
 
        What happens if a handle is opened to a file and the file is then deleted?
        Check to see if yaffs generates an error code for no reason.
index 64a7bde760c46a381def678ccef6b4a2db7ea687..6435529689b0fb566db762a5b27f3237eeadae1f 100644 (file)
@@ -27,6 +27,9 @@ Current BUGS
                Bug when trying to truncate a file in a non-existing directory. The error
                returned is ENOENT it should be ENOTDIR.
 
+               Bug when trying to stat a file in a non-existing directory. The error 
+               returned is ENOENT, it should be ENOTDIR 
+
        Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors.
        The function should return the error EINVAL. 
 
@@ -35,13 +38,31 @@ Current BUGS
 
        Bug with unmounting a non-existing mountpoint. The function returns ENODEV 
        but should be returning EINVAL.
-       
-       Bug with reading -1 bytes of a file without an error (test is in test_yaffs_read_EINVAL).
-       It should return EINVAL.
 
        Unmount2 forcing the unmount needs to break the handles so they return EBADF.
 
-       A read of -1 bytes tries to read 4 gig of data 
+       Bug with reading -1 bytes of a file without an error (test is in test_yaffs_read_EINVAL).
+       It should return EINVAL. This is because it was reading an empty file. 
+       When text is added to the file a read of -1 bytes tries to read 4 gig of data 
+
+       Bug when writing a file. the writhing to the file causes the file size to exceed the size of yaffs file system memory.
+       Output of test:
+               test_yaffs_write_EFBIG 
+               AddrToChunk of offset -2147483648 gives chunk -1048576 start 0
+               AddrToChunk of offset -2147481600 gives chunk -1048575 start 0
+               AddrToChunk of offset -2147479552 gives chunk -1048574 start 0  
+               AddrToChunk of offset -2147477504 gives chunk -1048573 start 0
+               AddrToChunk of offset -2147475456 gives chunk -1048572 start 0
+               AddrToChunk of offset -2147473408 gives chunk -1048571 start 0
+               AddrToChunk of offset -2147471360 gives chunk -1048570 start 0
+               AddrToChunk of offset -2147469312 gives chunk -1048569 start 0  
+               AddrToChunk of offset -2147467264 gives chunk -1048568 start 0
+               AddrToChunk of offset -2147465216 gives chunk -1048567 start 0
+               wrote a large amount of text to a file.(which is a bad thing)
+               test: test_yaffs_write_EFBIG failed
+               yaffs_error code 0
+               error is : Unknown error code
+
 
 Current WARNINGS
        
index 32745401c65b2a960bb8b1bdbdf2257d2bff7d8f..a11386d255070e1a1f6e7d77d7380ffb640196d2 100644 (file)
 #include "test_yaffs_access_ENOENT.h"
 
 #include "test_yaffs_stat.h"
+#include "test_yaffs_stat_ENOENT.h"
+#include "test_yaffs_stat_ENOTDIR.h"
+
+#include "test_yaffs_fstat.h"
+#include "test_yaffs_fstat_EBADF.h"
+
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
 #include "lib.h"
@@ -144,6 +150,11 @@ test_template test_list[]={
        {test_yaffs_read_EINVAL,test_yaffs_read_EINVAL_clean,"test_yaffs_read_EINVAL"},
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
+       {test_yaffs_stat_ENOENT,test_yaffs_stat_ENOENT_clean,"test_yaffs_stat_ENOENT"},
+       {test_yaffs_stat_ENOTDIR,test_yaffs_stat_ENOTDIR_clean,"test_yaffs_stat_ENOTDIR"},
+
+       {test_yaffs_fstat,test_yaffs_fstat_clean,"test_yaffs_fstat"},
+       {test_yaffs_fstat_EBADF,test_yaffs_fstat_EBADF_clean,"test_yaffs_fstat_EBADF"},
 
        {test_yaffs_ftruncate,test_yaffs_ftruncate_clean,"test_yaffs_ftruncate"},
        {test_yaffs_ftruncate_EBADF,test_yaffs_ftruncate_EBADF_clean,"test_yaffs_ftruncate_EBADF"},
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat.c b/direct/timothy_tests/quick_tests/test_yaffs_fstat.c
new file mode 100644 (file)
index 0000000..7345161
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_fstat.h"
+
+static int handle=0;
+int test_yaffs_fstat(void){
+       struct yaffs_stat stat;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               return  yaffs_fstat(handle , &stat);;
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+}
+
+int test_yaffs_fstat_clean(void){
+       if (handle<0){
+               return yaffs_close(handle);
+       }
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat.h b/direct/timothy_tests/quick_tests/test_yaffs_fstat.h
new file mode 100644 (file)
index 0000000..3fc0223
--- /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_fstat_h__
+#define __test_yaffs_fstat_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_fstat(void);
+int test_yaffs_fstat_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c
new file mode 100644 (file)
index 0000000..e44482d
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_fstat_EBADF.h"
+
+
+int test_yaffs_fstat_EBADF(void){
+       int output=0;
+       struct yaffs_stat stat;
+       int error_code=0;
+       output=yaffs_fstat(-1 , &stat);
+       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_fstat_EBADF_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h
new file mode 100644 (file)
index 0000000..4d24916
--- /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_fstat_EBADF_h__
+#define __test_yaffs_fstat_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_fstat_EBADF(void);
+int test_yaffs_fstat_EBADF_clean(void); 
+#endif
index 9a47c39046e027902ea0095e49a365e730dd2568..ddab41869192c878cf57fc4d5969ba6ecf051bb9 100644 (file)
@@ -46,6 +46,9 @@ int test_yaffs_ftruncate_EINVAL(void){
 }
 
 int test_yaffs_ftruncate_EINVAL_clean(void){
+       if (handle<0){
+               return yaffs_close(handle);
+       }
        return 1;
        
 }
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c
new file mode 100644 (file)
index 0000000..c6ee58b
--- /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_stat_ENOENT.h"
+
+int test_yaffs_stat_ENOENT(void){
+       int error_code=0;
+       struct yaffs_stat stat;
+       int output=0;
+       char text[100];
+       text[0] ='\0';
+       output=yaffs_stat("/yaffs2/non-existing_file", &stat);;
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOENT){
+                       return 1;
+               }
+               else {
+                       printf("returned error does not match the the expected error\n");
+                       return -1;
+               }
+       }
+       else{
+               printf("stated a non-existing file (which is a bad thing)\n");
+               return -1;
+       }       
+}
+
+int test_yaffs_stat_ENOENT_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h
new file mode 100644 (file)
index 0000000..b6d6b20
--- /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_stat_ENOENT_h__
+#define __test_yaffs_stat_ENOENT_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+
+int test_yaffs_stat_ENOENT(void);
+int test_yaffs_stat_ENOENT_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c
new file mode 100644 (file)
index 0000000..db38d16
--- /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_stat_ENOTDIR.h"
+
+int test_yaffs_stat_ENOTDIR(void){
+       int error_code=0;
+       struct yaffs_stat stat;
+       int output=0;
+       char text[100];
+       text[0] ='\0';
+       output=yaffs_stat("/non-existing-dir/foo", &stat);;
+       if (output<0){ 
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOTDIR){
+                       return 1;
+               }
+               else {
+                       printf("returned error does not match the the expected error\n");
+                       return -1;
+               }
+       }
+       else{
+               printf("stated a non-existing file (which is a bad thing)\n");
+               return -1;
+       }       
+}
+
+int test_yaffs_stat_ENOTDIR_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h
new file mode 100644 (file)
index 0000000..85ca669
--- /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_stat_ENOTDIR_h__
+#define __test_yaffs_stat_ENOTDIR_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+
+int test_yaffs_stat_ENOTDIR(void);
+int test_yaffs_stat_ENOTDIR_clean(void);
+#endif
index a61d3dfc0fa73fc0fe1573c2c518df727c081dd2..bfc591ea6b09c0eb0632bd3bcd191d31950cc667 100644 (file)
@@ -22,8 +22,16 @@ int test_yaffs_write_EFBIG(void)
        handle=test_yaffs_open();
        int x=0;
        
-       long int file_name_length=100000000000;
-
+       int file_name_length=20000;
+       if (handle<0){
+               printf("failed to open file\n");
+               return -1;
+       }
+       output=yaffs_lseek(handle,0x7FFFFF00, SEEK_SET);
+       if (output<0){
+               printf("failed to seek\n");
+               return -1;
+       }
        file_name = malloc(file_name_length);
        if(!file_name){
                printf("unable to create file text\n");