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 a22592a6e6842b0f74d0d4d9f94d961097fc7748..bf827268c2e8c326b4eac2e996b654a66cb43af8 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 b7b17b0990dce98de031af82976531f6020d595c..25b995e0b08cb827580cc14df22f578304ed32e0 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 6435529689b0fb566db762a5b27f3237eeadae1f..ed659a14561e613b7c8ae10328f9c884c8f3dca3 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 39b0713384d02acf6386a61c7b8304abf50cc9bd..a7219c59f31d303f31ac2757902ae2fba19278d9 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 50c548f6431cca573c9e833fcd2cd1c0bd0166b4..2efd08e2d7236c550e7fe65bb328b577fec060ce 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 720fdee55a7dceaf3a67a7955f077f57ae65d47c..17bce3b7321eddd6e4f52904ad2fb2c1fd313523 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 a11386d255070e1a1f6e7d77d7380ffb640196d2..b44bf9b67b268af1cb063372931e2207a04d2bcd 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 9a00b9398d9bf023ece703959b9ed895a3e0a2ff..da4f23e06f324a6e933114df4f68126bf753d085 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 3f9e26cbe380955056cddb28862f43454e6ed3f1..9919498340b7eafea73e50a10f035154ab137af2 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 cec038986b5bbd35a333571919b7e4075bead641..f8ba13a37717f2236a41a477e153db30e4a57aa5 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 b13a1a06a9367dcaed9254b74b376207f769377d..62fe9e2cdf063ec4ab53f286c1b634b5c1204fea 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 610e4ee7838096a11cd83efb1f59f2749b6462a2..3746886a1fbdd731548b153bf5b0ec00143dfa97 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 ad2402cb60d11f3dc62d4205cc47ea0252193297..c494f182c0888bbd560fd3a07c223a17b36dd1cf 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 5f322fc6a2ac0bec3f12120d98e3114a36790ca5..1c830194a34df31d581e65eb6f32ee6bf120eb9f 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 73451611c162ce4bc80650bc6d852f8cfa47b575..dfdc80d65ae3a43f288185b0e144b3e1c654be6a 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 3fc02233c1eebd7c9ee1f79a203c5782834bbb71..d4921f8e4831cc75e84f15c81dd7b2952e5df2c3 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 e44482ded45ec40b49a00157b33efe181b7de6f7..546ebea2eed0195cc93ab7522a08f31e97dadab2 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 4d2491683a71d604bb29aaa1252c75802413995e..453d8c289b343c2c2624dce531e3ab697038a6c4 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 a6d661bcb04b66638ac542926369b55faaaec902..cb380098be9c265f5df81ebb6822753b713f987c 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 b3f3956c7c516c2608c297adb0cb3c489019f5c1..9788997773926a9b6327c907a5ed90116acb082c 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 e3089065684a83068c8a5333d91f194eff0ca5ba..1e09d6f1d5b44c3165bce76b415eca06e3848cae 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 631150d048efd54ea4f68f0f9bd5a4a1bccc4883..895013c742de93b39909b44af51d77e0239ddd5f 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 3c99f1bb5065e54d51d26b997e886f659dfa741d..cff9ee06a9770bf0803b760300de24af51365c4c 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 0e10046546ac4fc654a82f6a8193f85d5cb1e6b6..c00b5fa161c1376bdf17d212e969bde124efae5b 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 ddab41869192c878cf57fc4d5969ba6ecf051bb9..15096ead04a2a2a76c8e0f5e866395c12f21f0b1 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 d95bdb827eb5de40a83907f4092366945fc26826..49a5fd65df94295ca35605580f1c37635612690c 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 98809c07a1a9f0216e663bd2f558f8b5b825db5b..f102fdedf114cc64d475534a1edf0966ed4b499a 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 d392127c943b3aca0173f7d9db3d7105cdaf8e1e..9854bae4e143e31c690257554152853372d6bef2 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 06d97646df8d0165fd0eee160cdf3e905bb07b94..c6f4264e345944d0d862ab3f9e97ab7abccd14ed 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 1530760a921c188c7441c74ae61504cf070dd58c..6911c803a3fb6583e355094a986c6cce7baa619d 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 5a001bb6f1f204661a6186e6cc791ecd31c00c09..6263c56b92e1f5767d6bcceade98ccad064a7c55 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 656a369872c776c7204de1ca2c3571b98186845b..e14350da7631919ab5de30edee34387ef1315f20 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 b03914e87279808b9fe0212320c099195de99b59..2d3a24479b1d441c6f0e4adc5eff9dee811d431d 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 5795c4bd67603a1e8d110d838f1bc50ef8a3d78b..4dae8dca26ffa2a5bc6f3d83a0f5cc2fbf2bd738 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 aac73cf5fb25c62d7603e35a4c652f77873b26af..572ffe1600d1c85b9ab4673bc0c1c41ece1cfd0e 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 4af829cd811886908487e0da5679210738387e76..57405c66a0ee92de0fa9df04061a0114d9bf9ac6 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_mount(void);
 int test_yaffs_mount_clean(void);
