forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -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>
|
2010-07-27 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
* psxobj01/Makefile.am, psxobj01/init.c, psxobj01/psxobj01.scn: Add
|
* psxobj01/Makefile.am, psxobj01/init.c, psxobj01/psxobj01.scn: Add
|
||||||
|
|||||||
@@ -138,6 +138,57 @@ void truncate_helper(void)
|
|||||||
} while (new > 0);
|
} 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)
|
void close_it(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@@ -147,11 +198,25 @@ void close_it(void)
|
|||||||
rtems_test_assert( rc == 0 );
|
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 Init(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
void *alloc_ptr = (void *)0;
|
||||||
|
Heap_Information_block Info;
|
||||||
|
|
||||||
puts( "\n\n*** TEST IMFS 01 ***" );
|
puts( "\n\n*** TEST IMFS 01 ***" );
|
||||||
|
|
||||||
for (i=0 ; i<sizeof(Buffer) ; i++ )
|
for (i=0 ; i<sizeof(Buffer) ; i++ )
|
||||||
@@ -169,8 +234,22 @@ rtems_task Init(
|
|||||||
|
|
||||||
open_it(false, false);
|
open_it(false, false);
|
||||||
truncate_helper();
|
truncate_helper();
|
||||||
close_it();
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 ***" );
|
puts( "*** END OF TEST IMFS 01 ***" );
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ directives:
|
|||||||
+ write
|
+ write
|
||||||
+ lseek
|
+ lseek
|
||||||
+ ftruncate
|
+ ftruncate
|
||||||
|
+ unlink
|
||||||
|
|
||||||
concepts:
|
concepts:
|
||||||
|
|
||||||
@@ -33,3 +34,5 @@ ensures the maximum file size is relatively small.
|
|||||||
|
|
||||||
+ This should exercise much of the singly, doubly and triply indirect
|
+ This should exercise much of the singly, doubly and triply indirect
|
||||||
block management code in the IMFS.
|
block management code in the IMFS.
|
||||||
|
|
||||||
|
+ Exercise unlink, and hence IMFS_memfile_remove
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ close(biggie) - OK
|
|||||||
open(biggie) - OK
|
open(biggie) - OK
|
||||||
Seek to end .. returned 1280
|
Seek to end .. returned 1280
|
||||||
lseek/ftruncate loop..
|
lseek/ftruncate loop..
|
||||||
|
Seek to end .. returned 1
|
||||||
|
lseek/ftruncate loop..
|
||||||
close(biggie) - OK
|
close(biggie) - OK
|
||||||
|
unlink(biggie) - OK
|
||||||
*** END OF TEST IMFS 01 ***
|
*** END OF TEST IMFS 01 ***
|
||||||
|
|||||||
Reference in New Issue
Block a user