summaryrefslogtreecommitdiff
path: root/direct
diff options
context:
space:
mode:
authorTimothy Manning <tfhmanning@gmail.com>2010-12-17 09:21:32 +1300
committerTimothy Manning <tfhmanning@gmail.com>2010-12-17 09:21:32 +1300
commit6e8abe36e3190664d26161ace6948c57f9ffda94 (patch)
tree4d2ac08e4db8218fec73e2574e3a0801f0d95ba8 /direct
parent34c624da44aa052d44993239c5a3be0b802673c9 (diff)
yaffs Added some more tests to direct/timothy_tests/mirror_tests
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
Diffstat (limited to 'direct')
-rw-r--r--direct/timothy_tests/mirror_tests/Makefile3
-rw-r--r--direct/timothy_tests/mirror_tests/lib.c4
-rw-r--r--direct/timothy_tests/mirror_tests/lib.h1
-rw-r--r--direct/timothy_tests/mirror_tests/linux_test_write.c35
-rw-r--r--direct/timothy_tests/mirror_tests/linux_test_write.h27
-rw-r--r--direct/timothy_tests/mirror_tests/mirror_tests.c21
-rw-r--r--direct/timothy_tests/mirror_tests/mirror_tests.h2
-rw-r--r--direct/timothy_tests/mirror_tests/yaffs_test_write.c35
-rw-r--r--direct/timothy_tests/mirror_tests/yaffs_test_write.h27
9 files changed, 147 insertions, 8 deletions
diff --git a/direct/timothy_tests/mirror_tests/Makefile b/direct/timothy_tests/mirror_tests/Makefile
index 4362cd9..8d74acf 100644
--- a/direct/timothy_tests/mirror_tests/Makefile
+++ b/direct/timothy_tests/mirror_tests/Makefile
@@ -49,7 +49,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
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
diff --git a/direct/timothy_tests/mirror_tests/lib.c b/direct/timothy_tests/mirror_tests/lib.c
index 1a9d6ac..558de9a 100644
--- a/direct/timothy_tests/mirror_tests/lib.c
+++ b/direct/timothy_tests/mirror_tests/lib.c
@@ -22,6 +22,10 @@ void set_print_level(int new_level)
{
PRINT_LEVEL=new_level;
}
+int get_print_level(void)
+{
+ return PRINT_LEVEL;
+}
void set_exit_on_error(int num)
{
diff --git a/direct/timothy_tests/mirror_tests/lib.h b/direct/timothy_tests/mirror_tests/lib.h
index 99c2763..c77e2f6 100644
--- a/direct/timothy_tests/mirror_tests/lib.h
+++ b/direct/timothy_tests/mirror_tests/lib.h
@@ -44,6 +44,7 @@ void generate_random_string(char *ptr,int length_of_str);
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);
diff --git a/direct/timothy_tests/mirror_tests/linux_test_write.c b/direct/timothy_tests/mirror_tests/linux_test_write.c
new file mode 100644
index 0000000..9695953
--- /dev/null
+++ b/direct/timothy_tests/mirror_tests/linux_test_write.c
@@ -0,0 +1,35 @@
+/*
+ * 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;
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_write.h b/direct/timothy_tests/mirror_tests/linux_test_write.h
new file mode 100644
index 0000000..ceb29fa
--- /dev/null
+++ b/direct/timothy_tests/mirror_tests/linux_test_write.h
@@ -0,0 +1,27 @@
+/*
+ * 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
diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.c b/direct/timothy_tests/mirror_tests/mirror_tests.c
index 28b88b5..758b0a9 100644
--- a/direct/timothy_tests/mirror_tests/mirror_tests.c
+++ b/direct/timothy_tests/mirror_tests/mirror_tests.c
@@ -31,18 +31,20 @@ typedef struct test_temp2 {
}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}
}
};
@@ -165,7 +167,7 @@ int run_random_test(int num_of_random_tests)
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++){
@@ -178,9 +180,14 @@ int run_random_test(int num_of_random_tests)
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();
@@ -295,7 +302,7 @@ int compare_linux_and_yaffs(void)
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])){
diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.h b/direct/timothy_tests/mirror_tests/mirror_tests.h
index 208f845..cac477c 100644
--- a/direct/timothy_tests/mirror_tests/mirror_tests.h
+++ b/direct/timothy_tests/mirror_tests/mirror_tests.h
@@ -32,6 +32,8 @@
#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
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_write.c b/direct/timothy_tests/mirror_tests/yaffs_test_write.c
new file mode 100644
index 0000000..eaa97da
--- /dev/null
+++ b/direct/timothy_tests/mirror_tests/yaffs_test_write.c
@@ -0,0 +1,35 @@
+/*
+ * 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;
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_write.h b/direct/timothy_tests/mirror_tests/yaffs_test_write.h
new file mode 100644
index 0000000..3d6220e
--- /dev/null
+++ b/direct/timothy_tests/mirror_tests/yaffs_test_write.h
@@ -0,0 +1,27 @@
+/*
+ * 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