summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testsuites/fstests/Makefile.am1
-rw-r--r--testsuites/fstests/configure.ac1
-rw-r--r--testsuites/fstests/fsrename/fsrename.doc19
-rw-r--r--testsuites/fstests/fsrename/test.c1208
-rw-r--r--testsuites/fstests/mimfs_fsrename/Makefile.am30
-rw-r--r--testsuites/fstests/mimfs_fsrename/mimfs_fsrename.scn287
6 files changed, 1546 insertions, 0 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am
index ed87f1b12f..539a2203f8 100644
--- a/testsuites/fstests/Makefile.am
+++ b/testsuites/fstests/Makefile.am
@@ -31,6 +31,7 @@ SUBDIRS += mimfs_fspermission
SUBDIRS += mimfs_fsrdwr
SUBDIRS += mimfs_fssymlink
SUBDIRS += mimfs_fstime
+SUBDIRS += mimfs_fsrename
SUBDIRS += mrfs_fserror
SUBDIRS += mrfs_fslink
SUBDIRS += mrfs_fspatheval
diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac
index 571f428a8e..e1337cb6a8 100644
--- a/testsuites/fstests/configure.ac
+++ b/testsuites/fstests/configure.ac
@@ -107,6 +107,7 @@ mimfs_fspermission/Makefile
mimfs_fsrdwr/Makefile
mimfs_fssymlink/Makefile
mimfs_fstime/Makefile
+mimfs_fsrename/Makefile
mrfs_fserror/Makefile
mrfs_fslink/Makefile
mrfs_fspatheval/Makefile
diff --git a/testsuites/fstests/fsrename/fsrename.doc b/testsuites/fstests/fsrename/fsrename.doc
new file mode 100644
index 0000000000..8d3a4df48e
--- /dev/null
+++ b/testsuites/fstests/fsrename/fsrename.doc
@@ -0,0 +1,19 @@
+# COPYRIGHT (c) 2014
+# Andre Marques <andre.lousa.marques at gmail.com>
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.org/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: fsrename
+
+directives:
+
+ + rename
+
+concepts:
+
+ + check if rename implementation conforms to POSIX.1-2008 \ No newline at end of file
diff --git a/testsuites/fstests/fsrename/test.c b/testsuites/fstests/fsrename/test.c
new file mode 100644
index 0000000000..b6a6026103
--- /dev/null
+++ b/testsuites/fstests/fsrename/test.c
@@ -0,0 +1,1208 @@
+/*
+ * COPYRIGHT (c) 2014
+ * Andre Marques <andre.lousa.marques at gmail.com>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "fstest.h"
+#include "fs_config.h"
+#include "pmacros.h"
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+
+const char rtems_test_name[] = "FSRENAME " FILESYSTEM;
+
+void test_initialize_filesystem (void);
+void test_shutdown_filesystem (void);
+
+static void symbolic_link_test (void)
+{
+ int fd;
+ int status;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *symlink01 = "slink01";
+ const char *symlink02 = "slink02";
+
+ char path01[20];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ struct stat statbuf;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to a symbolic link to another file.
+ */
+
+ puts ("\nOld is a simbolic link and rename operates on the simbolic link itself\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = symlink (name01, symlink01);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, symlink01, name02);
+ EXPECT_EQUAL (0, lstat, name02, &statbuf);
+
+ puts ("Testing if name02 is now a symlink");
+
+ if(S_ISLNK(statbuf.st_mode) != 0)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (0, unlink, name02);
+ EXPECT_EQUAL (-1, unlink, symlink01);
+
+ /*
+ * The new argument points to a symbolic link to another file and
+ * the old argument points to a file.
+ */
+
+ puts ("\nNew is a simbolic link and rename operates on the simbolic link itself\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = symlink (name01, symlink01);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, name02, symlink01);
+ EXPECT_EQUAL (0, lstat, symlink01, &statbuf);
+
+ puts ("Testing that symlink01 is not a symlink");
+
+ if(S_ISLNK(statbuf.st_mode) == 0)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (-1, unlink, name02);
+ EXPECT_EQUAL (0, unlink, symlink01);
+
+ /*
+ * The new argument points to a file inside a directory and
+ * the old argument points to a file which filepath contains
+ * a symbolic link loop.
+ */
+
+ puts ("\nTesting with symbolic link loop's\n");
+
+ status = symlink (symlink01, symlink02);
+ rtems_test_assert (status == 0);
+
+ status = symlink (symlink02, symlink01);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/test", symlink01);
+ EXPECT_ERROR (ELOOP, rename, path01, name01);
+
+ sprintf (path01, "%s/test", symlink02);
+ EXPECT_ERROR (ELOOP, rename, path01, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (-1, unlink, name01);
+ EXPECT_EQUAL (0, unlink, symlink01);
+ EXPECT_EQUAL (0, unlink, symlink02);
+
+ /*
+ * The new argument points to a file, which filepath contains
+ * a symbolic link loop, and
+ * the old argument points to a file inside a directory
+ */
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = symlink (symlink01, symlink02);
+ rtems_test_assert (status == 0);
+
+ status = symlink (symlink02, symlink01);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/test", symlink01);
+ EXPECT_ERROR (ELOOP, rename, name01, path01);
+
+ sprintf (path01, "%s/test", symlink02);
+ EXPECT_ERROR (ELOOP, rename, name01, path01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (0, unlink, symlink01);
+ EXPECT_EQUAL (0, unlink, symlink02);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void same_file_test (void)
+{
+ int fd;
+ int status;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *dir01 = "dir01";
+
+ char path01[30];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to the same file on the same directory.
+ */
+
+ puts ("\nRename file with itself\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, name01, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to the same file from another directory.
+ */
+
+ puts ("\nRename file with itself through a hard link in another directory\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, name02);
+ status = link (name01, path01);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, name01, path01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (0, unlink, path01);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void directory_test (void)
+{
+ int fd;
+ int status;
+ int i;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *dir01 = "dir01";
+ const char *dir02 = "dir02";
+
+ char path01[30];
+
+ char link_name[10];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ struct stat statbuf;
+
+ long LINK_MAX_val;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to a directory.
+ */
+
+ puts ("\nRename directory with file\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (ENOTDIR, rename, dir01, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to a directory and
+ * the old argument points to a file.
+ */
+
+ puts ("\nRename file with directory\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (EISDIR, rename, name01, dir01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to an empty directory and
+ * the old argument points to an ancestor directory of new.
+ */
+
+ puts ("\nRename directory with ancestor directory\n");
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir02, dir01);
+ status = mkdir (path01, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (EINVAL, rename, dir02, path01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, rmdir, path01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * The new argument points to an empty directory and
+ * the old argument points to a non empty directory.
+ */
+
+ puts ("\nRename directory with non empty directory\n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir02, name02);
+ fd = creat (path01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (-1, rename, dir01, dir02);
+
+ puts("Testing errno for EEXIST or ENOTEMPTY");
+
+ if(errno == EEXIST || errno == ENOTEMPTY)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, path01);
+ EXPECT_EQUAL (0, rmdir, dir01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * The new argument points to an empty directory and
+ * the old argument points to other empty directory.
+ */
+
+ puts ("\nRename empty directory with another empty directory\n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, dir01, dir02);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (-1, rmdir, dir01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * The new argument points to a non existant directory and
+ * the old argument points to an existant directory at LINK_MAX.
+ */
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ LINK_MAX_val = pathconf (dir01, _PC_LINK_MAX);
+ rtems_test_assert (LINK_MAX_val >= 0);
+
+ status = stat (dir01, &statbuf);
+ rtems_test_assert (status == 0);
+
+ for(i = statbuf.st_nlink; i < LINK_MAX_val; i++)
+ {
+ sprintf (link_name, "%s/%d", dir01, i);
+
+ status = mkdir (link_name, mode);
+ rtems_test_assert (status == 0);
+ }
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, dir01);
+ EXPECT_ERROR (EMLINK, rename, dir02, path01);
+
+ /*
+ * Clear directory
+ */
+
+ for(i = statbuf.st_nlink; i < LINK_MAX_val; i++)
+ {
+ sprintf (link_name, "%s/%d", dir01, i);
+
+ status = rmdir (link_name);
+ rtems_test_assert (status == 0);
+ }
+
+ EXPECT_EQUAL (-1, rmdir, path01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to another file on a directory with S_ISVTX.
+ */
+
+ puts ("\nRename files within directories protected with S_ISVTX\n");
+
+ status = mkdir (dir01, mode | S_ISVTX);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, name01);
+ fd = creat (path01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = chown (path01, 65534, -1);
+ rtems_test_assert (status == 0);
+
+ status = chown (dir01, 65534, -1);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (-1, rename, path01, name02);
+
+ puts("Testing errno for EPERM or EACCES");
+
+ if(errno == EPERM || errno == EACCES)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, path01);
+ EXPECT_EQUAL (0, unlink, name02);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to a file on a directory with S_ISVTX and
+ * the old argument points to a file outside that directory.
+ */
+
+ status = mkdir (dir01, mode | S_ISVTX);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, name01);
+ fd = creat (path01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = chown (path01, 65534, -1);
+ rtems_test_assert (status == 0);
+
+ status = chown (dir01, 65534, -1);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (-1, rename, name02, path01);
+
+ puts("Testing errno for EPERM or EACCES");
+
+ if(errno == EPERM || errno == EACCES)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, path01);
+ EXPECT_EQUAL (0, unlink, name02);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void arg_test (void)
+{
+ int fd;
+ int status;
+ int i;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *dir01 = "dir01";
+ const char *dir02 = "dir02";
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ char filename[NAME_MAX + 1];
+ char path01[20];
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a non existant file and
+ * the old argument points to a file.
+ */
+
+ puts ("\nRename file with non existant file\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, name01, name02);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (-1, unlink, name01);
+ EXPECT_EQUAL (0, unlink, name02);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to a non existant file.
+ */
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (ENOENT, rename, name02, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (-1, unlink, name02);
+
+ /*
+ * The new argument points to a non existant file and
+ * the old argument points to a file where a component of the
+ * filepath does not exist.
+ */
+
+ puts ("\nRename file with non existant filepath\n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s/%s", dir01, name01, name02);
+ EXPECT_ERROR (ENOENT, rename, path01, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (-1, unlink, name01);
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to a non existant directory and
+ * the old argument points to a directory.
+ */
+
+ puts ("\nRename directory with non existant directory\n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rename, dir01, dir02);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (-1, rmdir, dir01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * The new argument is a name bigger than NAME_MAX and
+ * the old argument points to a file.
+ */
+
+ puts ("\nRename file with a name size exceeding NAME_MAX\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ /* Generate string with NAME_MAX + 1 length */
+
+ for(i = 0; i < NAME_MAX + 1; i++)
+ strcat(filename, "a");
+
+ EXPECT_ERROR (ENAMETOOLONG, rename, name01, filename);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+ EXPECT_EQUAL (-1, unlink, filename);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void arg_format_test (void)
+{
+ int fd;
+ int status;
+ const char *name01 = "name01";
+
+ const char *dir01 = "dir01";
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a directory and
+ * the old argument points to current directory.
+ */
+
+ puts ("\nRename directory with current directory\n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (-1, rename, "." , dir01);
+
+ puts("Testing errno for EINVAL or EBUSY");
+
+ if(errno == EINVAL || errno == EBUSY)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * The new argument points to current directory and
+ * the old argument points to a directory.
+ */
+
+ EXPECT_EQUAL (-1, rename, dir01, ".");
+
+ puts("Testing errno for EINVAL or EBUSY");
+
+ if(errno == EINVAL || errno == EBUSY)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * The new argument points to a directory and
+ * the old argument points to previous directory.
+ */
+
+ puts ("\nRename directory with previous directory\n");
+
+ EXPECT_EQUAL (-1, rename, ".." , dir01);
+
+ puts("Testing errno for EINVAL or EBUSY");
+
+ if(errno == EINVAL || errno == EBUSY)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * The new argument points to previous directory and
+ * the old argument points to a directory.
+ */
+
+ EXPECT_EQUAL (-1, rename, dir01, "..");
+
+ puts("Testing errno for EINVAL or EBUSY");
+
+ if(errno == EINVAL || errno == EBUSY)
+ FS_PASS ();
+ else
+ FS_FAIL ();
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, rmdir, dir01);
+
+ /*
+ * The new argument points to a file and
+ * the old argument is an empty string.
+ */
+
+ puts("\nTesting empty filepaths\n");
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (ENOENT, rename, name01, "");
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+
+ /*
+ * The new argument is an empty string and
+ * the old argument points to a file.
+ */
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (ENOENT, rename, "", name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void write_permission_test (void)
+{
+ int fd;
+ int status;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *dir01 = "dir01";
+ const char *dir02 = "dir02";
+
+ char path01[20];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ mode_t no_write_access = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP
+ | S_IROTH | S_IXOTH;
+
+ const char *wd = __func__;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to another file,
+ * both inside a directory with no write permission.
+ */
+
+ puts ("\nRename two files on a directory with no write permission \n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ status = chdir (dir01);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = chmod (".", no_write_access);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (EACCES, rename, name01 , name02);
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file in a directory with no write access and
+ * the old argument points to another file on a directory with write access.
+ */
+
+ puts ("\nRename file between two directories, with and without write access\n");
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ status = chdir (dir02);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "../%s/%s", dir01, name02);
+ EXPECT_ERROR (EACCES, rename, name01, path01);
+
+ /*
+ * The new argument points to a file in a directory with write access and
+ * the old argument points to another file on a directory without write access.
+ */
+
+ EXPECT_ERROR (EACCES, rename, path01, name01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, name01);
+
+ sprintf (path01, "../%s", dir01);
+ status = chmod (path01, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "../%s/%s", dir01, name01);
+ EXPECT_EQUAL (0, unlink, path01);
+
+ sprintf (path01, "../%s/%s", dir01, name02);
+ EXPECT_EQUAL (0, unlink, path01);
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ EXPECT_EQUAL (0, rmdir, dir01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void search_permission_test (void)
+{
+ int fd;
+ int status;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ const char *dir01 = "dir01";
+ const char *dir02 = "dir02";
+
+ char path01[20];
+ char path02[20];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ mode_t no_execute_access = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
+ | S_IROTH | S_IWOTH;
+
+ const char *wd = __func__;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file and
+ * the old argument points to another file,
+ * both inside a directory with no execute permission.
+ */
+
+ puts ("\nRename two files on a directory with no execute permission \n");
+
+ status = mkdir (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, name01);
+ fd = creat (path01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ sprintf (path02, "%s/%s", dir01, name02);
+ fd = creat (path02, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = chmod (dir01, no_execute_access);
+ rtems_test_assert (status == 0);
+
+ EXPECT_ERROR (EACCES, rename, path01 , path02);
+
+ /*
+ * The new argument points to a file in a directory with no execute access and
+ * the old argument points to another file on a directory with execute access.
+ */
+
+ puts ("\nRename file between two directories, with and without execute access\n");
+
+ status = mkdir (dir02, mode);
+ rtems_test_assert (status == 0);
+
+ status = chdir (dir02);
+ rtems_test_assert (status == 0);
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir02, name01);
+ EXPECT_ERROR (EACCES, rename, path01, path02);
+
+ /*
+ * The new argument points to a file in a directory with execute access and
+ * the old argument points to another file on a directory without execute access.
+ */
+
+ EXPECT_ERROR (EACCES, rename, path02, path01);
+
+ /*
+ * Clear directory
+ */
+
+ EXPECT_EQUAL (0, unlink, path01);
+
+ status = chmod (dir01, mode);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", dir01, name01);
+ EXPECT_EQUAL (0, unlink, path01);
+ EXPECT_EQUAL (0, unlink, path02);
+ EXPECT_EQUAL (0, rmdir, dir01);
+ EXPECT_EQUAL (0, rmdir, dir02);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+static void filesystem_test (void)
+{
+ int fd;
+ int status;
+
+ const char *name01 = "name01";
+ const char *name02 = "name02";
+
+ char path01[20];
+
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ const char *wd = __func__;
+
+ /*
+ * Create a new directory and change the current directory to this
+ */
+
+ status = mkdir (wd, mode);
+ rtems_test_assert (status == 0);
+ status = chdir (wd);
+ rtems_test_assert (status == 0);
+
+ /*
+ * The new argument points to a file on another instance of the filesystem and
+ * the old argument points to a file on the base filesystem.
+ */
+
+ puts ("\nRename files across diferent filesystems\n");
+
+ test_initialize_filesystem ();
+
+ fd = creat (name01, mode);
+ rtems_test_assert (fd >= 0);
+ status = close (fd);
+ rtems_test_assert (status == 0);
+
+ sprintf (path01, "%s/%s", BASE_FOR_TEST, name02);
+ EXPECT_ERROR (EXDEV, rename, name01, path01);
+
+ /*
+ * Clear directory
+ */
+
+ test_shutdown_filesystem ();
+
+ EXPECT_EQUAL (-1, unlink, path01);
+ EXPECT_EQUAL (0, unlink, name01);
+
+ /*
+ * Go back to parent directory
+ */
+
+ status = chdir ("..");
+ rtems_test_assert (status == 0);
+
+ /*
+ * Remove test directory
+ */
+
+ status = rmdir (wd);
+ rtems_test_assert (status == 0);
+}
+
+void test (void)
+{
+ symbolic_link_test ();
+ same_file_test ();
+ directory_test ();
+ arg_test ();
+ arg_format_test ();
+ write_permission_test ();
+ search_permission_test ();
+ filesystem_test ();
+}
diff --git a/testsuites/fstests/mimfs_fsrename/Makefile.am b/testsuites/fstests/mimfs_fsrename/Makefile.am
new file mode 100644
index 0000000000..85b6072a25
--- /dev/null
+++ b/testsuites/fstests/mimfs_fsrename/Makefile.am
@@ -0,0 +1,30 @@
+
+rtems_tests_PROGRAMS = mimfs_fsrename
+mimfs_fsrename_SOURCES = ../fsrename/test.c
+mimfs_fsrename_SOURCES += ../support/fstest_support.c
+mimfs_fsrename_SOURCES += ../support/fstest_support.h
+mimfs_fsrename_SOURCES += ../support/fstest.h
+mimfs_fsrename_SOURCES += ../../psxtests/include/pmacros.h
+mimfs_fsrename_SOURCES += ../mimfs_support/fs_support.c
+mimfs_fsrename_SOURCES += ../mimfs_support/fs_config.h
+
+dist_rtems_tests_DATA = mimfs_fsrename.scn
+#dist_rtems_tests_DATA += mimfs_fsrename.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/support
+AM_CPPFLAGS += -I$(top_srcdir)/mimfs_support
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+
+LINK_OBJS = $(mimfs_fsrename_OBJECTS)
+LINK_LIBS = $(mimfs_fsrename_LDLIBS)
+
+mimfs_fsrename$(EXEEXT): $(mimfs_fsrename_OBJECTS) $(mimfs_fsrename_DEPENDENCIES)
+ @rm -f mimfs_fsrename$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/mimfs_fsrename/mimfs_fsrename.scn b/testsuites/fstests/mimfs_fsrename/mimfs_fsrename.scn
new file mode 100644
index 0000000000..3979c2f903
--- /dev/null
+++ b/testsuites/fstests/mimfs_fsrename/mimfs_fsrename.scn
@@ -0,0 +1,287 @@
+*** BEGIN OF TEST FSRENAME MOUNTED IMFS ***
+Initializing filesystem MOUNTED IMFS
+
+Old is a simbolic link and rename operates on the simbolic link itself
+
+Testing rename with arguments: symlink01, name02 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 78
+Testing lstat with arguments: name02, &statbuf EXPECT "0"
+PASS
+Testing if name02 is now a symlink
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 86
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: name02 EXPECT "0"
+PASS
+Testing unlink with arguments: symlink01 EXPECT "-1"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 94
+
+New is a simbolic link and rename operates on the simbolic link itself
+
+Testing rename with arguments: name02, symlink01 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 116
+Testing lstat with arguments: symlink01, &statbuf EXPECT "0"
+PASS
+Testing that symlink01 is not a symlink
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 124
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: name02 EXPECT "-1"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 131
+Testing unlink with arguments: symlink01 EXPECT "0"
+PASS
+
+Testing with symbolic link loop's
+
+Testing rename with arguments: "path01, name01" EXPECT "ELOOP"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 149
+Testing rename with arguments: "path01, name01" EXPECT "ELOOP"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 152
+Testing unlink with arguments: name01 EXPECT "-1"
+PASS
+Testing unlink with arguments: symlink01 EXPECT "0"
+PASS
+Testing unlink with arguments: symlink02 EXPECT "0"
+PASS
+Testing rename with arguments: "name01, path01" EXPECT "ELOOP"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 180
+Testing rename with arguments: "name01, path01" EXPECT "ELOOP"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 183
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: symlink01 EXPECT "0"
+PASS
+Testing unlink with arguments: symlink02 EXPECT "0"
+PASS
+
+Rename file with itself
+
+Testing rename with arguments: name01, name01 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 244
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+
+Rename file with itself through a hard link in another directory
+
+Testing rename with arguments: name01, path01 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 271
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: path01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename directory with file
+
+Testing rename with arguments: "dir01, name01" EXPECT "ENOTDIR"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 343
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename file with directory
+
+Testing rename with arguments: "name01, dir01" EXPECT "EISDIR"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 367
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename directory with ancestor directory
+
+Testing rename with arguments: "dir02, path01" EXPECT "EINVAL"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 390
+Testing rmdir with arguments: path01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+
+Rename directory with non empty directory
+
+Testing rename with arguments: dir01, dir02 EXPECT "-1"
+PASS
+Testing errno for EEXIST or ENOTEMPTY
+PASS
+Testing unlink with arguments: path01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+
+Rename empty directory with another empty directory
+
+Testing rename with arguments: dir01, dir02 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 448
+Testing rmdir with arguments: dir01 EXPECT "-1"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 454
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+Testing rename with arguments: "dir02, path01" EXPECT "EMLINK"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 483
+Testing rmdir with arguments: path01 EXPECT "-1"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 497
+Testing rmdir with arguments: dir02 EXPECT "0"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 498
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename files within directories protected with S_ISVTX
+
+Testing rename with arguments: path01, name02 EXPECT "-1"
+PASS
+Testing errno for EPERM or EACCES
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 535
+Testing unlink with arguments: path01 EXPECT "0"
+PASS
+Testing unlink with arguments: name02 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+Testing rename with arguments: name02, path01 EXPECT "-1"
+PASS
+Testing errno for EPERM or EACCES
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 577
+Testing unlink with arguments: path01 EXPECT "0"
+PASS
+Testing unlink with arguments: name02 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename file with non existant file
+
+Testing rename with arguments: name01, name02 EXPECT "0"
+PASS
+Testing unlink with arguments: name01 EXPECT "-1"
+PASS
+Testing unlink with arguments: name02 EXPECT "0"
+PASS
+Testing rename with arguments: "name02, name01" EXPECT "ENOENT"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 660
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: name02 EXPECT "-1"
+PASS
+
+Rename file with non existant filepath
+
+Testing rename with arguments: "path01, name01" EXPECT "ENOENT"
+PASS
+Testing unlink with arguments: name01 EXPECT "-1"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Rename directory with non existant directory
+
+Testing rename with arguments: dir01, dir02 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "-1"
+PASS
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+
+Rename file with a name size exceeding NAME_MAX
+
+Testing rename with arguments: "name01, filename" EXPECT "ENAMETOOLONG"
+PASS
+Testing unlink with arguments: name01 EXPECT "0"
+PASS
+Testing unlink with arguments: filename EXPECT "-1"
+PASS
+
+Rename directory with current directory
+
+Testing rename with arguments: "." , dir01 EXPECT "-1"
+PASS
+Testing errno for EINVAL or EBUSY
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 787
+Testing rename with arguments: dir01, "." EXPECT "-1"
+PASS
+Testing errno for EINVAL or EBUSY
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 801
+
+Rename directory with previous directory
+
+Testing rename with arguments: ".." , dir01 EXPECT "-1"
+PASS
+Testing errno for EINVAL or EBUSY
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 817
+Testing rename with arguments: dir01, ".." EXPECT "-1"
+PASS
+Testing errno for EINVAL or EBUSY
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 831
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+
+Testing empty filepaths
+
+Testing rename with arguments: "name01, \"\"" EXPECT "ENOENT"
+PASS
+Testing with arguments: name01 EXPECT "0"
+PASS
+Testing rename with arguments: "\"\", name01" EXPECT "ENOENT"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 869
+Testing with arguments: name01 EXPECT "0"
+PASS
+
+Rename two files on a directory with no write permission
+
+Testing rename with arguments: "name01 , name02" EXPECT "EACCES"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 947
+
+Rename file between two directories, with and without write access
+
+Testing rename with arguments: "name01, path01" EXPECT "EACCES"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 971
+Testing rename with arguments: "path01, name01" EXPECT "EACCES"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 978
+Testing with arguments: name01 EXPECT "0"
+PASS
+Testing with arguments: path01 EXPECT "0"
+PASS
+Testing with arguments: path01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+
+Rename two files on a directory with no execute permission
+
+Testing rename with arguments: "path01 , path02" EXPECT "EACCES"
+PASS
+
+Rename file between two directories, with and without execute access
+
+Testing rename with arguments: "path01, path02" EXPECT "EACCES"
+PASS
+Testing rename with arguments: "path02, path01" EXPECT "EACCES"
+FAIL testsuites/fstests/mimfs_fsrename/../fsrename/test.c: 1103
+Testing with arguments: path01 EXPECT "0"
+PASS
+Testing with arguments: path01 EXPECT "0"
+PASS
+Testing with arguments: path02 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir01 EXPECT "0"
+PASS
+Testing rmdir with arguments: dir02 EXPECT "0"
+PASS
+
+Rename files across diferent filesystems
+
+Testing rename with arguments: "name01, path01" EXPECT "EXDEV"
+PASS
+Testing with arguments: path01 EXPECT "-1"
+PASS
+Testing with arguments: name01 EXPECT "0"
+PASS
+
+
+Shutting down filesystem MOUNTED IMFS
+*** END OF TEST FSRENAME MOUNTED IMFS ***