have added some of the new tests
authorTimothy Manning <tfhmanning@gmail.com>
Thu, 17 Jan 2013 04:25:55 +0000 (17:25 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Thu, 17 Jan 2013 04:25:55 +0000 (17:25 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
13 files changed:
direct/test-framework/timothy_tests/quick_tests/Makefile
direct/test-framework/timothy_tests/quick_tests/lib.h
direct/test-framework/timothy_tests/quick_tests/quick_tests.h
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_ENOTEMPTY.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_dir_over_dir.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_file_over_file.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_full_dir_over_dir.h [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.c [new file with mode: 0644]
direct/test-framework/timothy_tests/quick_tests/test_yaffs_rename_to_null_file.h [new file with mode: 0644]

index ac6943109da5a6f2f43fd50387e2180995751e51..431c883c788ed677ab79101cd6d4762e2af3fa2d 100644 (file)
@@ -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_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 
                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 
index 094db3b95983dc53c34e53f36f4b132a9b4760b1..5e36ca05687e6a7b8cf9a948eca08c596d0badcf 100644 (file)
@@ -31,7 +31,8 @@
 #define FILE_TEXT_NBYTES 10
 #define TEST_DIR "/yaffs2/test_dir"
 #define DIR_PATH "/yaffs2/test_dir/new_directory"
 #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"
 #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"
 
 /* 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);
 
 void join_paths(char *path1,char *path2,char *new_path );
 void print_message(char *message,char print_level);
index 4a2288978ddc5e4393873a630f0b68331a79af56..324d3c4139a99574861bea1e6418fd2e8c378689 100644 (file)
 #include "test_yaffs_rename_ENAMETOOLONG2.h"
 #include "test_yaffs_rename_NULL.h"
 #include "test_yaffs_rename_NULL2.h"
 #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"
 
 #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_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"},
 
        {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 (file)
index 0000000..a13ee8a
--- /dev/null
@@ -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 <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.
+ */
+
+
+#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 (file)
index 0000000..10b634d
--- /dev/null
@@ -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 <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 __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 (file)
index 0000000..1a46919
--- /dev/null
@@ -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 <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.
+ */
+
+
+#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 (file)
index 0000000..e1ebd15
--- /dev/null
@@ -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 <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 __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 (file)
index 0000000..70652d6
--- /dev/null
@@ -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 <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.
+ */
+
+
+#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 (file)
index 0000000..ce99b00
--- /dev/null
@@ -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 <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 __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 (file)
index 0000000..64317ce
--- /dev/null
@@ -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 <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.
+ */
+
+
+#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 (file)
index 0000000..dfee3cd
--- /dev/null
@@ -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 <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 __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 (file)
index 0000000..ba04a4f
--- /dev/null
@@ -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 <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.
+ */
+
+
+#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 (file)
index 0000000..0858ecf
--- /dev/null
@@ -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
+