yaffs Have revised and checked each test in quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Sun, 14 Nov 2010 23:18:23 +0000 (12:18 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Sun, 14 Nov 2010 23:18:23 +0000 (12:18 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
118 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/current_bugs.txt
direct/timothy_tests/quick_tests/lib.c
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_access.c
direct/timothy_tests/quick_tests/test_yaffs_access.h
direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_chmod.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_chmod_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_fchmod.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fchmod.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fchmod_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_fstat.c
direct/timothy_tests/quick_tests/test_yaffs_fstat.h
direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_fstat_EBADF.h
direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate.h
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_lseek.c
direct/timothy_tests/quick_tests/test_yaffs_lseek.h
direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_lseek_EBADF.h
direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.c
direct/timothy_tests/quick_tests/test_yaffs_lseek_EFBIG.h
direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_lseek_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_mount.c
direct/timothy_tests/quick_tests/test_yaffs_mount.h
direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c
direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h
direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.h
direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.c
direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_open.c
direct/timothy_tests/quick_tests/test_yaffs_open.h
direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c
direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.h
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h
direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.h
direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h
direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.h
direct/timothy_tests/quick_tests/test_yaffs_read.c
direct/timothy_tests/quick_tests/test_yaffs_read.h
direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_read_EBADF.h
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_stat.c
direct/timothy_tests/quick_tests/test_yaffs_stat.h
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_stat_ENOTDIR.h
direct/timothy_tests/quick_tests/test_yaffs_truncate.c
direct/timothy_tests/quick_tests/test_yaffs_truncate.h
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_unlink.c
direct/timothy_tests/quick_tests/test_yaffs_unlink.h
direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h
direct/timothy_tests/quick_tests/test_yaffs_unmount.c
direct/timothy_tests/quick_tests/test_yaffs_unmount.h
direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.c
direct/timothy_tests/quick_tests/test_yaffs_unmount_EBUSY.h
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENAMETOOLONG.h
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h
direct/timothy_tests/quick_tests/test_yaffs_write.c
direct/timothy_tests/quick_tests/test_yaffs_write.h
direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_write_EBADF.h

index a22592a..bf82726 100644 (file)
@@ -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)
index b7b17b0..25b995e 100644 (file)
@@ -3,11 +3,18 @@ Made by Timothy Manning <timothy@yaffs.net> 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. 
index 6435529..ed659a1 100644 (file)
@@ -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
index 39b0713..a7219c5 100644 (file)
@@ -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);
+       }
+}
+       
+
+
index 50c548f..2efd08e 100644 (file)
 #ifndef _lib_h__
 #define _lib_h__
 
-
+#include <stdio.h>
 #include <string.h>
+
+#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
index 720fdee..17bce3b 100644 (file)
@@ -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<total_number_of_tests;x++){
                //printf("x %d\n",x);
                yaffs_set_error(0);     /*reset the last error to 0 */
-               printf("\nrunning test: %s \n",test_list[x].name_of_test);
+               sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
+               print_message(message,2);
                output=test_list[x].p_function();       /*run test*/
                if (output>=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);
 
 }
index a11386d..b44bf9b 100644 (file)
 #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);
index 9a00b93..da4f23e 100644 (file)
 
 #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;
 }
index 3f9e26c..9919498 100644 (file)
@@ -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
index cec0389..f8ba13a 100644 (file)
 
 #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;
 }
index b13a1a0..62fe9e2 100644 (file)
@@ -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
index 610e4ee..3746886 100644 (file)
 #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;
 }
 
index ad2402c..c494f18 100644 (file)
 #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 (file)
index 0000000..47646f3
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..11b3dc4
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..0596ca9
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..42d02ec
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..5e2d534
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..2029750
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..d931485
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..16f28f0
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..2390d0c
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..47c10c7
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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
index 5f322fc..1c83019 100644 (file)
 
 #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 (file)
index 0000000..3560235
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..a040fed
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..159f135
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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 (file)
index 0000000..14be155
--- /dev/null
@@ -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 <timothy@yaffs.net>
+ *
+ * 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
index 7345161..dfdc80d 100644 (file)
 
 #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;
index 3fc0223..d4921f8 100644 (file)
 
 #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
index e44482d..546ebea 100644 (file)
 #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;       
 }
