From: Timothy Manning Date: Mon, 8 Nov 2010 21:03:00 +0000 (+1300) Subject: yaffs More tests added to quick tests. X-Git-Tag: linux-mainline-patchset-4~110^2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=e0b53924703fe414a99dbf49682cf8459540a3e5;hp=-c yaffs More tests added to quick tests. Signed-off-by: Timothy Manning --- e0b53924703fe414a99dbf49682cf8459540a3e5 diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 4db4430..91ece44 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -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 \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 0a669e3..3b32b43 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -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 diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index 1f6a935..e057f12 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -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 { diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index decc191..3d5dc6a 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -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 index 0000000..e308906 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c @@ -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 + * + * 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 index 0000000..631150d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.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_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 index 0000000..3c99f1b --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c @@ -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 + * + * 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 index 0000000..0e10046 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_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_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 index 0000000..9a47c39 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c @@ -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 + * + * 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 index 0000000..d95bdb8 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.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_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 diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c index 5a2ec4d..17c5912 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c @@ -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*/ } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c index d86e081..b15156f 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c @@ -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){ diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c index dd7cc86..7ea85da 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c @@ -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 { diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c index 1fcfafe..bec53de 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c @@ -43,5 +43,5 @@ int test_yaffs_truncate_EINVAL(void){ } int test_yaffs_truncate_EINVAL_clean(void){ - return -1; + return 1; }