diff options
author | Timothy Manning <tfhmanning@gmail.com> | 2010-12-15 11:30:10 +1300 |
---|---|---|
committer | Timothy Manning <tfhmanning@gmail.com> | 2010-12-15 11:32:30 +1300 |
commit | 2870702e0b0f4342857222a36ffcb21886c7f4bf (patch) | |
tree | fb9244a4079f13c6ef6b5ffb22f93cff0179b709 /direct | |
parent | df369209e1ee1d05eba9527b1e6447e8e78d0988 (diff) |
yaffs Added 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/Makefile | 3 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/current_bugs.txt | 3 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/lib.c | 2 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/linux_test_truncate.c | 27 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/linux_test_truncate.h | 27 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/mirror_tests.c | 38 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/mirror_tests.h | 2 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/yaffs_test_truncate.c | 27 | ||||
-rw-r--r-- | direct/timothy_tests/mirror_tests/yaffs_test_truncate.h | 26 |
9 files changed, 138 insertions, 17 deletions
diff --git a/direct/timothy_tests/mirror_tests/Makefile b/direct/timothy_tests/mirror_tests/Makefile index f26ff4c..d252e4b 100644 --- a/direct/timothy_tests/mirror_tests/Makefile +++ b/direct/timothy_tests/mirror_tests/Makefile @@ -47,7 +47,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.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 index 0000000..523fd3b --- /dev/null +++ b/direct/timothy_tests/mirror_tests/current_bugs.txt @@ -0,0 +1,3 @@ + +BUGS + In yaffs having a pathname "yaffs2/tests//.." appears to create a file called ".." unstead of going back a directory. diff --git a/direct/timothy_tests/mirror_tests/lib.c b/direct/timothy_tests/mirror_tests/lib.c index 0d14430..1a9d6ac 100644 --- a/direct/timothy_tests/mirror_tests/lib.c +++ b/direct/timothy_tests/mirror_tests/lib.c @@ -40,7 +40,7 @@ void display_error(void) 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"); 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 index 0000000..8cdaace --- /dev/null +++ b/direct/timothy_tests/mirror_tests/linux_test_truncate.c @@ -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 index 0000000..219c96d --- /dev/null +++ b/direct/timothy_tests/mirror_tests/linux_test_truncate.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_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 diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.c b/direct/timothy_tests/mirror_tests/mirror_tests.c index 79c4dad..a022e4d 100644 --- a/direct/timothy_tests/mirror_tests/mirror_tests.c +++ b/direct/timothy_tests/mirror_tests/mirror_tests.c @@ -31,14 +31,16 @@ typedef struct test_temp2 { }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={ - 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; - 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"); @@ -63,6 +65,7 @@ int main(int argc, char *argv[]) for (x=0;x<num_of_random_tests;x++){ run_random_test(); } + yaffs_unmount("yaffs2"); return 0; } @@ -73,7 +76,7 @@ void init(int argc, char *argv[]) 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; @@ -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){ - 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; - 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); - 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); - 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)) && - (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(); @@ -180,7 +184,9 @@ int run_random_test(void) int select_test_id(int test_len) { int id=0; + //printf("test_len = %d\n",test_len); id=(rand() % test_len ); + //printf("id %d\n",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) { - char message[30]; + char message[200]; 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); @@ -228,9 +235,10 @@ void run_yaffs_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"); + //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); diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.h b/direct/timothy_tests/mirror_tests/mirror_tests.h index 5493900..0ae4be5 100644 --- a/direct/timothy_tests/mirror_tests/mirror_tests.h +++ b/direct/timothy_tests/mirror_tests/mirror_tests.h @@ -26,6 +26,8 @@ #include "linux_test_open.h" #include "yaffs_test_open.h" +#include "linux_test_truncate.h" +#include "yaffs_test_truncate.h" #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 index 0000000..688d66e --- /dev/null +++ b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c @@ -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 index 0000000..cf19013 --- /dev/null +++ b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h @@ -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 |