From: Timothy Manning Date: Tue, 16 Nov 2010 00:40:50 +0000 (+1300) Subject: yaffs More quick tests. X-Git-Tag: linux-mainline-patchset-4~90^2~2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=f0b3e63460ab0712ba14e68a482137a167f94d8f yaffs More quick tests. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index a966301..6e298b4 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -61,7 +61,10 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \ test_yaffs_close_EBADF.o\ test_yaffs_chmod.o test_yaffs_chmod_ENOENT.o test_yaffs_chmod_ENOTDIR.o test_yaffs_chmod_EINVAL.o \ - test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o + test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o\ + test_yaffs_fsync.o test_yaffs_fsync_EBADF.o \ + test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o \ + test_yaffs_mkdir.o YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 7ebc1fb..74d512a 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -22,6 +22,12 @@ Tests made test_yaffs_close_EBADF + test_yaffs_fdatasync + test_yaffs_fdatasync_EBADF + + test_yaffs_fsync + test_yaffs_fsync_EBADF + test_yaffs_ftruncate test_yaffs_ftruncate_EBADF test_yaffs_ftruncate_ENIVAL @@ -85,12 +91,6 @@ Tests to add test_yaffs_chmod_ELOOP test_yaffs_chmod_ENAMETOOLONG - test_yaffs_fsync - test_yaffs_fsync_EBADF - - test_yaffs_datasync - test_yaffs_datasync_EBADF - test_yaffs_lstat test_yaffs_lstat_EACCES test_yaffs_lstat_ENOTDIR diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index 110e3ee..12bd6af 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -93,6 +93,14 @@ #include "test_yaffs_fchmod.h" #include "test_yaffs_fchmod_EBADF.h" +#include "test_yaffs_fsync.h" +#include "test_yaffs_fsync_EBADF.h" + +#include "test_yaffs_fdatasync.h" +#include "test_yaffs_fdatasync_EBADF.h" + +#include "test_yaffs_mkdir.h" + #include "yaffsfs.h" #include "yaffs_error_converter.h" #include "lib.h" @@ -181,7 +189,15 @@ test_template test_list[]={ {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"}, {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"}, - {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"} + {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"}, + + {test_yaffs_fsync,test_yaffs_fsync_clean,"test_yaffs_fsync"}, + {test_yaffs_fsync_EBADF,test_yaffs_fsync_EBADF_clean,"test_yaffs_fsync_EBADF"}, + + {test_yaffs_fdatasync,test_yaffs_fdatasync_clean,"test_yaffs_fdatasync"}, + {test_yaffs_fdatasync_EBADF,test_yaffs_fdatasync_EBADF_clean,"test_yaffs_fdatasync_EBADF"}, + + {test_yaffs_mkdir,test_yaffs_mkdir_clean,"test_yaffs_mkdir"} }; void init_quick_tests(int argc, char *argv[]); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.c b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.c new file mode 100644 index 0000000..7711d50 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.c @@ -0,0 +1,33 @@ +/* + * 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_fdatasync.h" + +static int handle = 0; + +int test_yaffs_fdatasync(void) +{ + handle = test_yaffs_open(); + return yaffs_fdatasync(handle); +} + + +int test_yaffs_fdatasync_clean(void) +{ + if (handle >= 0){ + return yaffs_close(handle); + } else { + return 1; /* the file failed to open so there is no need to close it */ + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.h b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.h new file mode 100644 index 0000000..905e691 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync.h @@ -0,0 +1,26 @@ +/* + * 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_fdatasync_h__ +#define __test_yaffs_fdatasync_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_fdatasync(void); +int test_yaffs_fdatasync_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c new file mode 100644 index 0000000..edfbb95 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.c @@ -0,0 +1,42 @@ +/* + * 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_fdatasync.h" + + + +int test_yaffs_fdatasync_EBADF(void) +{ + int output = 0; + int error_code = 0; + output = yaffs_fdatasync(-1); + if (output==-1){ + error_code=yaffs_get_error(); + if (abs(error_code)==EBADF){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("non existant file synced.(which is a bad thing)\n",2); + return -1; + } +} + + +int test_yaffs_fdatasync_EBADF_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h new file mode 100644 index 0000000..d562c56 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fdatasync_EBADF.h @@ -0,0 +1,26 @@ +/* + * 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_fdatasync_EBADF_h__ +#define __test_yaffs_fdatasync_EBADF_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_fdatasync_EBADF(void); +int test_yaffs_fdatasync_EBADF_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync.c b/direct/timothy_tests/quick_tests/test_yaffs_fsync.c new file mode 100644 index 0000000..cff6ac1 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fsync.c @@ -0,0 +1,33 @@ +/* + * 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_fsync.h" + +static int handle = 0; + +int test_yaffs_fsync(void) +{ + handle = test_yaffs_open(); + return yaffs_fsync(handle); +} + + +int test_yaffs_fsync_clean(void) +{ + if (handle >= 0){ + return yaffs_close(handle); + } else { + return 1; /* the file failed to open so there is no need to close it */ + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync.h b/direct/timothy_tests/quick_tests/test_yaffs_fsync.h new file mode 100644 index 0000000..cbb9e0f --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fsync.h @@ -0,0 +1,26 @@ +/* + * 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_fsync_h__ +#define __test_yaffs_fsync_h__ + +#include "lib.h" +#include "yaffsfs.h" +#include "test_yaffs_open.h" + +int test_yaffs_fsync(void); +int test_yaffs_fsync_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c new file mode 100644 index 0000000..3f6e0c2 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.c @@ -0,0 +1,42 @@ +/* + * 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_fsync.h" + + + +int test_yaffs_fsync_EBADF(void) +{ + int output = 0; + int error_code = 0; + output = yaffs_fsync(-1); + if (output==-1){ + error_code=yaffs_get_error(); + if (abs(error_code)==EBADF){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + } else { + print_message("non existant file synced.(which is a bad thing)\n",2); + return -1; + } +} + + +int test_yaffs_fsync_EBADF_clean(void) +{ + return 1; +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.h new file mode 100644 index 0000000..fb689bb --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_fsync_EBADF.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_fsync_EBADF_h__ +#define __test_yaffs_fsync_EBADF_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_fsync_EBADF(void); +int test_yaffs_fsync_EBADF_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c new file mode 100644 index 0000000..aedaa80 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.c @@ -0,0 +1,33 @@ +/* + * 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_mkdir.h" + +static int handle = 0; + +int test_yaffs_mkdir(void) +{ + handle = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); + return handle; +} + + +int test_yaffs_mkdir_clean(void) +{ + if (handle >= 0){ + return yaffs_rmdir("/yaffs2/new_directory/"); + } else { + return 1; /* the file failed to open so there is no need to close it */ + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.h new file mode 100644 index 0000000..b59b454 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir.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_mkdir_h__ +#define __test_yaffs_mkdir_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_mkdir(void); +int test_yaffs_mkdir_clean(void); + +#endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c new file mode 100644 index 0000000..9948393 --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.c @@ -0,0 +1,49 @@ +/* + * 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_mkdir_EEXISTS.h" + +static int output = -1; + +int test_yaffs_mkdir_EEXISTS(void) +{ + output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); + if (output <0) { + print_message("filed to create the directory the first time\n",2); + return -1; + } + output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR); + if (output < 0){ + error_code = yaffs_get_error(); + if (abs(error_code) == EEXISTS){ + return 1; + } else { + print_message("different error than expected\n", 2); + return -1; + } + } else { + print_message("lseeked to a negative position (which is a bad thing)\n", 2); + return -1; + } +} + + +int test_yaffs_mkdir_EEXISTS_clean(void) +{ + if (output >= 0){ + return yaffs_rmdir("/yaffs2/new_directory/"); + } else { + return 1; + } +} + diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.h new file mode 100644 index 0000000..16d5bfe --- /dev/null +++ b/direct/timothy_tests/quick_tests/test_yaffs_mkdir_EEXISTS.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_mkdir_EEXISTS_h__ +#define __test_yaffs_mkdir_EEXISTS_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_mkdir_EEXISTS(void); +int test_yaffs_mkdir_EEXISTS_clean(void); + +#endif