+
 #endif
index eb08ef2f8775c2bec6ed4c960abab4211d8272bc..6f5a6738ee21311f15258aaab94765375b04cd0f 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 5c348692c9cf31ca8be945c8793237dc58200e08..27fde7e57c4837219d7ee5313f03d1db50819045 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_mount_EBUSY(void);
 int test_yaffs_mount_EBUSY_clean(void);
+
 #endif
index da12b1e3bf33660619380b25c0daeeac444d72de..0b3630815e654d92f57540167f1af78a28e75bc7 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 746fc487deb153ada2864923c86a5a342dbc836b..7a914e4054c433ac52af3a7f46b5f02e1e9d2df7 100644 (file)
@@ -24,4 +24,5 @@
 
 int test_yaffs_mount_ENAMETOOLONG(void);
 int test_yaffs_mount_ENAMETOOLONG_clean(void);
+
 #endif
index e0bc9f7f8d8dbed7574ef6f14bbf080bc16fcfe6..2688860992a1d94673eb3fad506ef49d310ef263 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 27cd767cd9adf06ba97c6e37c6d6afb15c7d248c..73522e8419187153202a17291d0a9ceeba0ae4c8 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_mount_ENODEV(void);
 int test_yaffs_mount_ENODEV_clean(void);
+
 #endif
index 01040fdf7b8c3a2def06e6ffd8393baa5e30a80d..3f64d8aebf65bd395cfefbe328f41477b2ee9ccf 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 e0e7ad6a00f0e480ce727b5722ba243039061d47..1c7ad758f2f145622f0e2451c90d97cb9eafca9f 100644 (file)
@@ -23,4 +23,5 @@
 
 int test_yaffs_mount_ENOENT(void);
 int test_yaffs_mount_ENOENT_clean(void);
+
 #endif
index d7237a89cbaec6e8732c4c1a4f2bc76dcc567b07..af7b7542aeccb61fa60249fdbde023286f45b830 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 d5883f4c573e2eda0ded420f29a136f3f99ac3b9..3fc83e09665f1bf053a9692c9e3a526c668a156b 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open(void);
 int test_yaffs_open_clean(void);
+
 #endif
index 90ba455eb9566f0190b3066076ba43cb7f7a5f2c..5bcbf2b87d0f2b12f75c85a51a46cc8fd292595d 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 50995f114ea49cd771f6e10f28195d9c09d4916f..ebc2107a93ba6f076e431f96e6666a1044f230e4 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_EEXIST(void);
 int test_yaffs_open_EEXIST_clean(void);
+
 #endif
index 35690285e2616b1f53730e7d0a7d0883583111e0..fb596ca6c9843c63c9fcc58be63e568cba82e330 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 85597daac862535b39806532a67ffbccfd687884..2e02ad3f0c5d619f4c592b50df878f807927a2bf 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_EINVAL(void);
 int test_yaffs_open_EINVAL_clean(void);
+
 #endif
index 3ea0918ac182641e926aa37dd92b198c3c48db6e..a0d86e296b89a6640f7eed0729fc0dcf78e6a388 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 de358470b8fcd30660fcba3fadf6a7a4fa8d26d3..1531cbb3f3a8beaa247b1c892324f969d31528b5 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_EINVAL2(void);
 int test_yaffs_open_EINVAL2_clean(void);
+
 #endif
index b15156fa8a364690fd5edb6ae63604eedcc96a2f..5d0a67052226af6ee3e92f7e101afd6cfb141105 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 3538510e95188888a11005addf2965da7074aee9..fac12d703728e34679f8f56b436d690372ee8560 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_EISDIR(void);
 int test_yaffs_open_EISDIR_clean(void);
+
 #endif
