From 58bd37c91ae156c746b7b57be68987eacb0d5cb2 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 26 Nov 2010 17:17:38 +1300 Subject: [PATCH] yaffs Added a test to direct/timothy_tests/quick_test Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 2 +- .../timothy_tests/quick_tests/quick_tests.h | 2 + .../quick_tests/test_yaffs_fchmod_EROFS.c | 56 +++++++++++++++++++ .../quick_tests/test_yaffs_fchmod_EROFS.h | 25 +++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index f948b01..252c635 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -67,7 +67,7 @@ TESTFILES = quick_tests.o lib.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_dir.o test_yaffs_chmod_ELOOP.o test_yaffs_chmod_EROFS.o \ - test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o\ + test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EROFS.o test_yaffs_fchmod_EINVAL.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 \ diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 1f12861..876ff40 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -110,6 +110,7 @@ #include "test_yaffs_fchmod.h" #include "test_yaffs_fchmod_EBADF.h" #include "test_yaffs_fchmod_EINVAL.h" +#include "test_yaffs_fchmod_EROFS.h" #include "test_yaffs_fsync.h" #include "test_yaffs_fsync_EBADF.h" @@ -300,6 +301,7 @@ test_template test_list[]={ {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"}, + {test_yaffs_fchmod_EROFS,test_yaffs_fchmod_EROFS_clean,"test_yaffs_fchmod_EROFS"}, {test_yaffs_fsync,test_yaffs_fsync_clean,"test_yaffs_fsync"}, {test_yaffs_fsync_EBADF,test_yaffs_fsync_EBADF_clean,"test_yaffs_fsync_EBADF"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c new file mode 100644 index 0000000..0d733fa --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.c @@ -0,0 +1,56 @@ +/* + * 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_fchmod_EROFS.h" +static int handle = -1; + +int test_yaffs_fchmod_EROFS(void) +{ + int error = 0; + int output = 0; + if (EROFS_setup() < 0 ){ + return -1; + } + handle = test_yaffs_open(); + + if (handle < 0){ + print_message("failed to open file\n",2); + return -1; + } + + output = yaffs_fchmod(handle,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 (which is a bad thing)\n",2); + return -1; + } + + +} + +int test_yaffs_fchmod_EROFS_clean(void) +{ + int output =-1; + if (handle >= 0) { + output= yaffs_close(handle); + } + return (EROFS_clean() && output); +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.h new file mode 100644 index 0000000..d360f63 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EROFS.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_fchmod_EROFS_h__ +#define __test_yaffs_fchmod_EROFS_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_fchmod_EROFS(void); +int test_yaffs_fchmod_EROFS_clean(void); + +#endif -- 2.30.2