From: Timothy Manning Date: Wed, 10 Nov 2010 03:15:33 +0000 (+1300) Subject: yaffs more tests for quick tests. X-Git-Tag: linux-mainline-patchset-4~103 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=4adb62b1e4338eaa34d02fdcb0c5d99cebea6747 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 58dabc0..a22592a 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -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 diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 2a5892f..b7b17b0 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -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. diff --git a/direct/timothy_tests/quick_tests/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt index 64a7bde..6435529 100644 --- a/direct/timothy_tests/quick_tests/current_bugs.txt +++ b/direct/timothy_tests/quick_tests/current_bugs.txt @@ -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 diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 3274540..a11386d 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -79,6 +79,12 @@ #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 index 0000000..7345161 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat.c @@ -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 + * + * 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 index 0000000..3fc0223 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat.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_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 index 0000000..e44482d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c @@ -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 + * + * 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 index 0000000..4d24916 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat_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_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 diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c index 9a47c39..ddab418 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c @@ -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 index 0000000..c6ee58b --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.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_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 index 0000000..b6d6b20 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h @@ -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 + * + * 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 index 0000000..db38d16 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.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_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 index 0000000..85ca669 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h @@ -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 + * + * 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 diff --git a/direct/timothy_tests/quick_tests/test_yaffs_write_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_write_EFBIG.c index a61d3df..bfc591e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_write_EFBIG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_write_EFBIG.c @@ -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");