[rtems commit] fstests/fsrename: Rename a file twice

Sebastian Huber sebh at rtems.org
Tue Mar 3 10:35:22 UTC 2020


Module:    rtems
Branch:    master
Commit:    c4d5a341bd5aad1141be929a5a7e67a59d3730aa
Changeset: http://git.rtems.org/rtems/commit/?id=c4d5a341bd5aad1141be929a5a7e67a59d3730aa

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Feb 29 11:34:53 2020 +0100

fstests/fsrename: Rename a file twice

---

 testsuites/fstests/fsrename/test.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/testsuites/fstests/fsrename/test.c b/testsuites/fstests/fsrename/test.c
index d5acb70..487c60b 100644
--- a/testsuites/fstests/fsrename/test.c
+++ b/testsuites/fstests/fsrename/test.c
@@ -208,6 +208,34 @@ static void symbolic_link_test (void)
   rtems_test_assert (status == 0);
 }
 
+static void rename_file_twice_test (void)
+{
+  const char *name01 = "name01";
+  const char *name02 = "name02";
+  const char *name03 = "name03";
+  mode_t      mode;
+  int         fd;
+  int         status;
+
+  puts ("\nRename file twice\n");
+
+  mode = S_IRWXU | S_IRWXG | S_IRWXO;
+  fd = creat (name01, mode);
+  rtems_test_assert (fd >= 0);
+  status = close (fd);
+  rtems_test_assert (status == 0);
+
+  EXPECT_EQUAL (0, rename, name01, name02);
+  EXPECT_EQUAL (0, rename, name02, name03);
+
+  errno = 0;
+  EXPECT_EQUAL (-1, unlink, name01);
+  rtems_test_assert (errno == ENOENT);
+  EXPECT_EQUAL (-1, unlink, name02);
+  rtems_test_assert (errno == ENOENT);
+  EXPECT_EQUAL (0, unlink, name03);
+}
+
 static void same_file_test (void)
 {
   int fd;
@@ -1221,6 +1249,7 @@ static void filesystem_test (void)
 void test (void)
 {
   symbolic_link_test ();
+  rename_file_twice_test ();
   same_file_test ();
   directory_test ();
   arg_test ();



More information about the vc mailing list