2009-08-05 Santosh G Vattam <vattam.santosh@gmail.com>

* 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.
This commit is contained in:
Joel Sherrill
2009-08-05 15:21:43 +00:00
parent 0d15414ed6
commit 6605d4dc99
5 changed files with 56 additions and 10 deletions

View File

@@ -1,3 +1,9 @@
2009-08-05 Santosh G Vattam <vattam.santosh@gmail.com>
* 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.
2009-08-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxsignal03/init.c, psxsignal03/psxsignal03.scn,

View File

@@ -8,7 +8,7 @@ SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psx10 psx11 psx12 psx13 psx14 psxautoinit01 psxautoinit02 psxbarrier01 \
psxcancel psxcleanup psxcond01 psxenosys psxkey01 psxkey02 psxkey03 \
psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 psxmutexattr01 psxobj01 \
psxrwlock01 psxsem01 psxsignal01 psxsignal02 psxsignal03 psxsignal03 \
psxrwlock01 psxsem01 psxsignal01 psxsignal02 psxsignal03 psxsignal04 \
psxspin01 psxspin02 psxsysconf psxtime psxtimer01 psxtimer02 psxualarm \
psxfatal01 psxfatal02 \
psxintrcritical01

View File

@@ -25,8 +25,10 @@ void *POSIX_Init(
)
{
struct mq_attr attr;
mqd_t Queue;
mqd_t Queue, second_Queue;
int sc;
Heap_Information_block info;
bool sb;
puts( "\n\n*** POSIX MESSAGE QUEUE TEST 4 ***" );
@@ -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 );

View File

@@ -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.

View File

@@ -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 ***