From a45194dd1a23a750f4ee8912258243dcdbcac69a Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 26 Nov 2010 12:28:21 +1300 Subject: [PATCH] yaffs More tests added to direct/timothy_tests/quick_tests Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 2 +- direct/timothy_tests/quick_tests/README.txt | 7 ++- direct/timothy_tests/quick_tests/lib.c | 23 ++++++++++ direct/timothy_tests/quick_tests/lib.h | 4 +- .../timothy_tests/quick_tests/quick_tests.h | 5 +++ .../quick_tests/test_yaffs_access_EROFS.c | 43 +++++++++++++++++++ .../quick_tests/test_yaffs_access_EROFS.h | 22 ++++++++++ .../quick_tests/test_yaffs_chmod_EROFS.c | 43 +++++++++++++++++++ .../quick_tests/test_yaffs_chmod_EROFS.h | 26 +++++++++++ 9 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index e0bbdf9..70750a1 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -58,7 +58,7 @@ 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_ENOENT2.o test_yaffs_access_ELOOP.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\ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index f79bc79..bbeb0d7 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -28,6 +28,9 @@ test_yaffs_fchmod_EINVAL.c test_yaffs_fdatasync.c test_yaffs_fdatasync_EBADF.c +test_yaffs_flush +test_yaffs_flush_EBADF + test_yaffs_freespace.c test_yaffs_freespace_EINVAL.c @@ -187,7 +190,6 @@ Tests to add test_yaffs_mkdir_EACCES - test_yaffs_mkdir_ELOOP test_yaffs_mkdir_ENAMETOOLONG test_yaffs_mkdir_EROFS @@ -238,9 +240,6 @@ Tests to add test_yaffs_dup test_yaffs_dup_EBADF - test_yaffs_flush - test_yaffs_flush_EBADF - test_yaffs_fchmod_EACCES test_yaffs_fchmod_ELOOP diff --git a/direct/timothy_tests/quick_tests/lib.c b/direct/timothy_tests/quick_tests/lib.c index bc00404..e297645 100644 --- a/direct/timothy_tests/quick_tests/lib.c +++ b/direct/timothy_tests/quick_tests/lib.c @@ -34,6 +34,29 @@ int get_exit_on_error(void) } +int EROFS_setup(void) +{ + int output= -1; + output=yaffs_remount(YAFFS_MOUNT_POINT,1,1); + if (output<0){ + print_message("failed to remount yaffs\n",2); + return -1; + } + return 1; +} + +int EROFS_clean(void) +{ + int output=-1; + output= yaffs_remount(YAFFS_MOUNT_POINT,1,0); + if (output<0){ + print_message("failed to remount yaffs\n",2); + return -1; + } + return 1; +} + + int set_up_ELOOP(void){ int output1=1; int output2=1; diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index f24e3aa..fdb28fe 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -21,7 +21,7 @@ #include "yaffsfs.h" -#define ELOOP 10 //the error code ELOOP is not defined yet so I'm making a stand in. + #define YAFFS_MOUNT_POINT "/yaffs2/" @@ -57,4 +57,6 @@ void set_print_level(int new_level); void set_exit_on_error(int num); int get_exit_on_error(void); int set_up_ELOOP(void); +int EROFS_setup(void); +int EROFS_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index e7a6b14..2e5fee3 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_EROFS.h" #include "test_yaffs_stat.h" #include "test_yaffs_stat_ENOENT.h" @@ -98,6 +99,7 @@ #include "test_yaffs_chmod_EINVAL.h" #include "test_yaffs_chmod_ENOENT2.h" #include "test_yaffs_chmod_ELOOP.h" +#include "test_yaffs_chmod_EROFS.h" #include "test_yaffs_fchmod.h" #include "test_yaffs_fchmod_EBADF.h" @@ -226,6 +228,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_EROFS,test_yaffs_access_EROFS_clean,"test_yaffs_access_EROFS"}, {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"}, {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"}, @@ -277,6 +280,8 @@ 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_EROFS,test_yaffs_chmod_EROFS_clean,"test_yaffs_chmod_EROFS"}, + {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"}, {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"}, {test_yaffs_fchmod_EINVAL,test_yaffs_fchmod_EINVAL_clean,"test_yaffs_fchmod_EINVAL"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.c new file mode 100644 index 0000000..5944ec1 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.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_EROFS.h" + +int test_yaffs_access_EROFS(void) +{ + int output=0; + int error=0; + if (EROFS_setup() < 0 ){ + return -1; + } + + output= yaffs_access(FILE_PATH,R_OK |W_OK); + if (output<0){ + error=yaffs_get_error(); + if ( abs(error)== EROFS){ + return 1; + } else { + print_message("error does not match expected error\n",2); + return -1; + } + } else{ + print_message("accessed an existing file with the file system mounted as read only (which is a bad thing)\n",2); + + return -1; + } +} + +int test_yaffs_access_EROFS_clean(void) +{ + return EROFS_clean(); +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.h new file mode 100644 index 0000000..ebf91fb --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EROFS.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_EROFS_h__ +#define __test_yaffs_access_EROFS_h__ +#include "lib.h" +#include "yaffsfs.h" +int test_yaffs_access_EROFS(void); +int test_yaffs_access_EROFS_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.c new file mode 100644 index 0000000..fef37e5 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.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_chmod_EROFS.h" + +int test_yaffs_chmod_EROFS(void) +{ + int error=0; + int output; + + EROFS_setup(); + + output = yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==EROFS){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded with EROFS setup (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_EROFS_clean(void) +{ + return test_yaffs_chmod() | EROFS_clean(); +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.h new file mode 100644 index 0000000..9b3f2d3 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EROFS.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_EROFS_h__ +#define __test_yaffs_chmod_EROFS_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_chmod.h" + +int test_yaffs_chmod_EROFS(void); +int test_yaffs_chmod_EROFS_clean(void); + +#endif -- 2.30.2