summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxmsgq01/init.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-28 13:46:03 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-28 13:46:03 +0000
commit5d8b8eb1f53bc813a5cc631538c4968798cb2004 (patch)
tree24833e4d4de990163f6c238a729e78bb40101010 /testsuites/psxtests/psxmsgq01/init.c
parent2009-07-28 Santosh G Vattam <vattam.santosh@gmail.com> (diff)
downloadrtems-5d8b8eb1f53bc813a5cc631538c4968798cb2004.tar.bz2
2009-07-28 Santosh G Vattam <vattam.santosh@gmail.com>
* psxmsgq01/init.c, psxmsgq01/psxmsgq01.scn: Add tests for various mq_timedreceive and mq_timedsend conditions. In particular test timeout in the past.
Diffstat (limited to 'testsuites/psxtests/psxmsgq01/init.c')
-rw-r--r--testsuites/psxtests/psxmsgq01/init.c99
1 files changed, 98 insertions, 1 deletions
diff --git a/testsuites/psxtests/psxmsgq01/init.c b/testsuites/psxtests/psxmsgq01/init.c
index ad132a0e43..8297bf46fb 100644
--- a/testsuites/psxtests/psxmsgq01/init.c
+++ b/testsuites/psxtests/psxmsgq01/init.c
@@ -1132,6 +1132,101 @@ void validate_mq_setattr()
}
}
+void verify_timedout_mq_timedreceive(
+ char *task_name,
+ int que,
+ int is_blocking
+)
+{
+ char message[ 100 ];
+ unsigned int priority;
+ struct timespec tm;
+ struct timeval tv1, tv2, tv3;
+ struct timezone tz1, tz2;
+ int status;
+
+ printf(
+ "Init: %s verify_timedout_mq_timedreceive - on queue %s ",
+ task_name,
+ Test_q[que].name
+ );
+
+ gettimeofday( &tv1, &tz1 );
+ tm.tv_sec = tv1.tv_sec - 1;
+ tm.tv_nsec = tv1.tv_usec * 1000;
+
+ status = mq_timedreceive( Test_q[ que ].mq, message, 100, &priority, &tm );
+
+ gettimeofday( &tv2, &tz2 );
+ tv3.tv_sec = tv2.tv_sec - tv1.tv_sec;
+ tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
+
+ fatal_int_service_status( status, -1, "mq_timedreceive status");
+
+ printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
+
+}
+
+void verify_mq_receive()
+{
+ int que;
+
+ Start_Test( "mq_timedout_receive" );
+
+ for( que = RW_QUEUE; que < CLOSED; que++ ) {
+ if (( que == BLOCKING ) || ( que == DEFAULT_RW ))
+ break;
+ else
+ verify_timedout_mq_timedreceive( "Init:", que, 0 );
+ }
+}
+
+void verify_timedout_mq_timedsend(
+ int que,
+ int is_blocking
+)
+{
+ struct timespec timeout;
+ struct timeval tv1, tv2, tv3;
+ struct timezone tz1, tz2;
+ int len;
+ int status;
+ char *msg;
+
+ printf( "Init: verify_timedout_mq_timedsend - on queue %s ", Test_q[que].name);
+ len = Predefined_Msgs[MAXMSG].size;
+ msg = Predefined_Msgs[MAXMSG].msg;
+
+ gettimeofday( &tv1, &tz1 );
+ timeout.tv_sec = tv1.tv_sec - 1;
+ timeout.tv_nsec = tv1.tv_usec * 1000;
+
+ status = mq_timedsend( Test_q[que].mq, msg, len , 0, &timeout );
+
+ gettimeofday( &tv2, &tz2 );
+ tv3.tv_sec = tv2.tv_sec - tv1.tv_sec;
+ tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
+
+ printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
+
+ if ( que == DEFAULT_RW )
+ Test_q[que].count++;
+}
+
+void verify_mq_send()
+{
+ int que;
+
+ Start_Test( "verify_timedout_mq_timedsend" );
+
+ for( que = RW_QUEUE; que < CLOSED; que++ ) {
+ if ( que == BLOCKING )
+ verify_timedout_mq_timedsend( que, 1 );
+ else
+ verify_timedout_mq_timedsend( que, 0 );
+ }
+}
+
void *POSIX_Init(
void *argument
)
@@ -1152,7 +1247,9 @@ void *POSIX_Init(
verify_open_functionality();
verify_notify();
verify_with_threads();
-
+ verify_mq_receive();
+ verify_mq_send();
+
puts( "*** END OF POSIX MESSAGE QUEUE TEST ***" );
rtems_test_exit( 0 );