From 43efb633bafe8d413f9a0f76e140fde7d6d96311 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 28 Jun 2010 18:48:25 +0000 Subject: 2010-06-28 Joel Sherrill * Makefile.am, configure.ac: Add test to exercise IMFS behaviour with files of maximum sizes. * psximfs01/.cvsignore, psximfs01/Makefile.am, psximfs01/init.c, psximfs01/psximfs01.doc, psximfs01/psximfs01.scn: New files. --- testsuites/psxtests/ChangeLog | 7 + testsuites/psxtests/Makefile.am | 2 +- testsuites/psxtests/configure.ac | 1 + testsuites/psxtests/psximfs01/.cvsignore | 2 + testsuites/psxtests/psximfs01/Makefile.am | 26 ++++ testsuites/psxtests/psximfs01/init.c | 193 ++++++++++++++++++++++++++++ testsuites/psxtests/psximfs01/psximfs01.doc | 35 +++++ testsuites/psxtests/psximfs01/psximfs01.scn | 16 +++ 8 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 testsuites/psxtests/psximfs01/.cvsignore create mode 100644 testsuites/psxtests/psximfs01/Makefile.am create mode 100644 testsuites/psxtests/psximfs01/init.c create mode 100644 testsuites/psxtests/psximfs01/psximfs01.doc create mode 100644 testsuites/psxtests/psximfs01/psximfs01.scn (limited to 'testsuites') diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index ea4792b5fc..243511e0c6 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,10 @@ +2010-06-28 Joel Sherrill + + * Makefile.am, configure.ac: Add test to exercise IMFS behaviour with + files of maximum sizes. + * psximfs01/.cvsignore, psximfs01/Makefile.am, psximfs01/init.c, + psximfs01/psximfs01.doc, psximfs01/psximfs01.scn: New files. + 2010-06-23 Joel Sherrill * Makefile.am, configure.ac: Revert accidentally committed patch. diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 0911b51c6a..66dfacbca6 100644 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -19,7 +19,7 @@ SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \ endif ## File IO tests -SUBDIRS += psxfile01 psxfile02 psxreaddir psxstat psxmount psx13 \ +SUBDIRS += psxfile01 psxfile02 psximfs01 psxreaddir psxstat psxmount psx13 \ psxchroot01 psxpasswd01 ## Until sys/uio.h is moved to libcsupport, we have to have networking diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac index 40d6b329e9..a36ea8cd18 100644 --- a/testsuites/psxtests/configure.ac +++ b/testsuites/psxtests/configure.ac @@ -91,6 +91,7 @@ psxfatal02/Makefile psxfile01/Makefile psxfile02/Makefile psxhdrs/Makefile +psximfs01/Makefile psxintrcritical01/Makefile psxitimer/Makefile psxkey01/Makefile diff --git a/testsuites/psxtests/psximfs01/.cvsignore b/testsuites/psxtests/psximfs01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtests/psximfs01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtests/psximfs01/Makefile.am b/testsuites/psxtests/psximfs01/Makefile.am new file mode 100644 index 0000000000..d6b51337a9 --- /dev/null +++ b/testsuites/psxtests/psximfs01/Makefile.am @@ -0,0 +1,26 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psximfs01 +psximfs01_SOURCES = init.c + +dist_rtems_tests_DATA = psximfs01.scn +dist_rtems_tests_DATA += psximfs01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psximfs01_OBJECTS) $(psximfs01_LDADD) +LINK_LIBS = $(psximfs01_LDLIBS) + +psximfs01$(EXEEXT): $(psximfs01_OBJECTS) $(psximfs01_DEPENDENCIES) + @rm -f psximfs01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtests/psximfs01/init.c b/testsuites/psxtests/psximfs01/init.c new file mode 100644 index 0000000000..dcdd813e59 --- /dev/null +++ b/testsuites/psxtests/psximfs01/init.c @@ -0,0 +1,193 @@ +/* + * 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 +#include "test_support.h" + +#include +#include +#include +#include +#include + +int TestFd; +uint8_t Buffer[256]; +ssize_t TotalWritten; + +#define FILE_NAME "biggie" + +void open_it(bool readOnly, bool create) +{ + int flag = 0; + + if ( readOnly ) + flag |= O_RDONLY; + else { + if ( create ) + flag |= O_CREAT; + flag |= O_RDWR; + } + + /* open the file */ + puts( "open(" FILE_NAME ") - OK " ); + TestFd = open( FILE_NAME, flag, 0777 ); + rtems_test_assert( TestFd != -1 ); +} + +void write_helper(void) +{ + ssize_t written; + + TotalWritten = 0; + puts( "write(" FILE_NAME ") - OK " ); + do { + written = write( TestFd, Buffer, sizeof(Buffer) ); + if ( written == -1 ) { + if ( errno == ENOSPC ) { + printf( "Total written = %d\n", TotalWritten ); + return; + } + fprintf( + stderr, + "Unable to create largest IMFS file (error=%s)\n", + strerror(errno) + ); + rtems_test_exit(0); + } + TotalWritten += written; + } while (1); + +} + +void read_helper(void) +{ + uint8_t ch; + ssize_t sc; + int i=0; + + puts( "read(" FILE_NAME ") - OK " ); + do { + sc = read( TestFd, &ch, sizeof(ch) ); + if ( sc == 1 ) { + if ( ch != (i%256) ) { + fprintf( + stderr, + "MISMATCH 0x%02x != 0x%02x at offset %d\n", + ch, + i % 256, + i + ); + rtems_test_exit(0); + } + i++; + continue; + } + /* Unsure if ENOSPC is the write error to be returned */ + if ( errno == ENOSPC && i == TotalWritten ) { + puts( "File correctly read until ENOSPC returned\n" ); + return; + } + fprintf( + stderr, + "ERROR - at offset %d - returned %d and error=%s\n", + i, + sc, + strerror( errno ) + ); + rtems_test_exit(0); + } while (1); +} + +void truncate_helper(void) +{ + off_t position; + off_t new; + off_t sc; + int rc; + + position = lseek( TestFd, 0, SEEK_END ); + printf( "Seek to end .. returned %d\n", (int) position ); + rtems_test_assert( position == TotalWritten ); + + puts( "lseek/ftruncate loop.." ); + new = position; + do { + sc = lseek( TestFd, new, SEEK_SET ); + rtems_test_assert( sc == new ); + + rc = ftruncate( TestFd, new ); + if ( rc != 0 ) { + fprintf( + stderr, + "ERROR - at offset %d - returned %d and error=%s\n", + (int) new, + rc, + strerror( errno ) + ); + } + rtems_test_assert( rc == 0 ); + --new; + } while (new > 0); +} + +void close_it(void) +{ + int rc; + + puts( "close(" FILE_NAME ") - OK " ); + rc = close( TestFd ); + rtems_test_assert( rc == 0 ); +} + +rtems_task Init( + rtems_task_argument argument +) +{ + int i; + puts( "\n\n*** TEST IMFS 01 ***" ); + + for (i=0 ; i +/* end of file */ diff --git a/testsuites/psxtests/psximfs01/psximfs01.doc b/testsuites/psxtests/psximfs01/psximfs01.doc new file mode 100644 index 0000000000..13125231a3 --- /dev/null +++ b/testsuites/psxtests/psximfs01/psximfs01.doc @@ -0,0 +1,35 @@ +# +# $Id$ +# +# 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. +# + +This file describes the directives and concepts tested by this test set. + +test set name: psximfs01 + +directives: + + + open + + close + + read + + write + + lseek + + ftruncate + +concepts: + ++ Create an IMFS instance with the smallest possible block size. This +ensures the maximum file size is relatively small. + ++ Create, write, and read a file of maximum size. + ++ Use ftruncate to shorten the file from the maximum size to 0. + ++ This should exercise much of the singly, doubly and triply indirect +block management code in the IMFS. diff --git a/testsuites/psxtests/psximfs01/psximfs01.scn b/testsuites/psxtests/psximfs01/psximfs01.scn new file mode 100644 index 0000000000..2d3b3877a4 --- /dev/null +++ b/testsuites/psxtests/psximfs01/psximfs01.scn @@ -0,0 +1,16 @@ +*** TEST IMFS 01 *** +open(biggie) - OK +write(biggie) - OK +Total written = 1280 +close(biggie) - OK + +open(biggie) - OK +read(biggie) - OK +File correctly read until ENOSPC returned + +close(biggie) - OK +open(biggie) - OK +Seek to end .. returned 1280 +lseek/ftruncate loop.. +close(biggie) - OK +*** END OF TEST IMFS 01 *** -- cgit v1.2.3