From: Timothy Manning Date: Mon, 8 Nov 2010 23:06:54 +0000 (+1300) Subject: yaffs More quick tests added. X-Git-Tag: linux-mainline-patchset-4~107 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=f2c8e9cf2b72e5ac6a776a1a1b188f8595e7c35c yaffs More quick tests added. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 6aeb346..cb13baa 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -54,7 +54,7 @@ TESTFILES = quick_tests.o lib.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_read.o test_yaffs_read_EBADF.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 \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 203f401..cc5b036 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -36,6 +36,8 @@ Tests made test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests modes are needed. test_yaffs_read + test_yaffs_read_EBADF + test_yaffs_stat test_yaffs_truncate @@ -76,6 +78,11 @@ Tests to add test_yaffs_close //This function has already been called by the time this test is reached. + + test_yaffs_read_EINVAL //test exists but is not finshed yet. + test_yaffs_read_EISDIR //Cannot be generated with yaffs. + test what happens if you read off the end of the file? + test_yaffs_unlink_EACCES test_yaffs_unlink_ELOOP test_yaffs_unlink_ENOMEM @@ -86,10 +93,10 @@ Tests to add test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link test_yaffs_ftruncate_EACCES - test_yaffs_ftruncate_EISDIR // - test_yaffs_ftruncate_ELOOP // - test_yaffs_ftruncate_ENOENT // - test_yaffs_ftruncate_ENOTDIR // + test_yaffs_ftruncate_EISDIR //Cannot be generated with yaffs. + test_yaffs_ftruncate_ELOOP //Cannot be generated with yaffs. + test_yaffs_ftruncate_ENOENT //Cannot be generated with yaffs. + test_yaffs_ftruncate_ENOTDIR //Cannot be generated with yaffs. test_yaffs_truncate_EACCES test_yaffs_truncate_ELOOP diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index d05167b..fd75a73 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -58,7 +58,9 @@ #include "test_yaffs_truncate_EFBIG.h" #include "test_yaffs_write.h" + #include "test_yaffs_read.h" +#include "test_yaffs_read_EBADF.h" #include "test_yaffs_lseek.h" #include "test_yaffs_lseek_EBADF.h" @@ -125,8 +127,9 @@ test_template test_list[]={ {test_yaffs_lseek_EFBIG,test_yaffs_lseek_EFBIG_clean,"test_yaffs_lseek_EFBIG"}, {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"}, - {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"}, + {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"}, + {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"}, {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c new file mode 100644 index 0000000..073f329 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c @@ -0,0 +1,40 @@ +/* + * 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_read_EBADF.h" + +int test_yaffs_read_EBADF(void){ + int error_code=0; + int output=0; + char text[100]; + text[0] ='\0'; + output=yaffs_read(-1, text, FILE_TEXT_NBYTES); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==EBADF){ + return 1; + } + else { + printf("returned error does not match the the expected error\n"); + return -1; + } + } + else{ + printf("read a non-existing file (which is a bad thing)\n"); + return -1; + } +} + +int test_yaffs_read_EBADF_clean(void){ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h new file mode 100644 index 0000000..845148f --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.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_read_EBADF_h__ +#define __test_yaffs_read_EBADF_h__ +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + + +int test_yaffs_read_EBADF(void); +int test_yaffs_read_EBADF_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c new file mode 100644 index 0000000..7e7d43e --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c @@ -0,0 +1,50 @@ +/* + * 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_read_EBADF.h" + +static int handle=0; + +int test_yaffs_read_EBADF(void){ + handle=test_yaffs_open(); + char text[20]="\0"; + int output=0; + //printf("handle %d\n",handle); + if (handle>=0){ + output=yaffs_read(-1, text, FILE_TEXT_NBYTES); + //printf("yaffs_test_read output: %d\n",output); + //printf("text in file is: '%s' expected text is '%s'\n",text,FILE_TEXT); + if (output<0){ + if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){ + return 1; + } + else { + printf("returned error does not match the the expected error\n"); + return -1; + } + } + else{ + printf("read a non-existing file (which is a bad thing)\n"); + return -1; + } + } + else { + printf("error opening file\n"); + return -1; + } + +} + +int test_yaffs_read_EBADF_clean(void){ + return yaffs_close(handle); +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h new file mode 100644 index 0000000..845148f --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.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_read_EBADF_h__ +#define __test_yaffs_read_EBADF_h__ +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + + +int test_yaffs_read_EBADF(void); +int test_yaffs_read_EBADF_clean(void); +#endif