yaffs Added more tests to direct/timothy_tests/mirror_tests
authorTimothy Manning <tfhmanning@gmail.com>
Tue, 14 Dec 2010 22:30:10 +0000 (11:30 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Tue, 14 Dec 2010 22:32:30 +0000 (11:32 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/mirror_tests/Makefile
direct/timothy_tests/mirror_tests/current_bugs.txt [new file with mode: 0644]
direct/timothy_tests/mirror_tests/lib.c
direct/timothy_tests/mirror_tests/linux_test_truncate.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_truncate.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_truncate.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_truncate.h [new file with mode: 0644]

index f26ff4c2053a46e4ff8e473c6d99b24c8cc43300..d252e4b7fe427821cf7cc70f748960e6726529c6 100644 (file)
@@ -47,7 +47,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
 #               yaffs_checkptrwtest.o\
 
 TESTFILES =    mirror_tests.o lib.o\
 #               yaffs_checkptrwtest.o\
 
 TESTFILES =    mirror_tests.o lib.o\
-               linux_test_open.o yaffs_test_open.o
+               linux_test_open.o yaffs_test_open.o\
+               linux_test_truncate.o yaffs_test_truncate.o
 
 
                  
 
 
                  
diff --git a/direct/timothy_tests/mirror_tests/current_bugs.txt b/direct/timothy_tests/mirror_tests/current_bugs.txt
new file mode 100644 (file)
index 0000000..523fd3b
--- /dev/null
@@ -0,0 +1,3 @@
+
+BUGS
+       In yaffs having a pathname "yaffs2/tests//.." appears to create a file called ".." unstead of going back a directory.
index 0d1443050763c4c2de188c00e65b79dfbd1c9581..1a9d6ac4f3ee44198c011a63c2d0962ad4af7824 100644 (file)
@@ -40,7 +40,7 @@ void display_error(void)
 
 void  generate_random_string(char *ptr,int length_of_str){
        unsigned int x;
 
 void  generate_random_string(char *ptr,int length_of_str){
        unsigned int x;
-       unsigned int length=((rand() %length_of_str)+1);        /*creates a int with the number of charecters been between 1 and 51*/           
+       unsigned int length=((rand() %(length_of_str-3))+3);    /*creates a int with the number of charecters been between 1 and 51*/           
        char letter='\0';
        strcpy(ptr,"");
        //printf("generating string\n");
        char letter='\0';
        strcpy(ptr,"");
        //printf("generating string\n");
diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.c b/direct/timothy_tests/mirror_tests/linux_test_truncate.c
new file mode 100644 (file)
index 0000000..8cdaace
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_truncate.h"
+
+int linux_test_truncate(arg_temp *args_struct)
+{
+       char path[200];
+       char message[200];
+       int output=0;
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output=truncate(path,args_struct->int1);
+       return output;
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.h b/direct/timothy_tests/mirror_tests/linux_test_truncate.h
new file mode 100644 (file)
index 0000000..219c96d
--- /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_truncate_h__
+#define __linux_test_truncate_h__
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int linux_test_truncate(arg_temp *args_struct);
+
+#endif
index 79c4daddd4a89ce11dd01cc65c41c0b105234fad..a022e4db30e79429a809709fcfb88f464396b0de 100644 (file)
@@ -31,14 +31,16 @@ typedef struct test_temp2 {
 }test_temp;
 
 test_temp yaffs_tests={
 }test_temp;
 
 test_temp yaffs_tests={
-       0,
-       {{"yaffs_test_open",yaffs_test_open}
+       2,
+       {{"yaffs_test_open",yaffs_test_open},
+       {"yaffs_test_truncate",yaffs_test_truncate}
        }
 };
 
 test_temp linux_tests={
        }
 };
 
 test_temp linux_tests={
-       0,
-       {{"linux_test_open",linux_test_open}
+       2,
+       {{"linux_test_open",linux_test_open},
+       {"linux_test_truncate",linux_test_truncate}
        }
 };
 
        }
 };
 
@@ -47,8 +49,8 @@ int main(int argc, char *argv[])
 {
        char message[100];
        int x;
 {
        char message[100];
        int x;
-       yaffs_tests.num_of_tests=(sizeof(yaffs_tests)/sizeof(test_temp));
-       linux_tests.num_of_tests=(sizeof(linux_tests)/sizeof(test_temp));
+//     yaffs_tests.num_of_tests=(sizeof(yaffs_tests)/sizeof(test_temp));
+//     linux_tests.num_of_tests=(sizeof(linux_tests)/sizeof(test_temp));
 
        init(argc,argv);
        print_message(1,"running mirror_tests\n");
 
        init(argc,argv);
        print_message(1,"running mirror_tests\n");
@@ -63,6 +65,7 @@ int main(int argc, char *argv[])
        for (x=0;x<num_of_random_tests;x++){
                run_random_test();
        }
        for (x=0;x<num_of_random_tests;x++){
                run_random_test();
        }
+       yaffs_unmount("yaffs2");
        return 0;
 }
 
        return 0;
 }
 
@@ -73,7 +76,7 @@ void init(int argc, char *argv[])
        int x=-1;
        char message[100];
        
        int x=-1;
        char message[100];
        
-       srand(time(NULL));
+       srand((unsigned)time(NULL));
        linux_struct.type_of_test =LINUX;
        yaffs_struct.type_of_test =YAFFS;
 
        linux_struct.type_of_test =LINUX;
        yaffs_struct.type_of_test =YAFFS;
 
@@ -112,7 +115,7 @@ void init(int argc, char *argv[])
                } else if (strcmp(argv[x],"-n")==0){
                        num_of_random_tests=atoi(argv[x+1]);
                } else if (strcmp(argv[x],"-n")==0){
                } 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]));
