[rtems commit] fstests/fsrdwr: Add truncate to zero test case

Sebastian Huber sebh at rtems.org
Fri May 11 11:57:22 UTC 2012


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 11 13:19:14 2012 +0200

fstests/fsrdwr: Add truncate to zero test case

---

 testsuites/fstests/fsrdwr/init.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/testsuites/fstests/fsrdwr/init.c b/testsuites/fstests/fsrdwr/init.c
index b6e033b..ae7ed7e 100644
--- a/testsuites/fstests/fsrdwr/init.c
+++ b/testsuites/fstests/fsrdwr/init.c
@@ -518,10 +518,42 @@ lseek_test (void)
   test_case_leave ();
 }
 
+static void
+truncate_to_zero (void)
+{
+  int fd;
+  ssize_t n;
+  int status;
+  off_t pos;
+
+  test_case_enter (__func__);
+
+  fd = creat ("file", mode);
+  rtems_test_assert (fd >= 0);
+
+  n = write (fd, databuf, len);
+  rtems_test_assert (n == (ssize_t) len);
+
+  pos = lseek (fd, 0, SEEK_END);
+  rtems_test_assert (pos == len);
+
+  status = ftruncate (fd, 0);
+  rtems_test_assert (status == 0);
+
+  pos = lseek (fd, 0, SEEK_END);
+  rtems_test_assert (pos == 0);
+
+  status = close (fd);
+  rtems_test_assert (status == 0);
+
+  test_case_leave ();
+}
+
 void
 test (void)
 {
   read_write_test ();
   lseek_test ();
   truncate_test03 ();
+  truncate_to_zero ();
 }




More information about the vc mailing list