From 6cb99e93f72bbb066c5abb4ab2cc0cd79f56a4f3 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 5 Nov 2010 09:50:42 +1300 Subject: [PATCH] yaffs All of the quick_tests programs are now working. Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/README.txt | 12 ++++++++++++ direct/timothy_tests/quick_tests/lib.h | 6 +++--- direct/timothy_tests/quick_tests/quick_tests.c | 1 + direct/timothy_tests/quick_tests/quick_tests.h | 4 ++-- .../quick_tests/test_yaffs_close_EBADF.c | 2 +- direct/timothy_tests/quick_tests/test_yaffs_open.c | 2 +- .../quick_tests/test_yaffs_open_EEXIST.c | 2 +- .../quick_tests/test_yaffs_open_EISDIR.c | 2 +- .../quick_tests/test_yaffs_open_ENOTDIR.c | 2 +- direct/timothy_tests/quick_tests/test_yaffs_read.c | 8 ++++---- direct/timothy_tests/quick_tests/test_yaffs_stat.c | 10 ++++++---- 11 files changed, 33 insertions(+), 18 deletions(-) diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 33b93e7..127898c 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -2,6 +2,18 @@ Made by Timothy Manning 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 diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index e0444f7..50c548f 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -20,12 +20,12 @@ #include #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_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" diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index bdef486..3753583 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -37,6 +37,7 @@ int main(){ //printf("len function %d",(sizeof(test_list)/sizeof(test_template))); for (x=0;x=0){ /*test has passed*/ diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 2c4210e..ebe55b6 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -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_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"}, diff --git a/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c index 5036b47..5f322fc 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_close_EBADF.c @@ -28,7 +28,7 @@ int test_yaffs_close_EBADF(void){ 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; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open.c b/direct/timothy_tests/quick_tests/test_yaffs_open.c index 89c7492..76ed67b 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open.c @@ -17,7 +17,7 @@ static int handle=0; 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; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c index 7ae81a1..90ba455 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EEXIST.c @@ -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(); - 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; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c index 0891aaa..d86e081 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c @@ -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(); - 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; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c index 4722e88..d9790cf 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_open_ENOTDIR.c @@ -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(); - 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; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read.c b/direct/timothy_tests/quick_tests/test_yaffs_read.c index fcfae7b..2bc2aba 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_read.c @@ -19,13 +19,13 @@ int test_yaffs_read(void){ 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); - 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 (text==FILE_TEXT){ + if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){ return 1; } else { diff --git a/direct/timothy_tests/quick_tests/test_yaffs_stat.c b/direct/timothy_tests/quick_tests/test_yaffs_stat.c index d47fd29..f99ab7f 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_stat.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_stat.c @@ -17,21 +17,23 @@ int test_yaffs_stat(void){ 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)); - 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; } - if (yaffs_test_stat_size()==FILE_SIZE){ + size=yaffs_test_stat_size(); + 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"); 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); - printf("output: %d\n",output); + //printf("output: %d\n",output); if (output>=0){ return stat.st_mode; } -- 2.30.2