yaffs Improvements on the quick tests code. note the bug is still here.
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 3 Nov 2010 03:21:10 +0000 (16:21 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 3 Nov 2010 03:27:09 +0000 (16:27 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
22 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_access.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_lseek.c
direct/timothy_tests/quick_tests/test_yaffs_lseek.h
direct/timothy_tests/quick_tests/test_yaffs_open_file.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_file.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.h [new file with mode: 0644]
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_stat.c
direct/timothy_tests/quick_tests/test_yaffs_stat.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_unlinking.c
direct/timothy_tests/quick_tests/test_yaffs_unlinking.h
direct/timothy_tests/quick_tests/test_yaffs_write.c
direct/timothy_tests/quick_tests/test_yaffs_write.h

index 8b1cdc18e527bbf0e97793a4ccbca5fbbf87883f..eb13201c20013785d917a9b503121e52d5879c76 100644 (file)
@@ -44,7 +44,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
 
 #               yaffs_checkptrwtest.o\
 
-YAFFSTESTOBJS  = $(COMMONTESTOBJS) quick_tests.o lib.o test_mount_yaffs.o   test_yaffs_unlinking.o test_open_file.o test_yaffs_ftruncate.o test_yaffs_truncate.o \
+YAFFSTESTOBJS  = $(COMMONTESTOBJS) quick_tests.o lib.o test_mount_yaffs.o   test_yaffs_unlinking.o test_yaffs_open_file.o test_yaffs_ftruncate.o test_yaffs_truncate.o \
                test_yaffs_write.o test_yaffs_read.o test_yaffs_lseek.o test_yaffs_access.o test_yaffs_stat.o
 
 PYTONOSYMLINKS = yaffs_error_converter.c yaffs_error_converter.h
index 61168be9f3d82dc69649dec869d737b0724e938d..035b4fac1be4a3c68b5a083cfa28a84cbd3b6c61 100644 (file)
@@ -31,7 +31,7 @@ test_template test_list[]={
        //{dummy_test_pass,dummy_test_pass_clean,"dummy_test_pass"},
        //{dummy_test_fail,dummy_test_fail_clean,"dummy_test_fail"},
        {mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"},
-       {test_open_file,test_open_file_clean,"test_open_file"},
+       {test_yaffs_open_file,test_yaffs_open_file_clean,"test_yaffs_open_file"},
        
        {test_yaffs_access,test_yaffs_access_clean,"test_yaffs_access"},
        {test_yaffs_unlinking, test_yaffs_unlinking_clean,"test_yaffs_unlinking"},
index 6a6ffad96ce710555f3d19dcf3dd00a893f7723c..bb9dd6f861452aa76bd1610986332d86072a88a0 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdio.h>
 
 #include "test_mount_yaffs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 #include "test_yaffs_unlinking.h"
 #include "test_yaffs_ftruncate.h"
 #include "test_yaffs_truncate.h"
index 181493d29d0bfdbe9c2a7523f999151a532d2112..23ff33fac3b7a20b3c32c481c9847381c21f3185 100644 (file)
@@ -2,7 +2,7 @@
 #define __test_yaffs_access_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 #include "test_yaffs_lseek.h"
 int test_yaffs_access(void);
 int test_yaffs_access_clean(void);
index 26a89a78f8ec46ba7708b87b5eefbf91de562788..02964f72714ccbd97b482a95493bb79b0ff8c7be 100644 (file)
@@ -1,25 +1,33 @@
 #include "test_yaffs_ftruncate.h"
 
+static int handle=0;
 int test_yaffs_ftruncate(void){
-       int handle=test_open_file();
+       handle=test_yaffs_open_file();
        if (handle>0){
                return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
        }
        else {
-               printf("error opening file");
+               printf("error opening file\n");
                return -1;
        }
 }
 
 int test_yaffs_ftruncate_clean(void){
        /* change file size back to orignal size */
-       int handle=test_open_file();
+       int output=0;
        if (handle>0){
-               return yaffs_ftruncate(handle,FILE_SIZE );
+               output=yaffs_ftruncate(handle,FILE_SIZE );
+               if (output>=0){
+                       return yaffs_close(handle);
+               }
+               else {
+                       printf("failed to truncate file\n");
+                       return -1;
+               }
        }
        else {
-               printf("error opening file in clean function");
+               printf("error opening file in clean function\n");
                return -1;
        }
-
+       
 }
index 68f9e43fd47ebd94065cc833e0de1613955ff560..cc2423b89442bf5cf9c3360b56c87ffa53d5552c 100644 (file)
@@ -2,7 +2,7 @@
 #define __test_yaffs_ftruncate_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 int test_yaffs_ftruncate(void);
 int test_yaffs_ftruncate_clean(void); 
 #endif
index d84bd512949921074e225afcbdce7ef95a75003f..a6afa51a3722493b1f9ea97dc8e590943d7751fd 100644 (file)
@@ -1,7 +1,8 @@
 #include "test_yaffs_lseek.h"
 
+static int handle=0;
 int test_yaffs_lseek(void){
-       int handle=test_open_file();
+       handle=test_yaffs_open_file();
        char text[20]="\0";
        int output=0;
        if (handle>0){
@@ -20,21 +21,6 @@ int test_yaffs_lseek(void){
 }
 
 int test_yaffs_lseek_clean(void){
-       /* need to reset the seek position*/
-       return test_yaffs_lseek_to_beginning(); 
-}
-int test_yaffs_lseek_to_beginning(void){
-       int handle=test_open_file();
-       if (handle>0){
-               if (0==yaffs_lseek(handle, 0, SEEK_SET)){       /*lseek returns the position of the seeker */
-                       return 1;
-               }
-               else {
-                       printf("lseek returned a different position to the expeced position\n");
-               } 
-       }
-       else {
-               printf("error opening file\n");
-               return -1;
-       }
+       return yaffs_close(handle);     
 }
+
index 772a0b47b5152a10993ab16a43b3469bd95ee1fe..0902b924e6c9ace3f86f1dd0bf9bf02385af1b53 100644 (file)
@@ -2,7 +2,7 @@
 #define __test_yaffs_lseek_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 
 int test_yaffs_lseek(void);
 int test_yaffs_lseek_clean(void);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_file.c b/direct/timothy_tests/quick_tests/test_yaffs_open_file.c
new file mode 100644 (file)
index 0000000..ec750e7
--- /dev/null
@@ -0,0 +1,16 @@
+#include "test_yaffs_open_file.h"
+
+
+int test_yaffs_open_file(void){
+       
+       int output=0;
+
+       /*printf("path %s\n",path); */
+       output=yaffs_open(FILE_PATH,O_CREAT | O_TRUNC| O_RDWR, FILE_MODE);
+
+       return output;
+}
+int test_yaffs_open_file_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_file.h b/direct/timothy_tests/quick_tests/test_yaffs_open_file.h
new file mode 100644 (file)
index 0000000..1f1bb91
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __test_yaffs_open_file_h__
+#define __test_yaffs_open_file_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_file(void);
+int test_yaffs_open_file_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.c
new file mode 100644 (file)
index 0000000..02c02bb
--- /dev/null
@@ -0,0 +1,21 @@
+#include "test_yaffs_open_file_ENOENT.h"
+
+
+int test_yaffs_open_file_ENOENT(void){
+       
+       int output=0;
+
+       /*printf("path %s\n",path); */
+       output=yaffs_open(FILE_PATH, O_TRUNC| O_RDWR, "/yaffs2/non_existant_file");
+       if (output==ENOENT){
+               return output;
+       }
+       else if (output >=0){
+               printf("non existant file opened.(which is a bad thing)\n");
+               return -1;
+       }
+}
+int test_yaffs_open_file_ENOENT_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_open_file_ENOENT.h
new file mode 100644 (file)
index 0000000..2aecff2
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __test_yaffs_open_file_ENOENT_h__
+#define __test_yaffs_open_file_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_file_ENOENT(void);
+int test_yaffs_open_file_ENOENT_clean(void);
+#endif
index 41cc07f5399165db56bcc40e45fff837dcaf1320..22a9d3db91f6aec3e2d056c66147018df902b281 100644 (file)
@@ -1,7 +1,9 @@
 #include "test_yaffs_read.h"
 
+static int handle=0;
+
 int test_yaffs_read(void){
-       int handle=test_open_file();
+       handle=test_yaffs_open_file();
        char text[20]="\0";
        int output=0;
        printf("handle %d\n",handle);
@@ -31,7 +33,5 @@ int test_yaffs_read(void){
 }
 
 int test_yaffs_read_clean(void){
-       /* need to reset the seek position*/
-       
-       return test_yaffs_lseek_to_beginning();
+       return yaffs_close(handle);
 }
index 972fb314375fb3e79b2cf114109c223bbbc10475..f21ca964613a6904a04a195953f332bba4a9cd1c 100644 (file)
@@ -2,8 +2,9 @@
 #define __test_yaffs_read_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
-#include "test_yaffs_lseek.h"
+#include "test_yaffs_open_file.h"
+
+
 int test_yaffs_read(void);
 int test_yaffs_read_clean(void);
 #endif
index d6c0eff9281fd741eac4aa30747452cf03d4c4c9..0d972a61cfe9f3f12e6286c7ae2569329d977d1c 100644 (file)
@@ -34,7 +34,7 @@ int test_yaffs_stat(void){
 }
 
 int test_yaffs_stat_clean(void){
-       return test_open_file();
+       return 1;
 }
 
 int yaffs_test_stat_mode(void){
index 2072be4d8fe99386e0d0e9090e603bfa0cc33e1a..21e12f391700f80e7374865be451b0a01a29c768 100644 (file)
@@ -2,7 +2,7 @@
 #define __test_yaffs_stat_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 #include "test_yaffs_lseek.h"
 int test_yaffs_stat(void);
 int test_yaffs_stat_clean(void);
index 300c340b93e2b031bdfac412a3d4558a29fd3cbb..57511edf20c19e0b2846a07209d4101826ca5f56 100644 (file)
@@ -1,7 +1,8 @@
 #include "test_yaffs_truncate.h"
+static int handle=0;
 
 int test_yaffs_truncate(void){
-       int handle=test_open_file();
+       handle=test_yaffs_open_file();
        if (handle>0){
                return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
        }
@@ -13,9 +14,13 @@ int test_yaffs_truncate(void){
 
 int test_yaffs_truncate_clean(void){
        /* change file size back to orignal size */
-       int handle=test_open_file();
+       int handle=test_yaffs_open_file();
+       int output=0;
        if (handle>0){
-               return yaffs_truncate(FILE_PATH,FILE_SIZE );
+               output= yaffs_truncate(FILE_PATH,FILE_SIZE );
+               if (output>=0){
+                       return yaffs_close(handle);
+               }
        }
        else {
                printf("error opening file in clean function");
index 8bc8669ad1f7e16b238835c6891b885644ee5877..f73d9bce2bddf7fbfc5fb907734c78bc2c27a962 100644 (file)
@@ -2,7 +2,7 @@
 #define __test_yaffs_truncate_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 int test_yaffs_truncate(void);
 int test_yaffs_truncate_clean(void); 
 #endif
index 795c8d4cccc47ad55d0a530ff8f23b9335c12392..d5f278734b31db4c8eff568255d2cad66126b644 100644 (file)
@@ -12,5 +12,5 @@ int test_yaffs_unlinking(void){
 }
 
 int test_yaffs_unlinking_clean(void){
-       return test_open_file();
+       return test_yaffs_open_file();
 }
index 34cf38cea414270caa44f267c8bbbd8a3b13c7ce..286cb454996ebe9f6476b60776dc095b82d49c5a 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
+#include "test_yaffs_open_file.h"
 #include "test_yaffs_access.h"
 
 int test_yaffs_unlinking(void);
index 336473c223ef4bdc61c4b2d971d25969de5bebeb..602afd52545561c635286c3a6fe854dc410e74dc 100644 (file)
@@ -1,7 +1,8 @@
 #include "test_yaffs_write.h"
 
+static int handle=0;
 int test_yaffs_write(void){
-       int handle=test_open_file();
+       handle=test_yaffs_open_file();
        if (handle>0){
                return yaffs_write(handle, FILE_TEXT, FILE_TEXT_NBYTES);
        }
@@ -13,10 +14,5 @@ int test_yaffs_write(void){
 }
 
 int test_yaffs_write_clean(void){
-       if (0==test_yaffs_lseek_to_beginning()){
-               return 1;
-       }
-       else {
-               return -1;
-       }
+       return yaffs_close(handle);
 }
index 671ed96951242ee7ea0979a8f9ee2278469dcfac..800412359ab5491b5618ec289a5a51b47e8423c5 100644 (file)
@@ -2,8 +2,7 @@
 #define __test_yaffs_write_h__
 #include "lib.h"
 #include "yaffsfs.h"
-#include "test_open_file.h"
-#include "test_yaffs_lseek.h"
+#include "test_yaffs_open_file.h"
 int test_yaffs_write(void);
 int test_yaffs_write_clean(void);
 #endif