test_yaffs_fdatasync.o test_yaffs_fdatasync_EBADF.o \
test_yaffs_mkdir.o test_yaffs_mkdir_EEXIST.o test_yaffs_mkdir_ENOTDIR.o \
test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o test_yaffs_fchmod_EINVAL.o \
- test_yaffs_symlink.o test_yaffs_symlink_ENOTDIR.o test_yaffs_symlink_EEXIST.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_symlink
test_yaffs_symlink_ENOTDIR
+ test_yaffs_symlink_EEXISTS
+ test_yaffs_symlink_ENOENT //if there is a slash on the end of new path
test_yaffs_fstat
test_yaffs_fstat_EBADF
test_yaffs_symlink_EACCES
- test_yaffs_symlink_EEXISTS
test_yaffs_symlink_ELOOP
test_yaffs_symlink_ENAMETOOLONG
- test_yaffs_symlink_ENOENT //if there is a slash on the end
test_yaffs_symlink_EROFS
+
+ //the yaffs_mknod function does not exist in yaffsfs, so these tests will be ignored.
test_yaffs_mknod
test_yaffs_mknod_EACCES
test_yaffs_mknod_EEXIST
#define SYMLINK_PATH "/yaffs2/sym_foo"
+#define NODE_PATH "/yaffs2/node"
+
/* warning do not define anything as FILE because there seems to be a conflict with stdio.h */
#define FILE_PATH "/yaffs2/foo"
print_message("\n\nrunning quick tests for yaffs\n\n", 0);
for (x=0;x<total_number_of_tests;x++){
- //printf("x %d\n",x);
+ output=test_yaffs_open();
+ printf("yaffs_open = %d\n",output);
+ printf("yaffs_open_clean = %d\n",yaffs_close(output));
yaffs_set_error(0); /*reset the last error to 0 */
sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
print_message(message,3);
#include "test_yaffs_symlink.h"
#include "test_yaffs_symlink_ENOTDIR.h"
#include "test_yaffs_symlink_EEXIST.h"
+#include "test_yaffs_symlink_ENOENT.h"
+#include "test_yaffs_mount2.h"
#include "yaffsfs.h"
#include "yaffs_error_converter.h"
{test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
{test_yaffs_write_EBADF,test_yaffs_write_EBADF_clean,"test_yaffs_write_EBADF"},
- {test_yaffs_write_big_file,test_yaffs_write_big_file_clean,"test_yaffs_write_big_file"},
+// {test_yaffs_write_big_file,test_yaffs_write_big_file_clean,"test_yaffs_write_big_file"},
{test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"},
{test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
{test_yaffs_symlink,test_yaffs_symlink_clean,"test_yaffs_symlink"},
{test_yaffs_symlink_ENOTDIR,test_yaffs_symlink_ENOTDIR_clean,"test_yaffs_symlink_ENOTDIR"},
- {test_yaffs_symlink_EEXIST,test_yaffs_symlink_EEXIST_clean,"test_yaffs_symlink_EEXIST"}
+ {test_yaffs_symlink_EEXIST,test_yaffs_symlink_EEXIST_clean,"test_yaffs_symlink_EEXIST"},
+ {test_yaffs_symlink_ENOENT,test_yaffs_symlink_ENOENT_clean,"test_yaffs_symlink_ENOENT"},
+
+ {test_yaffs_mount2,test_yaffs_mount2_clean,"test_yaffs_mount2"}
+
+
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_mknode.h"
+
+static int output = 0;
+
+int test_yaffs_mknode(void)
+{
+ output = yaffs_mknod(NODE_PATH,S_IREAD | S_IWRITE);
+ return output;
+}
+
+
+int test_yaffs_mknode_clean(void)
+{
+ if (output >= 0){
+ return yaffs_unlink(NODE_PATH);
+ } else {
+ return 1; /* the file failed to open so there is no need to close it */
+ }
+}
+
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_mknode_h__
+#define __test_yaffs_mknode_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mknode(void);
+int test_yaffs_mknode_clean(void);
+
+#endif
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_mount2.h"
+
+int test_yaffs_mount2(void)
+{
+ int output = -1;
+ printf("closing handle again %d\n",yaffs_close(0));
+ output= yaffs_unmount(YAFFS_MOUNT_POINT);
+ if (output < 0) {
+ print_message("failed to unmount current_mountpoint\n",2);
+ return -1;
+ }
+
+ output = yaffs_mount2(YAFFS_MOUNT_POINT,255);
+ return output;
+}
+
+int test_yaffs_mount2_clean(void)
+{
+ return 1;
+}
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_mount2__
+#define __test_yaffs_mount2__
+
+#include "yaffsfs.h"
+#include "lib.h"
+#include "test_yaffs_unmount.h"
+
+int test_yaffs_mount2(void);
+int test_yaffs_mount2_clean(void);
+
+#endif
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_symlink_ENOENT.h"
+
+static int output = 0;
+
+int test_yaffs_symlink_ENOENT(void)
+{
+ int error_code = 0;
+ output = yaffs_symlink(FILE_PATH,"/yaffs2//");
+ 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("created a symlink in a non-existing directory (which is a bad thing)\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_symlink_ENOENT_clean(void)
+{
+ if (output >= 0){
+ return yaffs_unlink(SYMLINK_PATH);
+ } else {
+ return 1; /* the file failed to open so there is no need to close it */
+ }
+}
+
+
+
--- /dev/null
+/*
+ * 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 <timothy@yaffs.net>
+ *
+ * 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_symlink_ENOENT_h__
+#define __test_yaffs_symlink_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_symlink_ENOENT(void);
+int test_yaffs_symlink_ENOENT_clean(void);
+
+#endif
*/
#include "test_yaffs_truncate_EINVAL.h"
-static int handle=-1;
+
int test_yaffs_truncate_EINVAL(void)
{
int error=0;
int output=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output= yaffs_truncate("/yaffs2/foo",-1 );
- if (output<0){
- error=yaffs_get_error();
- if (abs(error)==EINVAL){
- return 1;
- } else {
- print_message("received a different error than expected\n",2);
- return -1;
- }
- } else{
- print_message("truncated a file with a bad mode set.\n",2);
+
+ output= yaffs_truncate("/yaffs2/foo",-1 );
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==EINVAL){
+ return 1;
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
-
- } else {
- print_message("error opening file",2);
+ } else{
+ print_message("truncated a file with a bad mode set.\n",2);
return -1;
}
+
+
}
int test_yaffs_truncate_EINVAL_clean(void)
{
int error = 0;
int output = 0;
- handle = test_yaffs_open();
- if (handle>=0){
- output = yaffs_truncate("/yaffs2/",10);
- if (output < 0){
- error = yaffs_get_error();
- if (abs(error) == EISDIR){
- return 1;
- } else {
- print_message("received a different error than expected\n",2);
- return -1;
- }
- } else{
- print_message("truncated a directory\n",2);
+
+
+ output = yaffs_truncate("/yaffs2/",10);
+ if (output < 0){
+ error = yaffs_get_error();
+ if (abs(error) == EISDIR){
+ return 1;
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
-
- } else {
- print_message("error opening file\n",2);
- return 1;
+ } else{
+ print_message("truncated a directory\n",2);
+ return -1;
}
+
}
int test_yaffs_truncate_EISDIR_clean(void)
*/
#include "test_yaffs_truncate_ENOENT.h"
-static int handle = -1;
+
int test_yaffs_truncate_ENOENT(void)
{
int error=0;
int output=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
- if (output<0){
- error=yaffs_get_error();
- if (abs(error)==ENOENT){
- return 1;
- } else {
- print_message("received a different error than expected\n",2);
- return -1;
- }
- } else{
- print_message("truncated a nonexisting file\n",2);
+
+ output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==ENOENT){
+ return 1;
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
- }
- } else {
- print_message("error opening file",2);
+ }
+ } else{
+ print_message("truncated a nonexisting file\n",2);
return -1;
- }
+ }
+
}
int test_yaffs_truncate_ENOENT_clean(void)
#include "test_yaffs_truncate_ENOTDIR.h"
-static int handle = -1;
+
int test_yaffs_truncate_ENOTDIR(void)
{
int error=0;
int output=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
- if (output<0){
- error=yaffs_get_error();
- if (abs(error)==ENOTDIR){
- return 1;
- } else {
- print_message("received a different error than expected\n",2);
- return -1;
- }
- } else{
- print_message("truncated a nonexisting file\n",2);
+
+
+ output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==ENOTDIR){
+ return 1;
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
-
- } else {
- print_message("error opening file\n",2);
+ } else{
+ print_message("truncated a nonexisting file\n",2);
return -1;
}
}
*/
#include "test_yaffs_truncate_big_file.h"
-static int handle = -1;
+
int test_yaffs_truncate_big_file(void)
{
int error=0;
int output=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
- if (output<0){
- error=yaffs_get_error();
- if (abs(error)==EINVAL){ /*in yaffs EINVAL is used instead of big_file */
- return 1;
- } else {
- print_message("received a different error than expected\n",2);
- return -1;
- }
- } else{
- print_message("truncated a file to a massive size\n",2);
+
+ output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==EINVAL){ /*in yaffs EINVAL is used instead of big_file */
+ return 1;
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
-
- } else {
- print_message("error opening file\n",2);
+ } else{
+ print_message("truncated a file to a massive size\n",2);
return -1;
}
+
+
}
int test_yaffs_truncate_big_file_clean(void)
int test_yaffs_unlink_clean(void)
{
- return test_yaffs_open();
+ return test_yaffs_open()||test_yaffs_open_clean();
}