From: Timothy Manning Date: Thu, 17 Jan 2013 04:25:55 +0000 (+1300) Subject: have added some of the new tests X-Git-Tag: aleph1-release~62^2~1^2~1 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=dfb1bb995ecc12562408adf870ccf2006a244f44 have added some of the new tests Signed-off-by: Timothy Manning --- diff --git a/direct/test-framework/timothy_tests/quick_tests/Makefile b/direct/test-framework/timothy_tests/quick_tests/Makefile index ac69431..431c883 100644 --- a/direct/test-framework/timothy_tests/quick_tests/Makefile +++ b/direct/test-framework/timothy_tests/quick_tests/Makefile @@ -78,7 +78,8 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.o test_yaffs_rename_dir_to_file.o \ test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o test_yaffs_rename_ELOOP_dir.o test_yaffs_rename_EROFS.o \ test_yaffs_rename_ENAMETOOLONG.o test_yaffs_rename_ENAMETOOLONG2.o test_yaffs_rename_NULL.o test_yaffs_rename_NULL2.o \ - test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o \ + test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o test_yaffs_rename_to_null_file.o \ + test_yaffs_rename_file_over_file.o test_yaffs_rename_dir_over_dir.o test_yaffs_rename_full_dir_over_dir.o test_yaffs_rename_ENOTEMPTY.o \ test_yaffs_lstat_NULL.o \ test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o \ test_yaffs_dup.o test_yaffs_dup_EBADF.o diff --git a/direct/test-framework/timothy_tests/quick_tests/lib.h b/direct/test-framework/timothy_tests/quick_tests/lib.h index 094db3b..5e36ca0 100644 --- a/direct/test-framework/timothy_tests/quick_tests/lib.h +++ b/direct/test-framework/timothy_tests/quick_tests/lib.h @@ -31,7 +31,8 @@ #define FILE_TEXT_NBYTES 10 #define TEST_DIR "/yaffs2/test_dir" #define DIR_PATH "/yaffs2/test_dir/new_directory" - +#define DIR_PATH2 "/yaffs2/test_dir/new_directory2" +#define DIR_PATH2_FILE "/yaffs2/test_dir/new_directory2/foo" #define SYMLINK_PATH "/yaffs2/test_dir/sym_foo" #define HARD_LINK_PATH "/yaffs2/test_dir/hard_link" @@ -49,6 +50,7 @@ /* warning do not define anything as FILE because there seems to be a conflict with stdio.h */ #define FILE_PATH "/yaffs2/test_dir/foo" +#define FILE_PATH2 "/yaffs2/test_dir/foo2" void join_paths(char *path1,char *path2,char *new_path ); void print_message(char *message,char print_level); diff --git a/direct/test-framework/timothy_tests/quick_tests/quick_tests.h b/direct/test-framework/timothy_tests/quick_tests/quick_tests.h index 4a22889..324d3c4 100644 --- a/direct/test-framework/timothy_tests/quick_tests/quick_tests.h +++ b/direct/test-framework/timothy_tests/quick_tests/quick_tests.h @@ -241,6 +241,11 @@ #include "test_yaffs_rename_ENAMETOOLONG2.h" #include "test_yaffs_rename_NULL.h" #include "test_yaffs_rename_NULL2.h" +#include "test_yaffs_rename_file_over_file.h" +#include "test_yaffs_rename_dir_over_dir.h" +#include "test_yaffs_rename_to_null_file.h" +#include "test_yaffs_rename_full_dir_over_dir.h" +#include "test_yaffs_rename_ENOTEMPTY.h" #include "test_yaffs_lstat.h" #include "test_yaffs_lstat_ENOENT.h" @@ -495,6 +500,11 @@ test_template test_list[]={ {test_yaffs_rename_ENAMETOOLONG2,test_yaffs_rename_ENAMETOOLONG2_clean,"test_yaffs_rename_ENAMETOOLONG2"}, {test_yaffs_rename_NULL,test_yaffs_rename_NULL_clean,"test_yaffs_rename_NULL"}, {test_yaffs_rename_NULL2,test_yaffs_rename_NULL2_clean,"test_yaffs_rename_NULL2"}, + {test_yaffs_rename_to_null_file,test_yaffs_rename_to_null_file_clean,"test_yaffs_rename_to_null_file"}, + {test_yaffs_rename_file_over_file,test_yaffs_rename_file_over_file_clean,"test_yaffs_rename_file_over_file"}, + {test_yaffs_rename_dir_over_dir,test_yaffs_rename_dir_over_dir_clean,"test_yaffs_rename_dir_over_dir"}, + {test_yaffs_rename_full_dir_over_dir,test_yaffs_rename_full_dir_over_dir_clean,"test_yaffs_rename_full_dir_over_dir"}, + {test_yaffs_rename_ENOTEMPTY,test_yaffs_rename_ENOTEMPTY_clean,"test_yaffs_rename_ENOTEMPTY"}, {test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"}, {test_yaffs_lstat_ENOENT,test_yaffs_lstat_ENOENT_clean,"test_yaffs_lstat_ENOENT"}, diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c new file mode 100644 index 0000000..a13ee8a --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c @@ -0,0 +1,59 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "test_yaffs_rename_ENOTEMPTY.h" + +int test_yaffs_rename_ENOTEMPTY(void) +{ + + int output=0; + int error_code =0; + + if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir\n",1); + return -1; + } + if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir2\n",1); + return -1; + } + if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){ + print_message("failed to create file\n",1); + return -1; + } + output = yaffs_rename( DIR_PATH,DIR_PATH2 ); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==ENOTEMPTY){ + return 1; + } else { + print_message("different error than expected\n",2); + return -1; + } + print_message("could not rename a directory over a nonempty directory (which is a bad thing)\n",2); + return -1; + } + + return 1; + +} + + +int test_yaffs_rename_ENOTEMPTY_clean(void) +{ + return 1; +} + diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h new file mode 100644 index 0000000..10b634d --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h @@ -0,0 +1,25 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_ENOTEMPTY_H__ +#define __TEST_YAFFS_RENAME_ENOTEMPTY_H__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_rename_ENOTEMPTY(void); +int test_yaffs_rename_ENOTEMPTY_clean(void); + +#endif diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c new file mode 100644 index 0000000..1a46919 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c @@ -0,0 +1,48 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "test_yaffs_rename_dir_over_dir.h" + +int test_yaffs_rename_dir_over_dir(void) +{ + + int output=0; + int error_code =0; + + if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir\n",1); + return -1; + } + if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir2\n",1); + return -1; + } + output = yaffs_rename(DIR_PATH ,DIR_PATH2 ); + if (output<0){ + print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2); + return -1; + } + + return 1; + +} + + +int test_yaffs_rename_dir_over_dir_clean(void) +{ + return 1; +} + diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h new file mode 100644 index 0000000..e1ebd15 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h @@ -0,0 +1,25 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_DIR_OVER_DIR_H__ +#define __TEST_YAFFS_RENAME_DIR_OVER_DIR_H__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_rename_dir_over_dir(void); +int test_yaffs_rename_dir_over_dir_clean(void); + +#endif diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c new file mode 100644 index 0000000..70652d6 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c @@ -0,0 +1,48 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "test_yaffs_rename_file_over_file.h" + +int test_yaffs_rename_file_over_file(void) +{ + + int output=0; + int error_code =0; + + if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){ + print_message("failed to create file\n",1); + return -1; + } + if (yaffs_close(yaffs_open(FILE_PATH2,O_CREAT | O_RDWR, FILE_MODE))==-1){ + print_message("failed to create file\n",1); + return -1; + } + output = yaffs_rename(FILE_PATH ,FILE_PATH2 ); + if (output<0){ + print_message("could not rename a file over a file (which is a bad thing)\n",2); + return -1; + } + + return 1; + +} + + +int test_yaffs_rename_file_over_file_clean(void) +{ + return 1; +} + diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h new file mode 100644 index 0000000..ce99b00 --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h @@ -0,0 +1,25 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __test_yaffs_RENAME_FILE_OVER_FILE_H__ +#define __test_yaffs_RENAME_FILE_OVER_FILE_H__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_rename_file_over_file(void); +int test_yaffs_rename_file_over_file_clean(void); + +#endif diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c new file mode 100644 index 0000000..64317ce --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c @@ -0,0 +1,52 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "test_yaffs_rename_full_dir_over_dir.h" + +int test_yaffs_rename_full_dir_over_dir(void) +{ + + int output=0; + int error_code =0; + + if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir\n",1); + return -1; + } + if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){ + print_message("failed to create dir2\n",1); + return -1; + } + if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){ + print_message("failed to create file\n",1); + return -1; + } + output = yaffs_rename( DIR_PATH2,DIR_PATH ); + if (output<0){ + print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2); + return -1; + } + + return 1; + +} + + +int test_yaffs_rename_full_dir_over_dir_clean(void) +{ + return 1; +} + diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h new file mode 100644 index 0000000..dfee3cd --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h @@ -0,0 +1,25 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __TEST_YAFFS_RENAME_FULL_DIR_OVER_DIR_H__ +#define __TEST_YAFFS_RENAME_FULL_DIR_OVER_DIR_H__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_rename_full_dir_over_dir(void); +int test_yaffs_rename_full_dir_over_dir_clean(void); + +#endif diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c new file mode 100644 index 0000000..ba04a4f --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c @@ -0,0 +1,50 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "test_yaffs_rename_to_null_file.h" + +int test_yaffs_rename_to_null_file(void) +{ + int output=0; + int error_code =0; + + if (0 != yaffs_access(DIR_PATH,0)) { + output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD); + if (output < 0) { + print_message("failed to create directory\n",2); + return -1; + } + } + output = yaffs_rename(FILE_PATH , NULL); + if (output<0){ + error_code=yaffs_get_error(); + if (abs(error_code)==EFAULT){ + return 1; + } else { + print_message("returned error does not match the the expected error\n",2); + return -1; + } + } else{ + print_message("renamed to null path (which is a bad thing)\n",2); + return -1; + } +} + + +int test_yaffs_rename_to_null_file_clean(void) +{ + return 1; +} diff --git a/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h new file mode 100644 index 0000000..0858ecf --- /dev/null +++ b/direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h @@ -0,0 +1,11 @@ +#ifndef __test_yaffs_rename_NULL3_h__ +#define __test_yaffs_rename_NULL3_h__ + +#include "lib.h" +#include "yaffsfs.h" + +int test_yaffs_rename_to_null_file(void); +int test_yaffs_rename_to_null_file_clean(void); + +#endif +