From: Timothy Manning Date: Tue, 16 Nov 2010 02:02:51 +0000 (+1300) Subject: yaffs More tests for quick tests. X-Git-Tag: linux-mainline-patchset-4~89^2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=03704f115fc239e6a7df6eeb6da2716aec3318f8 yaffs More tests for quick tests. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 9737cdb..36a8b51 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -64,8 +64,9 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.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_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.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 diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index f2a9942..e5a3e26 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -52,6 +52,9 @@ Tests made test_yaffs_read_EBADF test_yaffs_read_EINVAL + test_yaffs_mkdir + test_yaffs_mkdir_EEXISTS + test_yaffs_mkdir_ENOTDIR test_yaffs_stat test_yaffs_stat_ENOENT @@ -103,13 +106,10 @@ Tests to add test_yaffs_readlink_ELOOP test_yaffs_readlink_ENAMETOOLONG - test_yaffs_mkdir + test_yaffs_mkdir_EACCES - test_yaffs_mkdir_EEXISTS test_yaffs_mkdir_ELOOP test_yaffs_mkdir_ENAMETOOLONG - test_yaffs_mkdir_ENOENT - test_yaffs_mkdir_ENOTDIR test_yaffs_mkdir_EROFS test_yaffs_symlink diff --git a/direct/timothy_tests/quick_tests/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt index ccada1d..534df7c 100644 --- a/direct/timothy_tests/quick_tests/current_bugs.txt +++ b/direct/timothy_tests/quick_tests/current_bugs.txt @@ -33,6 +33,8 @@ Current BUGS Bug when trying to chmod a file in a non-existing directory. The error returned is ENOENT, it should be ENOTDIR + Bug when trying to mkdir on top of a non-existing directory. The error + returned is ENOENT, it should be ENOTDIR. yaffs_mkdir should never return ENOENT. Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors. diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index 51b5794..b12c04f 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -30,6 +30,10 @@ #define FILE_TEXT "file foo " /* keep space at end of string */ #define FILE_TEXT_NBYTES 10 +#define DIR_PATH "/yaffs2/new_directory/" + +#define SYMLINK_PATH "/yaffs2/sym_foo" + /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ #define FILE_PATH "/yaffs2/foo" diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 47d8c89..00b6683 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -101,6 +101,10 @@ #include "test_yaffs_fdatasync_EBADF.h" #include "test_yaffs_mkdir.h" +#include "test_yaffs_mkdir_EEXIST.h" +#include "test_yaffs_mkdir_ENOTDIR.h" + +#include "test_yaffs_symlink.h" #include "yaffsfs.h" #include "yaffs_error_converter.h" @@ -199,7 +203,11 @@ test_template test_list[]={ {test_yaffs_fdatasync,test_yaffs_fdatasync_clean,"test_yaffs_fdatasync"}, {test_yaffs_fdatasync_EBADF,test_yaffs_fdatasync_EBADF_clean,"test_yaffs_fdatasync_EBADF"}, - {test_yaffs_mkdir,test_yaffs_mkdir_clean,"test_yaffs_mkdir"} + {test_yaffs_mkdir,test_yaffs_mkdir_clean,"test_yaffs_mkdir"}, + {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"} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c index aedaa80..a0b29b7 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c @@ -13,18 +13,18 @@ #include "test_yaffs_mkdir.h" -static int handle = 0; +static int output = -1; int test_yaffs_mkdir(void) { - handle = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); - return handle; + output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); + return output; } int test_yaffs_mkdir_clean(void) { - if (handle >= 0){ + if (output >= 0){ return yaffs_rmdir("/yaffs2/new_directory/"); } 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_mkdir_EEXISTS.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c similarity index 62% rename from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c rename to direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c index 9948393..939c214 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.c @@ -11,21 +11,30 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_mkdir_EEXISTS.h" +#include "test_yaffs_mkdir_EEXIST.h" static int output = -1; -int test_yaffs_mkdir_EEXISTS(void) +int test_yaffs_mkdir_EEXIST(void) { - output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); - if (output <0) { - print_message("filed to create the directory the first time\n",2); - return -1; + int error_code = 0; + + if (0==yaffs_access(DIR_PATH,0)){ + /* if the file exists then the file does not need to be created the first time*/ + + } else { + + output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR); + if (output <0) { + print_message("failed to create the directory the first time\n",2); + return -1; + } } + output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); if (output < 0){ error_code = yaffs_get_error(); - if (abs(error_code) == EEXISTS){ + if (abs(error_code) == EEXIST){ return 1; } else { print_message("different error than expected\n", 2); @@ -38,10 +47,10 @@ int test_yaffs_mkdir_EEXISTS(void) } -int test_yaffs_mkdir_EEXISTS_clean(void) +int test_yaffs_mkdir_EEXIST_clean(void) { if (output >= 0){ - return yaffs_rmdir("/yaffs2/new_directory/"); + return yaffs_rmdir(DIR_PATH); } else { return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.h similarity index 78% rename from direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h rename to direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.h index 16d5bfe..9b5b338 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXIST.h @@ -13,13 +13,13 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __test_yaffs_mkdir_EEXISTS_h__ -#define __test_yaffs_mkdir_EEXISTS_h__ +#ifndef __test_yaffs_mkdir_EEXIST_h__ +#define __test_yaffs_mkdir_EEXIST_h__ #include "lib.h" #include "yaffsfs.h" -int test_yaffs_mkdir_EEXISTS(void); -int test_yaffs_mkdir_EEXISTS_clean(void); +int test_yaffs_mkdir_EEXIST(void); +int test_yaffs_mkdir_EEXIST_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.c new file mode 100644 index 0000000..4b36abc --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_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_mkdir_ENOTDIR.h" + +static int output = -1; + +int test_yaffs_mkdir_ENOTDIR(void) +{ + int error_code = 0; + + + output = yaffs_mkdir("/non_existing_directory/new_directory/",O_CREAT | O_RDWR); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == ENOTDIR){ + return 1; + } else { + print_message("different error than expected\n", 2); + return -1; + } + } else { + print_message("created a new directory on top of an non-existing directory (which is a bad thing)\n", 2); + return -1; + } +} + + +int test_yaffs_mkdir_ENOTDIR_clean(void) +{ + if (output >= 0){ + return yaffs_rmdir(DIR_PATH); + } else { + return 1; + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_ENOTDIR.h new file mode 100644 index 0000000..570b406 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_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_mkdir_ENOTDIR_h__ +#define __test_yaffs_mkdir_ENOTDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_mkdir_ENOTDIR(void); +int test_yaffs_mkdir_ENOTDIR_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_symlink.c b/direct/timothy_tests/quick_tests/test_yaffs_symlink.c new file mode 100644 index 0000000..570136e --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_symlink.c @@ -0,0 +1,33 @@ +/* + * 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.h" + +static int output = 0; + +int test_yaffs_symlink(void) +{ + output = yaffs_symlink(FILE_PATH,SYMLINK_PATH); + return output; +} + + +int test_yaffs_symlink_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.h b/direct/timothy_tests/quick_tests/test_yaffs_symlink.h new file mode 100644 index 0000000..e41bfeb --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_symlink.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_h__ +#define __test_yaffs_symlink_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_symlink(void); +int test_yaffs_symlink_clean(void); + +#endif