index 44fd562dc041e771f7f8b3e2287e1a4b3af6b298..228f73614d0469a0101113570203fe7590afcf79 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 8325fd56cf59c15928c0c2eaa14d536271e10775..852745286f855b45c2216f23eb6f78a851777828 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_ENAMETOOLONG(void);
 int test_yaffs_open_ENAMETOOLONG_clean(void);
+
 #endif
index 259f96436185dd32c17c8abf3dbc916e363a42f6..c3eba4a94431a5a08c7d9a47d6b96524bf314d57 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 ff2663b0d4635b84c3afa6ae4b6dd32ab3587687..abc576a83afee6733be379a848bda142dcec86da 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_ENOENT(void);
 int test_yaffs_open_ENOENT_clean(void);
+
 #endif
index d9790cf8be2b1ded5e98caa484be98e0e513f6b4..25082ae273d4a0081e0ffb9d9394e5fa4b84db02 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 d164ea9e34270e6e4b80106ce2b8e39b5840798c..d611dd29aed0737a27914ea288d6cd2660682c75 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_open_ENOTDIR(void);
 int test_yaffs_open_ENOTDIR_clean(void);
+
 #endif
index a5157d24f7d4064c603dea33fc023e3de18cfdfc..48e98260ff15d500f041acfbd94fab982fd0bda0 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 b118854cdc028fe09701b429551a2110df4b1766..bc01b474310cd0caa6187cabe8062ff24c443cb5 100644 (file)
@@ -22,4 +22,5 @@
 
 int test_yaffs_read(void);
 int test_yaffs_read_clean(void);
+
 #endif
index 073f3297e44522f690255be89a67cca98df3be2f..1ae921692f2b1ceeaae1193eda6eadf088e6f125 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 845148f51f58e7b2658cc302b689a2a1110e2ef3..d17f5b88618b04bc6c26a524c95094af1488dcb7 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 46e11f78c2936f1e13540a6eb4ce71ab52af6327..e3ce96667c53ac0113d892cb88f4ee3752c9515e 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 c2c54b7729fb96a89b4222fa8a5331f183da7b5b..ee559276343c73b9061ca54c282f35350379b3d9 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 d379944d769b4e27d61c1411b71a86edb4fd8aa0..83efcdbb05a3a5126c0ce7de8657c088eeefc42c 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 f7e27afce508d043d1f514092a8a8bc3dd0433ae..e389483baa5dbd7370f963bdd16658948016695d 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 c6ee58be43b1b601a2f6344a20494c59e62dff54..9a740b8e65bd5e701fcb3d9002cdb3c2ebf446f6 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 b6d6b20f3dfe4a22bcb8d0d0c565133d16e17fe9..a2f82096dc7fde7ba8480f52828e084beec39440 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 db38d16cc36b3581bdf52e8e08f12c1cb333d6bb..d0ab0e7e33686bf84d6c3d12a86d96b3daa009a2 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 85ca6698cbfd8945c8019b1e46e0d8899e771088..c279f8f900262a2a6571c785bb596f2014797013 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 c1ae528c72c4f510e463b75ec97017b8195d7b6c..e4cd7f9e91f0d6cb90f5e5e480bac5adf50ab5d5 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 5540060810e1d50bddeada86ea196e75eaff2591..94a304a67b8f3303140df9ed70a8afa1ac8e11ac 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 0fc79af6ead130e0a13166748c51bf11d8efdc0a..0d698654916f3fe3a1a108379d55e818bf781cbe 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 15f0999c0ea9da57a966d9f4941d2978b200ea66..5a459ad0e963fb0a6cc3602ea4910cc28510df70 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 7c8fd9d19b15eafc4020cac63022c962f9d7ac50..f56045abc085f04a8acb3676da02209242add32b 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 f78af54d3d0a0cc7e52eeaa4abae5d1536b38814..7a71a5e70957499e3b1ef0925f47d7e06dc07f0e 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 5fa4601a4fc88594bdbaa0db5e3449874ea2a70e..cfd1d82422388eccc912b55fa9dea93b50b5aa7b 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 7299c6d0747f7058b6a9dadb882d0ac3dadf1435..4e485ef1f5a194d757de9369c1ebe8d7ea3765e4 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 7d264e5203382c5d173afa896fac082d63462d15..72d7314079a46a95925e9b8815f4bf3f43ab63fd 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 1a74d87ed6a7cd8a2289893dd04bca9a03bafe4d..07fe6a44ed7d5388ea315838c03dfd45db4a3210 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 bda51ef15d32ad394b9f7cd74b845557d2c5db40..c2414db43711800cf3373c94d81bf65f754620fe 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 1352ccfabe374ba3cb97a20e7f435cfe279dbb90..75cf7c0f76eb29ae1d812d60c087268e0b36dc12 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 a28efc4297612d82769f9278e2af99e4e4bb823b..bab34766ce78a61d831c30fc8138689a5f3c1361 100644 (file)
@@ -23,4 +23,5 @@
 
 int test_yaffs_unlink(void);
 int test_yaffs_unlink_clean(void);
