From: Timothy Manning Date: Mon, 8 Nov 2010 03:50:06 +0000 (+1300) Subject: yaffs More tests for quick tests. X-Git-Tag: linux-mainline-patchset-4~110^2~5 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=a8fba94306bc6fcaf7d546a3276c12a168ed6261 yaffs More tests for quick tests. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 3567b88..4db4430 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -48,9 +48,11 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_ENOENT.o test_yaffs_mount_EBUSY.o \ test_yaffs_unmount.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_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_lseek.o \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 5134478..8487ac6 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -24,6 +24,8 @@ Tests made test_yaffs_open_ENAMETOOLONG test_yaffs_open_ENOENT test_yaffs_open_ENOTDIR + test_yaffs_open_EINVAL + test_yaffs_open_EINVAL2 //the function open has to modes which can be set, so two modes are needed. test_yaffs_read test_yaffs_stat @@ -33,6 +35,7 @@ Tests made test_yaffs_truncate_EISDIR test_yaffs_truncate_ENOENT test_yaffs_truncate_ENIVAL + test_yaffs_truncate_EFBIG test_yaffs_unlink test_yaffs_unlink_EISDIR @@ -80,13 +83,11 @@ Tests to add test_yaffs_ftruncate_ELOOP test_yaffs_ftruncate_ENOENT test_yaffs_ftruncate_ENOTDIR - test_yaffs_ftruncate_EPERM test_yaffs_truncate_EACCES - test_yaffs_truncate_EFBIG test_yaffs_truncate_ELOOP test_yaffs_truncate_ENAMETOOLONG - test_yaffs_truncate_EPERM + check to see if an error code is generated when there isn't an error. diff --git a/direct/timothy_tests/quick_tests/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt index 3ecd20c..d2b4a48 100644 --- a/direct/timothy_tests/quick_tests/current_bugs.txt +++ b/direct/timothy_tests/quick_tests/current_bugs.txt @@ -27,6 +27,16 @@ Current BUGS Bug truncating a file to a size of -1 does not cause an error. + BUG truncating a file to a size greater than the maximum file size should + return the error EFBIG. However EFBIG has not been defined in yaffs and + needs to be added. When a file is truncated to a large size + (size =10000000000000000000000000000000000000000000) the truncate + function works without any errors, which is wrong. + + Bug with opening a file with bad mode. yaffs_open has two modes which + are passed into it. if the modes are set to 255 the open function + does not report any errors. (Also need to try this with modes set to -1.) + Current WARNINGS WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index ecde804..decc191 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -31,6 +31,8 @@ #include "test_yaffs_open_ENOENT.h" #include "test_yaffs_open_ENOTDIR.h" #include "test_yaffs_open_ENAMETOOLONG.h" +#include "test_yaffs_open_EINVAL.h" +#include "test_yaffs_open_EINVAL2.h" #include "test_yaffs_close_EBADF.h" @@ -49,6 +51,7 @@ #include "test_yaffs_truncate_EISDIR.h" #include "test_yaffs_truncate_ENOENT.h" #include "test_yaffs_truncate_EINVAL.h" +#include "test_yaffs_truncate_EFBIG.h" #include "test_yaffs_write.h" #include "test_yaffs_read.h" @@ -90,6 +93,8 @@ test_template test_list[]={ {test_yaffs_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"}, {test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"}, {test_yaffs_open_ENAMETOOLONG,test_yaffs_open_ENAMETOOLONG_clean,"test_yaffs_open_ENAMETOOLONG"}, + {test_yaffs_open_EINVAL,test_yaffs_open_EINVAL_clean,"test_yaffs_open_EINVAL"}, + {test_yaffs_open_EINVAL2,test_yaffs_open_EINVAL2_clean,"test_yaffs_open_EINVAL2"}, {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"}, @@ -118,7 +123,8 @@ test_template test_list[]={ {test_yaffs_truncate_ENOTDIR,test_yaffs_truncate_ENOTDIR_clean,"test_yaffs_truncate_ENOTDIR"}, {test_yaffs_truncate_EISDIR,test_yaffs_truncate_EISDIR_clean,"test_yaffs_truncate_EISDIR"}, {test_yaffs_truncate_EINVAL,test_yaffs_truncate_EINVAL_clean,"test_yaffs_truncate_EINVAL"}, - {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"} + {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"}, + {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"} }; void init_quick_tests(void); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c new file mode 100644 index 0000000..5a2ec4d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c @@ -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 + * + * 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_EINVAL.h" + +static int handle=0; +int test_yaffs_open_EINVAL(void){ + int output=0; + int error_code=0; + /*printf("path %s\n",path); */ + handle=yaffs_open(FILE_PATH, 255,FILE_MODE); + if (handle==-1){ + error_code=yaffs_get_error(); + //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code); + if (abs(error_code)== EINVAL){ + return 1; + } + else { + printf("different error than expected\n"); + return -1; + } + } + else { + printf(" file opened with bad mode.(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_EINVAL_clean(void){ + if (handle >=0){ + return yaffs_close(handle); + } + else { + return -1; /* the file failed to open so there is no need to close it*/ + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h new file mode 100644 index 0000000..85597da --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h @@ -0,0 +1,24 @@ +/* + * 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 + * + * 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_EINVAL_h__ +#define __test_yaffs_open_EINVAL_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_open_EINVAL(void); +int test_yaffs_open_EINVAL_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c new file mode 100644 index 0000000..cdab776 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c @@ -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 + * + * 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_EINVAL2.h" + +static int handle=0; +int test_yaffs_open_EINVAL2(void){ + int output=0; + int error_code=0; + /*printf("path %s\n",path); */ + handle=yaffs_open(FILE_PATH, O_CREAT | O_RDWR ,255); + if (handle==-1){ + error_code=yaffs_get_error(); + //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code); + if (abs(error_code)== EINVAL){ + return 1; + } + else { + printf("different error than expected\n"); + return -1; + } + } + else { + printf(" file opened with bad mode.(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_EINVAL2_clean(void){ + if (handle >=0){ + return yaffs_close(handle); + } + else { + return 1; /* the file failed to open so there is no need to close it*/ + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h new file mode 100644 index 0000000..de35847 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h @@ -0,0 +1,24 @@ +/* + * 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 + * + * 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_EINVAL2_h__ +#define __test_yaffs_open_EINVAL2_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_open_EINVAL2(void); +int test_yaffs_open_EINVAL2_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c new file mode 100644 index 0000000..dd7cc86 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c @@ -0,0 +1,47 @@ +/* + * 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 + * + * 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_truncate_EFBIG.h" +static int handle=0; + +int test_yaffs_truncate_EFBIG(void){ + int error=0; + int output=0; + handle=test_yaffs_open(); + if (handle>=0){ + output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 ); + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==EINVAL){ + return 1; + } + else { + printf("recieved a different error than expected\n"); + return -1; + } + } + else{ + printf("truncated a file to a massive size\n"); + return -1; + } + + } + else { + printf("error opening file"); + return -1; + } +} + +int test_yaffs_truncate_EFBIG_clean(void){ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h new file mode 100644 index 0000000..15f0999 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h @@ -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 + * + * 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_truncate_EFBIG_h__ +#define __test_yaffs_truncate_EFBIG_h__ +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" +int test_yaffs_truncate_EFBIG(void); +int test_yaffs_truncate_EFBIG_clean(void); +#endif