From de9d60531e0b398feb6304e02e940fbf6cbc4f57 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Wed, 24 Nov 2010 12:52:07 +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 | 60 +++++++++---------- .../timothy_tests/quick_tests/quick_tests.h | 5 +- .../quick_tests/test_yaffs_lstat.c | 51 ++++++++++++++++ .../quick_tests/test_yaffs_lstat.h | 25 ++++++++ .../quick_tests/test_yaffs_symlink.c | 7 +++ 6 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_lstat.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_lstat.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index 813c60f..bafcbc1 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -87,7 +87,8 @@ TESTFILES = quick_tests.o lib.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_ENOENT2.o test_yaffs_rename_dir_to_file.o \ - test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o + test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o \ + test_yaffs_lstat.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index c6d316b..3479aa5 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -183,37 +183,13 @@ Tests to add test_yaffs_symlink_ENAMETOOLONG test_yaffs_symlink_EROFS - - //the yaffs_mknod function does not exist in yaffsfs, so these tests will not be added. - test_yaffs_mknod - test_yaffs_mknod_EACCES - test_yaffs_mknod_EEXIST - test_yaffs_mknod_EINVAL - test_yaffs_mknod_ELOOP - test_yaffs_mknod_ENAMETOOLONG - test_yaffs_mknod_ENOENT - test_yaffs_mknod_ENOTDIR - test_yaffs_mknod_EROFS - - - test_yaffs_mount2_EINVAL //cannot happen in yaffs since the mode is not checked. - test_yaffs_mount2_ENOTDIR //cannot be generated in yaffs. - test_yaffs_mount2_ENOENT //cannot be generated in yaffs. test_yaffs_mount2_ENAMETOOLONG test_yaffs_mount2_with read only set - - - test_yaffs_unmount2_ENOENT //cannot be generated in yaffs. - test_yaffs_unmount2_ENOTDIR //cannot be generated in yaffs. test_yaffs_unmount2_ENAMETOOLONG - test_yaffs_remount_force_off_read_only_on test_yaffs_remount_force_on_read_only_on - test_yaffs_remount_ENOENT //cannot be generated in yaffs - test_yaffs_remount_ENOTDIR //cannot be generated in yaffs - test_yaffs_freespace_ENAMETOOLONG test_yaffs_totalspace_ENAMETOOLONG @@ -227,11 +203,10 @@ Tests to add test_yaffs_closedir - test_yaffs_link_EACCES test_yaffs_link_ELOOP - test_yaffs_link_EMLINK //should not happen on yaffs + test_yaffs_link_ENAMETOOLONG test_yaffs_link_EPERM test_yaffs_link_EROFS @@ -242,16 +217,13 @@ Tests to add 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 test_yaffs_rename_ELOOP test_yaffs_rename_EMLINK test_yaffs_rename_EEXISTS or EPERM test_yaffs_rename_EROFS - test_yaffs_dup test_yaffs_dup_EBADF @@ -273,8 +245,6 @@ Tests to add test_yaffs_stat_EACCES test_yaffs_stat_ENAMETOOLONG - - test_yaffs_read_big_file test what happens if you read off the end of the file? @@ -322,6 +292,32 @@ Tests to add What happens when a mount point is mounted using mount2 with read only mode set and then a file is chmoded? + +Tests which do not exist in yaffs: + + test_yaffs_link_EMLINK //should not happen on yaffs + + //the yaffs_mknod function does not exist in yaffsfs, so these tests will not be added. + test_yaffs_mknod + test_yaffs_mknod_EACCES + test_yaffs_mknod_EEXIST + test_yaffs_mknod_EINVAL + test_yaffs_mknod_ELOOP + test_yaffs_mknod_ENAMETOOLONG + test_yaffs_mknod_ENOENT + test_yaffs_mknod_ENOTDIR + test_yaffs_mknod_EROFS + + test_yaffs_mount2_EINVAL //cannot happen in yaffs since the mode is not checked. + test_yaffs_mount2_ENOTDIR //cannot be generated in yaffs. + test_yaffs_mount2_ENOENT //cannot be generated in yaffs. + + test_yaffs_remount_ENOENT //cannot be generated in yaffs + test_yaffs_remount_ENOTDIR //cannot be generated in yaffs + + test_yaffs_unmount2_ENOENT //cannot be generated in yaffs. + test_yaffs_unmount2_ENOTDIR //cannot be generated in yaffs. + How to add a test First create the test .c and .h file. The file name and test function name should be the same. diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 1aca5cb..3f55512 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -167,6 +167,8 @@ #include "test_yaffs_rename_file_to_dir.h" #include "test_yaffs_rename_EEXISTS.h" +#include "test_yaffs_lstat.h" + #include "yaffsfs.h" #include "yaffs_error_converter.h" #include "lib.h" @@ -330,7 +332,8 @@ test_template test_list[]={ {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"}, {test_yaffs_rename_dir_to_file,test_yaffs_rename_dir_to_file_clean,"test_yaffs_rename_dir_to_file"}, {test_yaffs_rename_file_to_dir,test_yaffs_rename_file_to_dir_clean,"test_yaffs_rename_file_to_dir"}, - {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"} + {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"}, + {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"} }; void init_quick_tests(int argc, char *argv[]); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat.c b/direct/timothy_tests/quick_tests/test_yaffs_lstat.c new file mode 100644 index 0000000..1d1ecbd --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat.c @@ -0,0 +1,51 @@ +/* + * 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_lstat.h" + + +int test_yaffs_lstat(void) +{ + int output = -1; + struct yaffs_stat stat; + if (0 != yaffs_access(FILE_PATH,0)){ + output=test_yaffs_open(); + if (output>=0){ + output = yaffs_close(output); + if (output<0){ + print_message("failed to close file\n",2); + return -1; + } + } else { + print_message("failed to open file\n",2); + return -1; + } + } + if (0 != yaffs_access(SYMLINK_PATH,0)){ + output=yaffs_symlink(FILE_PATH,SYMLINK_PATH); + if (output<0){ + print_message("failed to open file\n",2); + return -1; + } + } + + output =yaffs_lstat(SYMLINK_PATH,&stat); + return output; +} + + +int test_yaffs_lstat_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat.h b/direct/timothy_tests/quick_tests/test_yaffs_lstat.h new file mode 100644 index 0000000..b460df2 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat.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_lstat_h__ +#define __test_yaffs_lstat_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_lstat(void); +int test_yaffs_lstat_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 index 570136e..ddebec1 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_symlink.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_symlink.c @@ -17,6 +17,13 @@ static int output = 0; int test_yaffs_symlink(void) { + if (0 == yaffs_access(SYMLINK_PATH,0)){ + output=yaffs_unlink(SYMLINK_PATH); + if (output<0){ + print_message("failed to unlink symlink\n",2); + return -1; + } + } output = yaffs_symlink(FILE_PATH,SYMLINK_PATH); return output; } -- 2.30.2