summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-29 22:35:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-29 22:35:36 +0000
commitbed8f3ea29d0bae1f926e84b9983ef5ff022e342 (patch)
treedd26c540bc407edb5fc074ce53836ca52e1a09a6 /testsuites/psxtests
parent2010-07-29 Bharath Suri <bharath.s.jois@gmail.com> (diff)
downloadrtems-bed8f3ea29d0bae1f926e84b9983ef5ff022e342.tar.bz2
2010-07-29 Bharath Suri <bharath.s.jois@gmail.com>
PR 1633/testing * psximfs01/init.c, psximfs01/psximfs01.scn, psximfs01/psximfs01.doc: New cases to exercise IMFS_memfile_remove.
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/ChangeLog7
-rw-r--r--testsuites/psxtests/psximfs01/init.c81
-rw-r--r--testsuites/psxtests/psximfs01/psximfs01.doc3
-rw-r--r--testsuites/psxtests/psximfs01/psximfs01.scn3
4 files changed, 93 insertions, 1 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index 4aaf5e4324..584d178b29 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-29 Bharath Suri <bharath.s.jois@gmail.com>
+
+ PR 1633/testing
+ * psximfs01/init.c, psximfs01/psximfs01.scn,
+ psximfs01/psximfs01.doc: New cases to exercise
+ IMFS_memfile_remove.
+
2010-07-27 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxobj01/Makefile.am, psxobj01/init.c, psxobj01/psxobj01.scn: Add
diff --git a/testsuites/psxtests/psximfs01/init.c b/testsuites/psxtests/psximfs01/init.c
index ce1c7c5669..a70cd8371b 100644
--- a/testsuites/psxtests/psximfs01/init.c
+++ b/testsuites/psxtests/psximfs01/init.c
@@ -138,6 +138,57 @@ void truncate_helper(void)
} while (new > 0);
}
+void extend_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 == 1 );
+
+ /*
+ * test case to ftruncate a file to a length > its size
+ */
+
+ rc = ftruncate( TestFd, 2 );
+ rtems_test_assert( rc == 0 );
+
+ puts( "lseek/ftruncate loop.." );
+ new = position;
+ do {
+ sc = lseek( TestFd, new, SEEK_SET );
+ if( sc == -1 ) {
+ if( errno == ENOSPC ) {
+ break;
+ }
+ else {
+ rtems_test_assert( 0 );
+ }
+ }
+
+ rc = ftruncate( TestFd, new );
+ if ( rc != 0 ) {
+ if( errno != ENOSPC ) {
+ fprintf(
+ stderr,
+ "ERROR - at offset %d - returned %d and error=%s\n",
+ (int) new,
+ rc,
+ strerror( errno )
+ );
+ }
+ else {
+ break;
+ }
+ }
+ rtems_test_assert( rc == 0 );
+ ++new;
+ } while ( 1 );
+}
+
void close_it(void)
{
int rc;
@@ -147,11 +198,25 @@ void close_it(void)
rtems_test_assert( rc == 0 );
}
+void unlink_it(void)
+{
+ int rc;
+
+ puts( "unlink(" FILE_NAME ") - OK" );
+ rc = unlink( FILE_NAME );
+ rtems_test_assert( rc == 0 );
+}
+
+extern Heap_Control *RTEMS_Malloc_Heap;
+
rtems_task Init(
rtems_task_argument argument
)
{
int i;
+ void *alloc_ptr = (void *)0;
+ Heap_Information_block Info;
+
puts( "\n\n*** TEST IMFS 01 ***" );
for (i=0 ; i<sizeof(Buffer) ; i++ )
@@ -169,8 +234,22 @@ rtems_task Init(
open_it(false, false);
truncate_helper();
+
+ /*
+ * Allocate the heap, so that extend cannot be successful
+ */
+ _Heap_Get_information( RTEMS_Malloc_Heap, &Info );
+ alloc_ptr = malloc( Info.Free.largest-4 );
+
+ extend_helper();
+
+ /*
+ * free the allocated heap memory
+ */
+ free(alloc_ptr);
+
close_it();
-
+ unlink_it();
puts( "*** END OF TEST IMFS 01 ***" );
diff --git a/testsuites/psxtests/psximfs01/psximfs01.doc b/testsuites/psxtests/psximfs01/psximfs01.doc
index 13125231a3..703c57b3c0 100644
--- a/testsuites/psxtests/psximfs01/psximfs01.doc
+++ b/testsuites/psxtests/psximfs01/psximfs01.doc
@@ -21,6 +21,7 @@ directives:
+ write
+ lseek
+ ftruncate
+ + unlink
concepts:
@@ -33,3 +34,5 @@ ensures the maximum file size is relatively small.
+ This should exercise much of the singly, doubly and triply indirect
block management code in the IMFS.
+
++ Exercise unlink, and hence IMFS_memfile_remove
diff --git a/testsuites/psxtests/psximfs01/psximfs01.scn b/testsuites/psxtests/psximfs01/psximfs01.scn
index 2d3b3877a4..0b516f8f25 100644
--- a/testsuites/psxtests/psximfs01/psximfs01.scn
+++ b/testsuites/psxtests/psximfs01/psximfs01.scn
@@ -12,5 +12,8 @@ close(biggie) - OK
open(biggie) - OK
Seek to end .. returned 1280
lseek/ftruncate loop..
+Seek to end .. returned 1
+lseek/ftruncate loop..
close(biggie) - OK
+unlink(biggie) - OK
*** END OF TEST IMFS 01 ***