index 4d24916..453d8c2 100644 (file)
 
 #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
index a6d661b..cb38009 100644 (file)
 
 #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;
-       }
-       
 }
index b3f3956..9788997 100644 (file)
 
 #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
index e308906..1e09d6f 100644 (file)
 
 #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;
-       
 }
index 631150d..895013c 100644 (file)
 
 #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
index 3c99f1b..cff9ee0 100644 (file)
 
 #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;
+       }
 }
index 0e10046..c00b5fa 100644 (file)
 
 #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
index ddab418..15096ea 100644 (file)
 
 #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;
-       
 }
index d95bdb8..49a5fd6 100644 (file)
 
 #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
index 98809c0..f102fde 100644 (file)
 
 #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 */
        }
 
index d392127..9854bae 100644 (file)
@@ -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
index 06d9764..c6f4264 100644 (file)
 #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;       
 }
 
index 1530760..6911c80 100644 (file)
@@ -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);
index 5a001bb..6263c56 100644 (file)
 
 #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 */
        }       
 }
index 656a369..e14350d 100644 (file)
@@ -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"
index b03914e..2d3a244 100644 (file)
 
 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 */
        }       
 }
index 5795c4b..4dae8dc 100644 (file)
@@ -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"
index aac73cf..572ffe1 100644 (file)
 
 #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;       
 }
index eb08ef2..6f5a673 100644 (file)
@@ -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;
 }
 
index da12b1e..0b36308 100644 (file)
 
 
 
-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<file_name_length -1; x++){
                file_name[x]='a';
        }
        file_name[file_name_length-2]='\0';
        
-       //printf("file name: %s\n",file_name);
+
 
 
        output=yaffs_mount(file_name);
@@ -45,20 +46,18 @@ int test_yaffs_mount_ENAMETOOLONG(void){
                error_code=yaffs_get_error();
                if (abs(error_code)== ENAMETOOLONG){
                        return 1;
-               }
-               else {
-                       printf("different error than expected\n");
+               } else {
+                       print_message("different error than expected\n", 2);
                        return -1;
                }
-       }
-       else {
-               printf("mounted a too long mount point name.(which is a bad thing)\n");
+       } else {
+               print_message("mounted a too long mount point name.(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_mount_ENAMETOOLONG_clean(void){
+
+int test_yaffs_mount_ENAMETOOLONG_clean(void)
+{
        return test_yaffs_mount();
 }
 
index e0bc9f7..2688860 100644 (file)
 
 #include "test_yaffs_mount_ENODEV.h"
 
-static int handle=0;
-int test_yaffs_mount_ENODEV(void){
+static int handle = 0;
+
+int test_yaffs_mount_ENODEV(void)
+{
        int output=0;
        int error_code=0;
-       /*printf("path %s\n",path); */
-       handle=yaffs_mount("/nonexisting_mount_point/");
+
+       handle = yaffs_mount("/nonexisting_mount_point/");
        if (handle==-1){
-               error_code=yaffs_get_error();
-               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
-               if (abs(error_code)==ENODEV){
+               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 if (output >=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;
 }
 
index 01040fd..3f64d8a 100644 (file)
 #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();
 }
 
index d7237a8..af7b754 100644 (file)
 
 #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 */
        }
 }
 
index 90ba455..5bcbf2b 100644 (file)
 
 #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*/
        }
 }
index 3569028..fb596ca 100644 (file)
 
 #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*/
        }
 }
index 3ea0918..a0d86e2 100644 (file)
 
 #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*/
        }
 }
index b15156f..5d0a670 100644 (file)
 
 /*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*/
        }
 }
index 44fd562..228f736 100644 (file)
 
 
 
-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<file_name_length -1; x++){
-               file_name[x]='a';
+       for (x = strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+               file_name[x] = 'a';
        }
        file_name[file_name_length-2]='\0';
-       
-       //printf("file name: %s\n",file_name);
+       handle = yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
 
+       if (handle == -1){
+               error_code = yaffs_get_error();
 
-       handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
-
-       if (handle==-1){
-               error_code=yaffs_get_error();
-               //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
-               if (abs(error_code)== ENAMETOOLONG){
+               if (abs(error_code) == ENAMETOOLONG){
                        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("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);
        }
index 259f964..c3eba4a 100644 (file)
 
 #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);
        }
index d9790cf..25082ae 100644 (file)
 
 #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);
        }
index a5157d2..48e9826 100644 (file)
 
 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);
        }
index 073f329..1ae9216 100644 (file)
 
 #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;
 }
