summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spintrcritical06
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-20 14:49:25 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-20 14:49:25 +0000
commiteecd655794c1bc1f13fb13d5c09d224edeabf906 (patch)
tree36991a3a589cf1ec0ba67dcb131b95c5f4159be1 /testsuites/sptests/spintrcritical06
parent2009-07-20 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-eecd655794c1bc1f13fb13d5c09d224edeabf906.tar.bz2
2009-07-20 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add test case for the _Thread_queue_Enqueue_priority interrupt critical section where the TCB we are using as a current pointer is removed from the thread queue when we flash interrupts while searching forward. * spintrcritical06/.cvsignore, spintrcritical06/Makefile.am, spintrcritical06/init.c, spintrcritical06/spintrcritical06.doc, spintrcritical06/spintrcritical06.scn: New files.
Diffstat (limited to 'testsuites/sptests/spintrcritical06')
-rw-r--r--testsuites/sptests/spintrcritical06/.cvsignore2
-rw-r--r--testsuites/sptests/spintrcritical06/Makefile.am31
-rw-r--r--testsuites/sptests/spintrcritical06/init.c152
-rw-r--r--testsuites/sptests/spintrcritical06/spintrcritical06.doc31
-rw-r--r--testsuites/sptests/spintrcritical06/spintrcritical06.scn5
5 files changed, 221 insertions, 0 deletions
diff --git a/testsuites/sptests/spintrcritical06/.cvsignore b/testsuites/sptests/spintrcritical06/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/spintrcritical06/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/spintrcritical06/Makefile.am b/testsuites/sptests/spintrcritical06/Makefile.am
new file mode 100644
index 0000000000..4866992cfe
--- /dev/null
+++ b/testsuites/sptests/spintrcritical06/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = spintrcritical06
+spintrcritical06_SOURCES = init.c \
+ ../spintrcritical_support/intrcritical.c
+
+dist_rtems_tests_DATA = spintrcritical06.scn
+dist_rtems_tests_DATA += spintrcritical06.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+spintrcritical06_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/spintrcritical_support
+AM_CPPFLAGS += -DPRIORITY_NO_TIMEOUT_FORWARD
+
+LINK_OBJS = $(spintrcritical06_OBJECTS) $(spintrcritical06_LDADD)
+LINK_LIBS = $(spintrcritical06_LDLIBS)
+
+spintrcritical06$(EXEEXT): $(spintrcritical06_OBJECTS) $(spintrcritical06_DEPENDENCIES)
+ @rm -f spintrcritical06$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spintrcritical06/init.c b/testsuites/sptests/spintrcritical06/init.c
new file mode 100644
index 0000000000..e00ff2168d
--- /dev/null
+++ b/testsuites/sptests/spintrcritical06/init.c
@@ -0,0 +1,152 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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__ 1
+#include <tmacros.h>
+#include <intrcritical.h>
+
+/* common parameters */
+#define SEMAPHORE_ATTRIBUTES RTEMS_PRIORITY
+#define SEMAPHORE_OBTAIN_TIMEOUT 0
+
+#if defined(PRIORITY_NO_TIMEOUT_FORWARD)
+ #define TEST_NAME "06"
+ #define TEST_STRING "Priority/Restart Search Task (Forward)"
+
+ #define INIT_PRIORITY 2
+ #define BLOCKER_PRIORITY 1
+
+#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
+ #define TEST_NAME "07"
+ #define TEST_STRING "Priority/Restart Search Task (Backward)"
+ #define INIT_PRIORITY 126
+ #define BLOCKER_PRIORITY 127
+
+#else
+
+ #error "Test Mode not defined"
+#endif
+
+rtems_id Main_task;
+rtems_id Secondary_task_id;
+rtems_id Semaphore;
+volatile bool case_hit;
+
+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
+)
+{
+ (void) rtems_task_restart( Secondary_task_id, 1 );
+}
+
+rtems_task Secondary_task(
+ rtems_task_argument arg
+)
+{
+ rtems_status_code status;
+
+ if ( arg )
+ (void) rtems_semaphore_flush( Semaphore );
+
+ status = rtems_semaphore_obtain(
+ Semaphore,
+ RTEMS_DEFAULT_OPTIONS,
+ SEMAPHORE_OBTAIN_TIMEOUT
+ );
+ directive_failed( status, "rtems_semaphore_obtain" );
+}
+
+rtems_task Init(
+ rtems_task_argument ignored
+)
+{
+ rtems_status_code status;
+ int resets;
+
+ puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
+
+ puts( "Init - Trying to generate semaphore release from ISR while blocking" );
+ puts( "Init - Variation is: " TEST_STRING );
+ status = rtems_semaphore_create(
+ rtems_build_name( 'S', 'M', '1', ' ' ),
+ 0,
+ SEMAPHORE_ATTRIBUTES,
+ RTEMS_NO_PRIORITY,
+ &Semaphore
+ );
+ directive_failed( status, "rtems_semaphore_create of SM1" );
+
+ Main_task = rtems_task_self();
+
+ status = rtems_task_create(
+ rtems_build_name( 'B', 'L', 'C', 'K' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_NO_PREEMPT,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Secondary_task_id
+ );
+ directive_failed( status, "rtems_task_create" );
+
+ status = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
+ directive_failed( status, "rtems_task_start" );
+
+ interrupt_critical_section_test_support_initialize( test_release_from_isr );
+
+ for (resets=0 ; resets< 2 ;) {
+ if ( interrupt_critical_section_test_support_delay() )
+ resets++;
+
+ status = rtems_semaphore_obtain(
+ Semaphore,
+ RTEMS_DEFAULT_OPTIONS,
+ SEMAPHORE_OBTAIN_TIMEOUT
+ );
+ fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_semaphore_obtain");
+ }
+
+ puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TIMERS 1
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+#define CONFIGURE_INIT_TASK_PRIORITY INIT_PRIORITY
+#define CONFIGURE_INIT_TASK_MODE RTEMS_PREEMPT
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/sptests/spintrcritical06/spintrcritical06.doc b/testsuites/sptests/spintrcritical06/spintrcritical06.doc
new file mode 100644
index 0000000000..232be46491
--- /dev/null
+++ b/testsuites/sptests/spintrcritical06/spintrcritical06.doc
@@ -0,0 +1,31 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2009.
+# 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.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spintrcritical06
+
+directives:
+
+ _Thread_queue_Enqueue_priority
+ - interrupt synchronization
+ rtems_task_restart
+ _Thread_queue_Extract_priority
+
+concepts:
+
++ Ensure that removing the "search task" from the thread queue while we
+ are looping and enqueuing another works as expected. This case is where
+ the TCB we are using as a current pointer is removed from the thread queue
+ when we flash interrupts WHILE SEARCHING FORWARD.
+
+NOTE: There is no way to know this case is hit from a test perspective. The
+ test just runs and we check the coverage report.
diff --git a/testsuites/sptests/spintrcritical06/spintrcritical06.scn b/testsuites/sptests/spintrcritical06/spintrcritical06.scn
new file mode 100644
index 0000000000..ebc410797d
--- /dev/null
+++ b/testsuites/sptests/spintrcritical06/spintrcritical06.scn
@@ -0,0 +1,5 @@
+*** TEST INTERRUPT CRITICAL SECTION 06 ***
+Init - Trying to generate semaphore release from ISR while blocking
+Init - Variation is: Priority/Without Timeout/Multiple Tasks (Forward)
+Support - rtems_timer_create - creating timer 1
+*** END OF TEST INTERRUPT CRITICAL SECTION 06 ***