From: Timothy Manning Date: Mon, 29 Nov 2010 02:54:12 +0000 (+1300) Subject: yaffs Added some more tests to direct/timothy_tests/quick_tests X-Git-Tag: linux-mainline-patchset-4~26^2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=e0dca71d0430cb8d972a7e64860cdf4410ab084e yaffs Added some 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 57fdacb..1d8a025 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -50,7 +50,7 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_unmount.o test_yaffs_unmount_ENODEV.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \ test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o \ test_yaffs_open_ENAMETOOLONG.o test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o test_yaffs_open_ELOOP.o \ - test_yaffs_open_ELOOP_dir.o test_yaffs_open_EROFS.o \ + test_yaffs_open_ELOOP_dir.o test_yaffs_open_EROFS.o test_yaffs_open_EACCES.o \ test_yaffs_unlink.o test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o \ test_yaffs_unlink_ENOTDIR.o test_yaffs_unlink_ENOENT2.o test_yaffs_unlink_ELOOP_dir.o test_yaffs_unlink_EROFS.o \ test_yaffs_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_big_file.o \ @@ -63,6 +63,7 @@ TESTFILES = quick_tests.o lib.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_ELOOP_dir.o test_yaffs_access_ELOOP.o test_yaffs_access_EROFS.o \ + test_yaffs_access_EACCES.o \ test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o test_yaffs_stat_ENOENT2.o test_yaffs_stat_ELOOP.o \ test_yaffs_stat_ELOOP_dir.o\ test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 97dd42d..39fa4ca 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -12,6 +12,7 @@ test_yaffs_access_ENOENT2.c test_yaffs_access_ENOENT.c test_yaffs_access_ENOTDIR.c test_yaffs_access_EROFS.c + test_yaffs_chmod.c test_yaffs_chmod_EINVAL.c test_yaffs_chmod_ELOOP.c @@ -20,32 +21,42 @@ test_yaffs_chmod_ENOENT2.c test_yaffs_chmod_ENOENT.c test_yaffs_chmod_ENOTDIR.c test_yaffs_chmod_EROFS.c + test_yaffs_close.c test_yaffs_close_EBADF.c + test_yaffs_fchmod.c test_yaffs_fchmod_EBADF.c test_yaffs_fchmod_EINVAL.c test_yaffs_fchmod_EROFS.c + test_yaffs_fdatasync.c test_yaffs_fdatasync_EBADF.c test_yaffs_fdatasync_EROFS.c + test_yaffs_flush.c test_yaffs_flush_EBADF.c test_yaffs_flush_EROFS.c + test_yaffs_freespace.c test_yaffs_freespace_EINVAL.c + test_yaffs_fstat.c test_yaffs_fstat_EBADF.c + test_yaffs_fsync.c test_yaffs_fsync_EBADF.c test_yaffs_fsync_EROFS.c + test_yaffs_ftruncate_big_file.c test_yaffs_ftruncate.c test_yaffs_ftruncate_EBADF.c test_yaffs_ftruncate_EINVAL.c test_yaffs_ftruncate_EROFS.c + test_yaffs_inodecount.c test_yaffs_inodecount_EINVAL.c + test_yaffs_link.c test_yaffs_link_EEXIST.c test_yaffs_link_ELOOP_dir.c @@ -56,26 +67,31 @@ test_yaffs_link_ENOENT.c test_yaffs_link_ENOTDIR2.c test_yaffs_link_ENOTDIR.c test_yaffs_link_EROFS.c + test_yaffs_lseek_big_file.c test_yaffs_lseek.c test_yaffs_lseek_EBADF.c test_yaffs_lseek_EINVAL.c test_yaffs_lseek_EROFS.c + test_yaffs_lstat.c test_yaffs_lstat_ENOENT.c test_yaffs_lstat_ENOTDIR.c + test_yaffs_mkdir.c test_yaffs_mkdir_EEXIST.c test_yaffs_mkdir_ELOOP_dir.c test_yaffs_mkdir_ENOENT.c test_yaffs_mkdir_ENOTDIR.c test_yaffs_mkdir_EROFS.c + test_yaffs_mount2.c test_yaffs_mount2_ENODEV.c test_yaffs_mount.c test_yaffs_mount_EBUSY.c test_yaffs_mount_ENAMETOOLONG.c test_yaffs_mount_ENODEV.c + test_yaffs_open.c test_yaffs_open_EEXIST.c test_yaffs_open_EINVAL2.c @@ -87,15 +103,18 @@ test_yaffs_open_ENAMETOOLONG.c test_yaffs_open_ENOENT.c test_yaffs_open_ENOTDIR.c test_yaffs_open_EROFS.c + test_yaffs_read.c test_yaffs_read_EBADF.c test_yaffs_read_EINVAL.c + test_yaffs_remount_EINVAL.c test_yaffs_remount_ENODEV.c test_yaffs_remount_force_off_read_only_off.c test_yaffs_remount_force_off_read_only_on.c test_yaffs_remount_force_on_read_only_off.c test_yaffs_remount_force_on_read_only_on.c + test_yaffs_rename.c test_yaffs_rename_dir.c test_yaffs_rename_dir_ENOENT2.c @@ -109,6 +128,7 @@ test_yaffs_rename_ENOENT.c test_yaffs_rename_ENOTDIR.c test_yaffs_rename_EROFS.c test_yaffs_rename_file_to_dir.c + test_yaffs_rmdir.c test_yaffs_rmdir_EBUSY.c test_yaffs_rmdir_EINVAL.c @@ -116,12 +136,14 @@ test_yaffs_rmdir_ELOOP_dir.c test_yaffs_rmdir_ENOENT.c test_yaffs_rmdir_ENOTDIR.c test_yaffs_rmdir_EROFS.c + test_yaffs_stat.c test_yaffs_stat_ELOOP.c test_yaffs_stat_ELOOP_dir.c test_yaffs_stat_ENOENT2.c test_yaffs_stat_ENOENT.c test_yaffs_stat_ENOTDIR.c + test_yaffs_symlink.c test_yaffs_symlink_EEXIST.c test_yaffs_symlink_ELOOP_dir.c @@ -129,11 +151,14 @@ test_yaffs_symlink_ENOENT2.c test_yaffs_symlink_ENOENT.c test_yaffs_symlink_ENOTDIR.c test_yaffs_symlink_EROFS.c + test_yaffs_sync.c test_yaffs_sync_ENODEV.c test_yaffs_sync_EROFS.c + test_yaffs_totalspace.c test_yaffs_totalspace_EINVAL.c + test_yaffs_truncate_big_file.c test_yaffs_truncate.c test_yaffs_truncate_EINVAL.c @@ -144,6 +169,7 @@ test_yaffs_truncate_ENOENT2.c test_yaffs_truncate_ENOENT.c test_yaffs_truncate_ENOTDIR.c test_yaffs_truncate_EROFS.c + test_yaffs_unlink.c test_yaffs_unlink_EISDIR.c test_yaffs_unlink_ELOOP_dir.c @@ -152,6 +178,7 @@ test_yaffs_unlink_ENOENT2.c test_yaffs_unlink_ENOENT.c test_yaffs_unlink_ENOTDIR.c test_yaffs_unlink_EROFS.c + test_yaffs_unmount2.c test_yaffs_unmount2_EINVAL.c test_yaffs_unmount2_ENODEV.c @@ -161,6 +188,7 @@ test_yaffs_unmount.c test_yaffs_unmount_EBUSY.c test_yaffs_unmount_ENAMETOOLONG.c test_yaffs_unmount_ENODEV.c + test_yaffs_write_big_file.c test_yaffs_write.c test_yaffs_write_EBADF.c @@ -169,14 +197,9 @@ test_yaffs_write_EROFS.c Tests to add - test_yaffs_fchmod_EACCES - - test_yaffs_chmod_EACCES test_yaffs_chmod_ENAMETOOLONG - - test_yaffs_lstat_EACCES test_yaffs_lstat_ENAMETOOLONG @@ -187,12 +210,12 @@ Tests to add test_yaffs_readlink_ENAMETOOLONG - test_yaffs_mkdir_EACCES + test_yaffs_mkdir_ENAMETOOLONG - test_yaffs_symlink_EACCES + test_yaffs_symlink_ENAMETOOLONG @@ -216,21 +239,21 @@ Tests to add test_yaffs_closedir - test_yaffs_link_EACCES + test_yaffs_link_ENAMETOOLONG test_yaffs_link_EPERM - test_yaffs_rmdir_EACCES + test_yaffs_rmdir_ENOTEMPTY - test_yaffs_rename_EACCES + test_yaffs_rename_EMLINK test_yaffs_rename_EEXISTS or EPERM @@ -238,11 +261,11 @@ Tests to add test_yaffs_dup test_yaffs_dup_EBADF - test_yaffs_fchmod_EACCES + test_yaffs_fchmod_ELOOP - test_yaffs_open_EACCES + test_yaffs_open_ENOSPC test_yaffs_open_ELOOP test yaffs_open_running_out_of_handles error @@ -250,7 +273,7 @@ Tests to add - test_yaffs_stat_EACCES + test_yaffs_stat_ENAMETOOLONG test_yaffs_read_big_file @@ -270,21 +293,21 @@ Tests to add test_yaffs_pwrite_big_file test_yaffs_pwrite_EINVAL - test_yaffs_unlink_EACCES + test_yaffs_unlink_ENOMEM - test_yaffs_stat_EACCES + test_yaffs_stat_ELOOP - test_yaffs_access_EACCESS + test_yaffs_access_ENAMETOOLONG test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link - test_yaffs_ftruncate_EACCES - test_yaffs_truncate_EACCES + + test_yaffs_truncate_ENAMETOOLONG Add a truncate function for truncating a file size to -1. diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 67f562e..2705479 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -38,6 +38,7 @@ #include "test_yaffs_open_ELOOP.h" #include "test_yaffs_open_ELOOP_dir.h" #include "test_yaffs_open_EROFS.h" +#include "test_yaffs_open_EACCES.h" #include "test_yaffs_close_EBADF.h" @@ -92,6 +93,7 @@ #include "test_yaffs_access_ELOOP_dir.h" #include "test_yaffs_access_ELOOP.h" #include "test_yaffs_access_EROFS.h" +#include "test_yaffs_access_EACCES.h" #include "test_yaffs_stat.h" #include "test_yaffs_stat_ENOENT.h" @@ -246,6 +248,7 @@ test_template test_list[]={ {test_yaffs_open_ELOOP,test_yaffs_open_ELOOP_clean,"test_yaffs_open_ELOOP"}, {test_yaffs_open_ELOOP_dir,test_yaffs_open_ELOOP_dir_clean,"test_yaffs_open_ELOOP_dir"}, {test_yaffs_open_EROFS,test_yaffs_open_EROFS_clean,"test_yaffs_open_EROFS"}, + {test_yaffs_open_EACCES,test_yaffs_open_EACCES_clean,"test_yaffs_open_EACCES"}, {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"}, @@ -257,6 +260,7 @@ test_template test_list[]={ {test_yaffs_access_ELOOP_dir,test_yaffs_access_ELOOP_dir_clean,"test_yaffs_access_ELOOP_dir"}, {test_yaffs_access_ELOOP,test_yaffs_access_ELOOP_clean,"test_yaffs_access_ELOOP"}, {test_yaffs_access_EROFS,test_yaffs_access_EROFS_clean,"test_yaffs_access_EROFS"}, + {test_yaffs_access_EACCES,test_yaffs_access_EACCES_clean,"test_yaffs_access_EACCES"}, {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"}, {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.c b/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.c new file mode 100644 index 0000000..8aaa35d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.c @@ -0,0 +1,50 @@ +/* + * 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_EACCES.h" + +int test_yaffs_access_EACCES(void) +{ + int output=0; + int error=0; + output=yaffs_chmod(FILE_PATH,S_IREAD); + if (output<0){ + print_message("failed to chmod file\n",2); + return -1; + } + output= yaffs_access(FILE_PATH,W_OK); + if (output<0){ + error=yaffs_get_error(); + if ( abs(error)== EACCES){ + 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_EACCES_clean(void) +{ + int output=0; + output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE); + if (output<0){ + print_message("failed to chmod file\n",2); + return -1; + } + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.h b/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.h new file mode 100644 index 0000000..7cb624b --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EACCES.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_EACCES_h__ +#define __test_yaffs_access_EACCES_h__ +#include "lib.h" +#include "yaffsfs.h" +int test_yaffs_access_EACCES(void); +int test_yaffs_access_EACCES_clean(void); +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.c new file mode 100644 index 0000000..04de113 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.c @@ -0,0 +1,67 @@ +/* + * 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_open_EACCES.h" + +static int handle = -1; + +int test_yaffs_open_EACCES(void) +{ + int error_code=0; + int output =-1; + if (yaffs_access(FILE_PATH,0)!=0){ + output=yaffs_close(test_yaffs_open()); + if (output<0){ + print_message("failed to open file\n",2); + return -1; + } + } + + output=yaffs_chmod(FILE_PATH,S_IREAD); + if (output<0){ + print_message("failed to chmod file\n",2); + return -1; + } + handle=yaffs_open(FILE_PATH, O_TRUNC| O_RDWR,FILE_MODE ); + if (handle <0){ + error_code=yaffs_get_error(); + if (abs(error_code)==EACCES){ + return 1; + } + else { + print_message("different error than expected\n",2); + return -1; + } + } + else { + print_message("file opened with read and write permissions, chmoded to read only.(which is a bad thing)\n",2); + return -1; + } +} + +int test_yaffs_open_EACCES_clean(void) +{ + int output= -1; + int output2=-1; + if (handle >=0){ + output2= yaffs_close(handle); + } + output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE); + if (output<0){ + print_message("failed to chmod file\n",2); + return -1; + } + return (output2&&output); + +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.h new file mode 100644 index 0000000..83cc32a --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EACCES.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_open_EACCES_h__ +#define __test_yaffs_open_EACCES_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_open_EACCES(void); +int test_yaffs_open_EACCES_clean(void); + +#endif