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
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
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
for (x=0;x<total_number_of_tests;x++){
output=test_yaffs_open();
printf("yaffs_open = %d\n",output);
- printf("yaffs_open_clean = %d\n",yaffs_close(output));
+ printf("yaffs_close handle 0 = %d\n",yaffs_close(output));
+ //printf("yaffs_close handle 1#################################### =%d\n",yaffs_close(1));
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_unmount2.h"
#include "test_yaffs_sync.h"
+#include "test_yaffs_sync_ENOTDIR.h"
+#include "test_yaffs_sync_ENOENT.h"
+
#include "yaffsfs.h"
#include "yaffs_error_converter.h"
{test_yaffs_unmount2,test_yaffs_unmount2_clean,"test_yaffs_unmount2"},
- {test_yaffs_sync,test_yaffs_sync_clean,"test_yaffs_sync"}
+ {test_yaffs_sync,test_yaffs_sync_clean,"test_yaffs_sync"},
+ {test_yaffs_sync_ENOTDIR,test_yaffs_sync_ENOTDIR_clean,"test_yaffs_sync_ENOTDIR"},
+ {test_yaffs_sync_ENOENT,test_yaffs_sync_ENOENT_clean,"test_yaffs_sync_ENOENT"}
int test_yaffs_read_EINVAL(void)
{
int error_code = 0;
- handle=test_yaffs_open();
+ handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+ printf("newly opend handle = %d handle\n",handle);
char text[2000000]="\0";
int output=0;
{
int output=0;
if (handle>=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);
}
} else {
print_message("no open handle\n",2);
+ return -1;
}
}
}
-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;
- }
-
-}
#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
--- /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_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;
+}
+
--- /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_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
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){