+                       //srand(atoi(argv[x+1]));
                }
        }
 
                }
        }
 
@@ -152,19 +155,20 @@ int run_random_test(void)
        int id=0;
        int test_id=-1;
        int num_of_tests=1;
        int id=0;
        int test_id=-1;
        int num_of_tests=1;
-       char message[15];
+       char message[100];
        arg_temp args_struct;
        for (x=0;x<num_of_tests;x++) {
                errno=0;
                yaffs_set_error(0);
                test_id = select_test_id(yaffs_tests.num_of_tests);
        arg_temp args_struct;
        for (x=0;x<num_of_tests;x++) {
                errno=0;
                yaffs_set_error(0);
                test_id = select_test_id(yaffs_tests.num_of_tests);
-               sprintf(message,"test_id %d\n",test_id);
+               sprintf(message,"running test_id %d\n",test_id);
                print_message(3,message);
                generate_random_numbers(&args_struct);
                print_message(3,message);
                generate_random_numbers(&args_struct);
-               run_yaffs_test(id, &args_struct);
-               run_linux_test(id, &args_struct);
+               run_yaffs_test(test_id, &args_struct);
+               run_linux_test(test_id, &args_struct);
                if      ((abs(yaffs_get_error())!=abs(errno)) &&
                if      ((abs(yaffs_get_error())!=abs(errno)) &&
-                       (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0)
+                       (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
+                       (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
                        ){
                        print_message(2,"\ndiffrence in returned errors######################################\n");
                        get_error_yaffs();
                        ){
                        print_message(2,"\ndiffrence in returned errors######################################\n");
                        get_error_yaffs();
@@ -180,7 +184,9 @@ int run_random_test(void)
 int select_test_id(int test_len)
 {
        int id=0;
 int select_test_id(int test_len)
 {
        int id=0;
+       //printf("test_len = %d\n",test_len);
        id=(rand() % test_len );
        id=(rand() % test_len );
+       //printf("id %d\n",id);
        return id;
 
 }
        return id;
 
 }
@@ -212,9 +218,10 @@ void generate_random_numbers(arg_temp *args_struct)
 
 void run_yaffs_test(int id,arg_temp *args_struct)
 {
 
 void run_yaffs_test(int id,arg_temp *args_struct)
 {
-       char message[30];
+       char message[200];
        int output =0;
        print_message(3,"\n");
        int output =0;
        print_message(3,"\n");
+       //printf("id = %d\n",id);
        sprintf(message,"running_test %s\n",yaffs_tests.test_list[id].test_name);
        print_message(3,message);
        output=yaffs_tests.test_list[id].test_pointer(args_struct);
        sprintf(message,"running_test %s\n",yaffs_tests.test_list[id].test_name);
        print_message(3,message);
        output=yaffs_tests.test_list[id].test_pointer(args_struct);
@@ -228,9 +235,10 @@ void run_yaffs_test(int id,arg_temp *args_struct)
 
 void run_linux_test(int id,arg_temp *args_struct)
 {
 
 void run_linux_test(int id,arg_temp *args_struct)
 {
-       char message[30];
+       char message[200];
        int output =0;
        print_message(3,"\n");
        int output =0;
        print_message(3,"\n");
+       //printf("id = %d\n",id);
        sprintf(message,"running_test %s\n",linux_tests.test_list[id].test_name);
        print_message(3,message);
        output=linux_tests.test_list[id].test_pointer(args_struct);
        sprintf(message,"running_test %s\n",linux_tests.test_list[id].test_name);
        print_message(3,message);
        output=linux_tests.test_list[id].test_pointer(args_struct);
index 5493900956b29b5dbd09ff32784af4c61f02b2ae..0ae4be5cb091d9d7e87773c80fc0169d1fdebca4 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "linux_test_open.h"
 #include "yaffs_test_open.h"
 
 #include "linux_test_open.h"
 #include "yaffs_test_open.h"
+#include "linux_test_truncate.h"
+#include "yaffs_test_truncate.h"
 
 
 #define LINUX 1
 
 
 #define LINUX 1
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c
new file mode 100644 (file)
index 0000000..688d66e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_truncate.h"
+
+int yaffs_test_truncate(arg_temp *args_struct)
+{
+       char path[200];
+       char message[200];
+       int output=0;
+       join_paths(yaffs_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output=yaffs_truncate(path,args_struct->int1);
+       return output;
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h
new file mode 100644 (file)
index 0000000..cf19013
--- /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_truncate_h__
+#define __yaffs_test_truncate_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_truncate(arg_temp *args_struct);
+
+#endif