From: Timothy Manning Date: Sun, 7 Nov 2010 21:04:02 +0000 (+1300) Subject: yaffs Trying to find a bug in timothy quick tests. X-Git-Tag: linux-mainline-patchset-4~110^2~12 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=250248634f57704c06d3ae5050febb33ad5c67d8;ds=sidebyside yaffs Trying to find a bug in timothy quick tests. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index a340165..0e843e9 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -45,9 +45,9 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf # yaffs_checkptrwtest.o\ TESTFILES = quick_tests.o lib.o \ - test_mount_yaffs.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_unlinking.o \ + test_yaffs_mount.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_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_write.o \ test_yaffs_read.o \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 127898c..fca9396 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -5,15 +5,51 @@ Made by Timothy Manning on 04/11/2010 the yaffs_open function has been covered by tests the yaffs_close function has been covered by tests - - +tests made + test_yaffs_mount + test_yaffs_access + test_yaffs_close + test_yaffs_close_EBADF + test_yaffs_ftruncate + test_yaffs_lseek + test_yaffs_open + test_yaffs_open_EEXIST + test_yaffs_open_EISDIR + test_yaffs_open_ENAMETOOLONG + test_yaffs_open_ENOENT + test_yaffs_open_ENOTDIR + test_yaffs_read + test_yaffs_stat + test_yaffs_truncate + test_yaffs_unlink_EISDIR + test_yaffs_unlink_ENAMETOOLONG + test_yaffs_unlink_ENOENT + test_yaffs_unlink_ENOTDIR + test_yaffs_write tests to add + test_yaffs_mount_EACCES + test_yaffs_mount_EINVAL + test_yaffs_mount_ELOOP + test_yaffs_mount_EMFILE + test_yaffs_mount_ENAMETOOLONG + test_yaffs_mount_ENOENT + test_yaffs_mount_ENOTDIR test_yaffs_open_EACCES test_yaffs_open_ENOSPC test_yaffs_open_ELOOP Too many symbolic links were encountered in resolving pathname test_yaffs_close test yaffs_open_running_out_of_handles error + test_yaffs_unlink_EACCES + test_yaffs_unlink_ELOOP + test_yaffs_unlink_ENOENT + test_yaffs_unlink_ENOMEM check to see if an error code is generated when there isn't an error + test_yaffs_access_EACCESS + test_yaffs_access_ELOOP + test_yaffs_access_ENAMETOOLONG + test_yaffs_access_ENOENT + test_yaffs_access_ENOTDIR + test_yaffs_access_ENIVAL //mode is incorrect. How to add a test @@ -63,8 +99,11 @@ How to add a test BUGS Needing to include int random_seed; and int simulate_power_failure = 0; in any main program using yaffsfs.h - ENOSPC error in programs test_yaffs_open_ENOTDIR and test_yaffs_open_ENOENT. - ENOENT been returned by yaffs_read but the handle is good and the yaffs_open function does not return an error. + bug with opening a file with a name of 1,000,000 char long with no errors. + bug with unlinking a file with 1,000,000 get the error ENOENT but should be geting ENAMETOOLONG. + + FIXED-ENOSPC error in programs test_yaffs_open_ENOTDIR and test_yaffs_open_ENOENT. + FIXED-ENOENT been returned by yaffs_read but the handle is good and the yaffs_open function does not return an error. diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index 3753583..71a11f8 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -46,15 +46,22 @@ int main(){ else { /*test is assumed to have failed*/ //printf("test failed\n"); - printf("test: %s failed\n",test_list[x].fail_message); + printf("test: %s failed\n",test_list[x].name_of_test); num_of_tests_failed ++; - quit_quick_tests(1); - + + if (EXIT_ON_ERROR){ + printf("\n\n"); + quit_quick_tests(1); + } + else { + get_error(); + printf("\n\n"); + } } output=test_list[x].p_function_clean(); /*clean the test*/ if (output <0){ /* if the test failed to clean it's self then */ - printf("test: %s failed to clean\n",test_list[x].fail_message); + printf("test: %s failed to clean\n",test_list[x].name_of_test); num_of_tests_failed ++; num_of_tests_pass--; quit_quick_tests(1); @@ -68,20 +75,25 @@ int main(){ } void quit_quick_tests(int exit_code){ - int error_code=0; + if (num_of_tests_pass==total_number_of_tests && num_of_tests_failed==0){ printf("\t OK \n"); } else { - error_code=yaffs_get_error(); - printf("yaffs_error code %d\n",error_code); - printf("error is : %s\n",yaffs_error_to_str(error_code)); + get_error(); } printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed); yaffs_unmount(YAFFS_MOUNT_POINT); exit(exit_code); } +void get_error(void){ + int error_code=0; + error_code=yaffs_get_error(); + printf("yaffs_error code %d\n",error_code); + printf("error is : %s\n",yaffs_error_to_str(error_code)); +} + void init_quick_tests(void){ yaffs_start_up();; yaffs_set_trace(0); diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index ebe55b6..e7ae6ba 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -17,18 +17,24 @@ #define __quick_tests_h__ #include -#include "test_mount_yaffs.h" +#include "test_yaffs_mount.h" #include "test_yaffs_open.h" #include "test_yaffs_open_EISDIR.h" #include "test_yaffs_open_EEXIST.h" #include "test_yaffs_open_ENOENT.h" #include "test_yaffs_open_ENOTDIR.h" +#include "test_yaffs_open_ENAMETOOLONG.h" #include "test_yaffs_close_EBADF.h" -#include "test_yaffs_unlinking.h" +#include "test_yaffs_unlink.h" +#include "test_yaffs_unlink_EISDIR.h" +#include "test_yaffs_unlink_ENOENT.h" +#include "test_yaffs_unlink_ENAMETOOLONG.h" +#include "test_yaffs_unlink_ENOTDIR.h" + #include "test_yaffs_ftruncate.h" #include "test_yaffs_truncate.h" #include "test_yaffs_write.h" @@ -40,26 +46,36 @@ #include "yaffs_error_converter.h" #include "lib.h" + +#define EXIT_ON_ERROR 0 + typedef struct test { int (*p_function)(void); /*pointer to test function*/ int (*p_function_clean)(void); /*char pass_message[50]; will not need a pass message*/ - char *fail_message; /*pointer to fail message, needs to include name of test*/ + char *name_of_test; /*pointer to fail message, needs to include name of test*/ }test_template; test_template test_list[]={ - {mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"}, + {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"}, {test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"}, {test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"}, {test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"}, {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_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"}, {test_yaffs_access,test_yaffs_access_clean,"test_yaffs_access"}, - {test_yaffs_unlinking, test_yaffs_unlinking_clean,"test_yaffs_unlinking"}, + + {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"}, + {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"}, + {test_yaffs_unlink_ENOENT,test_yaffs_unlink_ENOENT_clean,"test_yaffs_unlink_ENOENT"}, + {test_yaffs_unlink_ENAMETOOLONG,test_yaffs_unlink_ENAMETOOLONG_clean,"test_yaffs_unlink_ENAMETOOLONG"}, + {test_yaffs_unlink_ENOTDIR,test_yaffs_unlink_ENOTDIR_clean,"test_yaffs_unlink_ENOTDIR"}, + {test_yaffs_lseek,test_yaffs_lseek_clean,"test_yaffs_lseek"}, {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"}, @@ -74,4 +90,5 @@ test_template test_list[]={ void init_quick_tests(void); void quit_quick_tests(int exit_code); +void get_error(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_mount_yaffs.c b/direct/timothy_tests/quick_tests/test_yaffs_mount.c similarity index 85% rename from direct/timothy_tests/quick_tests/test_mount_yaffs.c rename to direct/timothy_tests/quick_tests/test_yaffs_mount.c index 62ef790..aac73cf 100644 --- a/direct/timothy_tests/quick_tests/test_mount_yaffs.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount.c @@ -11,16 +11,16 @@ * published by the Free Software Foundation. */ -#include "test_mount_yaffs.h" +#include "test_yaffs_mount.h" -int mount_yaffs_test(void){ +int test_yaffs_mount(void){ int output=0; output=yaffs_mount(YAFFS_MOUNT_POINT); /*printf("output %d",output);*/ return output; } -int mount_yaffs_test_clean(void){ +int test_yaffs_mount_clean(void){ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_mount_yaffs.h b/direct/timothy_tests/quick_tests/test_yaffs_mount.h similarity index 82% rename from direct/timothy_tests/quick_tests/test_mount_yaffs.h rename to direct/timothy_tests/quick_tests/test_yaffs_mount.h index 89beda7..4af829c 100644 --- a/direct/timothy_tests/quick_tests/test_mount_yaffs.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount.h @@ -13,12 +13,12 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __mount_yaffs_test__ -#define __mount_yaffs_test__ +#ifndef __test_yaffs_mount__ +#define __test_yaffs_mount__ #include "yaffsfs.h" #include "lib.h" -int mount_yaffs_test(void); -int mount_yaffs_test_clean(void); +int test_yaffs_mount(void); +int test_yaffs_mount_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c new file mode 100644 index 0000000..e896abc --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c @@ -0,0 +1,63 @@ +/* + * 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_ENAMETOOLONG.h" + + + +static int handle=0; +int test_yaffs_open_ENAMETOOLONG(void){ + int output=0; + int x; + int error_code=0; + int file_name_length=1000000; + char file_name[file_name_length]; + + strcat(file_name,YAFFS_MOUNT_POINT); + for (x=strlen(YAFFS_MOUNT_POINT); x=0){ + printf("non existant file 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_ENAMETOOLONG_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_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h new file mode 100644 index 0000000..8325fd5 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.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_ENAMETOOLONG_h__ +#define __test_yaffs_open_ENAMETOOLONG_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_open_ENAMETOOLONG(void); +int test_yaffs_open_ENAMETOOLONG_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlinking.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink.c similarity index 86% rename from direct/timothy_tests/quick_tests/test_yaffs_unlinking.c rename to direct/timothy_tests/quick_tests/test_yaffs_unlink.c index 435cb92..1352ccf 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlinking.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink.c @@ -11,9 +11,9 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_unlinking.h" +#include "test_yaffs_unlink.h" -int test_yaffs_unlinking(void){ +int test_yaffs_unlink(void){ int output=yaffs_unlink(FILE_PATH); if (output>=0){ return (-test_yaffs_access()); /*return negative access. we do not want the file to be there*/ @@ -24,6 +24,6 @@ int test_yaffs_unlinking(void){ } } -int test_yaffs_unlinking_clean(void){ +int test_yaffs_unlink_clean(void){ return test_yaffs_open(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlinking.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink.h similarity index 81% rename from direct/timothy_tests/quick_tests/test_yaffs_unlinking.h rename to direct/timothy_tests/quick_tests/test_yaffs_unlink.h index fcabe69..a28efc4 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlinking.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink.h @@ -13,14 +13,14 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __test_yaffs_unlinking_h__ -#define __test_yaffs_unlinking_h__ +#ifndef __test_yaffs_unlink_h__ +#define __test_yaffs_unlink_h__ #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" #include "test_yaffs_access.h" -int test_yaffs_unlinking(void); -int test_yaffs_unlinking_clean(void); +int test_yaffs_unlink(void); +int test_yaffs_unlink_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c new file mode 100644 index 0000000..80c8f40 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.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_unlink_EISDIR.h" + +/*EISDIR is caused by trying to unlink a directory */ + +static int handle=0; +int test_yaffs_unlink_EISDIR(void){ + int output=0; + int error_code=0; + /*printf("path %s\n",path); */ + handle=yaffs_unlink(YAFFS_MOUNT_POINT); + if (handle==-1){ + error_code=yaffs_get_error(); + //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); + if (abs(error_code)== EISDIR){ + return 1; + } + else { + printf("different error than expected\n"); + return -1; + } + } + else if (output >=0){ + printf("directory unlinked 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_unlink_EISDIR_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_unlink_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h new file mode 100644 index 0000000..cdba6f5 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.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_unlink_EISDIR_h__ +#define __test_yaffs_unlink_EISDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_unlink_EISDIR(void); +int test_yaffs_unlink_EISDIR_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c new file mode 100644 index 0000000..1803c83 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c @@ -0,0 +1,59 @@ +/* + * 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_unlink_ENAMETOOLONG.h" + + +static int handle=0; +int test_yaffs_unlink_ENAMETOOLONG(void){ + int output=0; + int error_code=0; + int x=0; + int file_name_length=1000000; + char file_name[file_name_length]; + + strcat(file_name,YAFFS_MOUNT_POINT); + for (x=strlen(YAFFS_MOUNT_POINT); x=0){ + printf("directory unlinked 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_unlink_ENAMETOOLONG_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_unlink_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.h new file mode 100644 index 0000000..dffaeb9 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.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_unlink_ENAMETOOLONG_h__ +#define __test_yaffs_unlink_ENAMETOOLONG_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_unlink_ENAMETOOLONG(void); +int test_yaffs_unlink_ENAMETOOLONG_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c new file mode 100644 index 0000000..50803e5 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.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_unlink_EISDIR.h" + +/*EISDIR is caused by trying to unlink a directory */ + +static int handle=0; +int test_yaffs_unlink_ENOENT(void){ + int output=0; + int error_code=0; + /*printf("path %s\n",path); */ + handle=yaffs_unlink("/yaffs2/non_existant_file"); + if (handle==-1){ + error_code=yaffs_get_error(); + //printf("ENOENT def %d, Error code %d\n", EISDIR,error_code); + if (abs(error_code)== ENOENT){ + return 1; + } + else { + printf("different error than expected\n"); + return -1; + } + } + else if (output >=0){ + printf("directory unlinked 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_unlink_ENOENT_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_unlink_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h new file mode 100644 index 0000000..f13ca0c --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.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_unlink_ENOENT_h__ +#define __test_yaffs_unlink_ENOENT_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_unlink_ENOENT(void); +int test_yaffs_unlink_ENOENT_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c new file mode 100644 index 0000000..8724376 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c @@ -0,0 +1,43 @@ +/* + * 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_ENOTDIR.h" + + +int test_yaffs_unlink_ENOTDIR(void){ + int output=0; + int error_code=0; + /*printf("path %s\n",path); */ + output=yaffs_unlink("/nonexisting_dir/foo"); + if (output==-1){ + error_code=yaffs_get_error(); + //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); + if (abs(error_code)==ENOTDIR){ + return 1; + } + else { + printf("different error than expected\n"); + return -1; + } + } + else { + printf("non existant directory opened.(which is a bad thing)\n"); + return -1; + } + + +} +int test_yaffs_unlink_ENOTDIR_clean(void){ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h new file mode 100644 index 0000000..82e44da --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.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_unlink_ENOTDIR_h__ +#define __test_yaffs_unlink_ENOTDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_unlink_ENOTDIR(void); +int test_yaffs_unlink_ENOTDIR_clean(void); +#endif