summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-14 17:44:15 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-14 17:44:15 +0000
commit6bc19a148a3ea5306c21f71a63b3c4b7d91077c9 (patch)
tree842a5c159e836ed7e4db607cfbbfc742d7bd36b3 /testsuites/sptests
parent2007-12-14 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-6bc19a148a3ea5306c21f71a63b3c4b7d91077c9.tar.bz2
2007-12-14 Joel Sherrill <joel.sherrill@OARcorp.com>
* sp09/screen07.c, sp09/sp09.scn: Add test for rtems_message_queue_broadcast for bad buffer and count pointers. * sp30/init.c, sp30/sp30.scn: Add test for initiating timer server with bad priority or initiating twice. * sp37/sp37.scn, sp37/system.h: Add test for rtems_clock_tick when it forces a dispatch. * sp37/init.c: New file.
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/ChangeLog10
-rw-r--r--testsuites/sptests/sp09/screen07.c17
-rw-r--r--testsuites/sptests/sp09/sp09.scn2
-rw-r--r--testsuites/sptests/sp30/init.c30
-rw-r--r--testsuites/sptests/sp30/sp30.scn7
-rw-r--r--testsuites/sptests/sp37/init.c273
-rw-r--r--testsuites/sptests/sp37/sp37.scn2
-rw-r--r--testsuites/sptests/sp37/system.h4
8 files changed, 342 insertions, 3 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog
index 88b6a2f8c2..f8c8b2e532 100644
--- a/testsuites/sptests/ChangeLog
+++ b/testsuites/sptests/ChangeLog
@@ -1,3 +1,13 @@
+2007-12-14 Joel Sherrill <joel.sherrill@OARcorp.com>
+
+ * sp09/screen07.c, sp09/sp09.scn: Add test for
+ rtems_message_queue_broadcast for bad buffer and count pointers.
+ * sp30/init.c, sp30/sp30.scn: Add test for initiating timer server
+ with bad priority or initiating twice.
+ * sp37/sp37.scn, sp37/system.h: Add test for rtems_clock_tick when
+ it forces a dispatch.
+ * sp37/init.c: New file.
+
2007-12-13 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add new tests for interrupt disable,
diff --git a/testsuites/sptests/sp09/screen07.c b/testsuites/sptests/sp09/screen07.c
index 71d160ed18..571108276b 100644
--- a/testsuites/sptests/sp09/screen07.c
+++ b/testsuites/sptests/sp09/screen07.c
@@ -241,4 +241,21 @@ void Screen7()
"rtems_message_queue_urgent with illegal id"
);
puts( "TA1 - rtems_message_queue_urgent - RTEMS_INVALID_ID" );
+
+ status = rtems_message_queue_broadcast( Queue_id[ 1 ], NULL, MESSAGE_SIZE, &count );
+ fatal_directive_status(
+ status,
+ RTEMS_INVALID_ADDRESS,
+ "rtems_message_queue_broadcast with NULL count"
+ );
+ puts( "TA1 - rtems_message_queue_broadcast - NULL buffer - RTEMS_INVALID_ADDRESS" );
+
+ status = rtems_message_queue_broadcast( Queue_id[ 1 ], buffer, MESSAGE_SIZE, NULL );
+ fatal_directive_status(
+ status,
+ RTEMS_INVALID_ADDRESS,
+ "rtems_message_queue_broadcast with NULL count"
+ );
+ puts( "TA1 - rtems_message_queue_broadcast - NULL count - RTEMS_INVALID_ADDRESS" );
+
}
diff --git a/testsuites/sptests/sp09/sp09.scn b/testsuites/sptests/sp09/sp09.scn
index 74a2a1c542..8690776a70 100644
--- a/testsuites/sptests/sp09/sp09.scn
+++ b/testsuites/sptests/sp09/sp09.scn
@@ -122,6 +122,8 @@ TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1 - RTEMS_SUCCESSFUL
TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1 - RTEMS_SUCCESSFUL
TA1 - rtems_message_queue_send - BUFFER 3 TO Q 1 - RTEMS_TOO_MANY
TA1 - rtems_message_queue_urgent - RTEMS_INVALID_ID
+TA1 - rtems_message_queue_broadcast - NULL buffer - RTEMS_INVALID_ADDRESS
+TA1 - rtems_message_queue_broadcast - NULL count - RTEMS_INVALID_ADDRESS
<pause - screen 8>
TA1 - rtems_message_queue_delete - Q 1 - RTEMS_SUCCESSFUL
TA1 - rtems_message_queue_create - Q 1 - 2 DEEP - RTEMS_SUCCESSFUL
diff --git a/testsuites/sptests/sp30/init.c b/testsuites/sptests/sp30/init.c
index 525ac4301e..03eda41dfa 100644
--- a/testsuites/sptests/sp30/init.c
+++ b/testsuites/sptests/sp30/init.c
@@ -39,6 +39,20 @@ rtems_task Init(
status = rtems_clock_set( &time );
directive_failed( status, "rtems_clock_set" );
+ /* initiate with bad priority */
+ puts( "timer_initiate_server -- INVALID_PRIORITY" );
+ status = rtems_timer_initiate_server(
+ 1000,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_ATTRIBUTES
+ );
+ fatal_directive_status(
+ status,
+ RTEMS_INVALID_PRIORITY,
+ "rtems_timer_initiate_server bad priority"
+ );
+
+ puts( "timer_initiate_server -- OK" );
status = rtems_timer_initiate_server(
RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
RTEMS_MINIMUM_STACK_SIZE,
@@ -46,6 +60,22 @@ rtems_task Init(
);
directive_failed( status, "rtems_timer_initiate_server" );
+ puts( "timer_initiate_server -- already started" );
+ status = rtems_timer_initiate_server(
+ RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_ATTRIBUTES
+ );
+ fatal_directive_status(
+ status,
+ RTEMS_INCORRECT_STATE,
+ "rtems_timer_initiate_server already started"
+ );
+
+ /*
+ * Create test tasks
+ */
+
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
diff --git a/testsuites/sptests/sp30/sp30.scn b/testsuites/sptests/sp30/sp30.scn
index 9a7ac23124..5950d890c7 100644
--- a/testsuites/sptests/sp30/sp30.scn
+++ b/testsuites/sptests/sp30/sp30.scn
@@ -1,16 +1,19 @@
*** TEST 30 ***
+timer_initiate_server -- INVALID_PRIORITY
+timer_initiate_server -- OK
+timer_initiate_server -- already started
TA1 - rtems_clock_get - 09:00:00 12/31/1988
TA2 - rtems_clock_get - 09:00:00 12/31/1988
TA3 - rtems_clock_get - 09:00:00 12/31/1988
TA1 - rtems_clock_get - 09:00:05 12/31/1988
TA2 - rtems_clock_get - 09:00:10 12/31/1988
TA1 - rtems_clock_get - 09:00:10 12/31/1988
-TA3 - rtems_clock_get - 09:00:15 12/31/1988
TA1 - rtems_clock_get - 09:00:15 12/31/1988
+TA3 - rtems_clock_get - 09:00:15 12/31/1988
TA2 - rtems_clock_get - 09:00:20 12/31/1988
TA1 - rtems_clock_get - 09:00:20 12/31/1988
TA1 - rtems_clock_get - 09:00:25 12/31/1988
-TA3 - rtems_clock_get - 09:00:30 12/31/1988
TA2 - rtems_clock_get - 09:00:30 12/31/1988
TA1 - rtems_clock_get - 09:00:30 12/31/1988
+TA3 - rtems_clock_get - 09:00:30 12/31/1988
*** END OF TEST 30 ***
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
new file mode 100644
index 0000000000..6626a0ee96
--- /dev/null
+++ b/testsuites/sptests/sp37/init.c
@@ -0,0 +1,273 @@
+/*
+ * Interrupt Disable/Enable Tests
+ * Clock Tick from task level
+ *
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
+#define TEST_INIT
+#include "system.h"
+
+void test_interrupt_inline(void)
+{
+ rtems_interrupt_level level;
+ boolean in_isr;
+
+ puts( "interrupt is in progress (use body)" );
+ in_isr = rtems_interrupt_is_in_progress();
+ if ( in_isr ) {
+ puts( "interrupt reported to be is in progress (body)" );
+ rtems_test_exit( 0 );
+ }
+
+ puts( "interrupt disable (use inline)" );
+ rtems_interrupt_disable( level );
+
+ puts( "interrupt flash (use inline)" );
+ rtems_interrupt_flash( level );
+
+ puts( "interrupt enable (use inline)" );
+ rtems_interrupt_enable( level );
+}
+
+volatile int isr_in_progress_body;
+volatile int isr_in_progress_inline;
+
+void check_isr_in_progress_inline(void)
+{
+ boolean in_isr;
+
+ in_isr = rtems_interrupt_is_in_progress();
+ isr_in_progress_inline = ( in_isr ) ? 1 : 2;
+}
+
+#undef rtems_interrupt_disable
+#undef rtems_interrupt_enable
+#undef rtems_interrupt_flash
+#undef rtems_interrupt_is_in_progress
+
+rtems_timer_service_routine test_isr_in_progress(
+ rtems_id timer,
+ void *arg
+)
+{
+ boolean in_isr;
+
+ check_isr_in_progress_inline();
+
+ in_isr = rtems_interrupt_is_in_progress();
+ isr_in_progress_body = ( in_isr ) ? 1 : 2;
+}
+
+void check_isr_worked(
+ char *s,
+ int result
+)
+{
+ switch (result) {
+ case -1:
+ printf( "isr_in_progress(%s) timer did not fire\n", s );
+ break;
+ case 1:
+ printf( "isr_in_progress(%s) from ISR -- OK\n", s );
+ break;
+ case 2:
+ printf( "isr_in_progress(%s) from ISR -- returned bad value\n");
+ rtems_test_exit(0);
+ break;
+ }
+}
+
+volatile int blocked_task_status;
+rtems_id blocked_task_id;
+
+rtems_task blocked_task(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+
+ puts( "Blocking task... suspending self" );
+ blocked_task_status = 1;
+ status = rtems_task_suspend( RTEMS_SELF );
+ directive_failed( status, "rtems_task_suspend" );
+
+ blocked_task_status = 3;
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete" );
+}
+
+/*
+ * Timer Service Routine
+ *
+ * If we are in an ISR, then this is a normal clock tick.
+ * If we are not, then it is the test case.
+ */
+rtems_timer_service_routine test_unblock_task(
+ rtems_id timer,
+ void *arg
+)
+{
+ boolean in_isr;
+ rtems_status_code status;
+
+ in_isr = rtems_interrupt_is_in_progress();
+ status = rtems_task_is_suspended( blocked_task_id );
+ if ( in_isr ) {
+ status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+ return;
+ }
+
+ if ( (status != RTEMS_ALREADY_SUSPENDED) ) {
+ status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+ return;
+ }
+
+ blocked_task_status = 2;
+ _Thread_Disable_dispatch();
+ status = rtems_task_resume( blocked_task_id );
+ _Thread_Unnest_dispatch();
+ directive_failed( status, "rtems_task_resume" );
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_time_of_day time;
+ rtems_status_code status;
+ rtems_interrupt_level level;
+ boolean in_isr;
+ rtems_id timer;
+ int i;
+
+ puts( "\n\n*** TEST 37 ***" );
+
+ build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
+ status = rtems_clock_set( &time );
+ directive_failed( status, "rtems_clock_set" );
+
+ /*
+ * Timer used in multiple ways
+ */
+ status = rtems_timer_create( 1, &timer );
+ directive_failed( status, "rtems_timer_create" );
+
+ /*
+ * Test clock tick from outside ISR
+ */
+ status = rtems_clock_tick();
+ directive_failed( status, "rtems_clock_tick" );
+ puts( "clock_tick from task level" );
+
+ /*
+ * Now do a dispatch directly out of a clock tick that is
+ * called from a task. We need to create a task that will
+ * block so we have one to unblock. Then we schedule a TSR
+ * to run in the clock tick but it has to be careful to
+ * make sure it is not called from an ISR and that the
+ * dispatching critical section is managed properly to
+ * make the dispatch happen.
+ */
+
+ blocked_task_status = -1;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', '1', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &blocked_task_id
+ );
+ directive_failed( status, "rtems_task_create" );
+
+ status = rtems_task_start( blocked_task_id, blocked_task, 0 );
+ directive_failed( status, "rtems_task_start" );
+
+ status = rtems_task_wake_after( 10 );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ status = rtems_timer_fire_after( timer, 1, test_unblock_task, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+
+ /* we expect to be preempted from this call */
+ for ( i=0 ; i<100 && blocked_task_status != 3 ; i++ ) {
+ status = rtems_clock_tick();
+ directive_failed( status, "rtems_clock_tick" );
+ }
+ switch ( blocked_task_status ) {
+ case -1:
+ puts( "clock_tick with task preempt -- task blocked, timer did not fire" );
+ rtems_test_exit(0);
+ break;
+ case 1:
+ puts( "clock_tick with task preempt -- timer fired case 1" );
+ rtems_test_exit(0);
+ break;
+ case 2:
+ puts( "clock_tick with task preempt -- timer fired case 2" );
+ rtems_test_exit(0);
+ break;
+ case 3:
+ puts( "clock_tick from task level with preempt -- OK" );
+ break;
+ }
+
+ /*
+ * Test interrupt inline versions
+ */
+ test_interrupt_inline();
+
+ /*
+ * Test interrupt bodies
+ */
+ puts( "interrupt is in progress (use body)" );
+ in_isr = rtems_interrupt_is_in_progress();
+ if ( in_isr ) {
+ puts( "interrupt reported to be is in progress (body)" );
+ rtems_test_exit( 0 );
+ }
+
+ puts( "interrupt disable (use body)" );
+ rtems_interrupt_disable( level );
+
+ puts( "interrupt disable (use body)" );
+ rtems_interrupt_disable( level );
+
+ puts( "interrupt flash (use body)" );
+ rtems_interrupt_flash( level );
+
+ puts( "interrupt enable (use body)" );
+ rtems_interrupt_enable( level );
+
+ /*
+ * Test ISR in progress from actual ISR
+ */
+ isr_in_progress_body = -1;
+ isr_in_progress_inline = -1;
+
+ status = rtems_timer_fire_after( timer, 10, test_isr_in_progress, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+
+ status = rtems_task_wake_after( 100 );
+ directive_failed( status, "wake_after failed" );
+
+ check_isr_worked( "inline", isr_in_progress_body );
+
+ check_isr_worked( "body", isr_in_progress_body );
+
+
+ puts( "*** END OF TEST 37 ***" );
+ rtems_test_exit( 0 );
+}
diff --git a/testsuites/sptests/sp37/sp37.scn b/testsuites/sptests/sp37/sp37.scn
index adb85057b7..8eb38323fe 100644
--- a/testsuites/sptests/sp37/sp37.scn
+++ b/testsuites/sptests/sp37/sp37.scn
@@ -1,5 +1,7 @@
*** TEST 37 ***
clock_tick from task level
+Blocking task... suspending self
+clock_tick from task level with preempt -- OK
interrupt is in progress (use body)
interrupt disable (use inline)
interrupt flash (use inline)
diff --git a/testsuites/sptests/sp37/system.h b/testsuites/sptests/sp37/system.h
index 84b7ab8614..e09c6a35a4 100644
--- a/testsuites/sptests/sp37/system.h
+++ b/testsuites/sptests/sp37/system.h
@@ -27,8 +27,10 @@ rtems_task Init(
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_INIT_TASK_PRIORITY 2
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
-#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_MAXIMUM_TIMERS 1
#include <rtems/confdefs.h>