fsclose01: Add tmpfile() test case

Close #1971.
This commit is contained in:
Sebastian Huber
2018-02-05 09:31:32 +01:00
parent 03e5a7800d
commit 4ac5ffbb83
2 changed files with 28 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ directives:
- lseek() - lseek()
- read() - read()
- readv() - readv()
- tmpfile()
- write() - write()
- writev() - writev()
@@ -24,3 +25,4 @@ concepts:
- Ensure the close() return -1 with errno set to EBUSY in case the file - Ensure the close() return -1 with errno set to EBUSY in case the file
descriptor is still in use. descriptor is still in use.
- Ensure that close() cleans up resources allocated by tmpfile().

View File

@@ -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 * embedded brains GmbH
* Dornierstr. 4 * Dornierstr. 4
@@ -426,7 +426,7 @@ static void test_fd_free_fifo(const char *path)
rtems_test_assert(a != b); rtems_test_assert(a != b);
} }
static void test(test_context *ctx) static void test_close(test_context *ctx)
{ {
const char *path = "generic"; const char *path = "generic";
int rv; int rv;
@@ -507,10 +507,33 @@ static void test(test_context *ctx)
rtems_test_assert(ctx->writev_count == 1); 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) static void Init(rtems_task_argument arg)
{ {
TEST_BEGIN(); TEST_BEGIN();
test(&test_instance); test_close(&test_instance);
test_tmpfile(&test_instance);
TEST_END(); TEST_END();
rtems_test_exit(0); rtems_test_exit(0);
} }