[PATCH 2/2] validation: Use support functions
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Mar 22 10:10:49 UTC 2021
---
testsuites/validation/tc-barrier-create.c | 31 ++-----
testsuites/validation/tc-barrier-delete.c | 55 ++----------
testsuites/validation/tc-barrier-release.c | 74 ++++-----------
testsuites/validation/tc-barrier-wait.c | 100 ++++-----------------
testsuites/validation/tc-signal-catch.c | 30 ++-----
testsuites/validation/tc-signal-send.c | 82 ++++-------------
6 files changed, 66 insertions(+), 306 deletions(-)
diff --git a/testsuites/validation/tc-barrier-create.c b/testsuites/validation/tc-barrier-create.c
index 2db0baea98..436030ef84 100644
--- a/testsuites/validation/tc-barrier-create.c
+++ b/testsuites/validation/tc-barrier-create.c
@@ -55,6 +55,8 @@
#include <rtems.h>
#include <string.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -208,11 +210,6 @@ static const char * const * const RtemsBarrierReqCreate_PreDesc[] = {
typedef RtemsBarrierReqCreate_Context Context;
-typedef enum {
- PRIO_NORMAL = 1,
- PRIO_LOW
-} Priorities;
-
static void Worker( rtems_task_argument arg )
{
Context *ctx;
@@ -548,23 +545,10 @@ static void RtemsBarrierReqCreate_Post_IdVar_Check(
static void RtemsBarrierReqCreate_Setup( RtemsBarrierReqCreate_Context *ctx )
{
- rtems_status_code sc;
-
memset( ctx, 0, sizeof( *ctx ) );
ctx->id_value = INVALID_ID;
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_LOW,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->worker_id
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
- T_assert_rsc_success( sc );
+ ctx->worker_id = CreateTask( "WORK", PRIO_LOW );
+ StartTask( ctx->worker_id, Worker, ctx );
}
static void RtemsBarrierReqCreate_Setup_Wrap( void *arg )
@@ -580,12 +564,7 @@ static void RtemsBarrierReqCreate_Teardown(
RtemsBarrierReqCreate_Context *ctx
)
{
- rtems_status_code sc;
-
- if ( ctx->worker_id != 0 ) {
- sc = rtems_task_delete( ctx->worker_id );
- T_rsc_success( sc );
- }
+ DeleteTask( ctx->worker_id );
}
static void RtemsBarrierReqCreate_Teardown_Wrap( void *arg )
diff --git a/testsuites/validation/tc-barrier-delete.c b/testsuites/validation/tc-barrier-delete.c
index 5cfbee8c06..1655ff1b2f 100644
--- a/testsuites/validation/tc-barrier-delete.c
+++ b/testsuites/validation/tc-barrier-delete.c
@@ -55,6 +55,8 @@
#include <rtems.h>
#include <string.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -135,12 +137,6 @@ static const char * const * const RtemsBarrierReqDelete_PreDesc[] = {
typedef RtemsBarrierReqDelete_Context Context;
-typedef enum {
- PRIO_HIGH = 1,
- PRIO_NORMAL,
- PRIO_LOW
-} Priorities;
-
static void Worker( rtems_task_argument arg )
{
Context *ctx;
@@ -169,9 +165,7 @@ static void Worker( rtems_task_argument arg )
++ctx->wait_done;
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_LOW, &prio );
- T_rsc_success( sc );
+ prio = SetSelfPriority( PRIO_LOW );
T_eq_u32( prio, PRIO_HIGH );
}
}
@@ -295,28 +289,10 @@ static void RtemsBarrierReqDelete_Post_Flush_Check(
static void RtemsBarrierReqDelete_Setup( RtemsBarrierReqDelete_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
-
memset( ctx, 0, sizeof( *ctx ) );
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_HIGH );
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_LOW,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->worker_id
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
- T_assert_rsc_success( sc );
+ SetSelfPriority( PRIO_NORMAL );
+ ctx->worker_id = CreateTask( "WORK", PRIO_LOW );
+ StartTask( ctx->worker_id, Worker, ctx );
}
static void RtemsBarrierReqDelete_Setup_Wrap( void *arg )
@@ -332,18 +308,8 @@ static void RtemsBarrierReqDelete_Teardown(
RtemsBarrierReqDelete_Context *ctx
)
{
- rtems_status_code sc;
- rtems_task_priority prio;
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_NORMAL );
-
- if ( ctx->worker_id != 0 ) {
- sc = rtems_task_delete( ctx->worker_id );
- T_rsc_success( sc );
- }
+ DeleteTask( ctx->worker_id );
+ RestoreRunnerPriority();
}
static void RtemsBarrierReqDelete_Teardown_Wrap( void *arg )
@@ -357,12 +323,9 @@ static void RtemsBarrierReqDelete_Teardown_Wrap( void *arg )
static void RtemsBarrierReqDelete_Prepare( RtemsBarrierReqDelete_Context *ctx )
{
- rtems_status_code sc;
rtems_task_priority prio;
- prio = 0;
- sc = rtems_task_set_priority( ctx->worker_id, PRIO_HIGH, &prio );
- T_rsc_success( sc );
+ prio = SetPriority( ctx->worker_id, PRIO_HIGH );
T_true( prio == PRIO_LOW || prio == PRIO_HIGH );
}
diff --git a/testsuites/validation/tc-barrier-release.c b/testsuites/validation/tc-barrier-release.c
index ee7a28026e..ca13ef8a6d 100644
--- a/testsuites/validation/tc-barrier-release.c
+++ b/testsuites/validation/tc-barrier-release.c
@@ -55,6 +55,8 @@
#include <rtems.h>
#include <string.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -167,19 +169,6 @@ static const char * const * const RtemsBarrierReqRelease_PreDesc[] = {
typedef RtemsBarrierReqRelease_Context Context;
-typedef enum {
- PRIO_HIGH = 1,
- PRIO_NORMAL
-} Priorities;
-
-static void SendEvents( rtems_id id, rtems_event_set events )
-{
- rtems_status_code sc;
-
- sc = rtems_event_send( id, events );
- T_rsc_success( sc );
-}
-
static void Worker( rtems_task_argument arg )
{
Context *ctx;
@@ -187,19 +176,13 @@ static void Worker( rtems_task_argument arg )
ctx = (Context *) arg;
while ( true ) {
- rtems_status_code sc;
- rtems_event_set events;
-
- events = 0;
- sc = rtems_event_receive(
- RTEMS_ALL_EVENTS,
- RTEMS_EVENT_ANY | RTEMS_WAIT,
- RTEMS_NO_TIMEOUT,
- &events
- );
- T_rsc_success( sc );
+ rtems_event_set events;
+
+ events = ReceiveAnyEvents();
if ( ( events & EVENT_WAIT ) != 0 ) {
+ rtems_status_code sc;
+
sc = rtems_barrier_wait( ctx->id, RTEMS_NO_TIMEOUT );
T_rsc_success( sc );
}
@@ -372,32 +355,12 @@ static void RtemsBarrierReqRelease_Post_ReleasedVar_Check(
static void RtemsBarrierReqRelease_Setup( RtemsBarrierReqRelease_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
+ rtems_status_code sc;
memset( ctx, 0, sizeof( *ctx ) );
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_HIGH );
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_HIGH,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->worker_id
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_start(
- ctx->worker_id,
- Worker,
- (rtems_task_argument) ctx
- );
- T_assert_rsc_success( sc );
+ SetSelfPriority( PRIO_NORMAL );
+ ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
+ StartTask( ctx->worker_id, Worker, ctx );
sc = rtems_barrier_create(
NAME,
@@ -429,18 +392,9 @@ static void RtemsBarrierReqRelease_Teardown(
RtemsBarrierReqRelease_Context *ctx
)
{
- rtems_status_code sc;
- rtems_task_priority prio;
+ rtems_status_code sc;
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_NORMAL );
-
- if ( ctx->worker_id != 0 ) {
- sc = rtems_task_delete( ctx->worker_id );
- T_rsc_success( sc );
- }
+ DeleteTask( ctx->worker_id );
if ( ctx->manual_release_id != 0 ) {
sc = rtems_barrier_delete( ctx->manual_release_id );
@@ -451,6 +405,8 @@ static void RtemsBarrierReqRelease_Teardown(
sc = rtems_barrier_delete( ctx->auto_release_id );
T_rsc_success( sc );
}
+
+ RestoreRunnerPriority();
}
static void RtemsBarrierReqRelease_Teardown_Wrap( void *arg )
diff --git a/testsuites/validation/tc-barrier-wait.c b/testsuites/validation/tc-barrier-wait.c
index 2f7e41a28c..b67acabe13 100644
--- a/testsuites/validation/tc-barrier-wait.c
+++ b/testsuites/validation/tc-barrier-wait.c
@@ -55,6 +55,8 @@
#include <rtems.h>
#include <string.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -170,20 +172,6 @@ static const char * const * const RtemsBarrierReqWait_PreDesc[] = {
typedef RtemsBarrierReqWait_Context Context;
-typedef enum {
- PRIO_HIGH = 1,
- PRIO_NORMAL,
- PRIO_LOW
-} Priorities;
-
-static void SendEvents( rtems_id id, rtems_event_set events )
-{
- rtems_status_code sc;
-
- sc = rtems_event_send( id, events );
- T_rsc_success( sc );
-}
-
static void Worker( rtems_task_argument arg )
{
Context *ctx;
@@ -194,14 +182,7 @@ static void Worker( rtems_task_argument arg )
rtems_status_code sc;
rtems_event_set events;
- events = 0;
- sc = rtems_event_receive(
- RTEMS_ALL_EVENTS,
- RTEMS_EVENT_ANY | RTEMS_WAIT,
- RTEMS_NO_TIMEOUT,
- &events
- );
- T_rsc_success( sc );
+ events = ReceiveAnyEvents();
if ( ( events & EVENT_CHECK_TIMER ) != 0 ) {
T_eq_int(
@@ -238,9 +219,7 @@ static void Worker( rtems_task_argument arg )
id = &ctx->auto_release_id;
}
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
- T_rsc_success( sc );
+ prio = SetSelfPriority( PRIO_HIGH );
T_eq_u32( prio, PRIO_LOW );
sc = rtems_barrier_delete( ctx->id );
@@ -249,8 +228,7 @@ static void Worker( rtems_task_argument arg )
sc = rtems_barrier_create( NAME, attribute_set, maximum_waiters, id );
T_rsc_success( sc );
- sc = rtems_task_set_priority( RTEMS_SELF, prio, &prio );
- T_rsc_success( sc );
+ prio = SetSelfPriority( prio );
T_eq_u32( prio, PRIO_HIGH );
}
}
@@ -422,50 +400,15 @@ static void RtemsBarrierReqWait_Post_Status_Check(
static void RtemsBarrierReqWait_Setup( RtemsBarrierReqWait_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
+ rtems_status_code sc;
memset( ctx, 0, sizeof( *ctx ) );
ctx->main_id = rtems_task_self();
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_HIGH );
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_HIGH,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->high_worker_id
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_start(
- ctx->high_worker_id,
- Worker,
- (rtems_task_argument) ctx
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_LOW,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->low_worker_id
- );
- T_assert_rsc_success( sc );
-
- sc = rtems_task_start(
- ctx->low_worker_id,
- Worker,
- (rtems_task_argument) ctx
- );
- T_assert_rsc_success( sc );
+ SetSelfPriority( PRIO_NORMAL );
+ ctx->high_worker_id = CreateTask( "WRKH", PRIO_HIGH );
+ StartTask( ctx->high_worker_id, Worker, ctx );
+ ctx->low_worker_id = CreateTask( "WRKL", PRIO_LOW );
+ StartTask( ctx->low_worker_id, Worker, ctx );
sc = rtems_barrier_create(
NAME,
@@ -495,23 +438,10 @@ static void RtemsBarrierReqWait_Setup_Wrap( void *arg )
static void RtemsBarrierReqWait_Teardown( RtemsBarrierReqWait_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_NORMAL );
-
- if ( ctx->high_worker_id != 0 ) {
- sc = rtems_task_delete( ctx->high_worker_id );
- T_rsc_success( sc );
- }
+ rtems_status_code sc;
- if ( ctx->low_worker_id != 0 ) {
- sc = rtems_task_delete( ctx->low_worker_id );
- T_rsc_success( sc );
- }
+ DeleteTask( ctx->high_worker_id );
+ DeleteTask( ctx->low_worker_id );
if ( ctx->manual_release_id != 0 ) {
sc = rtems_barrier_delete( ctx->manual_release_id );
@@ -522,6 +452,8 @@ static void RtemsBarrierReqWait_Teardown( RtemsBarrierReqWait_Context *ctx )
sc = rtems_barrier_delete( ctx->auto_release_id );
T_rsc_success( sc );
}
+
+ RestoreRunnerPriority();
}
static void RtemsBarrierReqWait_Teardown_Wrap( void *arg )
diff --git a/testsuites/validation/tc-signal-catch.c b/testsuites/validation/tc-signal-catch.c
index 9025521aa9..be0ba2c7d3 100644
--- a/testsuites/validation/tc-signal-catch.c
+++ b/testsuites/validation/tc-signal-catch.c
@@ -56,6 +56,8 @@
#include <string.h>
#include <rtems/score/smpbarrier.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -666,15 +668,7 @@ static void RtemsSignalReqCatch_Setup( RtemsSignalReqCatch_Context *ctx )
rtems_status_code sc;
rtems_id scheduler_id;
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- 1,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->worker_id
- );
- T_assert_rsc_success( sc );
+ ctx->worker_id = CreateTask( "WORK", 1 );
sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
T_assert_rsc_success( sc );
@@ -682,12 +676,7 @@ static void RtemsSignalReqCatch_Setup( RtemsSignalReqCatch_Context *ctx )
sc = rtems_task_set_scheduler( ctx->worker_id, scheduler_id, 1 );
T_assert_rsc_success( sc );
- sc = rtems_task_start(
- ctx->worker_id,
- Worker,
- (rtems_task_argument) ctx
- );
- T_assert_rsc_success( sc );
+ StartTask( ctx->worker_id, Worker, ctx );
}
}
@@ -702,15 +691,8 @@ static void RtemsSignalReqCatch_Setup_Wrap( void *arg )
static void RtemsSignalReqCatch_Teardown( RtemsSignalReqCatch_Context *ctx )
{
- rtems_status_code sc;
-
- if ( ctx->worker_id != 0 ) {
- sc = rtems_task_delete( ctx->worker_id );
- T_rsc_success( sc );
- }
-
- sc = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
- T_rsc_success( sc );
+ DeleteTask( ctx->worker_id );
+ RestoreRunnerASR();
}
static void RtemsSignalReqCatch_Teardown_Wrap( void *arg )
diff --git a/testsuites/validation/tc-signal-send.c b/testsuites/validation/tc-signal-send.c
index 76ef5ead16..777143cf48 100644
--- a/testsuites/validation/tc-signal-send.c
+++ b/testsuites/validation/tc-signal-send.c
@@ -54,6 +54,8 @@
#include <rtems.h>
+#include "tc-support.h"
+
#include <rtems/test.h>
/**
@@ -217,36 +219,6 @@ static const char * const * const RtemsSignalReqSend_PreDesc[] = {
typedef RtemsSignalReqSend_Context Context;
-typedef enum {
- PRIO_HIGH = 1,
- PRIO_NORMAL
-} Priorities;
-
-static rtems_event_set Wait( void )
-{
- rtems_status_code sc;
- rtems_event_set events;
-
- events = 0;
- sc = rtems_event_receive(
- RTEMS_ALL_EVENTS,
- RTEMS_EVENT_ANY | RTEMS_WAIT,
- RTEMS_NO_TIMEOUT,
- &events
- );
- T_rsc_success( sc );
-
- return events;
-}
-
-static void SendEvents( rtems_id id, rtems_event_set events )
-{
- rtems_status_code sc;
-
- sc = rtems_event_send( id, events );
- T_rsc_success( sc );
-}
-
static void WorkerDone( const Context *ctx )
{
#if defined(RTEMS_SMP)
@@ -262,7 +234,7 @@ static void SendEventsToWorker( const Context *ctx, rtems_event_set events )
#if defined(RTEMS_SMP)
if ( rtems_scheduler_get_processor_maximum() > 1 ) {
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_WORKER_DONE );
}
#endif
@@ -293,12 +265,12 @@ static void SignalHandler( rtems_signal_set signal_set )
WorkerDone( ctx );
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_SEND_DONE );
WorkerDone( ctx );
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_DO_ENABLE );
} else {
sc = rtems_signal_catch( ctx->handler, RTEMS_NO_ASR );
@@ -321,7 +293,7 @@ static void Worker( rtems_task_argument arg )
rtems_status_code sc;
rtems_event_set events;
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_START );
if ( ctx->nested != 0 ) {
@@ -343,12 +315,12 @@ static void Worker( rtems_task_argument arg )
WorkerDone( ctx );
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_SEND_DONE );
WorkerDone( ctx );
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_DO_ENABLE );
sc = rtems_task_mode( mode, RTEMS_ASR_MASK, &mode );
@@ -357,7 +329,7 @@ static void Worker( rtems_task_argument arg )
WorkerDone( ctx );
}
- events = Wait();
+ events = ReceiveAnyEvents();
T_eq_u32( events, EVENT_END );
WorkerDone( ctx );
@@ -659,26 +631,13 @@ static void RtemsSignalReqSend_Post_Recursive_Check(
static void RtemsSignalReqSend_Setup( RtemsSignalReqSend_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
+ rtems_status_code sc;
memset( ctx, 0, sizeof( *ctx ) );
ctx->runner_id = rtems_task_self();
+ SetSelfPriority( PRIO_NORMAL );
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_HIGH );
-
- sc = rtems_task_create(
- rtems_build_name( 'W', 'O', 'R', 'K' ),
- PRIO_HIGH,
- RTEMS_MINIMUM_STACK_SIZE,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &ctx->worker_id
- );
- T_assert_rsc_success( sc );
+ ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
#if defined(RTEMS_SMP)
if ( rtems_scheduler_get_processor_maximum() > 1 ) {
@@ -692,8 +651,7 @@ static void RtemsSignalReqSend_Setup( RtemsSignalReqSend_Context *ctx )
}
#endif
- sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
- T_assert_rsc_success( sc );
+ StartTask( ctx->worker_id, Worker, ctx );
}
static void RtemsSignalReqSend_Setup_Wrap( void *arg )
@@ -707,18 +665,8 @@ static void RtemsSignalReqSend_Setup_Wrap( void *arg )
static void RtemsSignalReqSend_Teardown( RtemsSignalReqSend_Context *ctx )
{
- rtems_status_code sc;
- rtems_task_priority prio;
-
- prio = 0;
- sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
- T_rsc_success( sc );
- T_eq_u32( prio, PRIO_NORMAL );
-
- if ( ctx->worker_id != 0 ) {
- sc = rtems_task_delete( ctx->worker_id );
- T_rsc_success( sc );
- }
+ DeleteTask( ctx->worker_id );
+ RestoreRunnerPriority();
}
static void RtemsSignalReqSend_Teardown_Wrap( void *arg )
--
2.26.2
More information about the devel
mailing list