yaffs Found and fixed the bugs in quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Sun, 7 Nov 2010 21:12:35 +0000 (10:12 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Sun, 7 Nov 2010 23:43:06 +0000 (12:43 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c
direct/timothy_tests/quick_tests/test_yaffs_lseek.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c
direct/timothy_tests/quick_tests/test_yaffs_truncate.c

index 71a11f89f6e6c28ce5387d1139ae14c2ca0a88e5..24150823531843bcfb309a4ce5456ad30c78fcf6 100644 (file)
@@ -31,7 +31,7 @@ int main(){
 
        unsigned int x=0;       
        init_quick_tests();
 
        unsigned int x=0;       
        init_quick_tests();
-       printf("\n\nrunning quick tests for yaffs\n");
+       printf("\n\nrunning quick tests for yaffs\n\n");
        //printf("testing yaffs\n");
 
        //printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
        //printf("testing yaffs\n");
 
        //printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
@@ -50,6 +50,7 @@ int main(){
                        num_of_tests_failed ++; 
 
                        if (EXIT_ON_ERROR){
                        num_of_tests_failed ++; 
 
                        if (EXIT_ON_ERROR){
+                               get_error();
                                printf("\n\n");
                                quit_quick_tests(1);
                        }
                                printf("\n\n");
                                quit_quick_tests(1);
                        }
@@ -79,9 +80,6 @@ void quit_quick_tests(int exit_code){
        if (num_of_tests_pass==total_number_of_tests &&  num_of_tests_failed==0){
                printf("\t OK \n");
        }
        if (num_of_tests_pass==total_number_of_tests &&  num_of_tests_failed==0){
                printf("\t OK \n");
        }
-       else {
-               get_error();
-       }
        printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed);
        yaffs_unmount(YAFFS_MOUNT_POINT);
        exit(exit_code);
        printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed);
        yaffs_unmount(YAFFS_MOUNT_POINT);
        exit(exit_code);
index fec910d346d7bef5e72f1d961f2468f2215cedeb..a6d661bcb04b66638ac542926369b55faaaec902 100644 (file)
@@ -16,7 +16,7 @@
 static int handle=0;
 int test_yaffs_ftruncate(void){
        handle=test_yaffs_open();
 static int handle=0;
 int test_yaffs_ftruncate(void){
        handle=test_yaffs_open();
-       if (handle>0){
+       if (handle>=0){
                return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
        }
        else {
                return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
        }
        else {
@@ -28,7 +28,7 @@ int test_yaffs_ftruncate(void){
 int test_yaffs_ftruncate_clean(void){
        /* change file size back to orignal size */
        int output=0;
 int test_yaffs_ftruncate_clean(void){
        /* change file size back to orignal size */
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                output=yaffs_ftruncate(handle,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);
                output=yaffs_ftruncate(handle,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);
index 5e063eff5c2b5c883f7d6613e7f855098481c2cb..588635ebb485e92b81ed91e77f5fe8779660ee1e 100644 (file)
@@ -18,7 +18,7 @@ int test_yaffs_lseek(void){
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                if (0==yaffs_lseek(handle, 0, SEEK_SET)){
                        return 1;
                }
                if (0==yaffs_lseek(handle, 0, SEEK_SET)){
                        return 1;
                }
index e896abcf6b24fff21755fcc11bebb81d46aabe01..44fd562dc041e771f7f8b3e2287e1a4b3af6b298 100644 (file)
@@ -33,7 +33,7 @@ int test_yaffs_open_ENAMETOOLONG(void){
 
 
        handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
 
 
        handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
-       printf("handle %d \n",handle);
+
        if (handle==-1){
                error_code=yaffs_get_error();
                //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
        if (handle==-1){
                error_code=yaffs_get_error();
                //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
@@ -46,6 +46,7 @@ int test_yaffs_open_ENAMETOOLONG(void){
                }
        }
        else if (output >=0){
                }
        }
        else if (output >=0){
+               printf("handle %d \n",handle);
                printf("non existant file opened.(which is a bad thing)\n");
                return -1;
        }
                printf("non existant file opened.(which is a bad thing)\n");
                return -1;
        }
index 1b19bd5447fd7fd2f7c21af03cf3f461a6de36b0..c1ae528c72c4f510e463b75ec97017b8195d7b6c 100644 (file)
@@ -16,7 +16,7 @@ static int handle=0;
 
 int test_yaffs_truncate(void){
        handle=test_yaffs_open();
 
 int test_yaffs_truncate(void){
        handle=test_yaffs_open();
-       if (handle>0){
+       if (handle>=0){
                return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
        }
        else {
                return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
        }
        else {
@@ -27,9 +27,8 @@ int test_yaffs_truncate(void){
 
 int test_yaffs_truncate_clean(void){
        /* change file size back to orignal size */
 
 int test_yaffs_truncate_clean(void){
        /* change file size back to orignal size */
-       int handle=test_yaffs_open();
        int output=0;
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                output= yaffs_truncate(FILE_PATH,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);
                output= yaffs_truncate(FILE_PATH,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);