From c7ada078b9d435ea7e7eb4732974135e15006537 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Wed, 17 Nov 2010 15:10:17 +1300 Subject: [PATCH] yaffs Still trying to find the bug. Signed-off-by: Timothy Manning --- direct/timothy_tests/quick_tests/Makefile | 2 +- direct/timothy_tests/quick_tests/README.txt | 6 ++- .../timothy_tests/quick_tests/quick_tests.c | 3 +- .../timothy_tests/quick_tests/quick_tests.h | 7 ++- .../quick_tests/test_yaffs_read_EINVAL.c | 53 ++++++++++--------- .../quick_tests/test_yaffs_read_EINVAL.h | 8 +-- .../quick_tests/test_yaffs_sync_ENOENT.c | 43 +++++++++++++++ .../quick_tests/test_yaffs_sync_ENOENT.h | 25 +++++++++ .../quick_tests/test_yaffs_sync_ENOTDIR.c | 2 + 9 files changed, 114 insertions(+), 35 deletions(-) create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c create mode 100644 direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index dca2eed..0604e1d 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -69,7 +69,7 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.o test_yaffs_symlink_ENOENT.o \ test_yaffs_mount2.o \ test_yaffs_unmount2.o \ - test_yaffs_sync.o + test_yaffs_sync.o test_yaffs_sync_ENOTDIR.o test_yaffs_sync_ENOENT.o diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 5033e12..398512a 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -67,6 +67,9 @@ Tests made test_yaffs_symlink_EEXISTS test_yaffs_symlink_ENOENT //if there is a slash on the end of new path + test_yaffs_sync + test_yaffs_sync_ENOTDIR + test_yaffs_fstat test_yaffs_fstat_EBADF @@ -161,9 +164,8 @@ Tests to add test_yaffs_remount2_ENODEV test_yaffs_remount2_EINVAL - test_yaffs_sync + test_yaffs_sync_ENOENT - test_yaffs_sync_ENOTDIR test_yaffs_freespace test_yaffs_freespace_ENOENT diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index f127be7..115525b 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -37,7 +37,8 @@ int main(int argc, char *argv[]){ for (x=0;x=0){ - output=test_yaffs_read_EINVAL_init_clean(); + if(file_name){ + free(file_name); + file_name = NULL; + } + + + output= yaffs_truncate(FILE_PATH,FILE_SIZE ); + if (output>=0){ + output=test_yaffs_write(); + if (output<0){ + print_message("failed to write to file\n",2); + return -1; + } else { + output=test_yaffs_write_clean(); + if (output<0){ + print_message("failed to clean the write_to_file function\n",2); + } + } + } else { + print_message("failed to truncate file\n",2); + return -1; + } + if(output>=0){ output=yaffs_close(handle); if (output>=0){ + printf("closed the file, handle %d\n",handle); return 1; } else { print_message("could not close the handle\n",2); @@ -74,6 +98,7 @@ int test_yaffs_read_EINVAL_clean(void) } } else { print_message("no open handle\n",2); + return -1; } } @@ -115,28 +140,4 @@ int test_yaffs_read_EINVAL_init(void) } -int test_yaffs_read_EINVAL_init_clean(void) -{ - int output=1; - if(file_name){ - free(file_name); - file_name = NULL; - } - - - output= yaffs_truncate(FILE_PATH,FILE_SIZE ); - if (output>=0){ - output=test_yaffs_write(); - if (output>=0){ - return 1; - } else { - print_message("failed to write to file\n",2); - return -1; - } - } else { - print_message("failed to truncate file\n",2); - return -1; - } - -} diff --git a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h index ee55927..df25d55 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_read_EINVAL.h @@ -18,14 +18,14 @@ #include "lib.h" #include "yaffsfs.h" -#include "test_yaffs_open.h" -#include "test_yaffs_write.h" -#include "test_yaffs_truncate.h" +//#include "test_yaffs_open.h" +//#include "test_yaffs_write.h" +//#include "test_yaffs_truncate.h" 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 diff --git a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c new file mode 100644 index 0000000..2f1792d --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.c @@ -0,0 +1,43 @@ +/* + * 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 + * + * 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_sync_ENOENT.h" + + +int test_yaffs_sync_ENOENT(void) +{ + int error_code=-1; + int output = yaffs_sync("yaffs2/non-existing-file"); + + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==ENOENT){ + return 1; + } else { + print_message("returned error does not match the the expected error\n",2); + return -1; + } + } else { + print_message("synced a file in a non-existing directory (which is a bad thing)\n",2); + return -1; + } + + +} + + +int test_yaffs_sync_ENOENT_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h new file mode 100644 index 0000000..55cf61b --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOENT.h @@ -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 + * + * 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_sync_ENOENT_h__ +#define __test_yaffs_sync_ENOENT_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_sync_ENOENT(void); +int test_yaffs_sync_ENOENT_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOTDIR.c index 97fb2b1..0961af2 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOTDIR.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_sync_ENOTDIR.c @@ -16,7 +16,9 @@ int test_yaffs_sync_ENOTDIR(void) { + int error_code=-1; int output = yaffs_sync("non-existing-dir/foo"); + if (output<0){ error_code=yaffs_get_error(); if (abs(error_code)==ENOTDIR){ -- 2.30.2