From 6605d4dc991d44983f66d23a9bf95cffd55ff473 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 5 Aug 2009 15:21:43 +0000 Subject: 2009-08-05 Santosh G Vattam * Makefile.am, psxmsgq04/init.c, psxmsgq04/psxmsgq04.doc, psxmsgq04/psxmsgq04.scn: Exercise running out of memory while allocating the message buffers for a POSIX message queue. --- testsuites/psxtests/psxmsgq04/init.c | 40 ++++++++++++++++++++++++++--- testsuites/psxtests/psxmsgq04/psxmsgq04.doc | 9 +++---- testsuites/psxtests/psxmsgq04/psxmsgq04.scn | 9 +++++++ 3 files changed, 49 insertions(+), 9 deletions(-) (limited to 'testsuites/psxtests/psxmsgq04') diff --git a/testsuites/psxtests/psxmsgq04/init.c b/testsuites/psxtests/psxmsgq04/init.c index 21dca33049..958bd52daa 100644 --- a/testsuites/psxtests/psxmsgq04/init.c +++ b/testsuites/psxtests/psxmsgq04/init.c @@ -24,13 +24,15 @@ void *POSIX_Init( void *argument ) { - struct mq_attr attr; - mqd_t Queue; - int sc; + struct mq_attr attr; + mqd_t Queue, second_Queue; + int sc; + Heap_Information_block info; + bool sb; puts( "\n\n*** POSIX MESSAGE QUEUE TEST 4 ***" ); - attr.mq_maxmsg = 1; + attr.mq_maxmsg = 1; attr.mq_msgsize = sizeof(int); puts( "Init - Open message queue" ); @@ -51,6 +53,36 @@ void *POSIX_Init( perror( "mq_close failed" ); assert( sc == 0 ); + puts( "Init - Memory allocation error test" ); + + sb = rtems_workspace_get_information( &info ); + + attr.mq_msgsize = info.Free.largest; + + while ( attr.mq_msgsize > 0 ) { + second_Queue = mq_open("second_queue",O_CREAT | O_RDWR, 0x777, &attr ); + if ( second_Queue!=(-1) ) + break; + attr.mq_msgsize -= 48; + } + + if ( second_Queue == (-1) ) { + perror( "mq_open failed" ); + assert( second_Queue != (-1) ); + } + + puts( "Init - Message Queue created" ); + puts( "Init - Unlink message queue" ); + sc = mq_unlink( "second_queue" ); + if ( sc != 0 ) + perror( "mq_unlink failed" ); + assert( sc==0 ); + + puts( "Init - Close message queue" ); + sc = mq_close( second_Queue ); + if ( sc !=0 ) + perror( "mq_close failed" ); + assert( sc == 0 ); puts( "*** END OF POSIX MESSAGE QUEUE TEST 4 ***" ); rtems_test_exit( 0 ); diff --git a/testsuites/psxtests/psxmsgq04/psxmsgq04.doc b/testsuites/psxtests/psxmsgq04/psxmsgq04.doc index 9fed044849..c913a5b3d2 100644 --- a/testsuites/psxtests/psxmsgq04/psxmsgq04.doc +++ b/testsuites/psxtests/psxmsgq04/psxmsgq04.doc @@ -16,11 +16,10 @@ test set name: psxmsgq04 directives: mq_open - mq_send + mq_unlink + mq_close concepts: -+ Ensure that an error is returned when performing a blocking mq_send - from an Interrupt Service Routine. This condition is beyond the - POSIX Standard because they do not discuss interrupt processing and - what operations are allowed. ++ Ensure that the situation where we do not have enough Workspace memory + left to allocate the message buffers is properly handled. diff --git a/testsuites/psxtests/psxmsgq04/psxmsgq04.scn b/testsuites/psxtests/psxmsgq04/psxmsgq04.scn index e69de29bb2..7992f4403d 100644 --- a/testsuites/psxtests/psxmsgq04/psxmsgq04.scn +++ b/testsuites/psxtests/psxmsgq04/psxmsgq04.scn @@ -0,0 +1,9 @@ +*** POSIX MESSAGE QUEUE TEST 4 *** +Init - Open message queue +Init - Unlink message queue +Init - Close message queue +Init - Memory allocation error test +Init - Message Queue created +Init - Unlink message queue +Init - Close message queue +*** END OF POSIX MESSAGE QUEUE TEST 4 *** -- cgit v1.2.3