yaffs Added more tests to direct/timothy_tests/mirror_tests
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 15 Dec 2010 01:43:54 +0000 (14:43 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 15 Dec 2010 01:43:54 +0000 (14:43 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/mirror_tests/Makefile
direct/timothy_tests/mirror_tests/linux_test_unlink.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_unlink.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_unlink.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_unlink.h [new file with mode: 0644]

index d252e4b7fe427821cf7cc70f748960e6726529c6..4362cd9a90664dd3cf3c867272459c60fe9c5b71 100644 (file)
@@ -48,7 +48,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_truncate.o yaffs_test_truncate.o \
+               linux_test_unlink.o yaffs_test_unlink.o
 
 
                  
diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.c b/direct/timothy_tests/mirror_tests/linux_test_unlink.c
new file mode 100644 (file)
index 0000000..f22a57b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_unlink.h"
+
+int linux_test_unlink(arg_temp *args_struct)
+{
+       char path[250];
+       char message[150];
+       int output;
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output= unlink(path);
+       
+       if (output<0) {
+               print_message(3,"failed to unlink file\n");
+               return -1;
+       } else {
+               return 1;
+       }
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.h b/direct/timothy_tests/mirror_tests/linux_test_unlink.h
new file mode 100644 (file)
index 0000000..aac3bcd
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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_unlink_h__
+#define __linux_test_unlink_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int linux_test_unlink(arg_temp *args_struct);
+
+#endif
index a022e4db30e79429a809709fcfb88f464396b0de..d87dff51fc6fc7a8ac1cf2730b24c0f211ce5a03 100644 (file)
@@ -31,16 +31,18 @@ typedef struct test_temp2 {
 }test_temp;
 
 test_temp yaffs_tests={
-       2,
+       3,
        {{"yaffs_test_open",yaffs_test_open},
-       {"yaffs_test_truncate",yaffs_test_truncate}
+       {"yaffs_test_truncate",yaffs_test_truncate},
+       {"yaffs_test_unlink",yaffs_test_unlink}
        }
 };
 
 test_temp linux_tests={
-       2,
+       3,
        {{"linux_test_open",linux_test_open},
-       {"linux_test_truncate",linux_test_truncate}
+       {"linux_test_truncate",linux_test_truncate},
+       {"linux_test_unlink",linux_test_unlink}
        }
 };
 
@@ -65,6 +67,7 @@ int main(int argc, char *argv[])
        for (x=0;x<num_of_random_tests;x++){
                run_random_test();
        }
+       compare_linux_and_yaffs();
        yaffs_unmount("yaffs2");
        return 0;
 }
@@ -75,8 +78,9 @@ void init(int argc, char *argv[])
        dir[0]='\0';
        int x=-1;
        char message[100];
-       
+
        srand((unsigned)time(NULL));
+       yaffs_set_trace(0);
        linux_struct.type_of_test =LINUX;
        yaffs_struct.type_of_test =YAFFS;
 
@@ -101,6 +105,8 @@ void init(int argc, char *argv[])
                        printf("\t-q //quiet mode nothing is printed.\n");
                        printf("\t-n [number] //sets the number of random tests to run.\n");
                        printf("\t-s [number] //seeds rand with the number\n");
+                       printf("\t-t [number] //sets yaffs_trace to the number\n");
+                       printf("\t-c //removes emfile and test dir\n");
                        exit(0);
                } else if (strcmp(argv[x],"-yaffs_path")==0){
                        strcpy(yaffs_struct.root_path, argv[x+1]);
@@ -114,13 +120,18 @@ void init(int argc, char *argv[])
                        set_print_level(-1);
                } else if (strcmp(argv[x],"-n")==0){
                        num_of_random_tests=atoi(argv[x+1]);
-               } else if (strcmp(argv[x],"-n")==0){
-                       //srand(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-s")==0){
+                       srand(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-t")==0){
+                       yaffs_set_trace(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-c")==0){
+                       clean_dir();
+                       exit(0);
                }
        }
-
+       clean_dir();
        yaffs_start_up();
-       print_message(message,"\nmounting yaffs\n");
+       print_message(2,"\nmounting yaffs\n");
        x=yaffs_mount("yaffs2");
        if (x<0) {
                print_message(3,"failed to mount yaffs\n");
@@ -170,7 +181,7 @@ int run_random_test(void)
                        (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
                        (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
                        ){
-                       print_message(2,"\ndiffrence in returned errors######################################\n");
+                       print_message(2,"\ndifference in returned errors######################################\n");
                        get_error_yaffs();
                        get_error_linux();
                        if (get_exit_on_error()){ 
@@ -193,6 +204,35 @@ int select_test_id(int test_len)
 
 int compare_linux_and_yaffs(void)
 {
+       int x=0;
+       yaffs_DIR *yaffs_open_dir;
+       yaffs_dirent *yaffs_current_file;
+       
+       DIR *linux_open_dir;
+       struct dirent *linux_current_file;
+
+       yaffs_open_dir = yaffs_opendir(yaffs_struct.root_path);
+       
+       for (x=0;NULL!=yaffs_readdir(yaffs_open_dir);x++){};
+       printf("number of files in yaffs dir= %d\n",x);
+       
+       char yaffs_file_list[x][100];
+       yaffs_rewinddir(yaffs_open_dir);
+
+       for (x=0 ;NULL!=yaffs_current_file;x++)
+       {
+               yaffs_current_file =yaffs_readdir(yaffs_open_dir);
+               if (NULL!=yaffs_current_file){
+                       strcpy(yaffs_file_list[x],yaffs_current_file->d_name);
+               }
+       }
+
+       linux_open_dir = opendir(linux_struct.root_path);
+
+       for (x=0;NULL!=readdir(linux_open_dir);x++){};
+       printf("number of files in linux dir= %d\n",(x-2));     //the -2 is because linux shows 2 extra files which are automaticly created. 
+       
+       //printf("file_name %s\n", yaffs_current_file->d_name);
 //     generate_array_of_objects_in_yaffs(); 
 //     generate_array_of_objects_in_linux();
        //first do a check to see if both sides have the same objects on both sides. 
@@ -278,3 +318,37 @@ void get_error_linux(void)
        print_message(1,message);
 }
 
+void clean_dir(void)
+{
+       char string[200]; 
+       char file[200];
+       char message[200];
+       DIR *linux_open_dir;
+       struct dirent *linux_current_file;
+       int x=0;
+       
+       getcwd(string,200);
+       strcat(string,"/emfile-2k-0");
+       sprintf(message,"\n\nunlinking emfile at this path: %s\n",string);
+       print_message(3,message);
+       unlink(string);
+       
+
+       linux_open_dir = opendir(linux_struct.root_path);
+       if (linux_open_dir){
+               for (x=0 ;NULL!=linux_current_file   ;x++)
+               {
+                       linux_current_file =readdir(linux_open_dir);
+                       if (NULL!=linux_current_file){
+                               
+                               strcpy(file,linux_struct.root_path);
+                               strcat(file,linux_current_file->d_name);
+                               sprintf(message,"unlinking file %d\n",linux_current_file->d_name);
+                               print_message(3,message);
+                               unlink(file);
+                       }
+               }
+               unlink(linux_struct.root_path);
+       }
+       
+}
index 0ae4be5cb091d9d7e87773c80fc0169d1fdebca4..7d8617cb5a20377aee890d8be2eaa53408d44728 100644 (file)
@@ -17,6 +17,7 @@
 #define __mirror_tests_h__
 
 #include <stdio.h>
+#include <dirent.h>
 #include <unistd.h>    //used for getting the current directory. 
 #include <string.h>
 #include <errno.h>
 #include "lib.h"
 #include <time.h>
 
+
 #include "linux_test_open.h"
 #include "yaffs_test_open.h"
 #include "linux_test_truncate.h"
 #include "yaffs_test_truncate.h"
-
+#include "linux_test_unlink.h"
+#include "yaffs_test_unlink.h"
 
 #define LINUX 1
 #define YAFFS 2
@@ -46,6 +49,7 @@ int select_test_id(int test_len);
 void generate_random_numbers(arg_temp *args_struct);
 void run_yaffs_test(int id,arg_temp *args_struct);
 void run_linux_test(int id,arg_temp *args_struct);
+void clean_dir(void);
 //void generate_array_of_objects_in_yaffs(void); 
 //void generate_array_of_objects_in_linux(void);
 
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c
new file mode 100644 (file)
index 0000000..a6f1497
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_unlink.h"
+
+int yaffs_test_unlink(arg_temp *args_struct)
+{
+       char path[250];
+       char message[150];
+       int output;
+       join_paths(yaffs_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output= yaffs_unlink(path);
+
+       if (output<0) {
+               print_message(3,"failed to unlink file\n");
+               return -1;
+       } else {
+               return 1;
+       }
+
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h
new file mode 100644 (file)
index 0000000..4d1b881
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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_unlink_h__
+#define __yaffs_test_unlink_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_unlink(arg_temp *args_struct);
+
+#endif