test_yaffs_rmdir.o test_yaffs_rmdir_EBUSY.o test_yaffs_rmdir_EINVAL.o test_yaffs_rmdir_ENOENT.o \
test_yaffs_rmdir_ENOTDIR.o \
test_yaffs_rename.o test_yaffs_rename_ENOENT.o test_yaffs_rename_ENOTDIR.o test_yaffs_rename_EINVAL.o \
- test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.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
Current BUGS
-
- BUG with trying to rmdir /yaffs2/ the error returned is ENOTEMPTY.
- But the error that should be returned is EBUSY.
-
- BUG with trying to rmdir /yaffs2/. the error returned is ENOENT.
- But the error that should be returned is EINVAL.
-
- BUG with having slashes on the end of the second path passed into the rename function.
- The function returns ENOENT. but should be returning other errors.
+ Bug with test_yaffs_rename_dir it does not return an error code.
+
+ Bug with test_yaffs_rename_EEXIST should be giving the bug EEXIST but instead gives ENOENT.
Current WARNINGS
#define FILE_TEXT "file foo " /* keep space at end of string */
#define FILE_TEXT_NBYTES 10
-#define DIR_PATH "/yaffs2/new_directory/"
+#define DIR_PATH "/yaffs2/new_directory"
#define SYMLINK_PATH "/yaffs2/sym_foo"
#include "test_yaffs_rename_dir.h"
#include "test_yaffs_rename_dir_ENOENT.h"
#include "test_yaffs_rename_dir_ENOENT2.h"
+#include "test_yaffs_rename_dir_to_file.h"
+#include "test_yaffs_rename_file_to_dir.h"
+#include "test_yaffs_rename_EEXISTS.h"
#include "yaffsfs.h"
#include "yaffs_error_converter.h"
{test_yaffs_rename_EINVAL,test_yaffs_rename_EINVAL_clean,"test_yaffs_rename_EINVAL"},
{test_yaffs_rename_dir,test_yaffs_rename_dir_clean,"test_yaffs_rename_dir"},
{test_yaffs_rename_dir_ENOENT,test_yaffs_rename_dir_ENOENT_clean,"test_yaffs_rename_dir_ENOENT"},
- {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"}
+ {test_yaffs_rename_dir_ENOENT2,test_yaffs_rename_dir_ENOENT2_clean,"test_yaffs_rename_dir_ENOENT2"},
+ {test_yaffs_rename_dir_to_file,test_yaffs_rename_dir_to_file_clean,"test_yaffs_rename_dir_to_file"},
+ {test_yaffs_rename_file_to_dir,test_yaffs_rename_file_to_dir_clean,"test_yaffs_rename_file_to_dir"},
+ {test_yaffs_rename_EEXISTS,test_yaffs_rename_EEXISTS_clean,"test_yaffs_rename_EEXISTS"}
};
void init_quick_tests(int argc, char *argv[]);
#include "test_yaffs_mkdir.h"
-static int output = -1;
+
int test_yaffs_mkdir(void)
{
- output = yaffs_mkdir("/yaffs2/new_directory/",O_CREAT | O_RDWR);
+ int output=-1;
+ if (0==yaffs_access(DIR_PATH,0)) {
+ output=yaffs_rmdir(DIR_PATH);
+ if (output<0) {
+ print_message("the directory already exists and cannot be removed.\n",2);
+ return -1;
+ }
+ }
+ output = yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR);
return output;
}
int test_yaffs_mkdir_clean(void)
{
- if (output >= 0){
- return yaffs_rmdir("/yaffs2/new_directory/");
+ if (0==yaffs_access(DIR_PATH,0)) {
+ return yaffs_rmdir(DIR_PATH);
} else {
- return 1; /* the file failed to open so there is no need to close it */
+ return 1;
}
}
--- /dev/null
+/*
+ * 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 "test_yaffs_rename_EEXISTS.h"
+
+
+int test_yaffs_rename_EEXISTS(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;
+ }
+ }
+ if (0 != yaffs_access(RENAME_DIR_PATH,0)) {
+ output = yaffs_mkdir(RENAME_DIR_PATH,S_IWRITE | S_IREAD);
+ if (output < 0) {
+ error_code=yaffs_get_error();
+ if (abs(error_code)!=EEXIST){
+ print_message("failed to create second directory\n",2);
+ return -1;
+ }
+ }
+ }
+ output= yaffs_open("/yaffs2/dir2/file",O_CREAT | O_RDWR, FILE_MODE);
+ if (output<0){
+ print_message("failed to open file in the second directory\n",2);
+ return -1;
+ }
+ output = yaffs_rename(DIR_PATH , RENAME_DIR_PATH);
+ if (output<0){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==EEXIST){
+ return 1;
+ } else {
+ print_message("returned error does not match the the expected error\n",2);
+ return -1;
+ }
+ } else{
+ print_message("removed /yaffs2/ directory (which is a bad thing)\n",2);
+ return -1;
+ }
+}
+
+
+int test_yaffs_rename_EEXISTS_clean(void)
+{
+ int output = 0;
+ if (0 == yaffs_access(RENAME_PATH,0) && 0 != yaffs_access(DIR_PATH,0)) {
+ output = yaffs_rename(RENAME_PATH,FILE_PATH);
+ if (output < 0) {
+ print_message("failed to remove the directory\n",2);
+ return -1;
+ }
+ }
+ return 1;
+
+}
+
--- /dev/null
+/*
+ * 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 __test_yaffs_rename_EEXISTS_h__
+#define __test_yaffs_rename_EEXISTS_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_EEXISTS(void);
+int test_yaffs_rename_EEXISTS_clean(void);
+
+#endif
int error_code =0;
if (0 != yaffs_access(DIR_PATH,0)) {
- printf("dir does not exist\n");
output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
if (output < 0) {
print_message("failed to create directory\n",2);
}
}
output = yaffs_rename( DIR_PATH , RENAME_DIR_PATH);
- printf("output %d\n",output);
return output;
}
--- /dev/null
+/*
+ * 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 "test_yaffs_rename_dir_to_file.h"
+
+
+int test_yaffs_rename_dir_to_file(void)
+{
+ int output=0;
+
+ if (0 != yaffs_access(DIR_PATH,0)) {
+ output= yaffs_mkdir(DIR_PATH,(S_IREAD | S_IWRITE));
+ if (output<0) {
+ print_message("failed to create directory\n",2);
+ return -1;
+ }
+ }
+ output = yaffs_rename( DIR_PATH , RENAME_PATH);
+ if (output<0){
+ print_message("failed to rename a file over an empty directory\n",2);
+ return -1;
+ } else{
+ return 1;
+ }
+
+}
+
+
+int test_yaffs_rename_dir_to_file_clean(void)
+{
+ int output = 0;
+ if (0 == yaffs_access(RENAME_DIR_PATH,0)) {
+ output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH);
+ if (output < 0) {
+ print_message("failed to rename the file\n",2);
+ return -1;
+ }
+ }
+ return 1;
+
+}
+
--- /dev/null
+/*
+ * 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 __test_yaffs_rename_dir_to_file_h__
+#define __test_yaffs_rename_dir_to_file_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_rename_dir_to_file(void);
+int test_yaffs_rename_dir_to_file_clean(void);
+
+#endif
--- /dev/null
+/*
+ * 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 "test_yaffs_rename_file_to_dir.h"
+
+
+int test_yaffs_rename_file_to_dir(void)
+{
+ int output=0;
+
+ if (0 != yaffs_access(FILE_PATH,0)) {
+ output = test_yaffs_open();
+ if (output < 0) {
+ print_message("failed to create file\n",2);
+ return -1;
+ } else {
+ output = yaffs_close(output);
+ if (output < 0) {
+ print_message("failed to close file\n",2);
+ return -1;
+ }
+ }
+ }
+ output = yaffs_rename( "/yaffs2/foo" , RENAME_DIR_PATH);
+ if (output<0){
+ print_message("failed to rename a file over an empty directory\n",2);
+ return -1;
+ } else{
+ return 1;
+ }
+
+}
+
+
+int test_yaffs_rename_file_to_dir_clean(void)
+{
+ int output = 0;
+ if (0 == yaffs_access(RENAME_DIR_PATH,0)) {
+ output = yaffs_unlink(RENAME_DIR_PATH);
+ if (output < 0) {
+ print_message("failed to unlink the file\n",2);
+ return -1;
+ }
+ }
+ return 1;
+
+}
+
--- /dev/null
+/*
+ * 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 __test_yaffs_rename_file_to_dir_h__
+#define __test_yaffs_rename_file_to_dir_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_rename_file_to_dir(void);
+int test_yaffs_rename_file_to_dir_clean(void);
+
+#endif