2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com>

* psxmsgq04/init.c, psxmsgq04/psxmsgq04.scn: Tinker with test to ensure
	that it hits both failing to allocate memory for the message queue
	name and message buffers.
This commit is contained in:
Joel Sherrill
2009-08-06 19:24:38 +00:00
parent 0d214a7c29
commit c005d41297
3 changed files with 56 additions and 15 deletions

View File

@@ -1,3 +1,9 @@
2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com>
* psxmsgq04/init.c, psxmsgq04/psxmsgq04.scn: Tinker with test to ensure
that it hits both failing to allocate memory for the message queue
name and message buffers.
2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com> 2009-08-06 Joel Sherrill <joel.sherrill@OARcorp.com>
* psxintrcritical01/init.c: Lower microseconds per tick so tests run * psxintrcritical01/init.c: Lower microseconds per tick so tests run

View File

@@ -27,8 +27,12 @@ void *POSIX_Init(
struct mq_attr attr; struct mq_attr attr;
mqd_t Queue, second_Queue; mqd_t Queue, second_Queue;
int sc; int sc;
Heap_Information_block start;
Heap_Information_block info; Heap_Information_block info;
size_t to_alloc;
void *alloced;
bool sb; bool sb;
const char *name;
puts( "\n\n*** POSIX MESSAGE QUEUE TEST 4 ***" ); puts( "\n\n*** POSIX MESSAGE QUEUE TEST 4 ***" );
@@ -60,27 +64,54 @@ void *POSIX_Init(
perror( "mq_close failed" ); perror( "mq_close failed" );
assert( sc == 0 ); assert( sc == 0 );
sb = rtems_workspace_get_information( &start );
assert( start.Free.number == 1 );
to_alloc = start.Free.largest;
/* find the largest we can actually allocate */
while ( 1 ) {
sb = rtems_workspace_allocate( to_alloc, &alloced );
if ( sb )
break;
to_alloc -= 4;
}
rtems_workspace_free( alloced );
/*
* Now do the test
*/
puts( "Init - Memory allocation error test" ); puts( "Init - Memory allocation error test" );
sb = rtems_workspace_get_information( &info ); sb = rtems_workspace_get_information( &info );
attr.mq_msgsize = info.Free.largest; attr.mq_maxmsg = 1;
attr.mq_msgsize = 200;
name = Get_Longest_Name();
while ( attr.mq_msgsize > 0 ) { while ( attr.mq_msgsize > 0 ) {
second_Queue = mq_open("second_queue",O_CREAT | O_RDWR, 0x777, &attr ); sb = rtems_workspace_allocate( to_alloc, &alloced );
assert( sb );
second_Queue = mq_open(name,O_CREAT | O_RDWR, 0x777, &attr );
/* free the memory we snagged, then check the status */
rtems_workspace_free( alloced );
if ( second_Queue != (-1) ) if ( second_Queue != (-1) )
break; break;
attr.mq_msgsize -= 48;
/* attr.mq_msgsize -= 48; */
to_alloc -= 4;
} }
if ( second_Queue == (-1) ) { if ( second_Queue == -1 )
perror( "mq_open failed" ); rtems_test_exit(0);
assert( second_Queue != (-1) );
}
puts( "Init - Message Queue created" ); puts( "Init - Message Queue created" );
puts( "Init - Unlink message queue" ); puts( "Init - Unlink message queue" );
sc = mq_unlink( "second_queue" ); sc = mq_unlink( name );
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_unlink failed" ); perror( "mq_unlink failed" );
assert( sc == 0 ); assert( sc == 0 );
@@ -90,6 +121,7 @@ void *POSIX_Init(
if ( sc != 0 ) if ( sc != 0 )
perror( "mq_close failed" ); perror( "mq_close failed" );
assert( sc == 0 ); assert( sc == 0 );
puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" ); puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" );
rtems_test_exit( 0 ); rtems_test_exit( 0 );
@@ -103,6 +135,10 @@ void *POSIX_Init(
#define CONFIGURE_POSIX_INIT_THREAD_TABLE #define CONFIGURE_POSIX_INIT_THREAD_TABLE
/* account for message buffers and string names */
#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1, sizeof(int))
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1 #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS 2 #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS 2
@@ -111,4 +147,3 @@ void *POSIX_Init(
#define CONFIGURE_INIT #define CONFIGURE_INIT
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */

View File

@@ -1,8 +1,8 @@
*** POSIX MESSAGE QUEUE TEST 4 *** *** POSIX MESSAGE QUEUE TEST 4 ***
Init - Open message queue Init - Open message queue instance 1
Init - Open message queue instance 2 - FAIL - ENFILE Init - Open message queue instance 2 - FAIL - ENFILE
Init - Unlink message queue Init - Unlink message queue instance 1
Init - Close message queue Init - Close message queue instance 1
Init - Memory allocation error test Init - Memory allocation error test
Init - Message Queue created Init - Message Queue created
Init - Unlink message queue Init - Unlink message queue