From 43f79e97ed02fe66be94b568da60126bcc351b0c Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Wed, 24 Nov 2010 09:48:36 +1300 Subject: [PATCH] yaffs Adding more tests 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 | 2 + .../timothy_tests/quick_tests/quick_tests.h | 4 +- .../quick_tests/test_yaffs_rename_EINVAL.c | 2 +- .../quick_tests/test_yaffs_rename_dir.c | 1 + .../test_yaffs_rename_dir_ENOENT.c | 2 +- .../test_yaffs_rename_dir_ENOENT2.c | 59 +++++++++++++++++++ .../test_yaffs_rename_dir_ENOENT2.h | 26 ++++++++ .../test_yaffs_rename_dir_not_empty.c | 49 +++++++++++++++ .../test_yaffs_rename_dir_not_empty.h | 26 ++++++++ 10 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index bb60030..7e4f7b3 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -86,7 +86,7 @@ TESTFILES = quick_tests.o lib.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_dir.o test_yaffs_rename_dir_ENOENT.o + test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index d26844a..c6d316b 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -241,6 +241,8 @@ Tests to add test_yaffs_rmdir_ENOTEMPTY test_yaffs_rmdir_EROFS + + what happens if a file is renamed into a dir. //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 diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index fe10c73..91403e3 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -162,6 +162,7 @@ #include "test_yaffs_rename_EINVAL.h" #include "test_yaffs_rename_dir.h" #include "test_yaffs_rename_dir_ENOENT.h" +#include "test_yaffs_rename_dir_ENOENT2.h" #include "yaffsfs.h" #include "yaffs_error_converter.h" @@ -322,7 +323,8 @@ test_template test_list[]={ {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_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"} + {test_yaffs_rename_dir_ENOENT,test_yaffs_rename_dir_ENOENT_clean,"test_yaffs_rename_dir_ENOENT"}, + {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"} }; void init_quick_tests(int argc, char *argv[]); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c index 95ddc37..5a1f675 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_EINVAL.c @@ -46,7 +46,7 @@ int test_yaffs_rename_EINVAL(void) int test_yaffs_rename_EINVAL_clean(void) { int output = 0; - if (0 == yaffs_access(RENAME_PATH,0)) { + if (0 == yaffs_access(RENAME_PATH,0) && 0 != yaffs_access(DIR_PATH,0)) { output = yaffs_rename(RENAME_PATH,FILE_PATH); if (output < 0) { print_message("failed to remove the directory\n",2); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c index 5c7a254..323a0e7 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir.c @@ -27,6 +27,7 @@ int test_yaffs_rename_dir(void) } } output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH); + printf("output %d\n",output); return output; } 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 index a4232e6..3485236 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT.c @@ -29,7 +29,7 @@ int test_yaffs_rename_dir_ENOENT(void) output = yaffs_rename( "/yaffs2/non-existing-dir/" , RENAME_DIR_PATH); if (output<0){ error_code=yaffs_get_error(); - if (abs(error_code)==EINVAL){ + if (abs(error_code)==ENOENT){ return 1; } else { print_message("returned error does not match the the expected error\n",2); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.c new file mode 100644 index 0000000..9550cce --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.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_ENOENT2.h" + + +int test_yaffs_rename_dir_ENOENT2(void) +{ + int output=0; + int error_code =0; + + if (0 != yaffs_access(DIR_PATH,0)) { + output = mkdir(DIR_PATH,S_IREAD | S_IWRITE); + if (output < 0) { + print_message("failed to create dir\n",2); + return -1; + } + } + output = yaffs_rename( DIR_PATH , "/yaffs2/nonexisting-dir/dir"); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==ENOENT){ + 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_ENOENT2_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_ENOENT2.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.h new file mode 100644 index 0000000..0cdb256 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_ENOENT2.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_ENOENT2_h__ +#define __test_yaffs_rename_dir_ENOENT2_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_rename_dir_ENOENT2(void); +int test_yaffs_rename_dir_ENOENT2_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c new file mode 100644 index 0000000..637f758 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.c @@ -0,0 +1,49 @@ +/* + * 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; + output = yaffs_open("/yaffs2/new_directory/file",O_CREAT | O_RDWR, S_IREAD | S_IWRITE); + if (output < 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 dir\n",2); + return -1; + } + } + return 1; + +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.h b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.h new file mode 100644 index 0000000..1b99f95 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_rename_dir_not_empty.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 -- 2.30.2