summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2008-01-18 16:33:35 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2008-01-18 16:33:35 +0000
commit0e4232bbd6d49e16c2890e9dd9652eabade607a2 (patch)
treede8254eaaa40106797c25f87617cfaa690bd7f7e /testsuites/psxtests
parent2008-01-18 Jennifer Averett <jennifer.averett@OARcorp.com> (diff)
downloadrtems-0e4232bbd6d49e16c2890e9dd9652eabade607a2.tar.bz2
2008-01-18 Jennifer Averett <jennifer.averett@OARcorp.com>
* psx01/init.c, psxmsgq01/init.c, psxtimer01/psxtimer.c, psxtimer01/psxtimer01.scn, psxtimer02/psxtimer.c:
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/ChangeLog5
-rw-r--r--testsuites/psxtests/psx01/init.c14
-rw-r--r--testsuites/psxtests/psxmsgq01/init.c10
-rw-r--r--testsuites/psxtests/psxtimer01/psxtimer.c146
-rw-r--r--testsuites/psxtests/psxtimer01/psxtimer01.scn3
-rw-r--r--testsuites/psxtests/psxtimer02/psxtimer.c6
6 files changed, 139 insertions, 45 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog
index 9220786d68..4ede460e1f 100644
--- a/testsuites/psxtests/ChangeLog
+++ b/testsuites/psxtests/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-18 Jennifer Averett <jennifer.averett@OARcorp.com>
+
+ * psx01/init.c, psxmsgq01/init.c, psxtimer01/psxtimer.c,
+ psxtimer01/psxtimer01.scn, psxtimer02/psxtimer.c:
+
2007-12-20 Joel Sherrill <joel.sherrill@oarcorp.com>
* psxsignal01/.cvsignore, psxualarm/.cvsignore: New files.
diff --git a/testsuites/psxtests/psx01/init.c b/testsuites/psxtests/psx01/init.c
index c503260748..acd1986100 100644
--- a/testsuites/psxtests/psx01/init.c
+++ b/testsuites/psxtests/psx01/init.c
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -52,8 +52,13 @@ void *POSIX_Init(
/* error cases in clock_gettime and clock_settime */
+ puts( "Init: clock_gettime - EINVAL (NULL timespec)" );
+ status = clock_gettime( CLOCK_REALTIME, NULL );
+ assert( status == -1 );
+ assert( errno == EINVAL );
+
puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
- status = clock_settime( -1, &tv );
+ status = clock_gettime( -1, &tv );
assert( status == -1 );
assert( errno == EINVAL );
@@ -102,8 +107,11 @@ void *POSIX_Init(
remaining = sleep( 3 );
assert( !remaining );
-
+
/* print new times to make sure it has changed and we can get the realtime */
+ status = clock_gettime( CLOCK_PROCESS_CPUTIME, &tv );
+ assert( !status );
+ printf("Time since boot: (%d, %d)\n", tv.tv_sec,tv.tv_nsec );
status = clock_gettime( CLOCK_REALTIME, &tv );
assert( !status );
diff --git a/testsuites/psxtests/psxmsgq01/init.c b/testsuites/psxtests/psxmsgq01/init.c
index b152ffc6fb..8922173018 100644
--- a/testsuites/psxtests/psxmsgq01/init.c
+++ b/testsuites/psxtests/psxmsgq01/init.c
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -43,7 +43,7 @@ typedef struct {
int count;
} Test_queue_type;
-Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES ] =
+Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES + 1 ] =
{
{ 0, 0, "Qread", ( O_CREAT | O_RDONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
{ 0, 1, "Qwrite", ( O_CREAT | O_WRONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
@@ -51,6 +51,7 @@ Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES ] =
{ 0, 3, "Qblock", ( O_CREAT | O_RDWR ) , MAXMSG, MSGSIZE, 0 },
{ 0, 4, "Qdefault", ( O_CREAT | O_RDWR ) , 10, 16, 0 },
{ 0, 5, "mq6", ( O_CREAT | O_WRONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
+ { 0, 6, "Qblock", ( O_RDWR ) , MAXMSG, MSGSIZE, 0 },
};
#define RW_NAME Test_q[ RW_QUEUE ].name
@@ -130,7 +131,7 @@ void open_test_queues()
puts( "Init: Open Test Queues" );
- for( que = 0; que < NUMBER_OF_TEST_QUEUES; que++ ) {
+ for( que = 0; que < NUMBER_OF_TEST_QUEUES+1; que++ ) {
tq = &Test_q[ que ];
if ( que == DEFAULT_RW)
@@ -141,6 +142,8 @@ void open_test_queues()
assert( Test_q[que].mq != (-1) );
}
+ status = mq_close( Test_q[NUMBER_OF_TEST_QUEUES].mq );
+ fatal_posix_service_status( status, 0, "mq_close duplicate message queue");
status = mq_close( Test_q[CLOSED].mq );
fatal_posix_service_status( status, 0, "mq_close message queue");
status = mq_unlink( CLOSED_NAME );
@@ -949,7 +952,6 @@ void verify_notify()
/*
* XXX setup notification
*/
-
printf( "_____mq_notify - notify when %s gets a message\n",RW_NAME);
status = mq_notify( Test_q[RW_QUEUE].mq, &event );
fatal_posix_service_status( status, 0, "mq_notify valid status");
diff --git a/testsuites/psxtests/psxtimer01/psxtimer.c b/testsuites/psxtests/psxtimer01/psxtimer.c
index f4d58a2d40..bfe4e278ae 100644
--- a/testsuites/psxtests/psxtimer01/psxtimer.c
+++ b/testsuites/psxtests/psxtimer01/psxtimer.c
@@ -27,13 +27,14 @@
#include <sched.h> /* schedule facilities */
#include <time.h> /* time facilities */
#include <stdio.h> /* console facilities */
-
+#include <rtems/score/timespec.h>
/* temporal parameters of a task */
struct periodic_params {
struct timespec period;
+ int count; /* Number of iterations to run */
int signo; /* signal number */
int id; /* task identification */
};
@@ -46,25 +47,39 @@ struct shared_data {
pthread_mutex_t mutex;
pthread_cond_t sync;
int updated;
- int x;
};
struct shared_data data;
+void StopTimer(
+ timer_t timer_id,
+ struct itimerspec *timerdata
+)
+{
+ timerdata->it_value.tv_sec = 0;
+ timerdata->it_value.tv_nsec = 0;
+ if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,timerdata,NULL) == -1) {
+ perror ("Error in timer setting\n");
+ pthread_exit ((void *) -1);
+ }
+}
+
/* task A */
-
void * task_a (void *arg)
{
struct timespec my_period;
int my_sig, received_sig;
struct itimerspec timerdata;
+ struct itimerspec timergetdata;
timer_t timer_id;
time_t clock;
struct sigevent event;
sigset_t set;
+ struct periodic_params *params;
- my_period = ((struct periodic_params*) arg)->period;
- my_sig = ((struct periodic_params*) arg)->signo;
+ params = arg;
+ my_period = params->period;
+ my_sig = params->signo;
/* timer create */
event.sigev_notify = SIGEV_SIGNAL;
@@ -82,18 +97,34 @@ void * task_a (void *arg)
/* set the timer in periodic mode */
timerdata.it_interval = my_period;
timerdata.it_value = my_period;
- if (timer_settime(timer_id, 0, &timerdata, NULL) == -1) {
+ if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,&timerdata,&timergetdata) == -1) {
perror ("Error in timer setting\n");
pthread_exit ((void *) -1);
}
+ printf(
+ "task A: timer_settime - value=%d:%d interval=%d:%d\n",
+ timergetdata.it_value.tv_sec, timergetdata.it_value.tv_nsec,
+ timergetdata.it_interval.tv_sec, timergetdata.it_interval.tv_nsec
+ );
+
/* periodic activity */
while(1) {
if (sigwait(&set,&received_sig) == -1) {
perror ("Error in sigwait\n");
}
+ if (timer_gettime(timer_id, &timerdata) == -1) {
+ perror ("Error in timer_gettime\n");
+ pthread_exit ((void *) -1);
+ }
+ if (! _Timespec_Equal_to( &timerdata.it_value, &my_period )){
+ perror ("Error in Task A timer_gettime\n");
+ }
clock = time(NULL);
- printf("Executing task A %s", ctime(&clock));
+ printf("Executing task A with count = %2i %s", params->count, ctime(&clock));
+ params->count--;
+ if (params->count == 0)
+ StopTimer(timer_id, &timerdata);
}
return NULL;
}
@@ -109,13 +140,12 @@ void * task_b (void *arg)
time_t clock;
struct sigevent event;
sigset_t set;
+ struct periodic_params *params;
- int x; /* value to be copied to the shared datum */
+ params = arg;
+ my_period = params->period;
+ my_sig = params->signo;
- my_period = ((struct periodic_params*) arg)->period;
- my_sig = ((struct periodic_params*) arg)->signo;
-
- x = 1;
/* timer create */
event.sigev_notify = SIGEV_SIGNAL;
@@ -132,11 +162,12 @@ void * task_b (void *arg)
/* set the timer in periodic mode */
timerdata.it_interval = my_period;
- timerdata.it_value = my_period;
- if (timer_settime(timer_id, 0, &timerdata, NULL) == -1) {
+ timerdata.it_value = _TOD_Now;
+ _Timespec_Add_to( &timerdata.it_value, &my_period);
+ if (timer_settime(timer_id,TIMER_ABSTIME,&timerdata,NULL) == -1) {
perror ("Error in timer setting\n");
pthread_exit ((void *) -1);
- }
+ }
/* periodic activity */
while(1) {
@@ -144,14 +175,26 @@ void * task_b (void *arg)
perror ("Error in sigwait\n");
pthread_exit ((void *) -1);
}
+
+ if (timer_gettime(timer_id, &timerdata) == -1) {
+ perror ("Error in timer_gettime\n");
+ pthread_exit ((void *) -1);
+ }
+ if (! _Timespec_Equal_to( &timerdata.it_value, &my_period) ){
+ perror ("Error in Task B timer_gettime\n");
+ }
+
pthread_mutex_lock (&data.mutex);
clock = time(NULL);
- printf("Executing task B with x = %i %s", x, ctime(&clock));
- data.x = x;
+ printf("Executing task B with count = %2i %s\n",
+ params->count, ctime(&clock)
+ );
data.updated = TRUE;
pthread_cond_signal (&data.sync);
pthread_mutex_unlock (&data.mutex);
- x++;
+ params->count--;
+ if (params->count == 0)
+ StopTimer(timer_id, &timerdata);
}
return NULL;
}
@@ -160,20 +203,20 @@ void * task_b (void *arg)
void * task_c (void *arg)
{
+ int count;
struct timespec my_period;
int my_sig, received_sig;
struct itimerspec timerdata;
+ struct itimerspec timergetdata;
timer_t timer_id;
time_t clock;
struct sigevent event;
sigset_t set;
+ struct periodic_params *params;
- int x; /* value to be copied to the shared datum */
-
- my_period = ((struct periodic_params*) arg)->period;
- my_sig = ((struct periodic_params*) arg)->signo;
-
- x = 0;
+ params = arg;
+ my_period = params->period;
+ my_sig = params->signo;
/* timer create */
event.sigev_notify = SIGEV_SIGNAL;
@@ -191,30 +234,58 @@ void * task_c (void *arg)
/* set the timer in periodic mode */
timerdata.it_interval = my_period;
timerdata.it_value = my_period;
- if (timer_settime(timer_id, 0, &timerdata, NULL) == -1) {
+ if (timer_settime(timer_id,POSIX_TIMER_RELATIVE,&timerdata,NULL) == -1) {
perror ("Error in timer setting\n");
pthread_exit ((void *) -1);
}
/* periodic activity */
- while(1) {
+ for (count=0 ; ; count++) {
if (sigwait(&set,&received_sig) == -1) {
perror ("Error in sigwait\n");
pthread_exit ((void *) -1);
}
+ if (timer_gettime(timer_id, &timerdata) == -1) {
+ perror ("Error in timer_gettime\n");
+ pthread_exit ((void *) -1);
+ }
+ if (! _Timespec_Equal_to( &timerdata.it_value, &my_period) ){
+ perror ("Error in Task C timer_gettime\n");
+ }
pthread_mutex_lock (&data.mutex);
while (data.updated == FALSE) {
pthread_cond_wait (&data.sync,&data.mutex);
}
- x = data.x;
clock = time(NULL);
- printf("Executing task C with x = %i %s", x, ctime(&clock));
+ printf("Executing task C with count = %2i %s\n",
+ params->count, ctime(&clock)
+ );
+
+ if ( count && (count % 5) == 0 ) {
+ int overruns = 0;
+ sleep(1);
+ overruns = timer_getoverrun( timer_id );
+ printf( "task C: timer_getoverrun - overruns=%d\n", overruns );
+
+ if (timer_gettime(timer_id, &timergetdata) == -1) {
+ perror ("Error in timer setting\n");
+ pthread_exit ((void *) -1);
+ }
+ printf(
+ "task C: timer_gettime - %d:%d remaining from %d:%d\n",
+ timergetdata.it_value.tv_sec, timergetdata.it_value.tv_nsec,
+ timergetdata.it_interval.tv_sec, timergetdata.it_interval.tv_nsec
+ );
+ }
+
pthread_mutex_unlock (&data.mutex);
+ params->count--;
+ if (params->count == 0)
+ StopTimer(timer_id, &timerdata);
}
return NULL;
}
-
/* main */
void *POSIX_Init (
@@ -234,7 +305,6 @@ void *POSIX_Init (
puts( "\n\n*** POSIX Timers Test 01 ***" );
data.updated = FALSE;
- data.x = 0;
/* mask signal */
sigemptyset (&set);
@@ -267,21 +337,18 @@ void *POSIX_Init (
}
/* set explicit schedule for every task */
- if (pthread_attr_setinheritsched (&attr,
- PTHREAD_EXPLICIT_SCHED) != 0) {
+ if (pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED) != 0) {
perror("Error in attribute inheritsched\n");
}
/* set task independent (join will not use) */
- if (pthread_attr_setdetachstate (&attr,
- PTHREAD_CREATE_DETACHED) != 0) {
+ if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0) {
perror ("Error in attribute detachstate\n");
}
/* schedule policy POSIX_FIFO (priority preemtive and FIFO within the same
priority) */
- if (pthread_attr_setschedpolicy (&attr,
- SCHED_FIFO) != 0) {
+ if (pthread_attr_setschedpolicy (&attr, SCHED_FIFO) != 0) {
perror ("Error in attribute setschedpolicy\n");
}
@@ -296,6 +363,7 @@ void *POSIX_Init (
params_a.period.tv_sec = 1; /* seconds */
params_a.period.tv_nsec = 000000000; /* nanoseconds */
+ params_a.count = 20;
params_a.signo = SIGALRM;
if (pthread_create (&ta, &attr, task_a, &params_a) != 0 ) {
perror ("Error in thread create for task a\n");
@@ -311,6 +379,7 @@ void *POSIX_Init (
/* Temporal parameters (2 sec. periodicity) */
params_b.period.tv_sec = 2; /* seconds */
params_b.period.tv_nsec = 000000000; /* nanoseconds */
+ params_b.count = 10;
params_b.signo = SIGALRM;
if (pthread_create (&tb, &attr, task_b, &params_b) != 0) {
perror ("Error in thread create for task b\n");
@@ -326,14 +395,15 @@ void *POSIX_Init (
/* Temporal parameters (3 sec. periodicity) */
params_c.period.tv_sec = 3; /* seconds */
params_c.period.tv_nsec = 000000000; /* nanoseconds */
+ params_c.count = 6;
params_c.signo = SIGALRM;
if (pthread_create (&tc, &attr, task_c, &params_c) != 0) {
perror ("Error in thread create for task c\n");
}
- /* execute 20 seconds and finish */
- sleep (20);
+ /* execute 25 seconds and finish */
+ sleep (25);
puts( "*** END OF POSIX Timers Test 01 ***" );
rtems_test_exit (0);
}
diff --git a/testsuites/psxtests/psxtimer01/psxtimer01.scn b/testsuites/psxtests/psxtimer01/psxtimer01.scn
index 75e36852fa..bf8f73bca3 100644
--- a/testsuites/psxtests/psxtimer01/psxtimer01.scn
+++ b/testsuites/psxtests/psxtimer01/psxtimer01.scn
@@ -1,4 +1,5 @@
*** POSIX Timers Test 01 ***
+task A: timer_settime - value=0:0 interval=0:0
Executing task A Fri Jan 1 00:00:01 1988
Executing task B with x = 1 Fri Jan 1 00:00:02 1988
Executing task A Fri Jan 1 00:00:02 1988
@@ -32,6 +33,8 @@ Executing task A Fri Jan 1 00:00:17 1988
Executing task B with x = 9 Fri Jan 1 00:00:18 1988
Executing task C with x = 9 Fri Jan 1 00:00:18 1988
Executing task A Fri Jan 1 00:00:18 1988
+task C: timer_getoverrun - overruns=0
+task C: timer_gettime - 2:0 remaining from 3:0
Executing task A Fri Jan 1 00:00:19 1988
Executing task B with x = 10 Fri Jan 1 00:00:20 1988
*** END OF POSIX Timers Test 01 ***
diff --git a/testsuites/psxtests/psxtimer02/psxtimer.c b/testsuites/psxtests/psxtimer02/psxtimer.c
index 330d4abbe0..9a97e5ccdf 100644
--- a/testsuites/psxtests/psxtimer02/psxtimer.c
+++ b/testsuites/psxtests/psxtimer02/psxtimer.c
@@ -92,6 +92,12 @@ void *POSIX_Init (
status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #2" );
+ itimer.it_value = _TOD_Now;
+ itimer.it_value.tv_sec = itimer.it_value.tv_sec - 1;
+ puts( "timer_settime - bad itimer value - previous time - EINVAL" );
+ status = timer_settime( timer, TIMER_ABSTIME, &itimer, NULL );
+ fatal_posix_service_status_errno( status, EINVAL, "bad itimer value #3" );
+
itimer.it_value.tv_nsec = 0;
puts( "timer_settime - bad clock value - EINVAL" );
status = timer_settime( timer, 0x80, &itimer, NULL );