diff options
-rw-r--r-- | testsuites/psxtests/ChangeLog | 10 | ||||
-rw-r--r-- | testsuites/psxtests/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/psxtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtests/psxfchx01/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtests/psxfchx01/Makefile.am | 28 | ||||
-rw-r--r-- | testsuites/psxtests/psxfchx01/init.c | 226 | ||||
-rw-r--r-- | testsuites/psxtests/psxfchx01/psxfchx01.doc | 25 | ||||
-rw-r--r-- | testsuites/psxtests/psxfchx01/psxfchx01.scn | 45 | ||||
-rw-r--r-- | testsuites/psxtests/psxstat/psxstat.scn | 5 | ||||
-rw-r--r-- | testsuites/psxtests/psxstat/test.c | 25 |
10 files changed, 368 insertions, 1 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 471b77fe8d..bec7c04105 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,13 @@ +2010-07-12 Bharath Suri <bharath.s.jois@gmail.com> + + PR 1613/testing + * psxfchx01/init.c, psxfchx01/Makefile.am, psxfchx01/.cvsignore, + psxfchx01/psxfchx01.doc, psxfchx01/psxfchx01.scn: New + tests. Improves coverage of fchdir, fchmod, fchown directives. + * configure.ac, Makefile.am: Changes to accommodate new test. + * psxstat/test.c, psxstat/psxstat.scn: Added new test case to test + statvfs routine under libcsupport. + 2010-07-09 Bharath Suri <bharath.s.jois@gmail.com> PR 1610/testing diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index ad99411d64..287112c5a8 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -21,7 +21,7 @@ endif ## File IO tests SUBDIRS += psxfile01 psxfile02 psxfilelock01 psxgetrusage01 psxid01 \ psximfs01 psxreaddir psxstat psxmount psx13 psxchroot01 psxpasswd01 \ - psxpasswd02 psxpipe01 psxtimes01 + psxpasswd02 psxpipe01 psxtimes01 psxfchx01 ## Until sys/uio.h is moved to libcsupport, we have to have networking ## enabled to support readv and writev. Hopefully this is a temporary diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index e220e6284d..9645969e3b 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -86,6 +86,7 @@ psxcond01/Makefile psxenosys/Makefile psxfatal01/Makefile psxfatal02/Makefile +psxfchx01/Makefile psxfile01/Makefile psxfile02/Makefile psxfilelock01/Makefile diff --git a/testsuites/psxtests/psxfchx01/.cvsignore b/testsuites/psxtests/psxfchx01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psxfchx01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psxfchx01/Makefile.am b/testsuites/psxtests/psxfchx01/Makefile.am new file mode 100644 index 0000000000..7c01161c37 --- /dev/null +++ b/testsuites/psxtests/psxfchx01/Makefile.am @@ -0,0 +1,28 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxfchx01 +psxfchx01_SOURCES = init.c ../include/pmacros.h + +dist_rtems_tests_DATA = psxfchx01.scn + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +psxfchx01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) + +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxfchx01_OBJECTS) $(psxfchx01_LDADD) +LINK_LIBS = $(psxfchx01_LDLIBS) + +psxfchx01$(EXEEXT): $(psxfchx01_OBJECTS) $(psxfchx01_DEPENDENCIES) + @rm -f psxfchx01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psxfchx01/init.c b/testsuites/psxtests/psxfchx01/init.c new file mode 100644 index 0000000000..83ec35debb --- /dev/null +++ b/testsuites/psxtests/psxfchx01/init.c @@ -0,0 +1,226 @@ +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include <bsp.h> +#include <pmacros.h> +#include <unistd.h> +#include <errno.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> + +rtems_task Init( + rtems_task_argument ignored +) +{ + int status = 0; + int fd = 0; + + puts( "*** TEST Posix file op tests - 01 ***" ); + + /**************************************************** + * fchdir tests + ***************************************************/ + + puts( "Init - fchdir tests" ); + + puts( "Init - Attempt fchdir with bad file descriptor - expect EBADF" ); + status = fchdir( 5 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - Attempt fchdir with bad file descriptor - expect EBADF" ); + status = fchdir( 3 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - opening /newfile in write-mode -- OK" ); + fd = open( "/newfile", O_WRONLY | O_CREAT, S_IWUSR ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchdir on the file descriptor - expect EINVAL" ); + status = fchdir( fd ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + puts(" Init - closing /newfile -- OK" ); + status = close( fd ); + rtems_test_assert( status == 0 ); + + puts( "Init - removing /newfile -- OK" ); + status = unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "Init - opening /newfile in read-mode -- OK" ); + fd = open( "/newfile", O_RDONLY | O_CREAT, S_IRUSR); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchdir on the file descriptor - expect ENOTDIR" ); + status = fchdir( fd ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOTDIR ); + + puts( "Init - closing and removing /newfile -- OK" ); + status = close( fd ); + status |= unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "Init - create directory /tmp - RWX permissions -- OK" ); + status = mkdir( "/tmp", S_IRWXU ); + rtems_test_assert( status == 0 ); + + puts( "Init - open the /tmp, get the file descriptor -- OK" ); + fd = open( "/tmp", O_RDONLY ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchdir on the file descriptor -- OK" ); + status = fchdir( fd ); + rtems_test_assert( status == 0 ); + + puts( "Init - close the file descriptor -- OK" ); + status = close( fd ); + rtems_test_assert( status == 0 ); + + puts( "Init - remove directory /tmp -- OK" ); + status = rmdir( "/tmp" ); + rtems_test_assert( status == 0 ); + + puts( "Init - creating directory /tmp - read permission -- OK" ); + status = mkdir( "/tmp", S_IRUSR ); + rtems_test_assert( status == 0 ); + + puts( "Init - open the /tmp, get the file descriptor -- OK" ); + fd = open( "/tmp", O_RDONLY ); + rtems_test_assert( fd != -1 ); + + puts( "Init - attempt fchdir on the file descriptor -- expect EACCES" ); + status = fchdir( fd ); + rtems_test_assert( status == -1); + rtems_test_assert( errno == EACCES ); + + puts( "Init - close the file descriptor -- OK" ); + status = close( fd ); + rtems_test_assert( status == 0 ); + + puts( "Init - remove directory /tmp -- OK" ); + status = rmdir( "/tmp" ); + rtems_test_assert( status == 0 ); + + puts( "End of fchdir tests" ); + + /**************************************************** + * fchmod tests + ***************************************************/ + + puts( "\nInit - fchmod tests" ); + + puts( "Init - fchmod, with a bad file descriptor - expect EBADF" ); + status = fchmod( 4, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - fchmod, with an unopened file descriptor - expect EBADF" ); + status = fchmod( 3, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - open new file: /newfile in read-only mode -- OK" ); + fd = open( "/newfile", O_RDONLY | O_CREAT, S_IRWXU ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchmod, with the opened file descriptor - expect EINVAL" ); + status = fchmod( fd, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + puts(" Init - close and remove /newfile" ); + status = close( fd ); + status |= unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "Init - open new file: /newfile in read-write mode -- OK" ); + fd = open( "/newfile", O_RDWR | O_CREAT, S_IRWXU ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchmod, with the opened file descriptor -- OK" ); + status = fchmod( fd, S_IRUSR ); + rtems_test_assert( status == 0 ); + + puts(" Init - close and remove /newfile -- OK" ); + status = close( fd ); + status |= unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "End of fchmod tests" ); + + /**************************************************** + * fchown tests + ***************************************************/ + + puts( "\nInit - fchown tests" ); + + puts( "Init - fchown, with a bad file descriptor - expect EBADF" ); + status = fchown( 4, 0, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - fchown, with an unopened file descriptor - expect EBADF" ); + status = fchown( 3, 0, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EBADF ); + + puts( "Init - open new file: /newfile in read-only mode -- OK" ); + fd = open( "/newfile", O_RDONLY | O_CREAT, S_IRWXU ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchown, with the opened file descriptor - expect EINVAL" ); + status = fchown( fd, 0, 0 ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EINVAL ); + + puts(" Init - close and remove /newfile" ); + status = close( fd ); + status |= unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "Init - open new file: /newfile in read-write mode -- OK" ); + fd = open( "/newfile", O_RDWR | O_CREAT, S_IRWXU ); + rtems_test_assert( fd != -1 ); + + puts( "Init - fchown, with the opened file descriptor -- OK" ); + status = fchown( fd, 1, 0 ); + rtems_test_assert( status == 0 ); + + puts(" Init - close and remove /newfile -- OK" ); + status = close( fd ); + status |= unlink( "/newfile" ); + rtems_test_assert( status == 0 ); + + puts( "End of fchown tests" ); + + puts( "*** END OF TEST Posix file op tests - 01 ***" ); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4 + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> +/* end of file */ diff --git a/testsuites/psxtests/psxfchx01/psxfchx01.doc b/testsuites/psxtests/psxfchx01/psxfchx01.doc new file mode 100644 index 0000000000..97f0e02c8d --- /dev/null +++ b/testsuites/psxtests/psxfchx01/psxfchx01.doc @@ -0,0 +1,25 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2009. +# On-Line Applications Research Corporation (OAR). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: psxfchx01 + +directives: + ++ fchdir ++ fchmod ++ fchown + +concepts: + ++ Exercise the fildes based operations - fchdir, fchmod, fchown + diff --git a/testsuites/psxtests/psxfchx01/psxfchx01.scn b/testsuites/psxtests/psxfchx01/psxfchx01.scn new file mode 100644 index 0000000000..85f3ce8683 --- /dev/null +++ b/testsuites/psxtests/psxfchx01/psxfchx01.scn @@ -0,0 +1,45 @@ +*** TEST Posix file op tests - 01 *** +Init - fchdir tests +Init - Attempt fchdir with bad file descriptor - expect EBADF +Init - Attempt fchdir with bad file descriptor - expect EBADF +Init - opening /newfile in write-mode -- OK +Init - fchdir on the file descriptor - expect EINVAL + Init - closing /newfile -- OK +Init - removing /newfile -- OK +Init - opening /newfile in read-mode -- OK +Init - fchdir on the file descriptor - expect ENOTDIR +Init - closing and removing /newfile -- OK +Init - create directory /tmp - RWX permissions -- OK +Init - open the /tmp, get the file descriptor -- OK +Init - fchdir on the file descriptor -- OK +Init - close the file descriptor -- OK +Init - remove directory /tmp -- OK +Init - creating directory /tmp - read permission -- OK +Init - open the /tmp, get the file descriptor -- OK +Init - attempt fchdir on the file descriptor -- expect EACCES +Init - close the file descriptor -- OK +Init - remove directory /tmp -- OK +End of fchdir tests + +Init - fchmod tests +Init - fchmod, with a bad file descriptor - expect EBADF +Init - fchmod, with an unopened file descriptor - expect EBADF +Init - open new file: /newfile in read-only mode -- OK +Init - fchmod, with the opened file descriptor - expect EINVAL + Init - close and remove /newfile +Init - open new file: /newfile in read-write mode -- OK +Init - fchmod, with the opened file descriptor -- OK + Init - close and remove /newfile -- OK +End of fchmod tests + +Init - fchown tests +Init - fchown, with a bad file descriptor - expect EBADF +Init - fchown, with an unopened file descriptor - expect EBADF +Init - open new file: /newfile in read-only mode -- OK +Init - fchown, with the opened file descriptor - expect EINVAL + Init - close and remove /newfile +Init - open new file: /newfile in read-write mode -- OK +Init - fchown, with the opened file descriptor -- OK + Init - close and remove /newfile -- OK +End of fchown tests +*** END OF TEST Posix file op tests - 01 *** diff --git a/testsuites/psxtests/psxstat/psxstat.scn b/testsuites/psxtests/psxstat/psxstat.scn index 20525b0d2f..c8cc62e0b7 100644 --- a/testsuites/psxtests/psxstat/psxstat.scn +++ b/testsuites/psxtests/psxstat/psxstat.scn @@ -1,3 +1,4 @@ + *** STAT TEST 01 *** --->Current Time: - rtems_clock_get_tod - 09:00:00 12/31/1988 Making directory /my_mount_point/dir1 @@ -1703,6 +1704,10 @@ lstat( /my_mount_point/symlinks/a_dir_symlink/a_file_symlink ) returned ...st_ctime Sat Dec 31 09:00:35 1988 ...st_blksize 0 ...st_blocks 0 +statvfs, with invalid path - expect EFAULT +create /tmp -- OK +statvfs, with valid path - expect ENOTSUP +statvfs tested! *** END OF STAT TEST 01 *** diff --git a/testsuites/psxtests/psxstat/test.c b/testsuites/psxtests/psxstat/test.c index 0549806763..90f1431dfc 100644 --- a/testsuites/psxtests/psxstat/test.c +++ b/testsuites/psxtests/psxstat/test.c @@ -774,6 +774,29 @@ void Show_Time(void) print_time( " - rtems_clock_get_tod - ", &time, "\n" ); } +void test_statvfs( void ) +{ + + int status = 0; + struct statvfs stat; + + puts( "statvfs, with invalid path - expect EFAULT" ); + status = statvfs( NULL , &stat ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == EFAULT ); + + puts( "create /tmp -- OK" ); + status = mkdir( "/tmp", 0777 ); + rtems_test_assert( status == 0 ); + + puts( "statvfs, with valid path - expect ENOTSUP" ); + status = statvfs( "/tmp", &stat ); + rtems_test_assert( status == -1 ); + rtems_test_assert( errno == ENOTSUP ); + + puts( "statvfs tested!" ); +} + /* * main entry point to the test */ @@ -902,6 +925,8 @@ int main( status = rtems_task_wake_after( TIMEOUT_VALUE ); lchown_multiple_files( SymLinks ); + test_statvfs(); + puts( "\n\n*** END OF STAT TEST 01 ***" ); rtems_test_exit(0); } |