yaffs Added some more tests to direct/timothy_tests/mirror_tests
authorTimothy Manning <tfhmanning@gmail.com>
Thu, 16 Dec 2010 20:21:32 +0000 (09:21 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Thu, 16 Dec 2010 20:21:32 +0000 (09:21 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/mirror_tests/Makefile
direct/timothy_tests/mirror_tests/lib.c
direct/timothy_tests/mirror_tests/lib.h
direct/timothy_tests/mirror_tests/linux_test_write.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_write.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/mirror_tests.c
direct/timothy_tests/mirror_tests/mirror_tests.h
direct/timothy_tests/mirror_tests/yaffs_test_write.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_write.h [new file with mode: 0644]

index 4362cd9..8d74acf 100644 (file)
@@ -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
 
 
                  
index 1a9d6ac..558de9a 100644 (file)
@@ -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)
 {
index 99c2763..c77e2f6 100644 (file)
@@ -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 (file)
index 0000000..9695953
--- /dev/null
@@ -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 (file)
index 0000000..ceb29fa
--- /dev/null
@@ -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
index 28b88b5..758b0a9 100644 (file)
@@ -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])){
index 208f845..cac477c 100644 (file)
@@ -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 (file)
index 0000000..eaa97da
--- /dev/null
@@ -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 (file)
index 0000000..3d6220e
--- /dev/null
@@ -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