From 7897e76da06203d6e2c20f13a1ce79e64809930a Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 26 Nov 2010 13:49:25 +1300 Subject: [PATCH] yaffs Adding more tests to direct/timothy_tests/quick_tests Signed-off-by: Timothy Manning --- direct/python/yaffs_error_converter.c | 1 + direct/timothy_tests/quick_tests/Makefile | 6 +- .../timothy_tests/quick_tests/quick_tests.h | 6 ++ .../quick_tests/test_yaffs_access_ELOOP.c | 2 +- .../quick_tests/test_yaffs_access_ELOOP2.c | 43 +++++++++++++ .../quick_tests/test_yaffs_access_ELOOP2.h | 22 +++++++ .../quick_tests/test_yaffs_chmod_ELOOP.c | 2 +- .../quick_tests/test_yaffs_chmod_ELOOP2.c | 46 ++++++++++++++ .../quick_tests/test_yaffs_chmod_ELOOP2.h | 26 ++++++++ .../quick_tests/test_yaffs_link_ELOOP.c | 62 +++++++++++++++++++ .../quick_tests/test_yaffs_link_ELOOP.h | 25 ++++++++ 11 files changed, 236 insertions(+), 5 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.h diff --git a/direct/python/yaffs_error_converter.c b/direct/python/yaffs_error_converter.c index 1701c5e..0d1601f 100644 --- a/direct/python/yaffs_error_converter.c +++ b/direct/python/yaffs_error_converter.c @@ -38,6 +38,7 @@ static const struct error_entry error_list[] = { { EISDIR , "EISDIR"}, { ENFILE, "ENFILE"}, { EROFS, "EROFS"}, + { ELOOP, "ELOOP"}, { 0, NULL } }; diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index e018dc9..af56984 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -58,12 +58,12 @@ 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_big_file.o \ test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o \ - test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP.o test_yaffs_access_EROFS.o \ + test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP.o test_yaffs_access_ELOOP2.o test_yaffs_access_EROFS.o \ test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o test_yaffs_stat_ENOENT2.o test_yaffs_stat_ELOOP.o \ test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \ test_yaffs_close_EBADF.o\ test_yaffs_chmod.o test_yaffs_chmod_ENOENT.o test_yaffs_chmod_ENOTDIR.o test_yaffs_chmod_EINVAL.o \ - test_yaffs_chmod_ENOENT2.o test_yaffs_chmod_ELOOP.o test_yaffs_chmod_EROFS.o \ + test_yaffs_chmod_ENOENT2.o test_yaffs_chmod_ELOOP.o test_yaffs_chmod_ELOOP2.o test_yaffs_chmod_EROFS.o \ test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o\ test_yaffs_fsync.o test_yaffs_fsync_EBADF.o \ test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o \ @@ -82,7 +82,7 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_inodecount.o test_yaffs_inodecount_EINVAL.o \ test_yaffs_link.o test_yaffs_link_ENOENT.o test_yaffs_link_EEXIST.o test_yaffs_link_ENOTDIR.o \ test_yaffs_link_ENOTDIR2.o test_yaffs_link_ENOENT2.o test_yaffs_link_ENOENT3.o test_yaffs_link_ENOENT3.o \ - test_yaffs_link_ENOENT4.o \ + test_yaffs_link_ENOENT4.o test_yaffs_link_ELOOP.o \ test_yaffs_rmdir.o test_yaffs_rmdir_EBUSY.o test_yaffs_rmdir_EINVAL.o test_yaffs_rmdir_ENOENT.o \ test_yaffs_rmdir_ENOTDIR.o \ test_yaffs_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \ diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 2e5fee3..6dbea34 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -82,6 +82,7 @@ #include "test_yaffs_access_ENOENT.h" #include "test_yaffs_access_ENOENT2.h" #include "test_yaffs_access_ELOOP.h" +#include "test_yaffs_access_ELOOP2.h" #include "test_yaffs_access_EROFS.h" #include "test_yaffs_stat.h" @@ -99,6 +100,7 @@ #include "test_yaffs_chmod_EINVAL.h" #include "test_yaffs_chmod_ENOENT2.h" #include "test_yaffs_chmod_ELOOP.h" +#include "test_yaffs_chmod_ELOOP2.h" #include "test_yaffs_chmod_EROFS.h" #include "test_yaffs_fchmod.h" @@ -157,6 +159,7 @@ #include "test_yaffs_link_ENOENT2.h" #include "test_yaffs_link_ENOENT3.h" #include "test_yaffs_link_ENOENT4.h" +#include "test_yaffs_link_ELOOP.h" #include "test_yaffs_rmdir.h" @@ -228,6 +231,7 @@ test_template test_list[]={ {test_yaffs_access_ENOENT,test_yaffs_access_ENOENT_clean,"test_yaffs_access_ENOENT"}, {test_yaffs_access_ENOENT2,test_yaffs_access_ENOENT2_clean,"test_yaffs_access_ENOENT2"}, {test_yaffs_access_ELOOP,test_yaffs_access_ELOOP_clean,"test_yaffs_access_ELOOP"}, + {test_yaffs_access_ELOOP2,test_yaffs_access_ELOOP2_clean,"test_yaffs_access_ELOOP2"}, {test_yaffs_access_EROFS,test_yaffs_access_EROFS_clean,"test_yaffs_access_EROFS"}, {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"}, @@ -280,6 +284,7 @@ test_template test_list[]={ {test_yaffs_chmod_ENOTDIR,test_yaffs_chmod_ENOTDIR_clean,"test_yaffs_chmod_ENOTDIR"}, {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"}, {test_yaffs_chmod_ELOOP,test_yaffs_chmod_ELOOP_clean,"test_yaffs_chmod_ELOOP"}, + {test_yaffs_chmod_ELOOP2,test_yaffs_chmod_ELOOP2_clean,"test_yaffs_chmod_ELOOP2"}, {test_yaffs_chmod_EROFS,test_yaffs_chmod_EROFS_clean,"test_yaffs_chmod_EROFS"}, {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"}, @@ -339,6 +344,7 @@ test_template test_list[]={ {test_yaffs_link_ENOENT2,test_yaffs_link_ENOENT2_clean,"test_yaffs_link_ENOENT2"}, {test_yaffs_link_ENOENT3,test_yaffs_link_ENOENT3_clean,"test_yaffs_link_ENOENT3"}, {test_yaffs_link_ENOENT4,test_yaffs_link_ENOENT4_clean,"test_yaffs_link_ENOENT4"}, + {test_yaffs_link_ELOOP,test_yaffs_link_ELOOP_clean,"test_yaffs_link_ELOOP"}, {test_yaffs_rmdir,test_yaffs_rmdir_clean,"test_yaffs_rmdir"}, {test_yaffs_rmdir_EBUSY,test_yaffs_rmdir_EBUSY_clean,"test_yaffs_rmdir_EBUSY"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c index 8338cc4..feae2ef 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c @@ -21,7 +21,7 @@ int test_yaffs_access_ELOOP(void) print_message("failed to setup symlinks\n",2); return -1; } - output= yaffs_access(ELOOP_PATH,0); + output= yaffs_access(ELOOP_PATH "file",0); if (output<0){ error=yaffs_get_error(); if ( abs(error)== ELOOP){ diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.c new file mode 100644 index 0000000..719bedc --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.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_access_ELOOP2.h" + +int test_yaffs_access_ELOOP2(void) +{ + int output=0; + int error=0; + if (set_up_ELOOP()<0){ + print_message("failed to setup symlinks\n",2); + return -1; + } + output= yaffs_access(ELOOP_PATH,0); + if (output<0){ + error=yaffs_get_error(); + if ( abs(error)== ELOOP){ + return 1; + } else { + print_message("error does not match expected error\n",2); + return -1; + } + } else{ + print_message("accessed an existing file with bad mode (which is a bad thing\n",2); + + return -1; + } +} + +int test_yaffs_access_ELOOP2_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.h new file mode 100644 index 0000000..85809a2 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP2.h @@ -0,0 +1,22 @@ +/* + * 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__access_ELOOP2_h__ +#define __test_yaffs_access_ELOOP2_h__ +#include "lib.h" +#include "yaffsfs.h" +int test_yaffs_access_ELOOP2(void); +int test_yaffs_access_ELOOP2_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c index ae62f54..d573337 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c @@ -23,7 +23,7 @@ int test_yaffs_chmod_ELOOP(void) return -1; } - output = yaffs_chmod(ELOOP_PATH,S_IREAD|S_IWRITE); + output = yaffs_chmod(ELOOP_PATH "file",S_IREAD|S_IWRITE); if (output<0){ error=yaffs_get_error(); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.c new file mode 100644 index 0000000..32266dc --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.c @@ -0,0 +1,46 @@ +/* + * 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_chmod_ELOOP2.h" + +int test_yaffs_chmod_ELOOP2(void) +{ + int error=0; + int output; + + if (set_up_ELOOP()<0){ + print_message("failed to setup symlinks\n",2); + return -1; + } + + output = yaffs_chmod(ELOOP_PATH,S_IREAD|S_IWRITE); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==ELOOP){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded the ELOOP (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_ELOOP2_clean(void) +{ + return test_yaffs_chmod(); +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.h new file mode 100644 index 0000000..336aadc --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP2.h @@ -0,0 +1,26 @@ +/* + * 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_chmod_ELOOP2_h__ +#define __test_yaffs_chmod_ELOOP2_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_chmod.h" + +int test_yaffs_chmod_ELOOP2(void); +int test_yaffs_chmod_ELOOP2_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c new file mode 100644 index 0000000..89b2632 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c @@ -0,0 +1,62 @@ +/* + * 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_link_ELOOP.h" + + + +int test_yaffs_link_ELOOP(void) +{ + int output=0; + int error =0; + + if (set_up_ELOOP()<0){ + print_message("failed to setup symlinks\n",2); + return -1; + } + + output = yaffs_link(ELOOP_PATH "file",HARD_LINK_PATH); + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==ELOOP){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("created a hard link to a non-existing-dir (which is a bad thing)\n",2); + return -1; + } +} + + +int test_yaffs_link_ELOOP_clean(void) +{ + int output=0; + int error =0; + output= yaffs_unlink(HARD_LINK_PATH); + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==ENOENT){ + //if the file does not exist then the error should be ENOENT. + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } 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_link_ELOOP.h b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.h new file mode 100644 index 0000000..589ac1e --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.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_link_ELOOP_h__ +#define __test_yaffs_link_ELOOP_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_link_ELOOP(void); +int test_yaffs_link_ELOOP_clean(void); + +#endif -- 2.30.2