diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-08 20:26:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-08 20:26:45 +0000 |
commit | a5e620e89d70794cf80a1b77965e6a3ab4127daa (patch) | |
tree | 740a50769494f2b0c7fef7819ec8cc44be6de353 /testsuites/sptests/sp27 | |
parent | 2009-07-08 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-a5e620e89d70794cf80a1b77965e6a3ab4127daa.tar.bz2 |
2009-07-08 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac, sp27/Makefile.am, sp27/init.c,
sp27/sp27.doc, sp27/sp27.scn: Rework sp27 so it can be reinstantiated
as sp27a and test flushing both counting and binary semaphores.
Reformatted.
* sp27a/.cvsignore, sp27a/Makefile.am, sp27a/sp27a.doc,
sp27a/sp27a.scn: New files.
Diffstat (limited to 'testsuites/sptests/sp27')
-rw-r--r-- | testsuites/sptests/sp27/Makefile.am | 2 | ||||
-rw-r--r-- | testsuites/sptests/sp27/init.c | 134 | ||||
-rw-r--r-- | testsuites/sptests/sp27/sp27.doc | 25 | ||||
-rw-r--r-- | testsuites/sptests/sp27/sp27.scn | 2 |
4 files changed, 103 insertions, 60 deletions
diff --git a/testsuites/sptests/sp27/Makefile.am b/testsuites/sptests/sp27/Makefile.am index b9a2d124a4..39518f939d 100644 --- a/testsuites/sptests/sp27/Makefile.am +++ b/testsuites/sptests/sp27/Makefile.am @@ -16,6 +16,8 @@ include $(top_srcdir)/../automake/leaf.am sp27_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel) +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + LINK_OBJS = $(sp27_OBJECTS) $(sp27_LDADD) LINK_LIBS = $(sp27_LDLIBS) diff --git a/testsuites/sptests/sp27/init.c b/testsuites/sptests/sp27/init.c index 6150631b8d..9e257f396c 100644 --- a/testsuites/sptests/sp27/init.c +++ b/testsuites/sptests/sp27/init.c @@ -12,110 +12,126 @@ */ #include <bsp.h> +#include <tmacros.h> -rtems_task Init (rtems_task_argument argument); void starttask(int arg); rtems_task subtask(rtems_task_argument arg); -#define CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - -#define CONFIGURE_MAXIMUM_TASKS 6 -#define CONFIGURE_MAXIMUM_SEMAPHORES 1 - -#define CONFIGURE_MICROSECONDS_PER_TICK 52429 - -#define CONFIGURE_INIT - -#include <rtems/confdefs.h> - -#include <rtems/error.h> #include <stdio.h> #include <stdlib.h> #define NTASK 4 +#if defined(USE_COUNTING_SEMAPHORE) + #define TEST_NAME "27a" + #define TEST_SEMAPHORE_TYPE "counting" + #define TEST_SEMAPHORE_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES +#else + #define TEST_NAME "27" + #define TEST_SEMAPHORE_TYPE "binary" + #define TEST_SEMAPHORE_ATTRIBUTES (RTEMS_LOCAL| \ + RTEMS_BINARY_SEMAPHORE|RTEMS_NO_INHERIT_PRIORITY| \ + RTEMS_NO_PRIORITY_CEILING|RTEMS_FIFO) +#endif + rtems_id semaphore; volatile int flags[NTASK]; -rtems_task -subtask (rtems_task_argument arg) +rtems_task subtask( + rtems_task_argument arg +) { rtems_status_code sc; for (;;) { flags[arg]++; - sc = rtems_semaphore_obtain (semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + sc = rtems_semaphore_obtain(semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc == RTEMS_SUCCESSFUL) - puts ("Obtained semaphore -- and should not have done so!"); + puts("Obtained semaphore -- and should not have done so!"); else if (sc != RTEMS_UNSATISFIED) - printf ("Can't get semaphore: %s\n", rtems_status_text (sc)); + printf("Can't get semaphore: %s\n", rtems_status_text(sc)); } } -void -starttask (int arg) +void starttask( + int arg +) { rtems_id tid; rtems_status_code sc; rtems_task_priority priority; - rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority); - sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', arg + 'A'), + rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority); + sc = rtems_task_create(rtems_build_name('S', 'R', 'V', arg + 'A'), priority, RTEMS_MINIMUM_STACK_SIZE, RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0), RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL, &tid); - if (sc != RTEMS_SUCCESSFUL) { - printf ("Can't create task: %s\n", rtems_status_text (sc)); - rtems_task_suspend (RTEMS_SELF); - } - sc = rtems_task_start (tid, subtask, (rtems_task_argument) arg); - if (sc != RTEMS_SUCCESSFUL) { - printf ("Can't start task: %s\n", rtems_status_text (sc)); - rtems_task_suspend (RTEMS_SELF); - } + directive_failed( sc, "task create" ); + + sc = rtems_task_start(tid, subtask, (rtems_task_argument) arg); + directive_failed( sc, "task start" ); } -rtems_task -Init (rtems_task_argument ignored) +void doTest() { - int pass, i; rtems_status_code sc; + rtems_attribute attr; + int pass, i; - puts( "\n\n*** TEST 27 ***" ); - puts("Testing semaphore flush"); - sc = rtems_semaphore_create ( - rtems_build_name ('S', 'E', 'M', 'F'), + sc = rtems_semaphore_create( + rtems_build_name('S', 'E', 'M', 'F'), 0, - RTEMS_LOCAL| - RTEMS_BINARY_SEMAPHORE|RTEMS_NO_INHERIT_PRIORITY| - RTEMS_NO_PRIORITY_CEILING|RTEMS_FIFO, + TEST_SEMAPHORE_ATTRIBUTES, 0, &semaphore); - if (sc != RTEMS_SUCCESSFUL) { - printf ("Can't flush semaphore: %s\n", rtems_status_text (sc)); - exit (1); - } + directive_failed( sc, "semaphore create" ); + + for (i = 0 ; i < NTASK ; i++) + flags[i] = 0; + for (i = 0 ; i < NTASK ; i++) - starttask (i); + starttask(i); + for (pass = 1 ; pass < 10 ; pass++) { - rtems_task_wake_after (1); + rtems_task_wake_after(1); for (i = 0 ; i < NTASK ; i++) { if (flags[i] != pass) - printf ("flags[%d] = %d -- expected %d\n", i, flags[i], pass); - } - sc = rtems_semaphore_flush (semaphore); - if (sc != RTEMS_SUCCESSFUL) { - printf ("Can't flush semaphore: %s\n", rtems_status_text (sc)); - exit (1); + printf("flags[%d] = %d -- expected %d\n", i, flags[i], pass); } + sc = rtems_semaphore_flush(semaphore); + directive_failed( sc, "semaphore flush" ); } - printf ("Flushed all waiting tasks\n", NTASK ); - puts( "*** END OF TEST 27 ***" ); - exit (1); + printf("Flushed all waiting tasks\n", NTASK ); +} + +rtems_task Init( + rtems_task_argument ignored +) +{ + puts( "\n\n*** TEST " TEST_NAME " ***" ); + puts( "Testing " TEST_SEMAPHORE_TYPE " semaphore flush" ); + doTest(); + puts( "*** END OF TEST " TEST_NAME " ***" ); + + rtems_test_exit(0); } + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 6 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1 + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> + +/**************** END OF CONFIGURATION INFORMATION ****************/ + diff --git a/testsuites/sptests/sp27/sp27.doc b/testsuites/sptests/sp27/sp27.doc index e69de29bb2..dc781d77d2 100644 --- a/testsuites/sptests/sp27/sp27.doc +++ b/testsuites/sptests/sp27/sp27.doc @@ -0,0 +1,25 @@ +# +# $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: sp27 + +directives: + + rtems_semaphore_create + rtems_semaphore_obtain + rtems_semaphore_flush + +concepts: + ++ Ensure that flushing a counting semaphore with multiple waiting tasks + works as expected. diff --git a/testsuites/sptests/sp27/sp27.scn b/testsuites/sptests/sp27/sp27.scn index 7b914bf614..81695e741f 100644 --- a/testsuites/sptests/sp27/sp27.scn +++ b/testsuites/sptests/sp27/sp27.scn @@ -1,4 +1,4 @@ *** TEST 27 *** -Testing semaphore flush +Testing counting semaphore flush Flushed all waiting tasks *** END OF TEST 27 *** |