index 845148f..d17f5b8 100644 (file)
 
 #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
index 46e11f7..e3ce966 100644 (file)
 
 #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;
        }
 
index c2c54b7..ee55927 100644 (file)
@@ -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
index d379944..83efcdb 100644 (file)
 
 #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;
        }
 }
index f7e27af..e389483 100644 (file)
 
 #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
index c6ee58b..9a740b8 100644 (file)
 
 #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;
 }
index b6d6b20..a2f8209 100644 (file)
 
 #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
index db38d16..d0ab0e7 100644 (file)
@@ -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;
 }
index 85ca669..c279f8f 100644 (file)
 
 #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
index c1ae528..e4cd7f9 100644 (file)
  */
 
 #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;
        }
 
index 5540060..94a304a 100644 (file)
 
 #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
index 0fc79af..0d69865 100644 (file)
  */
 
 #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;
 }
index 15f0999..5a459ad 100644 (file)
 
 #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
index 7c8fd9d..f56045a 100644 (file)
  */
 
 #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;
 }
index f78af54..7a71a5e 100644 (file)
 
 #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
index 5fa4601..cfd1d82 100644 (file)
  */
 
 #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;
 }
index 7299c6d..4e485ef 100644 (file)
 
 #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
index 7d264e5..72d7314 100644 (file)
  */
 
 #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;
 }
index 1a74d87..07fe6a4 100644 (file)
 
 #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
index bda51ef..c2414db 100644 (file)
  */
 
 #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;
 }
index 1352ccf..75cf7c0 100644 (file)
 
 #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();
 }
index 80c8f40..ca5d660 100644 (file)
 
 /*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*/
        }
 }
index 8f25543..d675d01 100644 (file)
@@ -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;
 }
 
index 8821257..113b148 100644 (file)
 
 #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*/
        }
 }
index 8724376..5eaff8c 100644 (file)
 #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;
 }
 
index b3ddba2..8111206 100644 (file)
 
 #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();      
 }
index 2c6145b..88c93dd 100644 (file)
 #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;
        }
 }
index 1af5761..ecceb22 100644 (file)
 
 #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<file_name_length -1; x++){
                file_name[x]='a';
        }
        file_name[file_name_length-2]='\0';
        
-       //printf("file name: %s\n",file_name);
-
-
        output=yaffs_unmount(file_name);
 
        if (output<0){
                error_code=yaffs_get_error();
                if (abs(error_code)== ENAMETOOLONG){
                        return 1;
-               }
-               else {
-                       printf("different error than expected\n");
+               } else {
+                       print_message("different error than expected\n",2);
                        return -1;
                }
-       }
-       else {
-               printf("mounted a too long mount point name.(which is a bad thing)\n");
+       } else {
+               print_message("mounted a too long mount point name.(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_unmount_ENAMETOOLONG_clean(void){
+int test_yaffs_unmount_ENAMETOOLONG_clean(void)
+{
        return 1;
 }
 
index 5eb853c..75753cd 100644 (file)
 
 #include "test_yaffs_mount_ENOENT.h"
 
-
-int test_yaffs_unmount_ENOENT(void){
+int test_yaffs_unmount_ENOENT(void)
+{
        int output=0;
        int error_code=0;
-       /*printf("path %s\n",path); */
-       
-       
 
        output=yaffs_unmount("/non_existaint_mount_point/");
        if (output==-1){
                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("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_ENOENT_clean(void){
+int test_yaffs_unmount_ENOENT_clean(void)
+{
        return 1;
 }
 
index cd5a61f..6695cca 100644 (file)
 
 #include "test_yaffs_write.h"
 
-static int handle=0;
-int test_yaffs_write(void){
+static int handle=-1;
+
+int test_yaffs_write(void)
+{
        handle=test_yaffs_open();
        if (handle>=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 */
        }       
 }
index 473a009..022d5d4 100644 (file)
 
 #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
index a889b34..5ed718e 100644 (file)
 
 #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 */
        }       
 }
index 6b427fb..db03ed6 100644 (file)
 
 #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