From f3b2098d2fde2c023ad8f84484d647b16e4c5f0f Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Tue, 23 Nov 2010 15:36:31 +1300 Subject: [PATCH] yaffs Added more tests to direct/timothy_tests/quick_tests Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 3 +- direct/timothy_tests/quick_tests/README.txt | 3 +- direct/timothy_tests/quick_tests/lib.h | 2 + .../timothy_tests/quick_tests/quick_tests.h | 6 +- .../quick_tests/test_yaffs_rename_dir.c | 47 +++++++++++++++ .../quick_tests/test_yaffs_rename_dir.h | 26 ++++++++ .../test_yaffs_rename_dir_ENOENT.c | 59 +++++++++++++++++++ .../test_yaffs_rename_dir_ENOENT.h | 26 ++++++++ 8 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 3c5352e..bb60030 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -85,7 +85,8 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_link_ENOTDIR2.o test_yaffs_link_ENOENT2.o test_yaffs_link_ENOENT3.o test_yaffs_link_ENOENT3.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 + test_yaffs_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \ + test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 3d8015b..d26844a 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -94,6 +94,7 @@ test_yaffs_remount_force_on_read_only_on.c test_yaffs_rename test_yaffs_rename_ENOENT test_yaffs_rename_ENOTDIR +test_yaffs_rename_EINVAL test_yaffs_rmdir.c test_yaffs_rmdir_EBUSY @@ -243,13 +244,11 @@ Tests to add //need to do rename for directories. //what happens if the dir or file is renamed over an existing dir or file test_yaffs_rename_EACCES - test_yaffs_rename_EINVAL test_yaffs_rename_ELOOP test_yaffs_rename_EMLINK test_yaffs_rename_EEXISTS or EPERM test_yaffs_rename_EROFS - test_yaffs_rename test_yaffs_dup test_yaffs_dup_EBADF diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index 9981b65..d52b974 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -40,6 +40,8 @@ #define RENAME_PATH "/yaffs2/foo2" +#define RENAME_DIR_PATH "/yaffs2/dir2" + /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 305e8d9..fe10c73 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -160,6 +160,8 @@ #include "test_yaffs_rename_ENOENT.h" #include "test_yaffs_rename_ENOTDIR.h" #include "test_yaffs_rename_EINVAL.h" +#include "test_yaffs_rename_dir.h" +#include "test_yaffs_rename_dir_ENOENT.h" #include "yaffsfs.h" #include "yaffs_error_converter.h" @@ -318,7 +320,9 @@ test_template test_list[]={ {test_yaffs_rename,test_yaffs_rename_clean,"test_yaffs_rename"}, {test_yaffs_rename_ENOENT,test_yaffs_rename_ENOENT_clean,"test_yaffs_rename_ENOENT"}, {test_yaffs_rename_ENOTDIR,test_yaffs_rename_ENOTDIR_clean,"test_yaffs_rename_ENOTDIR"}, - {test_yaffs_rename_EINVAL,test_yaffs_rename_EINVAL_clean,"test_yaffs_rename_EINVAL"} + {test_yaffs_rename_EINVAL,test_yaffs_rename_EINVAL_clean,"test_yaffs_rename_EINVAL"}, + {test_yaffs_rename_dir,test_yaffs_rename_dir_clean,"test_yaffs_rename_dir"}, + {test_yaffs_rename_dir_ENOENT,test_yaffs_rename_dir_ENOENT_clean,"test_yaffs_rename_dir_ENOENT"} }; void init_quick_tests(int argc, char *argv[]); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c new file mode 100644 index 0000000..5c7a254 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c @@ -0,0 +1,47 @@ +/* + * 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_rename_dir.h" + + +int test_yaffs_rename_dir(void) +{ + int output=0; + int error_code =0; + + if (0 != yaffs_access(FILE_PATH,0)) { + output = test_yaffs_open(); + if (output < 0) { + print_message("failed to create file\n",2); + return -1; + } + } + output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH); + return output; +} + + +int test_yaffs_rename_dir_clean(void) +{ + int output = 0; + if (0 == yaffs_access(RENAME_DIR_PATH,0)) { + output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH); + if (output < 0) { + print_message("failed to rename the file\n",2); + return -1; + } + } + return 1; + +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.h new file mode 100644 index 0000000..1b99f95 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.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_rename_dir_h__ +#define __test_yaffs_rename_dir_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_rename_dir(void); +int test_yaffs_rename_dir_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c new file mode 100644 index 0000000..a4232e6 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.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_rename_dir_ENOENT.h" + + +int test_yaffs_rename_dir_ENOENT(void) +{ + int output=0; + int error_code =0; + + if (0 != yaffs_access(FILE_PATH,0)) { + output = test_yaffs_open(); + if (output < 0) { + print_message("failed to create file\n",2); + return -1; + } + } + output = yaffs_rename( "/yaffs2/non-existing-dir/" , RENAME_DIR_PATH); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==EINVAL){ + return 1; + } else { + print_message("returned error does not match the the expected error\n",2); + return -1; + } + } else{ + print_message("removed /yaffs2/ directory (which is a bad thing)\n",2); + return -1; + } + +} + + +int test_yaffs_rename_dir_ENOENT_clean(void) +{ + int output = 0; + if (0 == yaffs_access(RENAME_DIR_PATH,0)) { + output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH); + if (output < 0) { + print_message("failed to rename the file\n",2); + return -1; + } + } + return 1; + +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.h new file mode 100644 index 0000000..ffdd09d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.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_rename_dir_ENOENT_h__ +#define __test_yaffs_rename_dir_ENOENT_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_rename_dir_ENOENT(void); +int test_yaffs_rename_dir_ENOENT_clean(void); + +#endif -- 2.30.2