summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-23 13:58:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-23 13:58:54 +0000
commit4a4aabcae089380caf816ffd787aeb206947415d (patch)
treec1e0bc496d79f7bfd8da37afee425bd6a43a815d /testsuites
parent2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-4a4aabcae089380caf816ffd787aeb206947415d.tar.bz2
2008-01-23 Joel Sherrill <joel.sherrill@OARcorp.com>
Add sp42 to exercise thread queue with knowledge of the implementation so we can exercise all of the normal paths possible. * Makefile.am, configure.ac: Add sp42. * sp42/.cvsignore, sp42/init.c, sp42/sp42.scn: New files.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/ChangeLog7
-rw-r--r--testsuites/sptests/Makefile.am2
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/sp42/.cvsignore2
-rw-r--r--testsuites/sptests/sp42/init.c173
-rw-r--r--testsuites/sptests/sp42/sp42.scn0
6 files changed, 184 insertions, 1 deletions
diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog
index 321820aafb..8db5d3a7d8 100644
--- a/testsuites/sptests/ChangeLog
+++ b/testsuites/sptests/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-23 Joel Sherrill <joel.sherrill@OARcorp.com>
+
+ Add sp42 to exercise thread queue with knowledge of the implementation
+ so we can exercise all of the normal paths possible.
+ * Makefile.am, configure.ac: Add sp42.
+ * sp42/.cvsignore, sp42/init.c, sp42/sp42.scn: New files.
+
2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com>
* sp39/init.c: Add case for long timeout on blocking operation.
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 10cac13896..90ccb30fc8 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 sp41 spsize
+ sp30 sp31 sp32 sp33 sp34 sp35 sp37 sp38 sp39 sp40 sp41 sp42 spsize
DIST_SUBDIRS = $(SUBDIRS) spfatal
include $(top_srcdir)/../automake/subdirs.am
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 79e8454368..00d882a85d 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -66,6 +66,7 @@ sp38/Makefile
sp39/Makefile
sp40/Makefile
sp41/Makefile
+sp42/Makefile
spsize/Makefile
spfatal/Makefile
])
diff --git a/testsuites/sptests/sp42/.cvsignore b/testsuites/sptests/sp42/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/sp42/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/sp42/init.c b/testsuites/sptests/sp42/init.c
new file mode 100644
index 0000000000..8a836d27fd
--- /dev/null
+++ b/testsuites/sptests/sp42/init.c
@@ -0,0 +1,173 @@
+/*
+ * Exercise thread queue enqueue and dequeue priority
+ *
+ * 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$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <bsp.h>
+
+#include "tmacros.h"
+
+#define MAX_TASKS 20
+
+/*
+ * Carefully chosen to exercise threadq enqueue/dequeue priority logic.
+ * Somewhat randomly sorted to ensure than if discipline is FIFO, run-time
+ * behavior won't be the same when released.
+ */
+rtems_task_priority Priorities[MAX_TASKS] = {
+ 37, 37, 37, 37, /* backward - more 2-n */
+ 2, 2, 2, 2, /* forward - multiple are on 2-n chain */
+ 4, 3, /* forward - search forward arbitrary */
+ 3, 3, 3, 3, /* forward - more 2-n */
+ 38, 37, /* backward - search backward arbitrary */
+ 34, 34, 34, 34, /* backward - multple on 2-n chain */
+};
+
+
+rtems_id Semaphore;
+rtems_id Task_id[ MAX_TASKS ];
+rtems_name Task_name[ MAX_TASKS ];
+
+rtems_task Locker_task(
+ rtems_task_argument unused
+)
+{
+ rtems_id tid;
+ uint32_t task_index;
+ rtems_status_code status;
+
+ status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
+ directive_failed( status, "rtems_task_ident" );
+
+ task_index = task_number( tid ) - 1;
+
+ status = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 0 );
+ directive_failed( status, "rtems_semaphore_obtain" );
+
+ put_name( Task_name[ task_index ], FALSE );
+ puts( " - unblocked - OK" );
+
+ (void) rtems_task_delete( RTEMS_SELF );
+}
+
+void do_test(
+ rtems_attribute attr,
+ boolean extract /* TRUE if extract, not release */
+)
+{
+ rtems_status_code status;
+ int i;
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'S', 'E', 'M', '0' ), /* name = SEM0 */
+ 0, /* unlocked */
+ RTEMS_BINARY_SEMAPHORE | attr, /* mutex w/desired discipline */
+ 0, /* IGNORED */
+ &Semaphore
+ );
+ directive_failed( status, "rtems_semaphore_create" );
+
+ for (i=0 ; i< MAX_TASKS ; i++ ) {
+
+ Task_name[ i ] = rtems_build_name(
+ 'T',
+ 'A',
+ '0' + (char)(i/10),
+ '0' + (char)(i%10)
+ );
+
+ status = rtems_task_create(
+ Task_name[ i ],
+ Priorities[ i ],
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ i ]
+ );
+ directive_failed( status, "rtems_task_create" );
+
+ status = rtems_task_start( Task_id[ i ], Locker_task, i );
+ directive_failed( status, "rtems_task_start" );
+
+ status = rtems_task_wake_after( 10 );
+ directive_failed( status, "rtems_task_wake_after" );
+ }
+
+ for (i=0 ; i< MAX_TASKS ; i++ ) {
+ if ( extract == FALSE ) {
+ status = rtems_semaphore_release( Semaphore );
+ directive_failed( status, "rtems_semaphore_release" );
+
+ status = rtems_task_wake_after( 100 );
+ directive_failed( status, "rtems_task_wake_after" );
+ } else {
+ status = rtems_task_delete( Task_id[ i ] );
+ directive_failed( status, "rtems_task_delete" );
+ }
+ }
+
+ /* one extra release for the initial state */
+ status = rtems_semaphore_release( Semaphore );
+ directive_failed( status, "rtems_semaphore_release" );
+
+ /* now delete the semaphore since no one is waiting and it is unlocked */
+ status = rtems_semaphore_delete( Semaphore );
+ directive_failed( status, "rtems_semaphore_delete" );
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ puts( "\n\n*** SP40 ***" );
+
+ if ( sizeof( Priorities ) / sizeof( rtems_task_priority ) != MAX_TASKS ) {
+ puts( "Priorities table does not have right number of entries" );
+ exit( 0 );
+ }
+
+ puts( "Exercising blocking discipline w/extract in FIFO order " );
+ do_test( RTEMS_FIFO, TRUE );
+
+ puts( "Exercising blocking discipline w/unblock in FIFO order" );
+ do_test( RTEMS_FIFO, FALSE );
+
+ rtems_test_pause_and_screen_number( 2 );
+
+ puts( "Exercising blocking discipline w/extract in priority order " );
+ do_test( RTEMS_PRIORITY, TRUE );
+
+ puts( "Exercising blocking discipline w/unblock in priority order" );
+ do_test( RTEMS_PRIORITY, FALSE );
+
+ puts( "*** END OF SP40 ***" );
+ exit(0);
+}
+
+/**************** START OF CONFIGURATION INFORMATION ****************/
+
+#define CONFIGURE_INIT
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS MAX_TASKS+1
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/**************** END OF CONFIGURATION INFORMATION ****************/
+
diff --git a/testsuites/sptests/sp42/sp42.scn b/testsuites/sptests/sp42/sp42.scn
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/sptests/sp42/sp42.scn