From 37b3d62be56e614fdce1449dd9b88aead76f052d Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 26 Nov 2010 14:24:45 +1300 Subject: [PATCH] yaffs Added more tests to direct/timothy_tests/quick_tests Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 7 +-- .../timothy_tests/quick_tests/quick_tests.h | 14 ++--- ..._ELOOP.c => test_yaffs_access_ELOOP_dir.c} | 8 +-- .../quick_tests/test_yaffs_access_ELOOP_dir.h | 22 ++++++++ ...d_ELOOP.c => test_yaffs_chmod_ELOOP_dir.c} | 8 +-- ...d_ELOOP.h => test_yaffs_chmod_ELOOP_dir.h} | 8 +-- ...nk_ELOOP.c => test_yaffs_link_ELOOP_dir.c} | 8 +-- ...nk_ELOOP.h => test_yaffs_link_ELOOP_dir.h} | 8 +-- .../quick_tests/test_yaffs_mkdir_ELOOP_dir.c | 51 +++++++++++++++++++ ...s_ELOOP.h => test_yaffs_mkdir_ELOOP_dir.h} | 11 ++-- .../quick_tests/test_yaffs_stat_ELOOP.c | 2 +- 11 files changed, 113 insertions(+), 34 deletions(-) rename direct/timothy_tests/quick_tests/{test_yaffs_access_ELOOP.c => test_yaffs_access_ELOOP_dir.c} (83%) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.h rename direct/timothy_tests/quick_tests/{test_yaffs_chmod_ELOOP.c => test_yaffs_chmod_ELOOP_dir.c} (82%) rename direct/timothy_tests/quick_tests/{test_yaffs_chmod_ELOOP.h => test_yaffs_chmod_ELOOP_dir.h} (78%) rename direct/timothy_tests/quick_tests/{test_yaffs_link_ELOOP.c => test_yaffs_link_ELOOP_dir.c} (87%) rename direct/timothy_tests/quick_tests/{test_yaffs_link_ELOOP.h => test_yaffs_link_ELOOP_dir.h} (77%) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.c rename direct/timothy_tests/quick_tests/{test_yaffs_access_ELOOP.h => test_yaffs_mkdir_ELOOP_dir.h} (76%) diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index af56984..a13bad0 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -58,16 +58,17 @@ 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_ELOOP2.o test_yaffs_access_EROFS.o \ + test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP_dir.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_ELOOP2.o test_yaffs_chmod_EROFS.o \ + test_yaffs_chmod_ENOENT2.o test_yaffs_chmod_ELOOP_dir.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 \ test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o test_yaffs_mkdir_ENOENT.o \ + test_yaffs_mkdir_ELOOP_dir.o \ test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \ test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o test_yaffs_symlink_ENOENT.o \ test_yaffs_symlink_ENOENT2.o \ @@ -82,7 +83,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_ELOOP.o \ + test_yaffs_link_ENOENT4.o test_yaffs_link_ELOOP_dir.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 6dbea34..8d819ee 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -81,7 +81,7 @@ #include "test_yaffs_access_ENOTDIR.h" #include "test_yaffs_access_ENOENT.h" #include "test_yaffs_access_ENOENT2.h" -#include "test_yaffs_access_ELOOP.h" +#include "test_yaffs_access_ELOOP_dir.h" #include "test_yaffs_access_ELOOP2.h" #include "test_yaffs_access_EROFS.h" @@ -99,7 +99,7 @@ #include "test_yaffs_chmod_ENOTDIR.h" #include "test_yaffs_chmod_EINVAL.h" #include "test_yaffs_chmod_ENOENT2.h" -#include "test_yaffs_chmod_ELOOP.h" +#include "test_yaffs_chmod_ELOOP_dir.h" #include "test_yaffs_chmod_ELOOP2.h" #include "test_yaffs_chmod_EROFS.h" @@ -117,6 +117,7 @@ #include "test_yaffs_mkdir_EEXIST.h" #include "test_yaffs_mkdir_ENOTDIR.h" #include "test_yaffs_mkdir_ENOENT.h" +#include "test_yaffs_mkdir_ELOOP_dir.h" #include "test_yaffs_symlink.h" @@ -159,7 +160,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_link_ELOOP_dir.h" #include "test_yaffs_rmdir.h" @@ -230,7 +231,7 @@ test_template test_list[]={ {test_yaffs_access_ENOTDIR,test_yaffs_access_ENOTDIR_clean,"test_yaffs_access_ENOTDIR"}, {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_ELOOP_dir,test_yaffs_access_ELOOP_dir_clean,"test_yaffs_access_ELOOP_dir"}, {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"}, @@ -283,7 +284,7 @@ test_template test_list[]={ {test_yaffs_chmod_ENOENT,test_yaffs_chmod_ENOENT_clean,"test_yaffs_chmod_ENOENT"}, {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_ELOOP_dir,test_yaffs_chmod_ELOOP_dir_clean,"test_yaffs_chmod_ELOOP_dir"}, {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"}, @@ -301,6 +302,7 @@ test_template test_list[]={ {test_yaffs_mkdir_EEXIST,test_yaffs_mkdir_EEXIST_clean,"test_yaffs_mkdir_EEXIST"}, {test_yaffs_mkdir_ENOTDIR,test_yaffs_mkdir_ENOTDIR_clean,"test_yaffs_mkdir_ENOTDIR"}, {test_yaffs_mkdir_ENOENT,test_yaffs_mkdir_ENOENT_clean,"test_yaffs_mkdir_ENOENT"}, + {test_yaffs_mkdir_ELOOP_dir,test_yaffs_mkdir_ELOOP_dir_clean,"test_yaffs_mkdir_ELOOP_dir"}, {test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"}, {test_yaffs_symlink_ENOTDIR,test_yaffs_symlink_ENOTDIR_clean,"test_yaffs_symlink_ENOTDIR"}, @@ -344,7 +346,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_link_ELOOP_dir,test_yaffs_link_ELOOP_dir_clean,"test_yaffs_link_ELOOP_dir"}, {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_dir.c similarity index 83% rename from direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c rename to direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.c index feae2ef..9f574d7 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.c @@ -11,9 +11,9 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_access_ELOOP.h" +#include "test_yaffs_access_ELOOP_dir.h" -int test_yaffs_access_ELOOP(void) +int test_yaffs_access_ELOOP_dir(void) { int output=0; int error=0; @@ -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 "file",0); + output= yaffs_access(ELOOP_PATH "/file",0); if (output<0){ error=yaffs_get_error(); if ( abs(error)== ELOOP){ @@ -37,7 +37,7 @@ int test_yaffs_access_ELOOP(void) } } -int test_yaffs_access_ELOOP_clean(void) +int test_yaffs_access_ELOOP_dir_clean(void) { return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.h new file mode 100644 index 0000000..45e8e6d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP_dir.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_ELOOP_dir_h__ +#define __test_yaffs_access_ELOOP_dir_h__ +#include "lib.h" +#include "yaffsfs.h" +int test_yaffs_access_ELOOP_dir(void); +int test_yaffs_access_ELOOP_dir_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_dir.c similarity index 82% rename from direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c rename to direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP_dir.c index d573337..1df90c5 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP_dir.c @@ -11,9 +11,9 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_chmod_ELOOP.h" +#include "test_yaffs_chmod_ELOOP_dir.h" -int test_yaffs_chmod_ELOOP(void) +int test_yaffs_chmod_ELOOP_dir(void) { int error=0; int output; @@ -23,7 +23,7 @@ int test_yaffs_chmod_ELOOP(void) return -1; } - output = yaffs_chmod(ELOOP_PATH "file",S_IREAD|S_IWRITE); + output = yaffs_chmod(ELOOP_PATH "/file",S_IREAD|S_IWRITE); if (output<0){ error=yaffs_get_error(); @@ -40,7 +40,7 @@ int test_yaffs_chmod_ELOOP(void) } -int test_yaffs_chmod_ELOOP_clean(void) +int test_yaffs_chmod_ELOOP_dir_clean(void) { return test_yaffs_chmod(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP_dir.h similarity index 78% rename from direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.h rename to direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP_dir.h index 3254f62..f47f53c 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ELOOP_dir.h @@ -13,14 +13,14 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __test_yaffs_chmod_ELOOP_h__ -#define __test_yaffs_chmod_ELOOP_h__ +#ifndef __test_yaffs_chmod_ELOOP_dir_h__ +#define __test_yaffs_chmod_ELOOP_dir_h__ #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_chmod.h" -int test_yaffs_chmod_ELOOP(void); -int test_yaffs_chmod_ELOOP_clean(void); +int test_yaffs_chmod_ELOOP_dir(void); +int test_yaffs_chmod_ELOOP_dir_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_dir.c similarity index 87% rename from direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c rename to direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP_dir.c index 89b2632..31c0900 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP_dir.c @@ -11,11 +11,11 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_link_ELOOP.h" +#include "test_yaffs_link_ELOOP_dir.h" -int test_yaffs_link_ELOOP(void) +int test_yaffs_link_ELOOP_dir(void) { int output=0; int error =0; @@ -25,7 +25,7 @@ int test_yaffs_link_ELOOP(void) return -1; } - output = yaffs_link(ELOOP_PATH "file",HARD_LINK_PATH); + output = yaffs_link(ELOOP_PATH "/file",HARD_LINK_PATH); if (output<0){ error=yaffs_get_error(); if (abs(error)==ELOOP){ @@ -41,7 +41,7 @@ int test_yaffs_link_ELOOP(void) } -int test_yaffs_link_ELOOP_clean(void) +int test_yaffs_link_ELOOP_dir_clean(void) { int output=0; int error =0; diff --git a/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.h b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP_dir.h similarity index 77% rename from direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.h rename to direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP_dir.h index 589ac1e..cfdb130 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_link_ELOOP_dir.h @@ -13,13 +13,13 @@ * 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__ +#ifndef __test_yaffs_link_ELOOP_dir_h__ +#define __test_yaffs_link_ELOOP_dir_h__ #include "lib.h" #include "yaffsfs.h" -int test_yaffs_link_ELOOP(void); -int test_yaffs_link_ELOOP_clean(void); +int test_yaffs_link_ELOOP_dir(void); +int test_yaffs_link_ELOOP_dir_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.c new file mode 100644 index 0000000..a33a1d1 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.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_mkdir_ELOOP_dir.h" + +static int output = -1; + +int test_yaffs_mkdir_ELOOP_dir(void) +{ + int error_code = 0; + + if (set_up_ELOOP()<0){ + print_message("failed to setup symlinks\n",2); + return -1; + } + + output = yaffs_mkdir(ELOOP_PATH "/file",O_CREAT | O_RDWR); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == ELOOP){ + return 1; + } else { + print_message("different error than expected\n", 2); + return -1; + } + } else { + print_message("created a new directory on top of an non-existing directory (which is a bad thing)\n", 2); + return -1; + } +} + + +int test_yaffs_mkdir_ELOOP_dir_clean(void) +{ + if (output >= 0){ + return yaffs_rmdir(DIR_PATH); + } else { + return 1; + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.h similarity index 76% rename from direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h rename to direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.h index d919792..816f786 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ELOOP_dir.h @@ -13,10 +13,13 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __test_yaffs__access_ELOOP_h__ -#define __test_yaffs_access_ELOOP_h__ +#ifndef __test_yaffs_mkdir_ELOOP_dir_h__ +#define __test_yaffs_mkdir_ELOOP_dir_h__ + #include "lib.h" #include "yaffsfs.h" -int test_yaffs_access_ELOOP(void); -int test_yaffs_access_ELOOP_clean(void); + +int test_yaffs_mkdir_ELOOP_dir(void); +int test_yaffs_mkdir_ELOOP_dir_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ELOOP.c b/direct/timothy_tests/quick_tests/test_yaffs_stat_ELOOP.c index 451b77f..ab83a8d 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat_ELOOP.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ELOOP.c @@ -28,7 +28,7 @@ int test_yaffs_stat_ELOOP(void) output=yaffs_stat(ELOOP_PATH, &stat);; if (output<0){ error_code=yaffs_get_error(); - if (abs(error_code)==ENOTDIR){ + if (abs(error_code)==ELOOP){ return 1; } else { print_message("returned error does not match the the expected error\n",2); -- 2.30.2