summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxmsgq04
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 15:21:43 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 15:21:43 +0000
commit6605d4dc991d44983f66d23a9bf95cffd55ff473 (patch)
tree0c35ad6946269e3bd2674207e3f54c3ac822c1bb /testsuites/psxtests/psxmsgq04
parent009-08-05 Chris Johns <chrisj@rtems.org> (diff)
downloadrtems-6605d4dc991d44983f66d23a9bf95cffd55ff473.tar.bz2
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.
Diffstat (limited to 'testsuites/psxtests/psxmsgq04')
-rw-r--r--testsuites/psxtests/psxmsgq04/init.c40
-rw-r--r--testsuites/psxtests/psxmsgq04/psxmsgq04.doc9
-rw-r--r--testsuites/psxtests/psxmsgq04/psxmsgq04.scn9
3 files changed, 49 insertions, 9 deletions
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 ***