From a32621e0d7f5f391e9152cfe710fa6c99ca44c50 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Mon, 15 Nov 2010 12:18:23 +1300 Subject: [PATCH] yaffs Have revised and checked each test in quick tests. Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 5 +- direct/timothy_tests/quick_tests/README.txt | 24 +++++-- .../quick_tests/current_bugs.txt | 12 +++- direct/timothy_tests/quick_tests/lib.c | 25 +++++--- direct/timothy_tests/quick_tests/lib.h | 10 ++- .../timothy_tests/quick_tests/quick_tests.c | 63 +++++++++++-------- .../timothy_tests/quick_tests/quick_tests.h | 22 ++++++- .../quick_tests/test_yaffs_access.c | 6 +- .../quick_tests/test_yaffs_access.h | 2 - .../quick_tests/test_yaffs_access_EINVAL.c | 18 +++--- .../quick_tests/test_yaffs_access_EINVAL.h | 2 - .../quick_tests/test_yaffs_access_ENOENT.c | 18 +++--- .../quick_tests/test_yaffs_access_ENOTDIR.c | 20 +++--- .../quick_tests/test_yaffs_chmod.c | 33 ++++++++++ .../quick_tests/test_yaffs_chmod.h | 25 ++++++++ .../quick_tests/test_yaffs_chmod_EINVAL.c | 39 ++++++++++++ .../quick_tests/test_yaffs_chmod_EINVAL.h | 25 ++++++++ .../quick_tests/test_yaffs_chmod_EINVAL2.c | 39 ++++++++++++ .../quick_tests/test_yaffs_chmod_EINVAL2.h | 25 ++++++++ .../quick_tests/test_yaffs_chmod_ENOENT.c | 39 ++++++++++++ .../quick_tests/test_yaffs_chmod_ENOENT.h | 25 ++++++++ .../quick_tests/test_yaffs_chmod_ENOTDIR.c | 39 ++++++++++++ .../quick_tests/test_yaffs_chmod_ENOTDIR.h | 25 ++++++++ .../quick_tests/test_yaffs_close_EBADF.c | 60 +++++++++--------- .../quick_tests/test_yaffs_fchmod.c | 49 +++++++++++++++ .../quick_tests/test_yaffs_fchmod.h | 25 ++++++++ .../quick_tests/test_yaffs_fchmod_EBADF.c | 56 +++++++++++++++++ .../quick_tests/test_yaffs_fchmod_EBADF.h | 25 ++++++++ .../quick_tests/test_yaffs_fstat.c | 22 ++++--- .../quick_tests/test_yaffs_fstat.h | 2 + .../quick_tests/test_yaffs_fstat_EBADF.c | 33 +++++----- .../quick_tests/test_yaffs_fstat_EBADF.h | 3 + .../quick_tests/test_yaffs_ftruncate.c | 39 ++++++------ .../quick_tests/test_yaffs_ftruncate.h | 5 +- .../quick_tests/test_yaffs_ftruncate_EBADF.c | 30 ++++----- .../quick_tests/test_yaffs_ftruncate_EBADF.h | 3 + .../quick_tests/test_yaffs_ftruncate_EFBIG.c | 58 +++++++++-------- .../quick_tests/test_yaffs_ftruncate_EFBIG.h | 3 + .../quick_tests/test_yaffs_ftruncate_EINVAL.c | 56 +++++++++-------- .../quick_tests/test_yaffs_ftruncate_EINVAL.h | 3 + .../quick_tests/test_yaffs_lseek.c | 37 +++++------ .../quick_tests/test_yaffs_lseek.h | 2 + .../quick_tests/test_yaffs_lseek_EBADF.c | 19 +++--- .../quick_tests/test_yaffs_lseek_EBADF.h | 2 +- .../quick_tests/test_yaffs_lseek_EFBIG.c | 42 ++++++------- .../quick_tests/test_yaffs_lseek_EFBIG.h | 1 + .../quick_tests/test_yaffs_lseek_EINVAL.c | 43 ++++++------- .../quick_tests/test_yaffs_lseek_EINVAL.h | 1 + .../quick_tests/test_yaffs_mount.c | 14 ++--- .../quick_tests/test_yaffs_mount.h | 1 + .../quick_tests/test_yaffs_mount_EBUSY.c | 18 +++--- .../quick_tests/test_yaffs_mount_EBUSY.h | 1 + .../test_yaffs_mount_ENAMETOOLONG.c | 35 +++++------ .../test_yaffs_mount_ENAMETOOLONG.h | 1 + .../quick_tests/test_yaffs_mount_ENODEV.c | 30 ++++----- .../quick_tests/test_yaffs_mount_ENODEV.h | 1 + .../quick_tests/test_yaffs_mount_ENOENT.c | 37 ++++++----- .../quick_tests/test_yaffs_mount_ENOENT.h | 1 + .../quick_tests/test_yaffs_open.c | 18 +++--- .../quick_tests/test_yaffs_open.h | 1 + .../quick_tests/test_yaffs_open_EEXIST.c | 39 ++++++------ .../quick_tests/test_yaffs_open_EEXIST.h | 1 + .../quick_tests/test_yaffs_open_EINVAL.c | 38 ++++++----- .../quick_tests/test_yaffs_open_EINVAL.h | 1 + .../quick_tests/test_yaffs_open_EINVAL2.c | 29 ++++----- .../quick_tests/test_yaffs_open_EINVAL2.h | 1 + .../quick_tests/test_yaffs_open_EISDIR.c | 28 ++++----- .../quick_tests/test_yaffs_open_EISDIR.h | 1 + .../test_yaffs_open_ENAMETOOLONG.c | 47 +++++++------- .../test_yaffs_open_ENAMETOOLONG.h | 1 + .../quick_tests/test_yaffs_open_ENOENT.c | 30 ++++----- .../quick_tests/test_yaffs_open_ENOENT.h | 1 + .../quick_tests/test_yaffs_open_ENOTDIR.c | 23 +++---- .../quick_tests/test_yaffs_open_ENOTDIR.h | 1 + .../quick_tests/test_yaffs_read.c | 30 ++++----- .../quick_tests/test_yaffs_read.h | 1 + .../quick_tests/test_yaffs_read_EBADF.c | 21 ++++--- .../quick_tests/test_yaffs_read_EBADF.h | 3 +- .../quick_tests/test_yaffs_read_EINVAL.c | 51 +++++++-------- .../quick_tests/test_yaffs_read_EINVAL.h | 2 + .../quick_tests/test_yaffs_stat.c | 51 +++++++-------- .../quick_tests/test_yaffs_stat.h | 3 + .../quick_tests/test_yaffs_stat_ENOENT.c | 18 +++--- .../quick_tests/test_yaffs_stat_ENOENT.h | 3 +- .../quick_tests/test_yaffs_stat_ENOTDIR.c | 16 ++--- .../quick_tests/test_yaffs_stat_ENOTDIR.h | 3 +- .../quick_tests/test_yaffs_truncate.c | 27 ++++---- .../quick_tests/test_yaffs_truncate.h | 3 + .../quick_tests/test_yaffs_truncate_EFBIG.c | 23 ++++--- .../quick_tests/test_yaffs_truncate_EFBIG.h | 3 + .../quick_tests/test_yaffs_truncate_EINVAL.c | 23 ++++--- .../quick_tests/test_yaffs_truncate_EINVAL.h | 3 + .../quick_tests/test_yaffs_truncate_EISDIR.c | 37 ++++++----- .../quick_tests/test_yaffs_truncate_EISDIR.h | 3 + .../quick_tests/test_yaffs_truncate_ENOENT.c | 27 ++++---- .../quick_tests/test_yaffs_truncate_ENOENT.h | 5 +- .../quick_tests/test_yaffs_truncate_ENOTDIR.c | 24 +++---- .../quick_tests/test_yaffs_unlink.c | 11 ++-- .../quick_tests/test_yaffs_unlink.h | 1 + .../quick_tests/test_yaffs_unlink_EISDIR.c | 28 ++++----- .../quick_tests/test_yaffs_unlink_EISDIR.h | 1 + .../test_yaffs_unlink_ENAMETOOLONG.c | 18 +++--- .../quick_tests/test_yaffs_unlink_ENOENT.c | 29 +++++---- .../quick_tests/test_yaffs_unlink_ENOENT.h | 1 + .../quick_tests/test_yaffs_unlink_ENOTDIR.c | 19 +++--- .../quick_tests/test_yaffs_unlink_ENOTDIR.h | 1 + .../quick_tests/test_yaffs_unmount.c | 14 ++--- .../quick_tests/test_yaffs_unmount.h | 1 + .../quick_tests/test_yaffs_unmount_EBUSY.c | 23 ++++--- .../quick_tests/test_yaffs_unmount_EBUSY.h | 1 + .../test_yaffs_unmount_ENAMETOOLONG.c | 28 +++------ .../test_yaffs_unmount_ENAMETOOLONG.h | 1 + .../quick_tests/test_yaffs_unmount_ENOENT.c | 21 +++---- .../quick_tests/test_yaffs_unmount_ENOENT.h | 1 + .../quick_tests/test_yaffs_write.c | 16 ++--- .../quick_tests/test_yaffs_write.h | 3 + .../quick_tests/test_yaffs_write_EBADF.c | 29 +++++---- .../quick_tests/test_yaffs_write_EBADF.h | 3 + 118 files changed, 1383 insertions(+), 806 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod.h create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index a22592a..bf82726 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -59,7 +59,10 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o\ test_yaffs_stat.o test_yaffs_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o \ test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \ - test_yaffs_close_EBADF.o + test_yaffs_close_EBADF.o\ + test_yaffs_chmod.o test_yaffs_chmod_ENOENT.o test_yaffs_chmod_ENOTDIR.o test_yaffs_chmod_EINVAL.o \ + test_yaffs_chmod_EINVAL2.o\ + test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index b7b17b0..25b995e 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -3,11 +3,18 @@ Made by Timothy Manning on 04/11/2010 Tests made + test_yaffs_chmod + test_yaffs_chmod_ENOENT + test_yaffs_chmod_ENOTDIR + + test_yaffs_fchmod + test_yaffs_fchmod_EBADF + test_yaffs_mount test_yaffs_mount_ENODEV test_yaffs_mount_ENAMETOOLONG test_yaffs_mount_ENOENT - test_yaffs_mount_EBUSY //called when trying to mount a new mount point with a mount point already mounted. + test_yaffs_mount_EBUSY //caused by trying to mount a new mount point with a mount point already mounted. test_yaffs_access test_yaffs_access_ENIVAL @@ -33,7 +40,7 @@ Tests made test_yaffs_open_ENOENT test_yaffs_open_ENOTDIR test_yaffs_open_EINVAL - test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests modes are needed. + test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests are needed. test_yaffs_read test_yaffs_read_EBADF @@ -59,7 +66,6 @@ Tests made test_yaffs_unlink_ENAMETOOLONG test_yaffs_unlink_ENOENT test_yaffs_unlink_ENOTDIR - test_yaffs_unlink_ENOENT test_yaffs_unmount test_yaffs_unmount_ENOENT @@ -72,6 +78,14 @@ Tests made Tests to add + test_yaffs_chmod_EACCES + test_yaffs_chmod_ELOOP + test_yaffs_chmod_ENAMETOOLONG + + + test_yaffs_fchmod_EACCES + test_yaffs_fchmod_ELOOP + test_yaffs_mount_EACCES //Cannot be generated with yaffs. test_yaffs_mount_EINVAL //Cannot be generated with yaffs. test_yaffs_mount_ELOOP //Cannot be generated with yaffs. @@ -84,7 +98,7 @@ Tests to add test_yaffs_open_EACCES test_yaffs_open_ENOSPC - test_yaffs_open_ELOOP //Too many symbolic links were encountered in resolving pathname + test_yaffs_open_ELOOP test yaffs_open_running_out_of_handles error test_yaffs_close //This function has already been called by the time this test is reached. @@ -134,6 +148,8 @@ Tests to add What happens when open a handle, unmount yaffs and then try to use the handle? + What happens when a mount point is mounted using mount2 with read only mode set and then a file is chmoded? + 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/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt index 6435529..ed659a1 100644 --- a/direct/timothy_tests/quick_tests/current_bugs.txt +++ b/direct/timothy_tests/quick_tests/current_bugs.txt @@ -30,6 +30,16 @@ Current BUGS Bug when trying to stat a file in a non-existing directory. The error returned is ENOENT, it should be ENOTDIR + Bug when trying to chmod a file in a non-existing directory. The error + returned is ENOENT, it should be ENOTDIR + + + + There may be a bug with trying to chmoding a file with the mode set to 0. + The chmod function does not return an error which means that it is unknown what modes the file is chmoded to. + When yaffs_open is used on the file the error EACCES is returned. It is possible that yaffs has changed the mode + to read only. + Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors. The function should return the error EINVAL. @@ -45,7 +55,7 @@ Current BUGS It should return EINVAL. This is because it was reading an empty file. When text is added to the file a read of -1 bytes tries to read 4 gig of data - Bug when writing a file. the writhing to the file causes the file size to exceed the size of yaffs file system memory. + Bug when writing a file. The writing to the file causes the file size to exceed the size of yaffs file system memory. Output of test: test_yaffs_write_EFBIG AddrToChunk of offset -2147483648 gives chunk -1048576 start 0 diff --git a/direct/timothy_tests/quick_tests/lib.c b/direct/timothy_tests/quick_tests/lib.c index 39b0713..a7219c5 100644 --- a/direct/timothy_tests/quick_tests/lib.c +++ b/direct/timothy_tests/quick_tests/lib.c @@ -14,7 +14,8 @@ #include "lib.h" -void join_paths(char *path1,char *path2,char *new_path ){ +void join_paths(char *path1,char *path2,char *new_path ) +{ //strcat(new_path,path1); /*since all functions have this then pull it out*/ if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') { @@ -24,31 +25,35 @@ void join_paths(char *path1,char *path2,char *new_path ){ //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))]; //strcpy(new_path,strcat(path1,path2)); //return new_path; - } - else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') { + } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') { /*paths are compatiable. concatanate them*/ strcat(new_path,path1); strcat(new_path,path2); - } - else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') { + } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') { /*need to add a "/". */ strcat(new_path,path1); strcat(new_path,"/"); strcat(new_path,path2); - - } - else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') { + } else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') { /*need to remove a "/". */ /*yaffs does not mind the extra slash. */ strcat(new_path,path1); strcat(new_path,path2); - } - else{ + } else { //error //return -1; } } +void print_message(char *message,char print_level) +{ + if (print_level <= PRINT_LEVEL){ + printf(message); + } +} + + + diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index 50c548f..2efd08e 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -16,8 +16,15 @@ #ifndef _lib_h__ #define _lib_h__ - +#include #include + +#define EXIT_ON_ERROR 0 +#define PRINT_LEVEL 2 //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3 + //0 just prints the number of tests passed and failed. + //1 is the basic print level. it will print the details of a failed test. + //2 will print if a test passes and cleans. + #define YAFFS_MOUNT_POINT "/yaffs2/" #define FILE_NAME "foo" #define FILE_SIZE 10 @@ -31,4 +38,5 @@ #define FILE_PATH "/yaffs2/foo" void join_paths(char *path1,char *path2,char *new_path ); +void print_message(char *message,char print_level); #endif diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index 720fdee..17bce3b 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -27,45 +27,46 @@ static unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_templat int main(){ int output=0; - + char message[30]; + message[0]='\0'; unsigned int x=0; init_quick_tests(); - printf("\n\nrunning quick tests for yaffs\n\n"); + print_message("\n\nrunning quick tests for yaffs\n\n", 0); //printf("testing yaffs\n"); //printf("len function %d",(sizeof(test_list)/sizeof(test_template))); for (x=0;x=0){ /*test has passed*/ - printf("\ttest %s passed\n",test_list[x].name_of_test); + sprintf(message,"\ttest %s passed\n",test_list[x].name_of_test); + print_message(message,2); num_of_tests_pass++; - } - else { + } else { /*test is assumed to have failed*/ //printf("test failed\n"); - printf("test: %s failed\n",test_list[x].name_of_test); + sprintf(message,"test: %s failed\n",test_list[x].name_of_test); + print_message(message,1); num_of_tests_failed ++; - - if (EXIT_ON_ERROR){ - get_error(); - printf("\n\n"); + + get_error(); + print_message("\n\n",1); + if (EXIT_ON_ERROR){ quit_quick_tests(1); } - else { - get_error(); - printf("\n\n"); - } + } output=0; output=test_list[x].p_function_clean(); /*clean the test*/ if (output <0){ /* if the test failed to clean it's self then */ - printf("test: %s failed to clean\n",test_list[x].name_of_test); + sprintf(message,"test: %s failed to clean\n",test_list[x].name_of_test); + print_message(message,1); num_of_tests_failed ++; num_of_tests_pass--; get_error(); @@ -75,34 +76,42 @@ int main(){ } } else { - printf("\ttest clean: %s passed\n",test_list[x].name_of_test); + sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test); + print_message(message,2); } } /*this is where the loop should break to*/ quit_quick_tests(0); - /* the progame should never get here*/ - return 0; } -void quit_quick_tests(int exit_code){ - +void quit_quick_tests(int exit_code) +{ + char message[30]; + message[0]='\0'; if (num_of_tests_pass==total_number_of_tests && num_of_tests_failed==0){ printf("\t OK \n"); } - printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed); + printf("tests: %d passed %d failed out of %d tests\n\n\n",num_of_tests_pass,num_of_tests_failed,total_number_of_tests); yaffs_unmount(YAFFS_MOUNT_POINT); exit(exit_code); } -void get_error(void){ +void get_error(void) +{ int error_code=0; + char message[30]; + message[0]='\0'; + error_code=yaffs_get_error(); - printf("yaffs_error code %d\n",error_code); - printf("error is : %s\n",yaffs_error_to_str(error_code)); + sprintf(message,"yaffs_error code %d\n",error_code); + print_message(message,1); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + print_message(message,1); } -void init_quick_tests(void){ - yaffs_start_up();; +void init_quick_tests(void) +{ + yaffs_start_up(); yaffs_set_trace(0); } diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index a11386d..b44bf9b 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -85,12 +85,21 @@ #include "test_yaffs_fstat.h" #include "test_yaffs_fstat_EBADF.h" +#include "test_yaffs_chmod.h" +#include "test_yaffs_chmod_ENOENT.h" +#include "test_yaffs_chmod_ENOTDIR.h" +#include "test_yaffs_chmod_EINVAL.h" +#include "test_yaffs_chmod_EINVAL2.h" + +#include "test_yaffs_fchmod.h" +#include "test_yaffs_fchmod_EBADF.h" + #include "yaffsfs.h" #include "yaffs_error_converter.h" #include "lib.h" -#define EXIT_ON_ERROR 0 + typedef struct test { int (*p_function)(void); /*pointer to test function*/ @@ -166,7 +175,16 @@ test_template test_list[]={ {test_yaffs_truncate_EISDIR,test_yaffs_truncate_EISDIR_clean,"test_yaffs_truncate_EISDIR"}, {test_yaffs_truncate_EINVAL,test_yaffs_truncate_EINVAL_clean,"test_yaffs_truncate_EINVAL"}, {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"}, - {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"} + {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"}, + + {test_yaffs_chmod,test_yaffs_chmod_clean,"test_yaffs_chmod"}, + {test_yaffs_chmod_ENOENT,test_yaffs_chmod_ENOENT_clean,"test_yaffs_chmod_ENOENT"}, + {test_yaffs_chmod_ENOTDIR,test_yaffs_chmod_ENOTDIR_clean,"test_yaffs_chmod_ENOTDIR"}, + {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"}, + {test_yaffs_chmod_EINVAL2,test_yaffs_chmod_EINVAL2_clean,"test_yaffs_chmod_EINVAL2"}, + + {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"}, + {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"} }; void init_quick_tests(void); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access.c b/direct/timothy_tests/quick_tests/test_yaffs_access.c index 9a00b93..da4f23e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access.c @@ -13,10 +13,12 @@ #include "test_yaffs_access.h" -int test_yaffs_access(void){ +int test_yaffs_access(void) +{ return yaffs_access(FILE_PATH,0); } -int test_yaffs_access_clean(void){ +int test_yaffs_access_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access.h b/direct/timothy_tests/quick_tests/test_yaffs_access.h index 3f9e26c..9919498 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_access.h @@ -17,8 +17,6 @@ #define __test_yaffs_access_h__ #include "lib.h" #include "yaffsfs.h" -#include "test_yaffs_open.h" -#include "test_yaffs_lseek.h" int test_yaffs_access(void); int test_yaffs_access_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c index cec0389..f8ba13a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c @@ -13,26 +13,28 @@ #include "test_yaffs_access_EINVAL.h" -int test_yaffs_access_EINVAL(void){ +int test_yaffs_access_EINVAL(void) +{ int output=0; int error=0; + output= yaffs_access(FILE_PATH,255); if (output<0){ error=yaffs_get_error(); if ( abs(error)== EINVAL){ return 1; - } - else { - printf("error does not match expected error\n"); + } else { + print_message("error does not match expected error\n",2); return -1; } - } - else{ - printf("accessed an existing file with bad mode (which is a bad thing\n"); + } else{ + print_message("accessed an existing file with bad mode (which is a bad thing\n",2); + return -1; } } -int test_yaffs_access_EINVAL_clean(void){ +int test_yaffs_access_EINVAL_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h index b13a1a0..62fe9e2 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h @@ -17,8 +17,6 @@ #define __test_yaffs_access_EINVAL_h__ #include "lib.h" #include "yaffsfs.h" -#include "test_yaffs_open.h" -#include "test_yaffs_lseek.h" int test_yaffs_access_EINVAL(void); int test_yaffs_access_EINVAL_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c index 610e4ee..3746886 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c @@ -14,28 +14,28 @@ #include "test_yaffs_access_ENOENT.h" -int test_yaffs_access_ENOENT(void){ +int test_yaffs_access_ENOENT(void) +{ int output=0; int error_code=0; - /*printf("path %s\n",path); */ + output=yaffs_access("/yaffs2/non_existant_file",0); if (output==-1){ error_code=yaffs_get_error(); if (abs(error_code)==ENOENT){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("non existant file accessed.(which is a bad thing)\n"); + } else { + print_message("non existant file accessed.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_access_ENOENT_clean(void){ +int test_yaffs_access_ENOENT_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c index ad2402c..c494f18 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c @@ -14,29 +14,29 @@ #include "test_yaffs_access_ENOTDIR.h" static int handle=0; -int test_yaffs_access_ENOTDIR(void){ + +int test_yaffs_access_ENOTDIR(void) +{ int output=0; int error_code=0; - /*printf("path %s\n",path); */ + output=yaffs_access("/nonexisting_dir/foo",0); if (output==-1){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==ENOTDIR){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("non existant directory accessed.(which is a bad thing)\n"); + } else { + print_message("non existant directory accessed.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_access_ENOTDIR_clean(void){ +int test_yaffs_access_ENOTDIR_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod.c new file mode 100644 index 0000000..47646f3 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod.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_chmod.h" + +int test_yaffs_chmod(void) +{ + int output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE); + + if (output>=0){ + /* there were no errors */ + return 1; + } else { + print_message("failed to chmod the file\n",2); + return -1; + } + +} + +int test_yaffs_chmod_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod.h new file mode 100644 index 0000000..11b3dc4 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod.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_chmod_h__ +#define __test_yaffs_chmod_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_chmod(void); +int test_yaffs_chmod_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c new file mode 100644 index 0000000..0596ca9 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c @@ -0,0 +1,39 @@ +/* + * 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_chmod_EINVAL.h" + +int test_yaffs_chmod_EINVAL(void) +{ + int error=0; + int output=yaffs_chmod("/non_existing_directory/foo",0); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==EINVAL){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded the file (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_EINVAL_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h new file mode 100644 index 0000000..42d02ec --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.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_chmod_EINVAL_h__ +#define __test_yaffs_chmod_EINVAL_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_chmod_EINVAL(void); +int test_yaffs_chmod_EINVAL_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c new file mode 100644 index 0000000..5e2d534 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c @@ -0,0 +1,39 @@ +/* + * 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_chmod_EINVAL2.h" + +int test_yaffs_chmod_EINVAL2(void) +{ + int error=0; + int output=yaffs_chmod("/non_existing_directory/foo",255); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==EINVAL){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded the file (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_EINVAL2_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h new file mode 100644 index 0000000..2029750 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.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_chmod_EINVAL2_h__ +#define __test_yaffs_chmod_EINVAL2_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_chmod_EINVAL2(void); +int test_yaffs_chmod_EINVAL2_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.c new file mode 100644 index 0000000..d931485 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.c @@ -0,0 +1,39 @@ +/* + * 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_chmod_ENOENT.h" + +int test_yaffs_chmod_ENOENT(void) +{ + int error=0; + int output=yaffs_chmod("/yaffs2/non_existing_file",S_IREAD|S_IWRITE); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==ENOENT){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded the file (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_ENOENT_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.h new file mode 100644 index 0000000..16f28f0 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.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_chmod_ENOENT_h__ +#define __test_yaffs_chmod_ENOENT_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_chmod_ENOENT(void); +int test_yaffs_chmod_ENOENT_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c new file mode 100644 index 0000000..2390d0c --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c @@ -0,0 +1,39 @@ +/* + * 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_chmod_ENOTDIR.h" + +int test_yaffs_chmod_ENOTDIR(void) +{ + int error=0; + int output=yaffs_chmod("/non_existing_directory/foo",S_IREAD|S_IWRITE); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==ENOTDIR){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded the file (which is a bad thing)\n",2); + return -1; + } + +} + +int test_yaffs_chmod_ENOTDIR_clean(void) +{ + return 1; +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.h new file mode 100644 index 0000000..47c10c7 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_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_chmod_ENOTDIR_h__ +#define __test_yaffs_chmod_ENOTDIR_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_chmod_ENOTDIR(void); +int test_yaffs_chmod_ENOTDIR_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c index 5f322fc..1c83019 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c @@ -15,48 +15,48 @@ #include "test_yaffs_open.h" -static int handle=0; - -int test_yaffs_close_EBADF(void){ - int output=0; - int error_code=0; - handle=test_yaffs_open(); - if (handle>=0){ - output=yaffs_close(handle); - if (output>=0){ - output=yaffs_close(handle); - if (output<0){ - /*error has happened */ - error_code=yaffs_get_error(); - //printf("EBADF def %d, Error code %d\n",(- EBADF),error_code); - if (abs(error_code)== EBADF){ +static int handle = 0; + +int test_yaffs_close_EBADF(void) +{ + int output = 0; + int error_code = 0; + + handle = test_yaffs_open(); + if (handle >= 0){ + output = yaffs_close(handle); + if (output >= 0){ + output = yaffs_close(handle); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EBADF){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("closed the same handle twice. (which is a bad thing)\n"); + } else { + print_message("closed the same handle twice. (which is a bad thing)\n", 2); return -1; } - } - else { - printf("failed to close the handle the firs time\n"); + } else { + print_message("failed to close the handle the firs time\n", 2); return -1; } - } - else { - printf("failed to open file\n"); + } else { + print_message("failed to open file\n", 2); return -1; } } -int test_yaffs_close_EBADF_clean(void){ - /* there is nothing that needs to be recreated */ - return 1; +int test_yaffs_close_EBADF_clean(void) +{ + if (handle <= 0){ + return yaffs_close(handle); + } else { + return 1; + } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod.c b/direct/timothy_tests/quick_tests/test_yaffs_fchmod.c new file mode 100644 index 0000000..3560235 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod.c @@ -0,0 +1,49 @@ +/* + * 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_fchmod.h" + +static int handle = -1; + +int test_yaffs_fchmod(void) +{ + int output = 0; + + handle = test_yaffs_open(); + + if (handle < 0){ + print_message("failed to open file\n",2); + return -1; + } + + output = yaffs_fchmod(handle,S_IREAD||S_IWRITE); + + if (output>=0){ + /* there were no errors */ + return 1; + } else { + print_message("failed to chmod the file\n",2); + return -1; + } + +} + +int test_yaffs_fchmod_clean(void) +{ + if (handle >= 0) { + printf("handle %d\n",handle); + return yaffs_close(handle); + } + return 1; + +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod.h b/direct/timothy_tests/quick_tests/test_yaffs_fchmod.h new file mode 100644 index 0000000..a040fed --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod.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_fchmod_h__ +#define __test_yaffs_fchmod_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_fchmod(void); +int test_yaffs_fchmod_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.c new file mode 100644 index 0000000..159f135 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.c @@ -0,0 +1,56 @@ +/* + * 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_fchmod_EBADF.h" + +static int handle = -1; + +int test_yaffs_fchmod_EBADF(void) +{ + int error = 0; + int output = 0; + + handle = test_yaffs_open(); + + if (handle < 0){ + print_message("failed to open file\n",2); + return -1; + } + + output = yaffs_fchmod(-1,S_IREAD||S_IWRITE); + + if (output<0){ + error=yaffs_get_error(); + if (abs(error)==EBADF){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("chmoded an non-existing file (which is a bad thing)\n",2); + return -1; + } + + +} + +int test_yaffs_fchmod_EBADF_clean(void) +{ + if (handle >= 0) { + printf("handle %d\n",handle); + return yaffs_close(handle); + } + return 1; + +} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.h new file mode 100644 index 0000000..14be155 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.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_fchmod_EBADF_h__ +#define __test_yaffs_fchmod_EBADF_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_fchmod_EBADF(void); +int test_yaffs_fchmod_EBADF_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat.c b/direct/timothy_tests/quick_tests/test_yaffs_fstat.c index 7345161..dfdc80d 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_fstat.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat.c @@ -13,21 +13,23 @@ #include "test_yaffs_fstat.h" -static int handle=0; -int test_yaffs_fstat(void){ +static int handle = -1; +int test_yaffs_fstat(void) +{ struct yaffs_stat stat; - handle=test_yaffs_open(); - if (handle>=0){ - return yaffs_fstat(handle , &stat);; - } - else { - printf("error opening file\n"); + handle = test_yaffs_open(); + + if (handle >= 0){ + return yaffs_fstat(handle , &stat); + } else { + print_message( "error opening file\n", 2 ); return -1; } } -int test_yaffs_fstat_clean(void){ - if (handle<0){ +int test_yaffs_fstat_clean(void) +{ + if (handle <= 0){ return yaffs_close(handle); } return 1; diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat.h b/direct/timothy_tests/quick_tests/test_yaffs_fstat.h index 3fc0223..d4921f8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_fstat.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat.h @@ -15,9 +15,11 @@ #ifndef __test_yaffs_fstat_h__ #define __test_yaffs_fstat_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_fstat(void); int test_yaffs_fstat_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c index e44482d..546ebea 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c @@ -14,29 +14,28 @@ #include "test_yaffs_fstat_EBADF.h" -int test_yaffs_fstat_EBADF(void){ - int output=0; +int test_yaffs_fstat_EBADF(void) +{ + int output = 0; struct yaffs_stat stat; - int error_code=0; - output=yaffs_fstat(-1 , &stat); - if (output<0){ - error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); - if (abs(error_code)== EBADF){ + int error_code = 0; + + output = yaffs_fstat(-1 , &stat); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EBADF){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("non existant file truncated.(which is a bad thing)\n"); + } else { + print_message("non existant file truncated.(which is a bad thing)\n", 2 ); return -1; } } -int test_yaffs_fstat_EBADF_clean(void){ - return 1; - +int test_yaffs_fstat_EBADF_clean(void) +{ + return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h index 4d24916..453d8c2 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_fstat_EBADF_h__ #define __test_yaffs_fstat_EBADF_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_fstat_EBADF(void); int test_yaffs_fstat_EBADF_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c index a6d661b..cb38009 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c @@ -13,34 +13,33 @@ #include "test_yaffs_ftruncate.h" -static int handle=0; -int test_yaffs_ftruncate(void){ - handle=test_yaffs_open(); - if (handle>=0){ +static int handle = -1; + +int test_yaffs_ftruncate(void) +{ + handle = test_yaffs_open(); + if (handle >= 0){ return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED ); - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n", 2); return -1; } } -int test_yaffs_ftruncate_clean(void){ +int test_yaffs_ftruncate_clean(void) +{ /* change file size back to orignal size */ - int output=0; - if (handle>=0){ - output=yaffs_ftruncate(handle,FILE_SIZE ); - if (output>=0){ + int output = 0; + if (handle >= 0){ + output = yaffs_ftruncate(handle,FILE_SIZE ); + if (output >= 0){ return yaffs_close(handle); - } - else { - printf("failed to truncate file\n"); + } else { + print_message("failed to truncate file\n", 2); return -1; } + } else { + /* the file was not opened so the file could not be truncated */ + return 1; } - else { - printf("error opening file in clean function\n"); - return -1; - } - } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.h index b3f3956..9788997 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_ftruncate_h__ #define __test_yaffs_ftruncate_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_ftruncate(void); -int test_yaffs_ftruncate_clean(void); +int test_yaffs_ftruncate_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c index e308906..1e09d6f 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c @@ -13,29 +13,29 @@ #include "test_yaffs_ftruncate_EBADF.h" -static int handle=0; -int test_yaffs_ftruncate_EBADF(void){ - int output=0; - int error_code=0; - output= yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED ); - if (output<0){ +static int handle = 0; + +int test_yaffs_ftruncate_EBADF(void) +{ + int output = 0; + int error_code = 0; + output = yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED ); + if (output < 0){ error_code=yaffs_get_error(); //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); - if (abs(error_code)== EBADF){ + if (abs(error_code) == EBADF){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("non existant file truncated.(which is a bad thing)\n"); + } else { + print_message("non existant file truncated.(which is a bad thing)\n", 2); return -1; } } -int test_yaffs_ftruncate_EBADF_clean(void){ +int test_yaffs_ftruncate_EBADF_clean(void) +{ return 1; - } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h index 631150d..895013c 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_ftruncate_EBADF_h__ #define __test_yaffs_ftruncate_EBADF_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_ftruncate_EBADF(void); int test_yaffs_ftruncate_EBADF_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c index 3c99f1b..cff9ee0 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c @@ -13,39 +13,47 @@ #include "test_yaffs_ftruncate_EFBIG.h" -static int handle=0; -int test_yaffs_ftruncate_EFBIG(void){ - int output=0; - int error_code=0; - handle=test_yaffs_open(); - if (handle>=0){ - output=yaffs_ftruncate(handle,10000000000000000000000000000000); - if (output<0){ - error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); - if (abs(error_code)== EINVAL){ /* yaffs uses the error EINVAL instead of EFBIG */ +static int handle = -1; + +int test_yaffs_ftruncate_EFBIG(void) +{ + int output = 0; + int error_code = 0; + handle = test_yaffs_open(); + + if (handle >= 0){ + output = yaffs_ftruncate(handle,10000000000000000000000000000000); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EINVAL){ /* yaffs uses the error EINVAL instead of EFBIG */ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("file truncated to a very large size.(which is a bad thing)\n"); + } else { + print_message("file truncated to a very large size.(which is a bad thing)\n", 2); return -1; } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n", 2); return -1; } - - - } int test_yaffs_ftruncate_EFBIG_clean(void){ - return 1; - + /* change file size back to orignal size */ + int output = 0; + if (handle >= 0){ + output = yaffs_ftruncate(handle,FILE_SIZE ); + if (output >= 0){ + return yaffs_close(handle); + } else { + print_message("failed to truncate file\n", 2); + return -1; + } + } else { + /* the file was not opened so the file could not be truncated */ + return 1; + } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h index 0e10046..c00b5fa 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_ftruncate_EFBIG_h__ #define __test_yaffs_ftruncate_EFBIG_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_ftruncate_EFBIG(void); int test_yaffs_ftruncate_EFBIG_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c index ddab418..15096ea 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c @@ -13,42 +13,48 @@ #include "test_yaffs_ftruncate_EINVAL.h" -static int handle=0; -int test_yaffs_ftruncate_EINVAL(void){ +static int handle = -1; + +int test_yaffs_ftruncate_EINVAL(void) +{ int output=0; int error_code=0; handle=test_yaffs_open(); - if (handle>=0){ - output=yaffs_ftruncate(handle,-1 ); + + if (handle >= 0){ + output = yaffs_ftruncate(handle,-1 ); if (output<0){ - error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); - if (abs(error_code)== EINVAL){ + error_code = yaffs_get_error(); + if (abs(error_code) == EINVAL){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("file truncated to a negative size.(which is a bad thing)\n"); + } else { + print_message("file truncated to a negative size.(which is a bad thing)\n", 2); return -1; } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n", 2); return -1; - } - - - + } } -int test_yaffs_ftruncate_EINVAL_clean(void){ - if (handle<0){ - return yaffs_close(handle); +int test_yaffs_ftruncate_EINVAL_clean(void) +{ + /* change file size back to orignal size */ + int output = 0; + if (handle >= 0){ + output = yaffs_ftruncate(handle,FILE_SIZE ); + if (output >= 0){ + return yaffs_close(handle); + } else { + print_message("failed to truncate file\n", 2); + return -1; + } + } else { + /* the file was not opened so the file could not be truncated */ + return 1; } - return 1; - } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h index d95bdb8..49a5fd6 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_ftruncate_EINVAL_h__ #define __test_yaffs_ftruncate_EINVAL_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_ftruncate_EINVAL(void); int test_yaffs_ftruncate_EINVAL_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek.c index 98809c0..f102fde 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek.c @@ -13,37 +13,38 @@ #include "test_yaffs_lseek.h" -static int handle=0; -int test_yaffs_lseek(void){ - handle=test_yaffs_open(); +static int handle = -1; + +int test_yaffs_lseek(void) +{ int output=0; - if (handle>=0){ - output=yaffs_lseek(handle, 0, SEEK_SET); - if (output==0){ + handle = test_yaffs_open(); + + + if (handle >= 0){ + output = yaffs_lseek(handle, 0, SEEK_SET); + if (output == 0){ return 1; - } - else { + } else { if (output<0){ - printf("lseek failed to seek\n"); - } - else { - printf("lseek returned a different position to the expeced position\n"); + print_message("lseek failed to seek\n",2); + } else { + print_message("lseek returned a different position to the expeced position\n", 2); return -1; } } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n", 2); return -1; } } -int test_yaffs_lseek_clean(void){ +int test_yaffs_lseek_clean(void) +{ if (handle>=0){ return yaffs_close(handle); - } - else { + } else { return 1; /* no handle was opened so there is no need to close a handle */ } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek.h index d392127..9854bae 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek.h @@ -15,6 +15,7 @@ #ifndef __test_yaffs_lseek_h__ #define __test_yaffs_lseek_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" @@ -22,4 +23,5 @@ int test_yaffs_lseek(void); int test_yaffs_lseek_clean(void); int test_yaffs_lseek_to_beginning(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c index 06d9764..c6f4264 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c @@ -14,26 +14,27 @@ #include "test_yaffs_lseek_EBADF.h" -int test_yaffs_lseek_EBADF(void){ +int test_yaffs_lseek_EBADF(void) +{ int error_code=0; int output=yaffs_lseek(-1, 0, SEEK_SET); + if (output<0){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==EBADF){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("lseeked to a negative position\n"); + } else { + print_message("lseeked to a negative position\n", 2); + return -1; } } -int test_yaffs_lseek_EBADF_clean(void){ +int test_yaffs_lseek_EBADF_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h index 1530760..6911c80 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h @@ -15,9 +15,9 @@ #ifndef __test_yaffs_lseek_EBADF_h__ #define __test_yaffs_lseek_EBADF_h__ + #include "lib.h" #include "yaffsfs.h" -#include "test_yaffs_open.h" int test_yaffs_lseek_EBADF(void); int test_yaffs_lseek_EBADF_clean(void); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c index 5a001bb..6263c56 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c @@ -13,42 +13,40 @@ #include "test_yaffs_lseek_EFBIG.h" -static int handle=-1; +static int handle = -1; -int test_yaffs_lseek_EFBIG(void){ - handle=test_yaffs_open(); - int error_code=0; - int output=0; +int test_yaffs_lseek_EFBIG(void) +{ + handle = test_yaffs_open(); + int error_code = 0; + int output = 0; - if (handle<0){ - printf("failed to open file\n"); + if (handle < 0){ + print_message("failed to open file\n",2); return -1; } - yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET); + output = yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET); - if (output<0){ - error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); - if (abs(error_code)==EINVAL){ + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EINVAL){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("lseeked to a very large size (which is a bad thing)\n"); + } else { + print_message("lseeked to a very large size (which is a bad thing)\n", 2); return -1; } } -int test_yaffs_lseek_EFBIG_clean(void){ - if (handle>=0){ +int test_yaffs_lseek_EFBIG_clean(void) +{ + if (handle >= 0){ return yaffs_close(handle); - } - else { + } else { return -1; /* no handle was opened so there is no need to close a handle */ } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h index 656a369..e14350d 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h @@ -15,6 +15,7 @@ #ifndef __test_yaffs_lseek_EFBIG_h__ #define __test_yaffs_lseek_EFBIG_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c index b03914e..2d3a244 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c @@ -15,41 +15,38 @@ int handle=-1; -int test_yaffs_lseek_EINVAL(void){ - handle=test_yaffs_open(); - int error_code=0; - int output=0; - - if (handle<0){ - printf("failed to open file\n"); +int test_yaffs_lseek_EINVAL(void) +{ + handle = test_yaffs_open(); + int error_code = 0; + int output = 0; + + if (handle < 0){ + print_message("failed to open file\n", 2); return -1; } - - output=yaffs_lseek(handle, 0, -1); + output = yaffs_lseek(handle, 0, -1); - if (output<0){ - error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); - if (abs(error_code)==EINVAL){ + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EINVAL){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("lseeked to a negative position (which is a bad thing)\n"); + } else { + print_message("lseeked to a negative position (which is a bad thing)\n", 2); return -1; } } -int test_yaffs_lseek_EINVAL_clean(void){ - if (handle>=0){ +int test_yaffs_lseek_EINVAL_clean(void) +{ + if (handle >= 0){ return yaffs_close(handle); - } - else { + } else { return 1; /* no handle was opened so there is no need to close a handle */ } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h index 5795c4b..4dae8dc 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h @@ -15,6 +15,7 @@ #ifndef __test_yaffs_lseek_EINVAL_h__ #define __test_yaffs_lseek_EINVAL_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount.c b/direct/timothy_tests/quick_tests/test_yaffs_mount.c index aac73cf..572ffe1 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount.c @@ -13,14 +13,14 @@ #include "test_yaffs_mount.h" -int test_yaffs_mount(void){ - int output=0; - output=yaffs_mount(YAFFS_MOUNT_POINT); - /*printf("output %d",output);*/ +int test_yaffs_mount(void) +{ + int output = 0; + output = yaffs_mount(YAFFS_MOUNT_POINT); return output; } -int test_yaffs_mount_clean(void){ - return 1; - +int test_yaffs_mount_clean(void) +{ + return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount.h b/direct/timothy_tests/quick_tests/test_yaffs_mount.h index 4af829c..57405c6 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount.h @@ -21,4 +21,5 @@ int test_yaffs_mount(void); int test_yaffs_mount_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c index eb08ef2..6f5a673 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c @@ -14,7 +14,8 @@ #include "test_yaffs_mount_EBUSY.h" -int test_yaffs_mount_EBUSY(void){ +int test_yaffs_mount_EBUSY(void) +{ int output=0; int error_code=0; @@ -24,19 +25,18 @@ int test_yaffs_mount_EBUSY(void){ //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==EBUSY){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else if (output >=0){ - printf("mounted the same mount point twice.(which is a bad thing)\n"); + } else { + print_message("mounted the same mount point twice.(which is a bad thing)\n", 2); return -1; } - } -int test_yaffs_mount_EBUSY_clean(void){ + +int test_yaffs_mount_EBUSY_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h index 5c34869..27fde7e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h @@ -21,4 +21,5 @@ int test_yaffs_mount_EBUSY(void); int test_yaffs_mount_EBUSY_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c index da12b1e..0b36308 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c @@ -16,27 +16,28 @@ -int test_yaffs_mount_ENAMETOOLONG(void){ - int output=0; - int x; - int error_code=0; - int file_name_length=1000000; +int test_yaffs_mount_ENAMETOOLONG(void) +{ + int output = 0; + int x = 0; + int error_code = 0; + int file_name_length = 1000000; char file_name[file_name_length]; /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */ - output=test_yaffs_unmount(); + output = test_yaffs_unmount(); if (output<0){ - printf("yaffs failed to unmount\n"); + print_message("yaffs failed to unmount\n", 2); return -1; } - + /* set up the file name */ for (x=0; x=0){ - printf("non existant directory opened.(which is a bad thing)\n"); + } else if (output >=0){ + print_message("non existant directory opened.(which is a bad thing)\n",2); return -1; } - } -int test_yaffs_mount_ENODEV_clean(void){ + +int test_yaffs_mount_ENODEV_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h index 27cd767..73522e8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h @@ -21,4 +21,5 @@ int test_yaffs_mount_ENODEV(void); int test_yaffs_mount_ENODEV_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c index 01040fd..3f64d8a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c @@ -14,37 +14,36 @@ #include "test_yaffs_mount_ENOENT.h" -int test_yaffs_mount_ENOENT(void){ - int output=0; - int error_code=0; - /*printf("path %s\n",path); */ - +int test_yaffs_mount_ENOENT(void) +{ + int output = 0; + int error_code = 0; /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */ - output=test_yaffs_unmount(); - if (output<0){ - printf("yaffs failed to unmount\n"); + output = test_yaffs_unmount(); + if (output < 0){ + print_message("yaffs failed to unmount\n", 2); return -1; } - output=yaffs_mount("/non_existaint_mount_point/"); - if (output==-1){ - error_code=yaffs_get_error(); - if (abs(error_code)==ENODEV){ + output = yaffs_mount("/non_existaint_mount_point/"); + if (output == -1){ + error_code = yaffs_get_error(); + if (abs(error_code) == ENODEV){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("non existant mount point mounted.(which is a bad thing)\n"); + } else { + print_message("non existant mount point mounted.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_mount_ENOENT_clean(void){ + +int test_yaffs_mount_ENOENT_clean(void) +{ return test_yaffs_mount(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h index e0e7ad6..1c7ad75 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h @@ -23,4 +23,5 @@ int test_yaffs_mount_ENOENT(void); int test_yaffs_mount_ENOENT_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open.c b/direct/timothy_tests/quick_tests/test_yaffs_open.c index d7237a8..af7b754 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open.c @@ -13,21 +13,21 @@ #include "test_yaffs_open.h" -static int handle=0; +static int handle = 0; -int test_yaffs_open(void){ - - handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE); +int test_yaffs_open(void) +{ + handle = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE); return handle; } -int test_yaffs_open_clean(void){ - if (handle >=0){ +int test_yaffs_open_clean(void) +{ + if (handle >= 0){ return yaffs_close(handle); - } - else { - return 1; /* the file failed to open so there is no need to close it*/ + } 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_open.h b/direct/timothy_tests/quick_tests/test_yaffs_open.h index d5883f4..3fc83e0 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open.h @@ -21,4 +21,5 @@ int test_yaffs_open(void); int test_yaffs_open_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c index 90ba455..5bcbf2b 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c @@ -13,35 +13,32 @@ #include "test_yaffs_open_EEXIST.h" -static int handle=0; -int test_yaffs_open_EEXIST(void){ - int output=0; - int error_code=0; - /*printf("path %s\n",path); */ - handle=yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE ); - if (handle==-1){ - error_code=yaffs_get_error(); - //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code); - if (abs(error_code)== EEXIST){ +static int handle = -1; + +int test_yaffs_open_EEXIST(void) +{ + int error_code = 0; + + handle = yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE ); + if (handle == -1){ + error_code = yaffs_get_error(); + if (abs(error_code) == EEXIST){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else if (output >=0){ - printf("non existant file opened.(which is a bad thing)\n"); + } else { + print_message("non existant file opened.(which is a bad thing)\n",2); return -1; } - /* the program should not get here but the compiler is complaining */ - return -1; } -int test_yaffs_open_EEXIST_clean(void){ + +int test_yaffs_open_EEXIST_clean(void) +{ if (handle >=0){ return yaffs_close(handle); - } - else { + } 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_open_EEXIST.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.h index 50995f1..ebc2107 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.h @@ -21,4 +21,5 @@ int test_yaffs_open_EEXIST(void); int test_yaffs_open_EEXIST_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c index 3569028..fb596ca 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c @@ -13,37 +13,35 @@ #include "test_yaffs_open_EINVAL.h" -static int handle=0; -int test_yaffs_open_EINVAL(void){ - int output=0; - int error_code=0; - /*printf("path %s\n",path); */ +static int handle = -1; + +int test_yaffs_open_EINVAL(void) +{ + int error_code = 0; + handle=yaffs_open(FILE_PATH, 255,FILE_MODE); - if (handle==-1){ - error_code=yaffs_get_error(); - if (abs(error_code)== EEXIST){ /* yaffs open does not check the mode. + if (handle == -1){ + error_code = yaffs_get_error(); + if (abs(error_code) == EEXIST){ /* yaffs open does not check the mode which is passed into the functon. so yaffs open does not return EINVAL. This causes the error EEXIST to happen instead because both O_CREAT and O_EXCL are set */ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf(" file opened with bad mode.(which is a bad thing)\n"); + } else { + print_message(" file opened with bad mode.(which is a bad thing)\n",2); return -1; } - /* the program should not get here but the compiler is complaining */ - return -1; } -int test_yaffs_open_EINVAL_clean(void){ - if (handle >=0){ + +int test_yaffs_open_EINVAL_clean(void) +{ + if (handle >= 0){ return yaffs_close(handle); - } - else { + } 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_open_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h index 85597da..2e02ad3 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h @@ -21,4 +21,5 @@ int test_yaffs_open_EINVAL(void); int test_yaffs_open_EINVAL_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c index 3ea0918..a0d86e2 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c @@ -15,27 +15,28 @@ #include "test_yaffs_open_EINVAL2.h" -static int handle=0; -int test_yaffs_open_EINVAL2(void){ - int output=0; - int error_code=0; - /*printf("path %s\n",path); */ +static int handle = -1; + +int test_yaffs_open_EINVAL2(void) +{ + handle=yaffs_open(FILE_PATH, O_CREAT | O_RDWR ,255); - if (handle==-1){ - printf("file not opened with bad creation mod set (which is a bad thing)\n"); + + /* yaffs_open does not check the modes passed into it. This means that the file should open */ + if (handle < 0){ + print_message("file not opened with bad creation mode set (which is a bad thing)\n",2); return -1; - } - else { + } else { /* file opened */ return 1; } - } -int test_yaffs_open_EINVAL2_clean(void){ - if (handle >=0){ + +int test_yaffs_open_EINVAL2_clean(void) +{ + if (handle >= 0){ return yaffs_close(handle); - } - else { + } 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_open_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h index de35847..1531cbb 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h @@ -21,4 +21,5 @@ int test_yaffs_open_EINVAL2(void); int test_yaffs_open_EINVAL2_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c index b15156f..5d0a670 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c @@ -15,34 +15,32 @@ /*EISDIR is caused by trying to open a directory */ -static int handle=0; -int test_yaffs_open_EISDIR(void){ - int output=0; +static int handle = -1; + +int test_yaffs_open_EISDIR(void) +{ int error_code=0; - /*printf("path %s\n",path); */ + handle=yaffs_open(YAFFS_MOUNT_POINT, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE ); - if (handle==-1){ + if (handle == -1){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); if (abs(error_code)== EISDIR){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n", 2); return -1; } - } - else { - printf("non existant directory opened.(which is a bad thing)\n"); + } else { + print_message("non existant directory opened.(which is a bad thing)\n", 2); return -1; } } -int test_yaffs_open_EISDIR_clean(void){ +int test_yaffs_open_EISDIR_clean(void) +{ if (handle >=0){ return yaffs_close(handle); - } - else { + } 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_open_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.h index 3538510..fac12d7 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.h @@ -21,4 +21,5 @@ int test_yaffs_open_EISDIR(void); int test_yaffs_open_EISDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c index 44fd562..228f736 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c @@ -15,45 +15,40 @@ -static int handle=0; -int test_yaffs_open_ENAMETOOLONG(void){ - int output=0; - int x; - int error_code=0; - int file_name_length=1000000; +static int handle = -1; + +int test_yaffs_open_ENAMETOOLONG(void) +{ + int output = 0; + int x = 0; + int error_code = 0; + int file_name_length = 1000000; char file_name[file_name_length]; strcat(file_name,YAFFS_MOUNT_POINT); - for (x=strlen(YAFFS_MOUNT_POINT); x=0){ - printf("handle %d \n",handle); - printf("non existant file opened.(which is a bad thing)\n"); + } else { + //printf("handle %d \n",handle); + print_message("non existant file opened.(which is a bad thing)\n", 2); return -1; } - /* the program should not get here but the compiler is complaining */ - return -1; } -int test_yaffs_open_ENAMETOOLONG_clean(void){ +int test_yaffs_open_ENAMETOOLONG_clean(void) +{ if (handle >=0){ return yaffs_close(handle); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h index 8325fd5..8527452 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h @@ -21,4 +21,5 @@ int test_yaffs_open_ENAMETOOLONG(void); int test_yaffs_open_ENAMETOOLONG_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.c index 259f964..c3eba4a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.c @@ -13,29 +13,31 @@ #include "test_yaffs_open_ENOENT.h" -static int handle=0; -int test_yaffs_open_ENOENT(void){ - int output=0; - int error_code=0; +static int handle = -1; + +int test_yaffs_open_ENOENT(void) +{ + int output = 0; + int error_code = 0; /*printf("path %s\n",path); */ - handle=yaffs_open("/yaffs2/non_existant_file", O_TRUNC| O_RDWR,FILE_MODE ); - if (handle==-1){ - error_code=yaffs_get_error(); - if (abs(error_code)==ENOENT){ + handle = yaffs_open("/yaffs2/non_existant_file", O_TRUNC| O_RDWR,FILE_MODE ); + if (handle == -1){ + error_code = yaffs_get_error(); + if (abs(error_code) == ENOENT){ return 1; } else { - printf("different error than expected\n"); + print_message("different error than expected\n",2); return -1; } - } - else if (output >=0){ - printf("non existant file opened.(which is a bad thing)\n"); + } else { + print_message("non existant file opened.(which is a bad thing)\n",2); return -1; } - } -int test_yaffs_open_ENOENT_clean(void){ + +int test_yaffs_open_ENOENT_clean(void) +{ if (handle >=0){ return yaffs_close(handle); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.h index ff2663b..abc576a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.h @@ -21,4 +21,5 @@ int test_yaffs_open_ENOENT(void); int test_yaffs_open_ENOENT_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c index d9790cf..25082ae 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c @@ -13,30 +13,31 @@ #include "test_yaffs_open_ENOTDIR.h" -static int handle=0; -int test_yaffs_open_ENOTDIR(void){ - int output=0; +static int handle = -1; + +int test_yaffs_open_ENOTDIR(void) +{ int error_code=0; - /*printf("path %s\n",path); */ + handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE ); - if (handle==-1){ + if (handle <0){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==ENOTDIR){ return 1; } else { - printf("different error than expected\n"); + print_message("different error than expected\n",2); return -1; } } - else if (output >=0){ - printf("non existant directory opened.(which is a bad thing)\n"); + else { + print_message("non existing directory opened.(which is a bad thing)\n",2); return -1; } - } -int test_yaffs_open_ENOTDIR_clean(void){ + +int test_yaffs_open_ENOTDIR_clean(void) +{ if (handle >=0){ return yaffs_close(handle); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.h index d164ea9..d611dd2 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.h @@ -21,4 +21,5 @@ int test_yaffs_open_ENOTDIR(void); int test_yaffs_open_ENOTDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read.c b/direct/timothy_tests/quick_tests/test_yaffs_read.c index a5157d2..48e9826 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_read.c @@ -15,37 +15,33 @@ static int handle=-1; -int test_yaffs_read(void){ - handle=test_yaffs_open(); - char text[20]="\0"; +int test_yaffs_read(void) +{ + char text[20] = "\0"; int output=0; - //printf("handle %d\n",handle); + + handle = test_yaffs_open(); if (handle>=0){ output=yaffs_read(handle, text, FILE_TEXT_NBYTES); - //printf("yaffs_test_read output: %d\n",output); - //printf("text in file is: '%s' expected text is '%s'\n",text,FILE_TEXT); if (output>0){ if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){ return 1; - } - else { - printf("returned text does not match the the expected text that should be in the file\n"); + } else { + print_message("returned text does not match the the expected text that should be in the file\n", 2); return -1; } - } - else{ - printf("error reading file\n"); + } else{ + print_message("error reading file\n", 2); return -1; } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n", 2); return -1; } - } -int test_yaffs_read_clean(void){ +int test_yaffs_read_clean(void) +{ if (handle>=0){ return yaffs_close(handle); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read.h b/direct/timothy_tests/quick_tests/test_yaffs_read.h index b118854..bc01b47 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_read.h @@ -22,4 +22,5 @@ int test_yaffs_read(void); int test_yaffs_read_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c index 073f329..1ae9216 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c @@ -13,28 +13,29 @@ #include "test_yaffs_read_EBADF.h" -int test_yaffs_read_EBADF(void){ +int test_yaffs_read_EBADF(void) +{ int error_code=0; int output=0; char text[100]; text[0] ='\0'; + output=yaffs_read(-1, text, FILE_TEXT_NBYTES); if (output<0){ - error_code=yaffs_get_error(); - if (abs(error_code)==EBADF){ + error_code = yaffs_get_error(); + if (abs(error_code) == EBADF){ return 1; - } - else { - printf("returned error does not match the the expected error\n"); + } else { + print_message("returned error does not match the the expected error\n",2); return -1; } - } - else{ - printf("read a non-existing file (which is a bad thing)\n"); + } else{ + print_message("read a non-existing file (which is a bad thing)\n",2); return -1; } } -int test_yaffs_read_EBADF_clean(void){ +int test_yaffs_read_EBADF_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h index 845148f..d17f5b8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h @@ -15,11 +15,12 @@ #ifndef __test_yaffs_read_EBADF_h__ #define __test_yaffs_read_EBADF_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" - int test_yaffs_read_EBADF(void); int test_yaffs_read_EBADF_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c index 46e11f7..e3ce966 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c @@ -13,53 +13,50 @@ #include "test_yaffs_read_EINVAL.h" -static int handle=0; - +static int handle = -1; static char *file_name = NULL; -int test_yaffs_read_EINVAL(void){ - int error_code=0; + +int test_yaffs_read_EINVAL(void) +{ + int error_code = 0; handle=test_yaffs_open(); char text[2000000]="\0"; int output=0; if (handle<0){ - printf("could not open file\n"); + print_message("could not open file\n",2); return -1; } /*there needs a large amout of test in the file in order to trigger EINVAL */ output=test_yaffs_read_EINVAL_init(); if (output<0){ - printf("could not write text to the file\n"); + print_message("could not write text to the file\n",2); return -1; } if (handle>=0){ output=yaffs_read(handle, text, -1); - if (output<0){ error_code=yaffs_get_error(); if (abs(error_code)== EINVAL){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else{ - printf("read a negative number of bytes (which is a bad thing)\n"); + } else{ + print_message("read a negative number of bytes (which is a bad thing)\n",2); return -1; } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n",2); return -1; } - } -int test_yaffs_read_EINVAL_clean(void){ +int test_yaffs_read_EINVAL_clean(void) +{ int output=0; if (handle>=0){ output=test_yaffs_read_EINVAL_init_clean(); @@ -68,28 +65,28 @@ int test_yaffs_read_EINVAL_clean(void){ if (output>=0){ return 1; } else { - printf("could not close the handle\n"); + print_message("could not close the handle\n",2); return -1; } } else { - printf("failed to fix the file\n"); + print_message("failed to fix the file\n",2); return -1; } + } else { + print_message("no open handle\n",2); } - } int test_yaffs_read_EINVAL_init(void) { int output=0; - int error_code=0; int x=0; int file_name_length=1000000; file_name = malloc(file_name_length); if(!file_name){ - printf("unable to create file text\n"); + print_message("unable to create file text\n",2); return -1; } @@ -104,7 +101,7 @@ int test_yaffs_read_EINVAL_init(void) if (handle>=0){ output= yaffs_write(handle, file_name, file_name_length-1); if (output<0){ - printf("could not write text to file\n"); + print_message("could not write text to file\n",2); return -1; } else { @@ -112,7 +109,7 @@ int test_yaffs_read_EINVAL_init(void) } } else { - printf("error opening file\n"); + print_message("error opening file\n",2); return -1; } @@ -133,11 +130,11 @@ int test_yaffs_read_EINVAL_init_clean(void) if (output>=0){ return 1; } else { - printf("failed to write to file\n"); + print_message("failed to write to file\n",2); return -1; } } else { - printf("failed to truncate file\n"); + print_message("failed to truncate file\n",2); return -1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h index c2c54b7..ee55927 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h @@ -15,6 +15,7 @@ #ifndef __test_yaffs_read_EINVAL_h__ #define __test_yaffs_read_EINVAL_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" @@ -26,4 +27,5 @@ int test_yaffs_read_EINVAL(void); int test_yaffs_read_EINVAL_clean(void); int test_yaffs_read_EINVAL_init(void); int test_yaffs_read_EINVAL_init_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat.c b/direct/timothy_tests/quick_tests/test_yaffs_stat.c index d379944..83efcdb 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat.c @@ -13,22 +13,22 @@ #include "test_yaffs_stat.h" -int test_yaffs_stat(void){ +int test_yaffs_stat(void) +{ + char message[20]; int mode=0; int size=0; - mode =yaffs_test_stat_mode(); - + message[0]='\0'; + + mode =yaffs_test_stat_mode(); if (mode>=0){ - if (FILE_MODE == (FILE_MODE & mode)){ mode=1; - } - else { - printf("mode did not match expected file mode\n"); + } else { + print_message("mode did not match expected file mode\n",2); return -1; } - } - else { + } else { mode =-1; } @@ -36,42 +36,40 @@ int test_yaffs_stat(void){ if (size >=0){ if (size==FILE_SIZE){ size=1; - } - else { - printf("file size %d, expected file size %d\n",size,FILE_SIZE); - printf("mode did not match expected file mode\n"); + } else { + sprintf(message,"file size %d, expected file size %d\n",size,FILE_SIZE); + print_message(message,2); + print_message("mode did not match expected file mode\n",2); return -1; } - } - else { + } else { size =-1; } if ((mode>0) && (size>0)){ return 1; - } - else { - /* a test failed*/ + } else { + /* one of the tests failed*/ return -1; } - } -int test_yaffs_stat_clean(void){ +int test_yaffs_stat_clean(void) +{ return 1; } -int yaffs_test_stat_mode(void){ +int yaffs_test_stat_mode(void) +{ struct yaffs_stat stat; int output=0; output=yaffs_stat(FILE_PATH, &stat); //printf("output: %d\n",output); if (output>=0){ return stat.st_mode; - } - else { - printf("failed to stat file mode\n") ; + } else { + print_message("failed to stat file mode\n",2) ; return -1; } } @@ -82,9 +80,8 @@ int yaffs_test_stat_size(void){ output=yaffs_stat(FILE_PATH, &stat); if (output>=0){ return stat.st_size; - } - else { - printf("failed to stat file size\n") ; + } else { + print_message("failed to stat file size\n",2) ; return -1; } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat.h b/direct/timothy_tests/quick_tests/test_yaffs_stat.h index f7e27af..e389483 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat.h @@ -15,12 +15,15 @@ #ifndef __test_yaffs_stat_h__ #define __test_yaffs_stat_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" #include "test_yaffs_lseek.h" + int test_yaffs_stat(void); int test_yaffs_stat_clean(void); int yaffs_test_stat_mode(void); int yaffs_test_stat_size(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c index c6ee58b..9a740b8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c @@ -13,29 +13,29 @@ #include "test_yaffs_stat_ENOENT.h" -int test_yaffs_stat_ENOENT(void){ +int test_yaffs_stat_ENOENT(void) +{ int error_code=0; struct yaffs_stat stat; int output=0; char text[100]; text[0] ='\0'; - output=yaffs_stat("/yaffs2/non-existing_file", &stat);; + output=yaffs_stat("/yaffs2/non-existing_file", &stat); if (output<0){ error_code=yaffs_get_error(); if (abs(error_code)==ENOENT){ return 1; - } - else { - printf("returned error does not match the the expected error\n"); + } else { + print_message("returned error does not match the the expected error\n",2); return -1; } - } - else{ - printf("stated a non-existing file (which is a bad thing)\n"); + } else{ + print_message("stated a non-existing file (which is a bad thing)\n",2); return -1; } } -int test_yaffs_stat_ENOENT_clean(void){ +int test_yaffs_stat_ENOENT_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h index b6d6b20..a2f8209 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h @@ -15,11 +15,12 @@ #ifndef __test_yaffs_stat_ENOENT_h__ #define __test_yaffs_stat_ENOENT_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" - int test_yaffs_stat_ENOENT(void); int test_yaffs_stat_ENOENT_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c index db38d16..d0ab0e7 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c @@ -13,7 +13,8 @@ #include "test_yaffs_stat_ENOTDIR.h" -int test_yaffs_stat_ENOTDIR(void){ +int test_yaffs_stat_ENOTDIR(void) +{ int error_code=0; struct yaffs_stat stat; int output=0; @@ -24,18 +25,17 @@ int test_yaffs_stat_ENOTDIR(void){ error_code=yaffs_get_error(); if (abs(error_code)==ENOTDIR){ return 1; - } - else { - printf("returned error does not match the the expected error\n"); + } else { + print_message("returned error does not match the the expected error\n",2); return -1; } - } - else{ - printf("stated a non-existing file (which is a bad thing)\n"); + } else { + print_message("stated a non-existing file (which is a bad thing)\n",2); return -1; } } -int test_yaffs_stat_ENOTDIR_clean(void){ +int test_yaffs_stat_ENOTDIR_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h index 85ca669..c279f8f 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h @@ -15,11 +15,12 @@ #ifndef __test_yaffs_stat_ENOTDIR_h__ #define __test_yaffs_stat_ENOTDIR_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" - int test_yaffs_stat_ENOTDIR(void); int test_yaffs_stat_ENOTDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate.c index c1ae528..e4cd7f9 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate.c @@ -12,30 +12,33 @@ */ #include "test_yaffs_truncate.h" -static int handle=0; +static int handle = -1; -int test_yaffs_truncate(void){ - handle=test_yaffs_open(); - if (handle>=0){ +int test_yaffs_truncate(void) +{ + handle = test_yaffs_open(); + if (handle >= 0){ return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED ); - } - else { - printf("error opening file"); + } else { + print_message("error opening file",2); return -1; } } -int test_yaffs_truncate_clean(void){ +int test_yaffs_truncate_clean(void) +{ /* change file size back to orignal size */ int output=0; - if (handle>=0){ + if (handle >= 0){ output= yaffs_truncate(FILE_PATH,FILE_SIZE ); if (output>=0){ return yaffs_close(handle); + } else { + print_message("failed to truncate file\n",2); + return -1; } - } - else { - printf("error opening file in clean function"); + } else { + print_message("error opening file in clean function\n",2); return -1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate.h index 5540060..94a304a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_truncate_h__ #define __test_yaffs_truncate_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_truncate(void); int test_yaffs_truncate_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c index 0fc79af..0d69865 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c @@ -12,9 +12,10 @@ */ #include "test_yaffs_truncate_EFBIG.h" -static int handle=0; +static int handle = -1; -int test_yaffs_truncate_EFBIG(void){ +int test_yaffs_truncate_EFBIG(void) +{ int error=0; int output=0; handle=test_yaffs_open(); @@ -24,24 +25,22 @@ int test_yaffs_truncate_EFBIG(void){ error=yaffs_get_error(); if (abs(error)==EINVAL){ /*in yaffs EINVAL is used instead of EFBIG */ return 1; - } - else { - printf("received a different error than expected\n"); + } else { + print_message("received a different error than expected\n",2); return -1; } - } - else{ - printf("truncated a file to a massive size\n"); + } else{ + print_message("truncated a file to a massive size\n",2); return -1; } - } - else { - printf("error opening file"); + } else { + print_message("error opening file\n",2); return -1; } } -int test_yaffs_truncate_EFBIG_clean(void){ +int test_yaffs_truncate_EFBIG_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h index 15f0999..5a459ad 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_truncate_EFBIG_h__ #define __test_yaffs_truncate_EFBIG_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_truncate_EFBIG(void); int test_yaffs_truncate_EFBIG_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c index 7c8fd9d..f56045a 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c @@ -12,9 +12,10 @@ */ #include "test_yaffs_truncate_EINVAL.h" -static int handle=0; +static int handle=-1; -int test_yaffs_truncate_EINVAL(void){ +int test_yaffs_truncate_EINVAL(void) +{ int error=0; int output=0; handle=test_yaffs_open(); @@ -24,24 +25,22 @@ int test_yaffs_truncate_EINVAL(void){ error=yaffs_get_error(); if (abs(error)==EINVAL){ return 1; - } - else { - printf("received a different error than expected\n"); + } else { + print_message("received a different error than expected\n",2); return -1; } - } - else{ - printf("truncated a file with a bad mode set.\n"); + } else{ + print_message("truncated a file with a bad mode set.\n",2); return -1; } - } - else { - printf("error opening file"); + } else { + print_message("error opening file",2); return -1; } } -int test_yaffs_truncate_EINVAL_clean(void){ +int test_yaffs_truncate_EINVAL_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h index f78af54..7a71a5e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_truncate_EINVAL_h__ #define __test_yaffs_truncate_EINVAL_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_truncate_EINVAL(void); int test_yaffs_truncate_EINVAL_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c index 5fa4601..cfd1d82 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c @@ -12,36 +12,35 @@ */ #include "test_yaffs_truncate.h" -static int handle=0; +static int handle= -1; -int test_yaffs_truncate_EISDIR(void){ - int error=0; - int output=0; - handle=test_yaffs_open(); +int test_yaffs_truncate_EISDIR(void) +{ + int error = 0; + int output = 0; + handle = test_yaffs_open(); if (handle>=0){ - output= yaffs_truncate("/yaffs2/",10); - if (output<0){ - error=yaffs_get_error(); - if (abs(error)==EISDIR){ + output = yaffs_truncate("/yaffs2/",10); + if (output < 0){ + error = yaffs_get_error(); + if (abs(error) == EISDIR){ return 1; - } - else { - printf("received a different error than expected\n"); + } else { + print_message("received a different error than expected\n",2); return -1; } - } - else{ - printf("truncated a directory\n"); + } else{ + print_message("truncated a directory\n",2); return -1; } - } - else { - printf("error opening file"); + } else { + print_message("error opening file\n",2); return 1; } } -int test_yaffs_truncate_EISDIR_clean(void){ +int test_yaffs_truncate_EISDIR_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h index 7299c6d..4e485ef 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_truncate_EISDIR_h__ #define __test_yaffs_truncate_EISDIR_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_truncate_EISDIR(void); int test_yaffs_truncate_EISDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c index 7d264e5..72d7314 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c @@ -12,11 +12,13 @@ */ #include "test_yaffs_truncate_ENOENT.h" -static int handle=0; +static int handle = -1; -int test_yaffs_truncate_ENOENT(void){ +int test_yaffs_truncate_ENOENT(void) +{ int error=0; int output=0; + handle=test_yaffs_open(); if (handle>=0){ output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED ); @@ -24,24 +26,21 @@ int test_yaffs_truncate_ENOENT(void){ error=yaffs_get_error(); if (abs(error)==ENOENT){ return 1; - } - else { - printf("received a different error than expected\n"); + } else { + print_message("received a different error than expected\n",2); return -1; } - } - else{ - printf("truncated a nonexisting file\n"); + } else{ + print_message("truncated a nonexisting file\n",2); return -1; - } - - } - else { - printf("error opening file"); + } + } else { + print_message("error opening file",2); return -1; } } -int test_yaffs_truncate_ENOENT_clean(void){ +int test_yaffs_truncate_ENOENT_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h index 1a74d87..07fe6a4 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_truncate_ENOENT_h__ #define __test_yaffs_truncate_ENOENT_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_truncate_ENOENT(void); -int test_yaffs_truncate_ENOENT_clean(void); +int test_yaffs_truncate_ENOENT_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c index bda51ef..c2414db 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c @@ -12,9 +12,11 @@ */ #include "test_yaffs_truncate_ENOTDIR.h" -static int handle=0; -int test_yaffs_truncate_ENOTDIR(void){ +static int handle = -1; + +int test_yaffs_truncate_ENOTDIR(void) +{ int error=0; int output=0; handle=test_yaffs_open(); @@ -24,24 +26,22 @@ int test_yaffs_truncate_ENOTDIR(void){ error=yaffs_get_error(); if (abs(error)==ENOTDIR){ return 1; - } - else { - printf("received a different error than expected\n"); + } else { + print_message("received a different error than expected\n",2); return -1; } - } - else{ - printf("truncated a nonexisting file\n"); + } else{ + print_message("truncated a nonexisting file\n",2); return -1; } - } - else { - printf("error opening file"); + } else { + print_message("error opening file\n",2); return -1; } } -int test_yaffs_truncate_ENOTDIR_clean(void){ +int test_yaffs_truncate_ENOTDIR_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink.c index 1352ccf..75cf7c0 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink.c @@ -13,17 +13,18 @@ #include "test_yaffs_unlink.h" -int test_yaffs_unlink(void){ +int test_yaffs_unlink(void) +{ int output=yaffs_unlink(FILE_PATH); if (output>=0){ return (-test_yaffs_access()); /*return negative access. we do not want the file to be there*/ - } - else { - printf("failed to unlink file\n") ; + } else { + print_message("failed to unlink file\n",2) ; return -1; } } -int test_yaffs_unlink_clean(void){ +int test_yaffs_unlink_clean(void) +{ return test_yaffs_open(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink.h index a28efc4..bab3476 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink.h @@ -23,4 +23,5 @@ int test_yaffs_unlink(void); int test_yaffs_unlink_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c index 80c8f40..ca5d660 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c @@ -15,35 +15,33 @@ /*EISDIR is caused by trying to unlink a directory */ -static int handle=0; -int test_yaffs_unlink_EISDIR(void){ - int output=0; +static int handle=-1; + +int test_yaffs_unlink_EISDIR(void) +{ int error_code=0; - /*printf("path %s\n",path); */ + handle=yaffs_unlink(YAFFS_MOUNT_POINT); if (handle==-1){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); if (abs(error_code)== EISDIR){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } } - else if (output >=0){ - printf("directory unlinked opened.(which is a bad thing)\n"); + else { + print_message("directory unlinked opened.(which is a bad thing)\n",2); return -1; } - /* the program should not get here but the compiler is complaining */ - return -1; + } -int test_yaffs_unlink_EISDIR_clean(void){ +int test_yaffs_unlink_EISDIR_clean(void) +{ if (handle >=0){ return yaffs_close(handle); - } - else { + }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_unlink_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h index cdba6f5..6d4b2c8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h @@ -21,4 +21,5 @@ int test_yaffs_unlink_EISDIR(void); int test_yaffs_unlink_EISDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c index 8f25543..d675d01 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c @@ -15,7 +15,8 @@ -int test_yaffs_unlink_ENAMETOOLONG(void){ +int test_yaffs_unlink_ENAMETOOLONG(void) +{ int output=0; int error_code=0; int x=0; @@ -28,26 +29,23 @@ int test_yaffs_unlink_ENAMETOOLONG(void){ } file_name[file_name_length-2]='\0'; - /*printf("path %s\n",path); */ output=yaffs_unlink(file_name); if (output==-1){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code); if (abs(error_code)== EISDIR){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("directory unlinked opened.(which is a bad thing)\n"); + } else { + print_message("directory unlinked opened.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_unlink_ENAMETOOLONG_clean(void){ +int test_yaffs_unlink_ENAMETOOLONG_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c index 8821257..113b148 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c @@ -13,33 +13,32 @@ #include "test_yaffs_unlink_ENOENT.h" -static int handle=0; -int test_yaffs_unlink_ENOENT(void){ - int output=0; +static int handle=-1; + +int test_yaffs_unlink_ENOENT(void) +{ int error_code=0; - /*printf("path %s\n",path); */ + handle=yaffs_unlink("/yaffs2/non_existant_file"); if (handle==-1){ error_code=yaffs_get_error(); - if (abs(error_code)==ENOENT){ + if (abs(error_code) == ENOENT){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else if (output >=0){ - printf("non existant file unlinked.(which is a bad thing)\n"); + } else { + print_message("non existant file unlinked.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_unlink_ENOENT_clean(void){ - if (handle >=0){ +int test_yaffs_unlink_ENOENT_clean(void) +{ + if (handle >= 0){ return test_yaffs_open(); - } - else { + } 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_unlink_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h index ec95fd7..1d419b8 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h @@ -22,4 +22,5 @@ int test_yaffs_unlink_ENOENT(void); int test_yaffs_unlink_ENOENT_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c index 8724376..5eaff8c 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c @@ -14,30 +14,29 @@ #include "test_yaffs_open_ENOTDIR.h" -int test_yaffs_unlink_ENOTDIR(void){ +int test_yaffs_unlink_ENOTDIR(void) +{ int output=0; int error_code=0; - /*printf("path %s\n",path); */ + output=yaffs_unlink("/nonexisting_dir/foo"); if (output==-1){ error_code=yaffs_get_error(); - //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==ENOTDIR){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("non existant directory opened.(which is a bad thing)\n"); + } else { + print_message("non existant directory opened.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_unlink_ENOTDIR_clean(void){ +int test_yaffs_unlink_ENOTDIR_clean(void) +{ return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h index 82e44da..a4c1565 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h @@ -21,4 +21,5 @@ int test_yaffs_unlink_ENOTDIR(void); int test_yaffs_unlink_ENOTDIR_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount.c index b3ddba2..8111206 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount.c @@ -13,14 +13,12 @@ #include "test_yaffs_unmount.h" -int test_yaffs_unmount(void){ - int output=0; - output=yaffs_unmount(YAFFS_MOUNT_POINT); - /*printf("output %d",output);*/ - return output; +int test_yaffs_unmount(void) +{ + return yaffs_unmount(YAFFS_MOUNT_POINT); } -int test_yaffs_unmount_clean(void){ - return test_yaffs_mount(); - +int test_yaffs_unmount_clean(void) +{ + return test_yaffs_mount(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount.h index 7b0562a..a6e2ea5 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount.h @@ -22,4 +22,5 @@ int test_yaffs_unmount(void); int test_yaffs_unmount_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.c index 2c6145b..88c93dd 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.c @@ -14,39 +14,38 @@ #include "test_yaffs_mount_EBUSY.h" static int handle=-1; -int test_yaffs_unmount_EBUSY(void){ + +int test_yaffs_unmount_EBUSY(void) +{ int output=0; int error_code=0; - /*printf("path %s\n",path); */ + handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE); if (handle<0){ printf("failed to open file\n"); return -1; } - output=yaffs_unmount(YAFFS_MOUNT_POINT); if (output==-1){ error_code=yaffs_get_error(); if (abs(error_code)==EBUSY){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("non existant mount point unmounted.(which is a bad thing)\n"); + } else { + print_message("non existant mount point unmounted.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_unmount_EBUSY_clean(void){ +int test_yaffs_unmount_EBUSY_clean(void) +{ if (handle>=0){ return yaffs_close(handle); - } - else { + } else { return 1; } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.h index fc41645..c40b6a3 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.h @@ -23,4 +23,5 @@ int test_yaffs_unmount_EBUSY(void); int test_yaffs_unmount_EBUSY_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c index 1af5761..ecceb22 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c @@ -13,47 +13,37 @@ #include "test_yaffs_unmount_ENAMETOOLONG.h" - - - -int test_yaffs_unmount_ENAMETOOLONG(void){ +int test_yaffs_unmount_ENAMETOOLONG(void) +{ int output=0; - int x; + int x=0; int error_code=0; int file_name_length=1000000; char file_name[file_name_length]; - - for (x=0; x=0){ return yaffs_write(handle, FILE_TEXT, FILE_TEXT_NBYTES); - } - else { + } else { printf("error opening file\n"); return -1; } - } -int test_yaffs_write_clean(void){ +int test_yaffs_write_clean(void) +{ if (handle>=0){ return yaffs_close(handle); - } - else { + } else { return 1; /* no handle was opened so there is no need to close a handle */ } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_write.h b/direct/timothy_tests/quick_tests/test_yaffs_write.h index 473a009..022d5d4 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_write.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_write.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_write_h__ #define __test_yaffs_write_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_write(void); int test_yaffs_write_clean(void); + #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.c index a889b34..5ed718e 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.c @@ -13,10 +13,13 @@ #include "test_yaffs_write_EBADF.h" -static int handle=0; -int test_yaffs_write_EBADF(void){ +static int handle= -1; + +int test_yaffs_write_EBADF(void) +{ int output=0; int error_code=0; + handle=test_yaffs_open(); if (handle>=0){ output= yaffs_write(-1, FILE_TEXT, FILE_TEXT_NBYTES); @@ -25,30 +28,26 @@ int test_yaffs_write_EBADF(void){ //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code); if (abs(error_code)==EBADF){ return 1; - } - else { - printf("different error than expected\n"); + } else { + print_message("different error than expected\n",2); return -1; } - } - else { - printf("wrote to a bad handle.(which is a bad thing)\n"); + } else { + print_message("wrote to a bad handle.(which is a bad thing)\n",2); return -1; } - } - else { - printf("error opening file\n"); + } else { + print_message("error opening file\n",2); return -1; } - } -int test_yaffs_write_EBADF_clean(void){ +int test_yaffs_write_EBADF_clean(void) +{ if (handle>=0){ return yaffs_close(handle); - } - else { + } else { return 1; /* no handle was opened so there is no need to close a handle */ } } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.h index 6b427fb..db03ed6 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.h @@ -15,9 +15,12 @@ #ifndef __test_yaffs_write_EBADF_h__ #define __test_yaffs_write_EBADF_h__ + #include "lib.h" #include "yaffsfs.h" #include "test_yaffs_open.h" + int test_yaffs_write_EBADF(void); int test_yaffs_write_EBADF_clean(void); + #endif -- 2.30.2