[rtems commit] fsclose01: Add tmpfile() test case

Sebastian Huber sebh at rtems.org
Mon Feb 5 08:32:24 UTC 2018


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Feb  5 09:31:32 2018 +0100

fsclose01: Add tmpfile() test case

Close #1971.

---

 testsuites/fstests/fsclose01/fsclose01.doc |  2 ++
 testsuites/fstests/fsclose01/init.c        | 29 ++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/testsuites/fstests/fsclose01/fsclose01.doc b/testsuites/fstests/fsclose01/fsclose01.doc
index 29277a4..89a734a 100644
--- a/testsuites/fstests/fsclose01/fsclose01.doc
+++ b/testsuites/fstests/fsclose01/fsclose01.doc
@@ -17,6 +17,7 @@ directives:
   - lseek()
   - read()
   - readv()
+  - tmpfile()
   - write()
   - writev()
 
@@ -24,3 +25,4 @@ concepts:
 
   - Ensure the close() return -1 with errno set to EBUSY in case the file
     descriptor is still in use.
+  - Ensure that close() cleans up resources allocated by tmpfile().
diff --git a/testsuites/fstests/fsclose01/init.c b/testsuites/fstests/fsclose01/init.c
index 3b65b3b..786749d 100644
--- a/testsuites/fstests/fsclose01/init.c
+++ b/testsuites/fstests/fsclose01/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012, 2018 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -426,7 +426,7 @@ static void test_fd_free_fifo(const char *path)
   rtems_test_assert(a != b);
 }
 
-static void test(test_context *ctx)
+static void test_close(test_context *ctx)
 {
   const char *path = "generic";
   int rv;
@@ -507,10 +507,33 @@ static void test(test_context *ctx)
   rtems_test_assert(ctx->writev_count == 1);
 }
 
+static void test_tmpfile(test_context *ctx)
+{
+  rtems_resource_snapshot before;
+  FILE *f;
+  int rv;
+
+  rv = mkdir("/tmp", S_IRWXU | S_IRWXG | S_IRWXO);
+  rtems_test_assert(rv == 0);
+
+  f = tmpfile();
+  rtems_test_assert(f != NULL);
+  rv = fclose(f);
+  rtems_test_assert(rv == 0);
+
+  rtems_resource_snapshot_take(&before);
+  f = tmpfile();
+  rtems_test_assert(f != NULL);
+  rv = fclose(f);
+  rtems_test_assert(rv == 0);
+  rtems_test_assert(rtems_resource_snapshot_check(&before));
+}
+
 static void Init(rtems_task_argument arg)
 {
   TEST_BEGIN();
-  test(&test_instance);
+  test_close(&test_instance);
+  test_tmpfile(&test_instance);
   TEST_END();
   rtems_test_exit(0);
 }




More information about the vc mailing list