From 4966064e2d0557eb3132888bf31ed1edac0fef4b Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Tue, 16 Nov 2010 15:49:09 +1300 Subject: [PATCH 1/1] yaffs More quick tests. Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 2 +- direct/timothy_tests/quick_tests/README.txt | 6 ++- .../timothy_tests/quick_tests/quick_tests.h | 5 +- .../quick_tests/test_yaffs_mkdir_EEXIST.c | 6 +-- .../quick_tests/test_yaffs_symlink_ENOTDIR.c | 47 +++++++++++++++++++ .../quick_tests/test_yaffs_symlink_ENOTDIR.h | 25 ++++++++++ 6 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 36a8b51..157abde 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -66,7 +66,7 @@ TESTFILES = quick_tests.o lib.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_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \ - test_yaffs_symlink.o + test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index e5a3e26..f98e419 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -60,6 +60,8 @@ Tests made test_yaffs_stat_ENOENT test_yaffs_stat_ENOTDIR + test_yaffs_symlink + test_yaffs_fstat test_yaffs_fstat_EBADF @@ -112,12 +114,12 @@ Tests to add test_yaffs_mkdir_ENAMETOOLONG test_yaffs_mkdir_EROFS - test_yaffs_symlink + test_yaffs_symlink_EACCES test_yaffs_symlink_EEXISTS test_yaffs_symlink_ELOOP test_yaffs_symlink_ENAMETOOLONG - test_yaffs_symlink_ENOENT + test_yaffs_symlink_ENOENT //if there is a slash on the end test_yaffs_symlink_ENOTDIR test_yaffs_symlink_EROFS diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 00b6683..d157d11 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -105,6 +105,8 @@ #include "test_yaffs_mkdir_ENOTDIR.h" #include "test_yaffs_symlink.h" +#include "test_yaffs_symlink_ENOTDIR.h" + #include "yaffsfs.h" #include "yaffs_error_converter.h" @@ -207,7 +209,8 @@ 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_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"} + {test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"}, + {test_yaffs_symlink_ENOTDIR,test_yaffs_symlink_ENOTDIR_clean,"test_yaffs_symlink_ENOTDIR"} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c index 939c214..b83594e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c @@ -49,10 +49,6 @@ int test_yaffs_mkdir_EEXIST(void) int test_yaffs_mkdir_EEXIST_clean(void) { - if (output >= 0){ - return yaffs_rmdir(DIR_PATH); - } else { - return 1; - } + return yaffs_rmdir(DIR_PATH); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.c new file mode 100644 index 0000000..b2f7867 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.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_symlink_ENOTDIR.h" + +static int output = 0; + +int test_yaffs_symlink_ENOTDIR(void) +{ + int error_code = 0; + output = yaffs_symlink(FILE_PATH,"non-existing-dir/sym_link"); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==ENOTDIR){ + return 1; + } else { + print_message("returned error does not match the the expected error\n",2); + return -1; + } + } else { + print_message("created a symlink in a non-existing directory (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_symlink_ENOTDIR_clean(void) +{ + if (output >= 0){ + return yaffs_unlink(SYMLINK_PATH); + } else { + return 1; /* the file failed to open so there is no need to close it */ + } +} + + + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.h new file mode 100644 index 0000000..e8f26eb --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_symlink_ENOTDIR.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_symlink_ENOTDIR_h__ +#define __test_yaffs_symlink_ENOTDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_symlink_ENOTDIR(void); +int test_yaffs_symlink_ENOTDIR_clean(void); + +#endif -- 2.30.2