yaffs All of the quick_tests programs are now working.
authorTimothy Manning <tfhmanning@gmail.com>
Thu, 4 Nov 2010 20:50:42 +0000 (09:50 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Thu, 4 Nov 2010 20:50:42 +0000 (09:50 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/quick_tests/README.txt
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_close_EBADF.c
direct/timothy_tests/quick_tests/test_yaffs_open.c
direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c
direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c
direct/timothy_tests/quick_tests/test_yaffs_read.c
direct/timothy_tests/quick_tests/test_yaffs_stat.c

index 33b93e71b91e5a2caaac08796f0da4919e8663da..127898c7f04ecda4654cd7c4d48dab6543f919f4 100644 (file)
@@ -2,6 +2,18 @@
 Made by Timothy Manning <timothy@yaffs.net> on 04/11/2010
 
 
 Made by Timothy Manning <timothy@yaffs.net> on 04/11/2010
 
 
+the yaffs_open function has been covered by tests
+the yaffs_close function has been covered by tests
+
+
+
+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_close
+       test yaffs_open_running_out_of_handles error
+       check to see if an error code is generated when there isn't an error
 
 
 How to add a test
 
 
 How to add a test
index e0444f7e541fda6a8e63dcbdf7185e11c1dd00d4..50c548f6431cca573c9e833fcd2cd1c0bd0166b4 100644 (file)
 #include <string.h>
 #define YAFFS_MOUNT_POINT "/yaffs2/"
 #define FILE_NAME "foo"
 #include <string.h>
 #define YAFFS_MOUNT_POINT "/yaffs2/"
 #define FILE_NAME "foo"
-#define FILE_SIZE 9
+#define FILE_SIZE 10
 
 #define FILE_MODE (S_IREAD | S_IWRITE)
 #define FILE_SIZE_TRUNCATED 100
 
 #define FILE_MODE (S_IREAD | S_IWRITE)
 #define FILE_SIZE_TRUNCATED 100
-#define FILE_TEXT "file foo"
-#define FILE_TEXT_NBYTES 9
+#define FILE_TEXT "file foo "  /* keep space at end of string */
+#define FILE_TEXT_NBYTES 10
 
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
 
 /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ 
 #define FILE_PATH "/yaffs2/foo"
index bdef486e65c010b2a0cd582976c5574fd6e5cd0a..3753583823f22542c58a0a5e7adcd02abbca9307 100644 (file)
@@ -37,6 +37,7 @@ int main(){
        //printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
        for (x=0;x<total_number_of_tests;x++){
                //printf("x %d\n",x);
        //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 */
                output=test_list[x].p_function();       /*run test*/
                if (output>=0){
                        /*test has passed*/
                output=test_list[x].p_function();       /*run test*/
                if (output>=0){
                        /*test has passed*/
index 2c4210ee1f0a94a6fb747dc1e5910c29e3d73109..ebe55b6fa5377c7756a6c0ce4f1350476940376a 100644 (file)
@@ -53,8 +53,8 @@ test_template test_list[]={
        {test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"},
        {test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"},
        {test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"},
        {test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"},
        {test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"},
        {test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"},
-//     {test_yaffs_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"},
-//     {test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"},
+       {test_yaffs_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"},
+       {test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"},
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
index 5036b475ecffe503e58e57d330b0142cd21f9ff4..5f322fc6a2ac0bec3f12120d98e3114a36790ca5 100644 (file)
@@ -28,7 +28,7 @@ int test_yaffs_close_EBADF(void){
                        if (output<0){
                                /*error has happened */
                                error_code=yaffs_get_error();
                        if (output<0){
                                /*error has happened */
                                error_code=yaffs_get_error();
-                               printf("EEXIST def %d, Error code %d\n",(- EBADF),error_code);
+                               //printf("EBADF def %d, Error code %d\n",(- EBADF),error_code);
                                if (abs(error_code)== EBADF){
                                        return 1;
                                }
                                if (abs(error_code)== EBADF){
                                        return 1;
                                }
index 89c7492701ce8876942650b45dafdbcc1e4cfd06..76ed67bdb4f366891437a04761a68793e2a127bc 100644 (file)
@@ -17,7 +17,7 @@ static int handle=0;
 
 int test_yaffs_open(void){
 
 
 int test_yaffs_open(void){
 
-       handle=yaffs_open(FILE_PATH,O_CREAT | O_TRUNC| O_RDWR, FILE_MODE);
+       handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
        return handle;
 }
 
        return handle;
 }
 
index 7ae81a1ac22908ce1e259a757fa1f3e8f2466b3c..90ba455eb9566f0190b3066076ba43cb7f7a5f2c 100644 (file)
@@ -21,7 +21,7 @@ int test_yaffs_open_EEXIST(void){
        handle=yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
        if (handle==-1){
                error_code=yaffs_get_error();
        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);
+               //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
                if (abs(error_code)== EEXIST){
                        return 1;
                }
                if (abs(error_code)== EEXIST){
                        return 1;
                }
index 0891aaa326da8317e0aeba74a5c12a5cb46c5224..d86e081ff9215ff06a6a3085355f9f583cdcc797 100644 (file)
@@ -23,7 +23,7 @@ int test_yaffs_open_EISDIR(void){
        handle=yaffs_open(YAFFS_MOUNT_POINT, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
        if (handle==-1){
                error_code=yaffs_get_error();
        handle=yaffs_open(YAFFS_MOUNT_POINT, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
        if (handle==-1){
                error_code=yaffs_get_error();
-               printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+               //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
                if (abs(error_code)== EISDIR){
                        return 1;
                }
                if (abs(error_code)== EISDIR){
                        return 1;
                }
index 4722e8814eaca81e1b79446f35c9e2025d6febd5..d9790cf8be2b1ded5e98caa484be98e0e513f6b4 100644 (file)
@@ -21,7 +21,7 @@ int test_yaffs_open_ENOTDIR(void){
        handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE );
        if (handle==-1){
                error_code=yaffs_get_error();
        handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE );
        if (handle==-1){
                error_code=yaffs_get_error();
-               printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
                if (abs(error_code)==ENOTDIR){
                        return 1;
                }
                if (abs(error_code)==ENOTDIR){
                        return 1;
                }
index fcfae7b22d9a44311a5e5620dd34506a5e3850b3..2bc2aba6c964eed2ea0ac0a042e32917c0045618 100644 (file)
@@ -19,13 +19,13 @@ int test_yaffs_read(void){
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
-       printf("handle %d\n",handle);
+       //printf("handle %d\n",handle);
        if (handle>=0){
                output=yaffs_read(handle, text, FILE_TEXT_NBYTES);
        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\n",text);
+               //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 (output>0){ 
-                       if (text==FILE_TEXT){
+                       if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
                                return 1;
                        }
                        else {
                                return 1;
                        }
                        else {
index d47fd2912cdf79de81a98b1d47be32b78e851d12..f99ab7f62eab44d61dea45a6cbe16de341e264d9 100644 (file)
@@ -17,21 +17,23 @@ int test_yaffs_stat(void){
        int mode=0;
        int size=0;
        mode =yaffs_test_stat_mode();
        int mode=0;
        int size=0;
        mode =yaffs_test_stat_mode();
-       printf("\nmode %o\n",mode);
+/*     printf("\nmode %o\n",mode);
        printf("expected mode %o \n",FILE_MODE);
        printf("anding together %o\n",FILE_MODE & mode);
        printf("%d\n",FILE_MODE == (FILE_MODE & mode));
        printf("expected mode %o \n",FILE_MODE);
        printf("anding together %o\n",FILE_MODE & mode);
        printf("%d\n",FILE_MODE == (FILE_MODE & mode));
-       if (FILE_MODE == (FILE_MODE & mode)){
+*/     if (FILE_MODE == (FILE_MODE & mode)){
                mode=1;
        }
        else {
                printf("mode did not match expected file mode\n");
                return -1;
        }
                mode=1;
        }
        else {
                printf("mode did not match expected file mode\n");
                return -1;
        }
-       if (yaffs_test_stat_size()==FILE_SIZE){
+       size=yaffs_test_stat_size();
+       if (size==FILE_SIZE){
                size=1;
        }
        else {
                size=1;
        }
        else {
+               printf("file size %d, expected file size %d\n",size,FILE_SIZE);
                printf("mode did not match expected file mode\n");
                return -1;
        }
                printf("mode did not match expected file mode\n");
                return -1;
        }
@@ -54,7 +56,7 @@ int yaffs_test_stat_mode(void){
        struct yaffs_stat stat;
        int output=0;
        output=yaffs_stat(FILE_PATH, &stat);
        struct yaffs_stat stat;
        int output=0;
        output=yaffs_stat(FILE_PATH, &stat);
-       printf("output: %d\n",output);
+       //printf("output: %d\n",output);
        if (output>=0){
                return stat.st_mode;    
        }
        if (output>=0){
                return stat.st_mode;    
        }