From 2870702e0b0f4342857222a36ffcb21886c7f4bf Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Wed, 15 Dec 2010 11:30:10 +1300 Subject: [PATCH] yaffs Added more tests to direct/timothy_tests/mirror_tests Signed-off-by: Timothy Manning --- direct/timothy_tests/mirror_tests/Makefile | 3 +- .../mirror_tests/current_bugs.txt | 3 ++ direct/timothy_tests/mirror_tests/lib.c | 2 +- .../mirror_tests/linux_test_truncate.c | 27 +++++++++++++ .../mirror_tests/linux_test_truncate.h | 27 +++++++++++++ .../timothy_tests/mirror_tests/mirror_tests.c | 38 +++++++++++-------- .../timothy_tests/mirror_tests/mirror_tests.h | 2 + .../mirror_tests/yaffs_test_truncate.c | 27 +++++++++++++ .../mirror_tests/yaffs_test_truncate.h | 26 +++++++++++++ 9 files changed, 138 insertions(+), 17 deletions(-) create mode 100644 direct/timothy_tests/mirror_tests/current_bugs.txt create mode 100644 direct/timothy_tests/mirror_tests/linux_test_truncate.c create mode 100644 direct/timothy_tests/mirror_tests/linux_test_truncate.h create mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_truncate.c create mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_truncate.h 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 + * + * 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 + * + * 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 +#include +#include +#include +#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 + * + * 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 + * + * 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 +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int yaffs_test_truncate(arg_temp *args_struct); + +#endif -- 2.30.2