diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-19 13:13:20 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-19 13:13:20 +0000 |
commit | efdc6987a79fe1c6253a94a7ae6120b86d62ef81 (patch) | |
tree | 91aca53e15b1c93d38ff57dde65143073f6d73d7 /testsuites/psxtests/psxfile01/test.c | |
parent | 2010-07-19 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-efdc6987a79fe1c6253a94a7ae6120b86d62ef81.tar.bz2 |
2010-07-19 Bharath Suri <bharath.s.jois@gmail.com>
PR 1623/testing
* psx13/test.c, psx13/psx13.scn: New cases to improve coverage of
utime() and fpathconf().
* psxfile01/test.c, psxfile01/psxfile01.scn: New cases to improve
coverage of rmdir(), unlink(), mknod(), link(), open(), read(),
write().
* psxstat/test.c, psxstat/psxstat.scn: New case to improve
coverage of readlink().
Diffstat (limited to 'testsuites/psxtests/psxfile01/test.c')
-rw-r--r-- | testsuites/psxtests/psxfile01/test.c | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index 8d6183560b..aa194dccd1 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -244,6 +244,16 @@ int main( rtems_test_assert (status == -1); rtems_test_assert( errno == ENOENT ); + puts( "rmdir /tmp/bha" ); + status = rmdir( "/tmp/bha" ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOENT ); + + puts( "unlink /dev/tty" ); + status = unlink( "/dev/tty" ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EISDIR ); + puts( "mknod /dev/test_console" ); status = mknod( "/dev/test_console", S_IFCHR, 0LL ); rtems_test_assert( !status ); @@ -339,16 +349,70 @@ int main( rtems_test_assert( fd == -1 ); rtems_test_assert( errno == EINVAL ); - puts( "Exercise the reentrant version _link_r -- Expect EEXIST" ); - status = _link_r( NULL, "", "" ); + puts( "Exercise the reentrant version _link_r -- Expect ENOENT" ); + status = _link_r( NULL, "/tmp/notexist", "/tmp/cannotexist" ); rtems_test_assert( status == -1 ); - rtems_test_assert( errno == EEXIST ); + rtems_test_assert( errno == ENOENT ); puts( "Unlink /tmp/bha using the reentrant version -- OK" ); status = _unlink_r( NULL, "/tmp/bha" ); rtems_test_assert( status == 0 ); /* + * Simple test case for mknod + */ + + puts( "mknod with bad type - expect EINVAL" ); + status = mknod( "/tmp/bha", 0, 0LL ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* + * Read from filedes opened for write + */ + + puts( "open /tmp/bha in write only mode -- OK" ); + fd = open( "/tmp/bha", O_CREAT | O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO ); + rtems_test_assert( fd != -1 ); + + puts( "attempt to read from /tmp/bha - expect EINVAL" ); + status = read( fd, buffer, 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + puts( "closing and unlinking /tmp/bha" ); + status = close( fd ); + status |= unlink( "/tmp/bha" ); + rtems_test_assert( status == 0 ); + + puts( "open /tmp/bha in read only mode -- OK" ); + fd = open( "/tmp/bha", O_CREAT | O_RDONLY, S_IRWXU|S_IRWXG|S_IRWXO ); + rtems_test_assert( fd != -1 ); + + puts( "attempt to read from /tmp/bha - expect EINVAL" ); + status = write( fd, buffer, 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + puts( "closing and unlinking /tmp/bha" ); + status = close( fd ); + status |= unlink( "/tmp/bha" ); + rtems_test_assert( status == 0 ); + + /* + * Read/write from an unopened filedes + */ + puts( "attempt to read from an unopened filedes - expect EBADF" ); + status = read( 5, buffer, 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "attempt to write to an unopened filedes - expect EBADF" ); + status = write( 5, buffer, 10 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + /* * Test simple write to a file at offset 0 */ |