summaryrefslogtreecommitdiffstats
path: root/testsuites/smptests/smp07
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-28 21:08:48 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-28 21:08:48 +0000
commite049eeae908fe5d6418433aa1495c796cc58424f (patch)
tree9ae2ca088f2dfc3787d5965e904b1c738e14ad57 /testsuites/smptests/smp07
parent2011-05-24 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-e049eeae908fe5d6418433aa1495c796cc58424f.tar.bz2
2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* .configure.ac.swp, ChangeLog, Makefile.am, README, config.h.in, configure.ac, smp01/.cvsignore, smp01/Makefile.am, smp01/init.c, smp01/smp01.doc, smp01/smp01.scn, smp01/system.h, smp01/tasks.c, smp02/.cvsignore, smp02/Makefile.am, smp02/init.c, smp02/smp02.doc, smp02/smp02.scn, smp02/system.h, smp02/tasks.c, smp03/.cvsignore, smp03/Makefile.am, smp03/init.c, smp03/smp03.doc, smp03/smp03.scn, smp03/system.h, smp03/tasks.c, smp04/.cvsignore, smp04/Makefile.am, smp04/init.c, smp04/smp04.doc, smp04/smp04.scn, smp04/system.h, smp04/tasks.c, smp05/.cvsignore, smp05/Makefile.am, smp05/init.c, smp05/smp05.doc, smp05/smp05.scn, smp06/.cvsignore, smp06/Makefile.am, smp06/init.c, smp06/smp06.doc, smp06/smp06.scn, smp07/.cvsignore, smp07/Makefile.am, smp07/init.c, smp07/smp07.doc, smp07/smp07.scn, smp08/.cvsignore, smp08/Makefile.am, smp08/init.c, smp08/smp08.doc, smp08/smp08.scn, smp08/system.h, smp08/tasks.c, smp09/.cvsignore, smp09/Makefile.am, smp09/init.c, smp09/smp09.doc, smp09/smp09.scn: New files.
Diffstat (limited to 'testsuites/smptests/smp07')
-rw-r--r--testsuites/smptests/smp07/.cvsignore2
-rw-r--r--testsuites/smptests/smp07/Makefile.am27
-rw-r--r--testsuites/smptests/smp07/init.c164
-rw-r--r--testsuites/smptests/smp07/smp07.doc24
-rw-r--r--testsuites/smptests/smp07/smp07.scn6
5 files changed, 223 insertions, 0 deletions
diff --git a/testsuites/smptests/smp07/.cvsignore b/testsuites/smptests/smp07/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/smptests/smp07/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/smptests/smp07/Makefile.am b/testsuites/smptests/smp07/Makefile.am
new file mode 100644
index 0000000000..de140d87bf
--- /dev/null
+++ b/testsuites/smptests/smp07/Makefile.am
@@ -0,0 +1,27 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = smp07
+smp07_SOURCES = init.c ../../support/src/locked_print.c
+
+dist_rtems_tests_DATA = smp07.scn
+dist_rtems_tests_DATA += smp07.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -DSMPTEST
+
+LINK_OBJS = $(smp07_OBJECTS) $(smp07_LDADD)
+LINK_LIBS = $(smp07_LDLIBS)
+
+smp07$(EXEEXT): $(smp07_OBJECTS) $(smp07_DEPENDENCIES)
+ @rm -f smp07$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c
new file mode 100644
index 0000000000..727bc15536
--- /dev/null
+++ b/testsuites/smptests/smp07/init.c
@@ -0,0 +1,164 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * 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>
+#include "test_support.h"
+
+volatile bool TaskRan = false;
+volatile bool TSRFired = false;
+rtems_id Semaphore;
+
+rtems_task Test_task(
+ rtems_task_argument argument
+)
+{
+ int cpu_num;
+ rtems_status_code sc;
+ char name[5];
+ char *p;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Get the CPU Number */
+ cpu_num = bsp_smp_processor_id();
+
+ /* Print that the task is up and running. */
+ locked_printf(" CPU %d runnng Task %s and blocking\n", cpu_num, name);
+
+ sc = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
+ directive_failed( sc,"obtain in test task");
+
+ if ( !TSRFired )
+ locked_printf( "*** ERROR TSR DID NOT FIRE BUT TEST TASK AWAKE***" );
+
+ TaskRan = true;
+
+ /* Print that the task is up and running. */
+ locked_printf(" CPU %d running Task %s after semaphore release\n", cpu_num, name);
+
+ (void) rtems_task_delete( RTEMS_SELF );
+}
+
+
+rtems_timer_service_routine TimerMethod(
+ rtems_id timer,
+ void *arg
+)
+{
+ /*
+ * Set flag and release the semaphore, allowing the blocked tasks to start.
+ */
+ TSRFired = true;
+
+ rtems_semaphore_release( Semaphore );
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int cpu_num;
+ rtems_id id;
+ rtems_status_code status;
+ rtems_interval per_second;
+ rtems_interval then;
+ rtems_id Timer;
+
+ locked_print_initialize();
+ locked_printf( "\n\n*** TEST SMP07 ***\n" );
+
+ /* Create/verify semaphore */
+ status = rtems_semaphore_create(
+ rtems_build_name ('S', 'E', 'M', '1'),
+ 1,
+ RTEMS_LOCAL |
+ RTEMS_SIMPLE_BINARY_SEMAPHORE |
+ RTEMS_PRIORITY,
+ 1,
+ &Semaphore
+ );
+ directive_failed( status, "rtems_semaphore_create" );
+
+ /* Lock semaphore */
+ status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
+ directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
+
+ /* Create and Start test task. */
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', '1', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ cpu_num = bsp_smp_processor_id();
+ locked_printf(" CPU %d start task TA1\n", cpu_num );
+ status = rtems_task_start( id, Test_task, 1 );
+ directive_failed( status, "task start" );
+
+ /* Create and start TSR */
+ locked_printf(" CPU %d create and start timer\n", cpu_num );
+ status = rtems_timer_create( rtems_build_name( 'T', 'M', 'R', '1' ), &Timer);
+ directive_failed( status, "rtems_timer_create" );
+
+ per_second = rtems_clock_get_ticks_per_second();
+ status = rtems_timer_fire_after( Timer, 2 * per_second, TimerMethod, NULL );
+ directive_failed( status, "rtems_timer_fire_after");
+
+ /*
+ * Wait long enough that TSR should have fired.
+ *
+ * Spin so CPU 0 is consumed. This forces task to run on CPU 1.
+ */
+ then = rtems_clock_get_ticks_since_boot() + 4 * per_second;
+ while (1) {
+ if ( rtems_clock_get_ticks_since_boot() > then )
+ break;
+ if ( TSRFired && TaskRan )
+ break;
+ };
+
+ /* Validate the timer fired and that the task ran */
+ if ( !TSRFired )
+ locked_printf( "*** ERROR TSR DID NOT FIRE ***" );
+
+ if ( !TaskRan ) {
+ locked_printf( "*** ERROR TASK DID NOT RUN ***" );
+ rtems_test_exit(0);
+ }
+
+ /* End the program */
+ locked_printf( "*** END OF TEST SMP07 ***\n" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_SMP_APPLICATION
+#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 2
+#define CONFIGURE_MAXIMUM_TIMERS 1
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/smptests/smp07/smp07.doc b/testsuites/smptests/smp07/smp07.doc
new file mode 100644
index 0000000000..89a029e76e
--- /dev/null
+++ b/testsuites/smptests/smp07/smp07.doc
@@ -0,0 +1,24 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2010.
+# 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: smp07
+
+directives:
+
+ rtems_semaphore_obtain
+ rtems_semaphore_release
+
+concepts:
+
++ Ensure that if a task is unblocked from an ISR on an SMP system, that
+ it will run.
diff --git a/testsuites/smptests/smp07/smp07.scn b/testsuites/smptests/smp07/smp07.scn
new file mode 100644
index 0000000000..671b29c50e
--- /dev/null
+++ b/testsuites/smptests/smp07/smp07.scn
@@ -0,0 +1,6 @@
+*** TEST SMP07 ***
+ CPU 0 start task TA1
+ CPU 0 create and start timer
+ CPU 1 runnng Task TA1 and blocking
+ CPU 1 running Task TA1 after semaphore release
+*** END OF TEST SMP07 ***