Changeset 1ad26cd in rtems for testsuites


Ignore:
Timestamp:
Oct 18, 2018, 10:38:58 AM (13 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
3cf12c9
Parents:
3825926
git-author:
Sebastian Huber <sebastian.huber@…> (10/18/18 10:38:58)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/22/18 06:06:05)
Message:

Support O_NOFOLLOW open() flag

Close #3546.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/psxfile01/test.c

    r3825926 r1ad26cd  
    6060static const char somefile[] = "somefile";
    6161
     62static const char somelink[] = "somelink";
     63
    6264/*
    6365 *  File test support routines.
     
    153155  status = unlink( somefile );
    154156  rtems_test_assert( status == 0 );
     157
     158  errno = 0;
     159  fd = open( somefile, O_RDONLY );
     160  rtems_test_assert( fd == -1 );
     161  rtems_test_assert( errno == ENOENT );
    155162}
    156163
     
    175182  status = unlink( somefile );
    176183  rtems_test_assert( status == 0 );
     184
     185  errno = 0;
     186  fd = open( somefile, O_RDONLY );
     187  rtems_test_assert( fd == -1 );
     188  rtems_test_assert( errno == ENOENT );
     189}
     190
     191static void test_open_nofollow(void)
     192{
     193  int status;
     194  int fd;
     195  struct stat st;
     196
     197  fd = open( somefile, O_CREAT, S_IRWXU );
     198  rtems_test_assert( fd >= 0 );
     199
     200  status = close( fd );
     201  rtems_test_assert( status == 0 );
     202
     203  status = symlink( somefile, somelink );
     204  rtems_test_assert( status == 0 );
     205
     206  fd = open( somelink, O_RDONLY );
     207  rtems_test_assert( fd >= 0 );
     208
     209  status = fstat( fd, &st );
     210  rtems_test_assert( status == 0 );
     211  rtems_test_assert( S_ISREG( st.st_mode ) );
     212
     213  status = close( fd );
     214  rtems_test_assert( status == 0 );
     215
     216#ifdef O_NOFOLLOW
     217  fd = open( somelink, O_RDONLY | O_NOFOLLOW );
     218  rtems_test_assert( fd >= 0 );
     219
     220  status = fstat( fd, &st );
     221  rtems_test_assert( status == 0 );
     222  rtems_test_assert( S_ISLNK( st.st_mode ) );
     223
     224  status = close( fd );
     225  rtems_test_assert( status == 0 );
     226#endif
     227
     228  status = unlink( somelink );
     229  rtems_test_assert( status == 0 );
     230
     231  errno = 0;
     232  fd = open( somelink, O_RDONLY );
     233  rtems_test_assert( fd == -1 );
     234  rtems_test_assert( errno == ENOENT );
     235
     236  status = unlink( somefile );
     237  rtems_test_assert( status == 0 );
     238
     239  errno = 0;
     240  fd = open( somefile, O_RDONLY );
     241  rtems_test_assert( fd == -1 );
     242  rtems_test_assert( errno == ENOENT );
    177243}
    178244
     
    210276  test_open_directory();
    211277  test_open_cloexec();
     278  test_open_nofollow();
    212279
    213280  /*
Note: See TracChangeset for help on using the changeset viewer.