2011-07-24 Joel Sherrill <joel.sherrill@oarcorp.com>

* sp04/tswitch.c, sp07/task1.c, sp07/task2.c, sp09/screen07.c,
	sp11/task1.c, sp11/task2.c, sp12/pridrv.c, sp12/pritask.c,
	sp13/task1.c, sp14/asr.c, sp14/task1.c, sp19/first.c, sp19/fptask.c,
	sp19/inttest.h, sp19/task1.c, sp20/task1.c, sp25/task1.c,
	sp26/task1.c, sp28/init.c, sp29/init.c, sp31/task1.c, sp32/init.c,
	sp33/init.c, sp34/changepri.c, sp36/strict_order_mut.c, sp37/init.c,
	sp43/init.c, sp44/init.c, sp48/init.c, sp54/init.c, sp59/init.c,
	sp65/init.c, sp68/init.c, spchain/init.c, spclockget/init.c,
	spfatal03/testcase.h, spfatal07/testcase.h, spfatal_support/init.c:
	Do not line length exceed 80 columns.
This commit is contained in:
Joel Sherrill
2011-07-24 22:10:20 +00:00
parent 0ef2534489
commit 9e15e9bfba
39 changed files with 774 additions and 703 deletions

View File

@@ -1,6 +1,4 @@
/*
* Test for rtems_semaphore_flush
*
* 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.
@@ -12,6 +10,7 @@
#include "config.h"
#endif
#include <tmacros.h>
#include <bsp.h>
rtems_task Init (rtems_task_argument argument);
@@ -42,156 +41,192 @@ void startTask(rtems_id arg);
rtems_task
subtask (rtems_task_argument arg)
{
rtems_status_code sc;
rtems_id sem = (rtems_id)arg;
rtems_status_code sc;
rtems_id sem = (rtems_id)arg;
for (;;) {
rtems_task_wake_after (ticksPerSecond * 2);
for (;;) {
rtems_task_wake_after (ticksPerSecond * 2);
sc = rtems_semaphore_release (sem);
if (sc != RTEMS_SUCCESSFUL)
printf ("%d: Can't release semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_release (sem);
if (sc != RTEMS_SUCCESSFUL) {
printf(
"%d: Can't release semaphore: %s\n", __LINE__,
rtems_status_text (sc)
);
}
}
}
void
startTask (rtems_id arg)
{
rtems_id tid;
rtems_status_code sc;
rtems_id tid;
rtems_status_code sc;
sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', 'A'),
RTEMS_MAXIMUM_PRIORITY - 1u,
RTEMS_MINIMUM_STACK_SIZE * 2,
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, arg);
if (sc != RTEMS_SUCCESSFUL) {
printf ("Can't start task: %s\n", rtems_status_text (sc));
rtems_task_suspend (RTEMS_SELF);
}
sc = rtems_task_create (rtems_build_name ('S', 'R', 'V', 'A'),
RTEMS_MAXIMUM_PRIORITY - 1u,
RTEMS_MINIMUM_STACK_SIZE * 2,
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, arg);
if (sc != RTEMS_SUCCESSFUL) {
printf ("Can't start task: %s\n", rtems_status_text (sc));
rtems_task_suspend (RTEMS_SELF);
}
}
rtems_task Init (rtems_task_argument ignored)
{
int i;
rtems_id semrec, semnorec;
rtems_status_code sc;
rtems_interval then, now;
int i;
rtems_id semrec, semnorec;
rtems_status_code sc;
rtems_interval then, now;
puts( "*** SP29 - SIMPLE SEMAPHORE TEST ***" );
puts( "This test only prints on errors." );
puts( "*** SP29 - SIMPLE SEMAPHORE TEST ***" );
puts( "This test only prints on errors." );
ticksPerSecond = rtems_clock_get_ticks_per_second();
if (ticksPerSecond <= 0) {
printf ("Invalid ticks per second: %" PRIdrtems_interval "\n", ticksPerSecond);
exit (1);
}
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'r', 'c'),
1,
RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY |RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
0,
&semrec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't create recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
exit (1);
}
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'n', 'c'),
1,
RTEMS_PRIORITY|RTEMS_SIMPLE_BINARY_SEMAPHORE|RTEMS_NO_INHERIT_PRIORITY |RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
0,
&semnorec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't create non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
exit (1);
}
ticksPerSecond = rtems_clock_get_ticks_per_second();
if (ticksPerSecond <= 0) {
printf(
"Invalid ticks per second: %" PRIdrtems_interval "\n",
ticksPerSecond
);
exit (1);
}
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'r', 'c'),
1,
RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY| \
RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
0,
&semrec
);
directive_failed( sc, "create recursive lock" );
sc = rtems_semaphore_obtain (semrec, RTEMS_NO_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't obtain recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semrec, RTEMS_NO_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't reobtain recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'n', 'c'),
1,
RTEMS_PRIORITY|RTEMS_SIMPLE_BINARY_SEMAPHORE|RTEMS_NO_INHERIT_PRIORITY| \
RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
0,
&semnorec
);
directive_failed( sc, "create non-recursive lock" );
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc == RTEMS_SUCCESSFUL) {
printf ("%d: Reobtain non-recursive-lock semaphore -- and should not have.\n", __LINE__);
}
sc = rtems_semaphore_obtain (semrec, RTEMS_NO_WAIT, 0);
directive_failed( sc, "obtain recursive lock" );
sc = rtems_semaphore_release (semnorec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't release non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_release (semnorec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't rerelease non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc == RTEMS_SUCCESSFUL) {
printf ("%d: Reobtain non-recursive-lock semaphore -- and should not have.\n", __LINE__);
}
else if (sc != RTEMS_UNSATISFIED) {
printf ("%d: Reobtain non-recursive-lock semaphore failed, but error is %d (%s), not RTEMS_UNSATISFIED.\n", __LINE__, sc, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semrec, RTEMS_NO_WAIT, 0);
directive_failed( sc, "reobtain recursive lock" );
sc = rtems_semaphore_release (semnorec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't release non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_release (semnorec);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't rerelease non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL) {
printf ("%d: Can't obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
}
/*
* Since this task is holding this, this task will block and timeout.
* Then the timeout error will be returned.
*/
then = rtems_clock_get_ticks_since_boot();
sc = rtems_semaphore_obtain (semnorec, RTEMS_WAIT, 5);
now = rtems_clock_get_ticks_since_boot();
if (sc == RTEMS_SUCCESSFUL) {
printf ("%d: Reobtain non-recursive-lock semaphore -- and should not have.\n", __LINE__);
}
else if (sc != RTEMS_TIMEOUT) {
printf ("%d: Reobtain non-recursive-lock semaphore failed, but error is %d (%s), not RTEMS_TIMEOUT.\n", __LINE__, sc, rtems_status_text (sc));
}
if ((then - now) < 4)
printf ("%d: Reobtain non-recursive-lock semaphore failed without timeout.\n", __LINE__);
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
directive_failed( sc, "reobtain recursive lock" );
startTask (semnorec);
then = rtems_clock_get_ticks_since_boot();
for (i = 0 ; i < 5 ; i++) {
rtems_interval diff;
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc == RTEMS_SUCCESSFUL) {
printf(
"%d: Reobtain non-recursive-lock semaphore -- and should not have.\n",
__LINE__
);
rtems_test_exit(1);
}
sc = rtems_semaphore_obtain (semnorec, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
now = rtems_clock_get_ticks_since_boot();
diff = (now - then);
then = now;
if (sc != RTEMS_SUCCESSFUL)
printf ("%d: Failed to obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
else if (diff < (int) (2 * ticksPerSecond))
printf ("%d: Obtained obtain non-recursive-lock semaphore too quickly -- %" PRIdrtems_interval " ticks not %" PRIdrtems_interval " ticks\n", __LINE__, diff, (2 * ticksPerSecond) );
}
sc = rtems_semaphore_release (semnorec);
directive_failed( sc, "release non-recursive lock" );
puts( "*** END OF TEST 29 ***" );
exit (0);
sc = rtems_semaphore_release (semnorec);
directive_failed( sc, "re-release non-recursive lock" );
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
directive_failed( sc, "obtain non-recursive lock" );
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
if (sc == RTEMS_SUCCESSFUL) {
printf(
"%d: Reobtain non-recursive-lock semaphore -- and should not have.\n",
__LINE__
);
} else if (sc != RTEMS_UNSATISFIED) {
printf(
"%d: Reobtain non-recursive-lock semaphore failed, but error is "
"%d (%s), not RTEMS_UNSATISFIED.\n",
__LINE__,
sc,
rtems_status_text (sc)
);
}
sc = rtems_semaphore_release (semnorec);
directive_failed( sc, "release non-recursive lock" );
sc = rtems_semaphore_release (semnorec);
directive_failed( sc, "rerelease non-recursive lock" );
sc = rtems_semaphore_obtain (semnorec, RTEMS_NO_WAIT, 0);
directive_failed( sc, "obtain non-recursive lock" );
/*
* Since this task is holding this, this task will block and timeout.
* Then the timeout error will be returned.
*/
then = rtems_clock_get_ticks_since_boot();
sc = rtems_semaphore_obtain (semnorec, RTEMS_WAIT, 5);
now = rtems_clock_get_ticks_since_boot();
if (sc == RTEMS_SUCCESSFUL) {
printf(
"%d: Reobtain non-recursive-lock semaphore -- and should not have.\n",
__LINE__
);
} else if (sc != RTEMS_TIMEOUT) {
printf(
"%d: Reobtain non-recursive-lock semaphore failed, but error is "
"%d (%s), not RTEMS_TIMEOUT.\n",
__LINE__,
sc,
rtems_status_text (sc)
);
}
if ((then - now) < 4) {
printf(
"%d: Reobtain non-recursive-lock semaphore failed without timeout.\n",
__LINE__
);
}
startTask (semnorec);
then = rtems_clock_get_ticks_since_boot();
for (i = 0 ; i < 5 ; i++) {
rtems_interval diff;
sc = rtems_semaphore_obtain(
semnorec,
RTEMS_WAIT,
RTEMS_NO_TIMEOUT
);
now = rtems_clock_get_ticks_since_boot();
diff = (now - then);
then = now;
if (sc != RTEMS_SUCCESSFUL) {
printf(
"%d: Failed to obtain non-recursive-lock semaphore: %s\n",
__LINE__,
rtems_status_text (sc)
);
} else if (diff < (int) (2 * ticksPerSecond)) {
printf(
"%d: Obtained obtain non-recursive-lock semaphore too quickly -- %"
PRIdrtems_interval " ticks not %" PRIdrtems_interval " ticks\n",
__LINE__,
diff,
(2 * ticksPerSecond)
);
}
}
puts( "*** END OF TEST 29 ***" );
rtems_test_exit (0);
}