summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-23 13:05:55 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-23 13:05:55 +0000
commit9185d61c541ad57d3ad472dbf85c1c1dfdafca6c (patch)
tree00e3aba926bf2db7296cca35c9833af68d6bfd08 /testsuites
parent2008-01-22 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-9185d61c541ad57d3ad472dbf85c1c1dfdafca6c.tar.bz2
2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com>
* sp39/init.c: Add case for long timeout on blocking operation. * Makefile.am, configure.ac: Add new test to exercise thread queue blokcing synchronization. sp39 and sp41 are very similar. * sp41/.cvsignore, sp41/Makefile.am, sp41/init.c, sp41/sp41.scn, sp41/system.h: New files.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/ChangeLog8
-rw-r--r--testsuites/sptests/Makefile.am2
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/sp39/init.c56
-rw-r--r--testsuites/sptests/sp41/.cvsignore2
-rw-r--r--testsuites/sptests/sp41/Makefile.am27
-rw-r--r--testsuites/sptests/sp41/init.c197
-rw-r--r--testsuites/sptests/sp41/sp41.scn0
-rw-r--r--testsuites/sptests/sp41/system.h39
9 files changed, 329 insertions, 3 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog
index e73e8b7e49..321820aafb 100644
--- a/testsuites/sptests/ChangeLog
+++ b/testsuites/sptests/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * sp39/init.c: Add case for long timeout on blocking operation.
+ * Makefile.am, configure.ac: Add new test to exercise thread
+ queue blokcing synchronization. sp39 and sp41 are very similar.
+ * sp41/.cvsignore, sp41/Makefile.am, sp41/init.c, sp41/sp41.scn,
+ sp41/system.h: New files.
+
2008-01-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* sp39/init.c: Clean up.
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index d648002c93..10cac13896 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal
## spfatal is not included for now
SUBDIRS = sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 sp09 sp11 sp12 sp13 sp14 \
sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 sp26 sp27 sp28 sp29 \
- sp30 sp31 sp32 sp33 sp34 sp35 sp37 sp38 sp39 sp40 spsize
+ sp30 sp31 sp32 sp33 sp34 sp35 sp37 sp38 sp39 sp40 sp41 spsize
DIST_SUBDIRS = $(SUBDIRS) spfatal
include $(top_srcdir)/../automake/subdirs.am
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 7fcdf6f26d..79e8454368 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -65,6 +65,7 @@ sp37/Makefile
sp38/Makefile
sp39/Makefile
sp40/Makefile
+sp41/Makefile
spsize/Makefile
spfatal/Makefile
])
diff --git a/testsuites/sptests/sp39/init.c b/testsuites/sptests/sp39/init.c
index 2432291cb5..22ea9a7d63 100644
--- a/testsuites/sptests/sp39/init.c
+++ b/testsuites/sptests/sp39/init.c
@@ -1,7 +1,7 @@
/*
* Classic API Signal to Task from ISR
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -44,6 +44,23 @@ rtems_timer_service_routine test_event_from_isr(
status = rtems_event_send( main_task, 0x01 );
}
+rtems_timer_service_routine test_event_with_timeout_from_isr(
+ rtems_id timer,
+ void *arg
+)
+{
+ rtems_status_code status;
+
+ if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
+ /*
+ * We want to catch the task while it is blocking. Otherwise
+ * just send and make it happy.
+ */
+ case_hit = TRUE;
+ }
+ status = rtems_event_send( main_task, 0x01 );
+}
+
rtems_task Init(
rtems_task_argument argument
)
@@ -76,7 +93,7 @@ rtems_task Init(
directive_failed( status, "rtems_task_create" );
/*
- * Test Event send successful from ISR
+ * Test Event send successful from ISR -- receive is forever
*/
case_hit = FALSE;
iterations = 0;
@@ -109,6 +126,41 @@ rtems_task Init(
);
/*
+ * Test Event send successful from ISR -- receive has timeout
+ */
+ case_hit = FALSE;
+ iterations = 0;
+ max = 1;
+
+ while (1) {
+ if ( case_hit )
+ break;
+ status = rtems_timer_fire_after(
+ timer, 1, test_event_with_timeout_from_isr, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+
+ for (i=0 ; i<max ; i++ )
+ if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_SATISFIED )
+ break;
+
+ status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 10, &out );
+ directive_failed( status, "rtems_event_receive" );
+ if ( case_hit == TRUE )
+ break;
+ max += 2;
+
+ /* with our clock tick, this is about 30 seconds */
+ if ( ++iterations >= 4 * 1000 * 30)
+ break;
+ }
+
+ printf(
+ "Event sent from ISR (with timeout) hitting synchronization "
+ "point has %soccurred\n",
+ (( case_hit == TRUE ) ? "" : "NOT ")
+ );
+
+ /*
* Now try for a timeout case
*/
iterations = 0;
diff --git a/testsuites/sptests/sp41/.cvsignore b/testsuites/sptests/sp41/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/sp41/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/sp41/Makefile.am b/testsuites/sptests/sp41/Makefile.am
new file mode 100644
index 0000000000..5e4bf34da4
--- /dev/null
+++ b/testsuites/sptests/sp41/Makefile.am
@@ -0,0 +1,27 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = sp41.exe
+sp41_exe_SOURCES = init.c system.h
+
+dist_rtems_tests_DATA = sp41.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+sp41_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sp41_exe_OBJECTS) $(sp41_exe_LDADD)
+LINK_LIBS = $(sp41_exe_LDLIBS)
+
+sp41.exe$(EXEEXT): $(sp41_exe_OBJECTS) $(sp41_exe_DEPENDENCIES)
+ @rm -f sp41.exe$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp41/init.c b/testsuites/sptests/sp41/init.c
new file mode 100644
index 0000000000..ad81ce642e
--- /dev/null
+++ b/testsuites/sptests/sp41/init.c
@@ -0,0 +1,197 @@
+/*
+ * Classic API Signal to Task from ISR
+ *
+ * COPYRIGHT (c) 1989-2008.
+ * 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 TEST_INIT
+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1
+#include "system.h"
+
+volatile boolean case_hit;
+
+rtems_id main_task;
+rtems_id Semaphore;
+
+Thread_blocking_operation_States getState(void)
+{
+ Objects_Locations location;
+ Semaphore_Control *sem;
+
+ sem = (Semaphore_Control *)_Objects_Get(
+ &_Semaphore_Information, Semaphore, &location );
+ if ( location != OBJECTS_LOCAL ) {
+ puts( "Bad object lookup" );
+ rtems_test_exit(0);
+ }
+ _Thread_Unnest_dispatch();
+
+ return sem->Core_control.semaphore.Wait_queue.sync_state;
+}
+
+rtems_timer_service_routine test_release_from_isr(
+ rtems_id timer,
+ void *arg
+)
+{
+ rtems_status_code status;
+
+ if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
+ case_hit = TRUE;
+ }
+ status = rtems_semaphore_release( Semaphore );
+}
+
+rtems_timer_service_routine test_release_with_timeout_from_isr(
+ rtems_id timer,
+ void *arg
+)
+{
+ rtems_status_code status;
+
+ if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
+ /*
+ * We want to catch the task while it is blocking. Otherwise
+ * just send and make it happy.
+ */
+ case_hit = TRUE;
+ }
+ status = rtems_semaphore_release( Semaphore );
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_id timer;
+ int i;
+ int max;
+ int iterations = 0;
+
+ puts( "\n\n*** TEST 41 ***" );
+
+ main_task = rtems_task_self();
+
+ /*
+ * Timer used in multiple ways
+ */
+ status = rtems_timer_create( 1, &timer );
+ directive_failed( status, "rtems_timer_create" );
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'S', 'M', '1', ' ' ),
+ 1,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ RTEMS_NO_PRIORITY,
+ &Semaphore
+ );
+ directive_failed( status, "rtems_semaphore_create of SM1" );
+
+ /*
+ * Test semaphore release successful from ISR -- obtain is forever
+ */
+ case_hit = FALSE;
+ iterations = 0;
+ max = 1;
+
+ while (1) {
+ if ( case_hit )
+ break;
+ status = rtems_timer_fire_after( timer, 1, test_release_from_isr, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+
+ for (i=0 ; i<max ; i++ )
+ if ( getState() == THREAD_BLOCKING_OPERATION_SATISFIED )
+ break;
+
+ status = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 0 );
+ directive_failed( status, "rtems_semaphore_obtain" );
+ if ( case_hit == TRUE )
+ break;
+ max += 2;
+
+ /* with our clock tick, this is about 30 seconds */
+ if ( ++iterations >= 4 * 1000 * 30)
+ break;
+ }
+
+ status = rtems_semaphore_release( Semaphore );
+ directive_failed( status, "rtems_semaphore_release" );
+ printf(
+ "Release from ISR hitting synchronization point has %soccurred\n",
+ (( case_hit == TRUE ) ? "" : "NOT ")
+ );
+
+ /*
+ * Test semaphore release successful from ISR -- obtain has timeout
+ */
+ case_hit = FALSE;
+ iterations = 0;
+ max = 1;
+
+ while (1) {
+ if ( case_hit )
+ break;
+ status = rtems_timer_fire_after(
+ timer, 1, test_release_with_timeout_from_isr, NULL );
+ directive_failed( status, "timer_fire_after failed" );
+
+ for (i=0 ; i<max ; i++ )
+ if ( getState() == THREAD_BLOCKING_OPERATION_SATISFIED )
+ break;
+
+ status = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 10 );
+ directive_failed( status, "rtems_semaphore_obtain" );
+ if ( case_hit == TRUE )
+ break;
+ max += 2;
+
+ /* with our clock tick, this is about 30 seconds */
+ if ( ++iterations >= 4 * 1000 * 30)
+ break;
+ }
+
+ printf(
+ "Release from ISR (with timeout) hitting synchronization "
+ "point has %soccurred\n",
+ (( case_hit == TRUE ) ? "" : "NOT ")
+ );
+
+ /*
+ * Now try for a timeout case -- semaphore must not be available
+ */
+ iterations = 0;
+ case_hit = FALSE;
+ max = 1;
+
+ puts(
+ "Run multiple times in attempt to hit threadq timeout synchronization point"
+ );
+ while (1) {
+
+ for (i=0 ; i<max ; i++ )
+ if ( getState() == THREAD_BLOCKING_OPERATION_SATISFIED )
+ break;
+
+ status = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
+ fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
+
+ if ( ++max > 10240 )
+ max = 0;
+
+ /* with our clock tick, this is about 30 seconds */
+ if ( ++iterations >= 4 * 1000 * 30)
+ break;
+ }
+
+ puts( "*** END OF TEST SP41 ***" );
+ rtems_test_exit( 0 );
+}
diff --git a/testsuites/sptests/sp41/sp41.scn b/testsuites/sptests/sp41/sp41.scn
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/sptests/sp41/sp41.scn
diff --git a/testsuites/sptests/sp41/system.h b/testsuites/sptests/sp41/system.h
new file mode 100644
index 0000000000..f2a81e6634
--- /dev/null
+++ b/testsuites/sptests/sp41/system.h
@@ -0,0 +1,39 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * 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$
+ */
+
+#include <tmacros.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 250
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TIMERS 1
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#include <rtems/confdefs.h>
+
+/* end of include file */