From: Timothy Manning Date: Wed, 24 Nov 2010 00:57:51 +0000 (+1300) Subject: yaffs Added more tests to direct/timothy_tests/quick_tests X-Git-Tag: linux-mainline-patchset-4~56 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=10d09f1cb066885e3934db0c2c7c86dd10cbc8bf yaffs Added more tests to direct/timothy_tests/quick_tests Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index bafcbc1..682551d 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -59,7 +59,7 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_read.o test_yaffs_read_EBADF.o test_yaffs_read_EINVAL.o\ test_yaffs_lseek.o test_yaffs_lseek_EBADF.o test_yaffs_lseek_EINVAL.o test_yaffs_lseek_big_file.o \ test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o \ - test_yaffs_access_ENOENT2.o \ + test_yaffs_access_ENOENT2.o test_yaffs_access_ELOOP.o \ test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o test_yaffs_stat_ENOENT2.o \ test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \ test_yaffs_close_EBADF.o\ @@ -88,7 +88,7 @@ TESTFILES = quick_tests.o lib.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_lstat.o + test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 3479aa5..120d765 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -56,6 +56,10 @@ test_yaffs_lseek.c test_yaffs_lseek_EBADF.c test_yaffs_lseek_EINVAL.c +test_yaffs_lstat +test_yaffs_lstat_ENOENT +test_yaffs_lstat_ENOTDIR + test_yaffs_mkdir.c test_yaffs_mkdir_EEXIST.c test_yaffs_mkdir_ENOENT.c @@ -158,11 +162,9 @@ Tests to add test_yaffs_chmod_ELOOP test_yaffs_chmod_ENAMETOOLONG - test_yaffs_lstat + test_yaffs_lstat_EACCES - test_yaffs_lstat_ENOTDIR test_yaffs_lstat_ENAMETOOLONG - test_yaffs_lstat_ENOENT test_yaffs_lstat_ELOOP test_yaffs_readlink diff --git a/direct/timothy_tests/quick_tests/lib.c b/direct/timothy_tests/quick_tests/lib.c index 1c3ca68..a9aecf7 100644 --- a/direct/timothy_tests/quick_tests/lib.c +++ b/direct/timothy_tests/quick_tests/lib.c @@ -33,6 +33,19 @@ int get_exit_on_error(void) return EXIT_ON_ERROR; } + +int set_up_ELOOP(void){ + int output1=1; + int output2=1; + if (0!=yaffs_access(ELOOP2)){ + output1=yaffs_symlink(ELOOP,ELOOP2); + } + if (0!=yaffs_access(ELOOP)){ + output2=yaffs_symlink(ELOOP2,ELOOP); + } + return (output1|output2); +} + void join_paths(char *path1,char *path2,char *new_path ) { diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index 9a74a08..ecbc1e2 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -42,7 +42,8 @@ #define RENAME_DIR_PATH "/yaffs2/dir2" - +#define ELOOP "/yaffs2/ELOOP" +#define ELOOP2 "/yaffs2/ELOOP2" /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ #define FILE_PATH "/yaffs2/foo" @@ -52,4 +53,5 @@ void print_message(char *message,char print_level); void set_print_level(int new_level); void set_exit_on_error(int num); int get_exit_on_error(void); +int set_up_ELOOP(void); #endif diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 3f55512..1e5b007 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -79,6 +79,7 @@ #include "test_yaffs_access_ENOTDIR.h" #include "test_yaffs_access_ENOENT.h" #include "test_yaffs_access_ENOENT2.h" +#include "test_yaffs_access_ELOOP.h" #include "test_yaffs_stat.h" #include "test_yaffs_stat_ENOENT.h" @@ -168,6 +169,9 @@ #include "test_yaffs_rename_EEXISTS.h" #include "test_yaffs_lstat.h" +#include "test_yaffs_lstat_ENOENT.h" +#include "test_yaffs_lstat_ENOTDIR.h" + #include "yaffsfs.h" #include "yaffs_error_converter.h" @@ -211,6 +215,7 @@ test_template test_list[]={ {test_yaffs_access_ENOTDIR,test_yaffs_access_ENOTDIR_clean,"test_yaffs_access_ENOTDIR"}, {test_yaffs_access_ENOENT,test_yaffs_access_ENOENT_clean,"test_yaffs_access_ENOENT"}, {test_yaffs_access_ENOENT2,test_yaffs_access_ENOENT2_clean,"test_yaffs_access_ENOENT2"}, + {test_yaffs_access_ELOOP,test_yaffs_access_ELOOP_clean,"test_yaffs_access_ELOOP"}, {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"}, {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"}, @@ -333,7 +338,10 @@ test_template test_list[]={ {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_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"} + + {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"}, + {test_yaffs_lstat_ENOENT,test_yaffs_lstat_ENOENT_clean,"test_yaffs_lstat_ENOENT"}, + {test_yaffs_lstat_ENOTDIR,test_yaffs_lstat_ENOTDIR_clean,"test_yaffs_lstat_ENOTDIR"} }; void init_quick_tests(int argc, char *argv[]); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c new file mode 100644 index 0000000..97c6dac --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.c @@ -0,0 +1,43 @@ +/* + * 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_access_ELOOP.h" + +int test_yaffs_access_ELOOP(void) +{ + int output=0; + int error=0; + if (set_up_ELOOP()<0){ + print_message("failed to setup symlinks\n",2); + return -1; + } + output= yaffs_access(ELOOP,0); + if (output<0){ + error=yaffs_get_error(); + if ( abs(error)== ELOOP){ + return 1; + } else { + print_message("error does not match expected error\n",2); + return -1; + } + } else{ + print_message("accessed an existing file with bad mode (which is a bad thing\n",2); + + return -1; + } +} + +int test_yaffs_access_ELOOP_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h new file mode 100644 index 0000000..d919792 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ELOOP.h @@ -0,0 +1,22 @@ +/* + * 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__access_ELOOP_h__ +#define __test_yaffs_access_ELOOP_h__ +#include "lib.h" +#include "yaffsfs.h" +int test_yaffs_access_ELOOP(void); +int test_yaffs_access_ELOOP_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOENT.c new file mode 100644 index 0000000..96083ae --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOENT.c @@ -0,0 +1,63 @@ +/* + * 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_ENOENT.h" + + +int test_yaffs_lstat_ENOENT(void) +{ + int output = -1; + int error_code = -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("yaffs2/non-existing-dir/",&stat); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==ENOENT){ + return 1; + } else { + print_message("different error than expected\n", 2); + return -1; + } + } else { + print_message("lstatted a non-existing file\n", 2); + return -1; + } +} + + +int test_yaffs_lstat_ENOENT_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOENT.h new file mode 100644 index 0000000..9a48599 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat_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_lstat_ENOENT_h__ +#define __test_yaffs_lstat_ENOENT_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_lstat_ENOENT(void); +int test_yaffs_lstat_ENOENT_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c new file mode 100644 index 0000000..8aec2e6 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.c @@ -0,0 +1,63 @@ +/* + * 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_ENOTDIR.h" + + +int test_yaffs_lstat_ENOTDIR(void) +{ + int output = -1; + int error_code = -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("yaffs2/foo/dir",&stat); + 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("lstatted a non-existing file\n", 2); + return -1; + } +} + + +int test_yaffs_lstat_ENOTDIR_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.h new file mode 100644 index 0000000..5db0c46 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_lstat_ENOTDIR.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_lstat_ENOTDIR_h__ +#define __test_yaffs_lstat_ENOTDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_lstat_ENOTDIR(void); +int test_yaffs_lstat_ENOTDIR_clean(void); + +#endif