diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-10-18 11:51:32 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-10-22 08:06:05 +0200 |
commit | 38259266018f49c23e6b72f58f740a2d423d9c62 (patch) | |
tree | dbda245287e4e730c30fc306052a162934342fda /testsuites/psxtests/psxfile01 | |
parent | psxreaddir: Adjust test due to opendir() changes (diff) | |
download | rtems-38259266018f49c23e6b72f58f740a2d423d9c62.tar.bz2 |
Support O_CLOEXEC open() flag
Make sure this flag is ignored and does not prevent a successful open.
Close #3547.
Diffstat (limited to 'testsuites/psxtests/psxfile01')
-rw-r--r-- | testsuites/psxtests/psxfile01/test.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index dbdce86be8..129412d3ef 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -57,6 +57,8 @@ char test_write_buffer[ 1024 ]; rtems_filesystem_operations_table IMFS_ops_no_evalformake; rtems_filesystem_operations_table IMFS_ops_no_rename; +static const char somefile[] = "somefile"; + /* * File test support routines. */ @@ -132,11 +134,10 @@ void stat_a_file( static void test_open_directory(void) { - static const char file[] = "somefile"; int status; int fd; - fd = open( file, O_CREAT, S_IRWXU ); + fd = open( somefile, O_CREAT, S_IRWXU ); rtems_test_assert( fd >= 0 ); status = close( fd ); @@ -144,12 +145,34 @@ static void test_open_directory(void) #ifdef O_DIRECTORY errno = 0; - fd = open( file, O_DIRECTORY, S_IRWXU ); + fd = open( somefile, O_DIRECTORY, S_IRWXU ); rtems_test_assert( fd == -1 ); rtems_test_assert( errno == ENOTDIR ); #endif - status = unlink( file ); + status = unlink( somefile ); + rtems_test_assert( status == 0 ); +} + +static void test_open_cloexec(void) +{ + int status; + int fd; + mode_t mode; + + mode = O_CREAT; + +#ifdef O_CLOEXEC + mode |= O_CLOEXEC; +#endif + + fd = open( somefile, mode, S_IRWXU ); + rtems_test_assert( fd >= 0 ); + + status = close( fd ); + rtems_test_assert( status == 0 ); + + status = unlink( somefile ); rtems_test_assert( status == 0 ); } @@ -185,6 +208,7 @@ int main( TEST_BEGIN(); test_open_directory(); + test_open_cloexec(); /* * Grab the maximum size of an in-memory file. |