TESTFILES = mirror_tests.o lib.o\
linux_test_open.o yaffs_test_open.o\
linux_test_truncate.o yaffs_test_truncate.o \
- linux_test_unlink.o yaffs_test_unlink.o
+ linux_test_unlink.o yaffs_test_unlink.o \
+ linux_test_write.o yaffs_test_write.o
{
PRINT_LEVEL=new_level;
}
+int get_print_level(void)
+{
+ return PRINT_LEVEL;
+}
void set_exit_on_error(int num)
{
void join_paths(char *path1,char *path2,char *new_path );
void print_message(char print_level, char *message);
void set_print_level(int new_level);
+int get_print_level(void);
void set_exit_on_error(int num);
int get_exit_on_error(void);
void display_error(void);
--- /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 "linux_test_write.h"
+
+int linux_test_write(arg_temp *args_struct)
+{
+ char path[200];
+ char message[200];
+ int output=0;
+ int handle=-1;
+ join_paths(linux_struct.root_path,args_struct->string1, path );
+ sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1);
+ print_message(3,message);
+ handle=open(path,args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND),args_struct->char2&(S_IREAD|S_IWRITE));
+ if (handle<0){
+ print_message(3,"failed to open a handle\n");
+ return -1; //handle failed to open
+ }
+ sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2));
+ print_message(3,message);
+ output=write(handle,args_struct->string2,strlen(args_struct->string2));
+ close(handle);
+ return output;
+}
--- /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 __linux_test_write_h__
+#define __linux_test_write_h__
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int linux_test_write(arg_temp *args_struct);
+
+#endif
}test_temp;
test_temp yaffs_tests={
- 3,
+ 4,
{{"yaffs_test_open",yaffs_test_open},
{"yaffs_test_truncate",yaffs_test_truncate},
- {"yaffs_test_unlink",yaffs_test_unlink}
+ {"yaffs_test_unlink",yaffs_test_unlink},
+ {"yaffs_test_write",yaffs_test_write}
}
};
test_temp linux_tests={
- 3,
+ 4,
{{"linux_test_open",linux_test_open},
{"linux_test_truncate",linux_test_truncate},
- {"linux_test_unlink",linux_test_unlink}
+ {"linux_test_unlink",linux_test_unlink},
+ {"linux_test_write",linux_test_write}
}
};
int x=-1;
int id=0;
int test_id=-1;
- int num_of_tests_before_check=10;
+ int num_of_tests_before_check=1;
char message[200];
arg_temp args_struct;
for (y=0;(y*num_of_tests_before_check)<num_of_random_tests;y++){
generate_random_numbers(&args_struct);
run_yaffs_test(test_id, &args_struct);
run_linux_test(test_id, &args_struct);
+ if (get_print_level()>=4){
+ get_error_yaffs();
+ get_error_linux();
+ }
if ((abs(yaffs_get_error())!=abs(errno)) &&
(abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
- (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
+ (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)&&
+ (abs(yaffs_get_error())!=EINVAL && abs(errno) != EBADF)
){
print_message(2,"\ndifference in returned errors######################################\n");
get_error_yaffs();
sprintf(message,"searching for yaffs file: %s\n",yaffs_file_list[x]);
print_message(3,message);
for (y=0;y<number_of_files_in_linux;y++){
- sprintf(message,"comparing to linux file: %s\n",linux_file_list[x]);
+ sprintf(message,"comparing to linux file: %s\n",linux_file_list[y]);
print_message(3,message);
if (0==strcmp(yaffs_file_list[x],linux_file_list[y])){
#include "yaffs_test_truncate.h"
#include "linux_test_unlink.h"
#include "yaffs_test_unlink.h"
+#include "linux_test_write.h"
+#include "yaffs_test_write.h"
#define LINUX 1
#define YAFFS 2
--- /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 "yaffs_test_write.h"
+
+int yaffs_test_write(arg_temp *args_struct)
+{
+ char path[200];
+ char message[200];
+ int output=0;
+ int handle;
+ join_paths(yaffs_struct.root_path,args_struct->string1, path );
+ sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1);
+ print_message(3,message);
+ handle=yaffs_open(path,args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND),args_struct->char2&(S_IREAD|S_IWRITE));
+ if (handle<0){
+ print_message(3,"failed to open a handle\n");
+ return -1; //handle failed to open
+ }
+ sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2));
+ print_message(3,message);
+ output=yaffs_write(handle,args_struct->string2,strlen(args_struct->string2));
+ yaffs_close(handle);
+ return output;
+}
--- /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 __yaffs_test_write_h__
+#define __yaffs_test_write_h__
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_write(arg_temp *args_struct);
+
+#endif