+
 #endif
index 80c8f40ba883135231a01f845d12897c5e92b925..ca5d6602c799039ab730009ad27a13613c42ebc9 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 cdba6f5b04fb52f933fadc2e44f58b1464e6462e..6d4b2c865e3291c943c709f7d6afc758cfb3a506 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_unlink_EISDIR(void);
 int test_yaffs_unlink_EISDIR_clean(void);
+
 #endif
index 8f255431b9ea0feff9048369a3739cc73a61a912..d675d01b692acf541813c227e5640c0e1538850c 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 882125780431f55fe2a0f23f6a3d1191db1ecfea..113b14840fd045734db81907d27dcfc248465139 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 ec95fd722407d0fb9c975a428645c3ff80ec56a6..1d419b8b5052777ab6eb2161ffb1fe2ed619167b 100644 (file)
@@ -22,4 +22,5 @@
 
 int test_yaffs_unlink_ENOENT(void);
 int test_yaffs_unlink_ENOENT_clean(void);
+
 #endif
index 8724376fb7a5c89498a0e52ae5d34a4cda59fbf8..5eaff8c6a7ae87fd6fea4c9cc5e678e47c2b84e0 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 82e44da2404ea2bff9fa812c0d091e549ed052dc..a4c1565bbac8b116e5c72a1b9b6a1769eec1e022 100644 (file)
@@ -21,4 +21,5 @@
 
 int test_yaffs_unlink_ENOTDIR(void);
 int test_yaffs_unlink_ENOTDIR_clean(void);
+
 #endif
index b3ddba2bfa21bae0b2b8dad79e18d561079c2f32..811120611093f8b03498c5aef59f2a248f0cb4dc 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 7b0562a4d287807a73fc4201c81e8fb6124bf536..a6e2ea57b16f54ad75a9aa094016eac3aaa8c06e 100644 (file)
@@ -22,4 +22,5 @@
 
 int test_yaffs_unmount(void);
 int test_yaffs_unmount_clean(void);
+
 #endif
index 2c6145b7004c6860653d08dbd33a4c44910b6f69..88c93dda7528fef5f07efbf5056f700eaf7a6090 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 fc4164548b7e553ee891dbdbff81bad74cb78da5..c40b6a36ed989b7e03de5949a844b3df6ce0016a 100644 (file)
@@ -23,4 +23,5 @@
 
 int test_yaffs_unmount_EBUSY(void);
 int test_yaffs_unmount_EBUSY_clean(void);
+
 #endif
index 1af57614d8c4df8e25f7685766cad60b30ca8a51..ecceb2228025947488facf9dc005f80fe778b4e7 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 f33767101566b8ba66ddc4826240147c1c4b2cd5..557689f54e3984fb6ac05d06d712a5aa2f0af57d 100644 (file)
@@ -24,4 +24,5 @@
 
 int test_yaffs_unmount_ENAMETOOLONG(void);
 int test_yaffs_unmount_ENAMETOOLONG_clean(void);
+
 #endif
index 5eb853ca8cca7cb0364c670c68cb329d2fbf1c0a..75753cda0a96e886e68f3fe09bd1dce5e9a20abe 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 9c4c2cc98b2b8c601b18e6db285cfe6c428343af..f6faa64bc06bbbd9dd6b20cf042c36c07614ecce 100644 (file)
@@ -23,4 +23,5 @@
 
 int test_yaffs_unmount_ENOENT(void);
 int test_yaffs_unmount_ENOENT_clean(void);
+
 #endif
index cd5a61ffec468a8fd6189f9ae5ec968a23643eb5..6695ccadec0c2c8b2e97316af9b2d57955060dc3 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 473a009e26da37a092bcd850c74bd0510ba663dd..022d5d467d8771676a3643b8055e6a44b49616e0 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 a889b349fb994b5f596840a0328c0e65b2d0d6b2..5ed718e0cd4298ce86bb788c93564780b0a27151 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 6b427fb043a520481908d3e5fc0d9f7099328409..db03ed65c5cc688ba4e3b15b40da39e88a70755f 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