summaryrefslogtreecommitdiff
path: root/testsuites/validation/tr-model-events-mgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/validation/tr-model-events-mgr.c')
-rw-r--r--[-rwxr-xr-x]testsuites/validation/tr-model-events-mgr.c280
1 files changed, 85 insertions, 195 deletions
diff --git a/testsuites/validation/tr-model-events-mgr.c b/testsuites/validation/tr-model-events-mgr.c
index b677fb3c82..4bb8f9773d 100755..100644
--- a/testsuites/validation/tr-model-events-mgr.c
+++ b/testsuites/validation/tr-model-events-mgr.c
@@ -1,7 +1,14 @@
/* SPDX-License-Identifier: BSD-2-Clause */
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsModelEventsMgr
+ */
+
/*
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Trinity College Dublin (http://www.tcd.ie)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,39 +58,27 @@ typedef enum {
PRIO_OTHER
} Priorities;
-typedef enum {
- SENDER_NONE,
- SENDER_SELF,
- SENDER_SELF_2,
- SENDER_WORKER,
- SENDER_INTERRUPT
-} SenderTypes;
-
-typedef enum {
- RECEIVE_SKIP,
- RECEIVE_NORMAL,
- RECEIVE_INTERRUPT
-} ReceiveTypes;
-
-typedef enum {
- RECEIVE_COND_UNKNOWN,
- RECEIVE_COND_SATSIFIED,
- RECEIVE_COND_UNSATISFIED
-} ReceiveConditionStates;
typedef struct {
- SenderTypes sender_type;
- Priorities sender_prio; // sender task priority.
+ rtems_status_code ( *send )( rtems_id, rtems_event_set ); // copy of the
+ // corresponding RtemsModelEventsMgr_Run() parameter
+ rtems_status_code ( *receive )
+ ( rtems_event_set, rtems_option
+ , rtems_interval, rtems_event_set * ); // copy of the
+ // corresponding RtemsModelEventsMgr_Run() parameter
+ rtems_event_set ( *get_pending_events )( Thread_Control * ); // copy of the
+ // corresponding RtemsModelEventsMgr_Run() parameter
+ unsigned int wait_class; // copy of the corresponding
+ // RtemsModelEventsMgr_Run() parameter
+ int waiting_for_event; // copy of the corresponding
+ // RtemsModelEventsMgr_Run() parameter
rtems_id receiver_id; // receiver ID used for the event send action.
rtems_event_set events_to_send; // events to send for the event send action
rtems_status_code send_status; // status of the event send action.
- ReceiveTypes receive_type; // scheduler ID of the runner task.
rtems_option receive_option_set; // option set used for the event receive action
rtems_interval receive_timeout; // timeout used for the event receive action
rtems_event_set received_events; // events received by the event receive action
rtems_status_code receive_status; // status of the event receive action
- ReceiveConditionStates receive_condition_state; // event conditon state of the
- // receiver task after the event send action
rtems_event_set unsatisfied_pending; // pending events after an event send action
// which did not satsify the event condition of the receiver
Thread_Control *runner_thread; // TCB of the runner task
@@ -95,66 +90,12 @@ typedef struct {
rtems_id other_sched; // scheduler ID of another scheduler
// which is not used by the runner task
T_thread_switch_log_4 thread_switch_log; // thread switch log
- rtems_status_code ( *send )( rtems_id, rtems_event_set ); // copy of the
- // corresponding RtemsModelEventsMgr_Run() parameter
- rtems_status_code ( *receive )
- ( rtems_event_set, rtems_option
- , rtems_interval, rtems_event_set * ); // copy of the
- // corresponding RtemsModelEventsMgr_Run() parameter
- rtems_event_set ( *get_pending_events )( Thread_Control * ); // copy of the
- // corresponding RtemsModelEventsMgr_Run() parameter
- unsigned int wait_class; // copy of the corresponding
- // RtemsModelEventsMgr_Run() parameter
- int waiting_for_event; // copy of the corresponding
- // RtemsModelEventsMgr_Run() parameter
- size_t pcs[ 4 ]; // pre-condition states for the next action
- bool in_action_loop; // indicates if test action loop is currently executed.
} RtemsModelEventsMgr_Context;
static RtemsModelEventsMgr_Context
RtemsModelEventsMgr_Instance;
-static const char * const RtemsModelEventsMgr_PreDesc_Id[] = {
- "InvId",
- "Task",
- "NA"
-};
-
-static const char * const RtemsModelEventsMgr_PreDesc_Send[] = {
- "Zero",
- "Unrelated",
- "Any",
- "All",
- "MixedAny",
- "MixedAll",
- "NA"
-};
-
-static const char * const RtemsModelEventsMgr_PreDesc_ReceiverState[] = {
- "NotWaiting",
- "Poll",
- "Timeout",
- "Lower",
- "Equal",
- "Higher",
- "Other",
- "Intend",
- "NA"
-};
-
-static const char * const RtemsModelEventsMgr_PreDesc_Satisfy[] = {
- "All",
- "Any",
- "NA"
-};
-
-static const char * const * const RtemsModelEventsMgr_PreDesc[] = {
- RtemsModelEventsMgr_PreDesc_Id,
- RtemsModelEventsMgr_PreDesc_Send,
- RtemsModelEventsMgr_PreDesc_ReceiverState,
- RtemsModelEventsMgr_PreDesc_Satisfy,
- NULL
-};
+static const char PromelaModelEventsMgr[] = "/PML-EventsMgr";
#define INPUT_EVENTS ( RTEMS_EVENT_5 | RTEMS_EVENT_23 )
@@ -224,51 +165,6 @@ static void Wakeup( rtems_id id )
T_quiet_rsc_success( sc );
}
-
-static bool IsSatisfiedState( Context *ctx )
-{
- return ctx->runner_thread->current_state != ctx->waiting_for_event;
-}
-
-static void SendAction( Context *ctx )
-{
- T_thread_switch_log *log;
-
- log = T_thread_switch_record_4( &ctx->thread_switch_log );
- T_quiet_null( log );
- ctx->send_status = ( *ctx->send )( ctx->receiver_id, ctx->events_to_send );
- log = T_thread_switch_record( NULL );
- T_quiet_eq_ptr( log, &ctx->thread_switch_log.log );
-}
-
-static void Send(
- Context *ctx,
- bool ( *is_satsified )( Context * )
-)
-{
- SendAction( ctx );
-
- if ( ( *is_satsified )( ctx ) ) {
- ctx->receive_condition_state = RECEIVE_COND_SATSIFIED;
- } else {
- rtems_status_code sc;
- rtems_event_set pending;
- rtems_event_set missing;
-
- ctx->receive_condition_state = RECEIVE_COND_UNSATISFIED;
- pending = ( *ctx->get_pending_events )( ctx->runner_thread );
- ctx->unsatisfied_pending = pending;
-
- missing = INPUT_EVENTS & ~ctx->events_to_send;
- T_ne_u32( missing, 0 );
- sc = ( *ctx->send )( ctx->runner_id, missing );
- T_rsc_success( sc );
-
- pending = ( *ctx->get_pending_events )( ctx->runner_thread );
- T_eq_u32( pending, ctx->events_to_send & ~INPUT_EVENTS );
- }
-}
-
static rtems_event_set GetPendingEvents( Context *ctx )
{
rtems_event_set pending;
@@ -340,31 +236,56 @@ static void initialise_semaphore( Context *ctx, rtems_id semaphore[] )
/* =============================================== */
+// @@@ 0 NAME Event_Manager_TestGen
+// @@@ 0 DEF NO_OF_EVENTS 4
#define NO_OF_EVENTS 4
+// @@@ 0 DEF EVTS_NONE 0
#define EVTS_NONE 0
+// @@@ 0 DEF EVTS_PENDING 0
#define EVTS_PENDING 0
+// @@@ 0 DEF EVT_0 1
#define EVT_0 1
+// @@@ 0 DEF EVT_1 2
#define EVT_1 2
+// @@@ 0 DEF EVT_2 4
#define EVT_2 4
+// @@@ 0 DEF EVT_3 8
#define EVT_3 8
+// @@@ 0 DEF NO_TIMEOUT 0
#define NO_TIMEOUT 0
+// @@@ 0 DEF TASK_MAX 2
#define TASK_MAX 2
+// @@@ 0 DEF BAD_ID 2
#define BAD_ID 2
+// @@@ 0 DEF SEMA_MAX 2
#define SEMA_MAX 2
+// @@@ 0 DEF RC_OK RTEMS_SUCCESSFUL
#define RC_OK RTEMS_SUCCESSFUL
+// @@@ 0 DEF RC_InvId RTEMS_INVALID_ID
#define RC_InvId RTEMS_INVALID_ID
+// @@@ 0 DEF RC_InvAddr RTEMS_INVALID_ADDRESS
#define RC_InvAddr RTEMS_INVALID_ADDRESS
+// @@@ 0 DEF RC_Unsat RTEMS_UNSATISFIED
#define RC_Unsat RTEMS_UNSATISFIED
+// @@@ 0 DEF RC_Timeout RTEMS_TIMEOUT
#define RC_Timeout RTEMS_TIMEOUT
-rtems_event_set pending[TASK_MAX];
-static unsigned int sendrc = 0;
-static unsigned int recrc = 0;
-static unsigned int recout = 0;
-rtems_id semaphore[SEMA_MAX];
+// @@@ 0 DCLARRAY EvtSet pending TASK_MAX
+static rtems_event_set pending[TASK_MAX];
+// @@@ 0 DECL byte sendrc 0
+static rtems_status_code sendrc = 0;
+// @@@ 0 DECL byte recrc 0
+static rtems_status_code recrc = 0;
+// @@@ 0 DECL byte recout 0
+static rtems_event_set recout = 0;
+// @@@ 0 DCLARRAY Semaphore semaphore SEMA_MAX
+static rtems_id semaphore[SEMA_MAX];
/* ===== TEST CODE SEGMENT 0 =====*/
static void TestSegment0( Context* ctx ) {
+ /* Test Name is defined in the Test Case code (tc-model-events-mgr.c) */
+
+ T_log(T_NORMAL,"@@@ 0 INIT");
initialise_pending( pending, TASK_MAX );
initialise_semaphore( ctx, semaphore );
@@ -373,47 +294,57 @@ static void TestSegment0( Context* ctx ) {
/* ===== TEST CODE SEGMENT 3 =====*/
static void TestSegment3( Context* ctx ) {
+ T_log(T_NORMAL,"@@@ 3 TASK Worker");
checkTaskIs( ctx->worker_id );
+ T_log(T_NORMAL,"@@@ 3 WAIT 0");
Wait( semaphore[0] );
- pending[1] = GetPendingEvents( ctx );
- T_eq_int( pending[1], 0 );
-
- T_log( T_NORMAL, "Calling Send(%d,%d)", mapid( ctx, 1), 14 );
- sendrc = rtems_event_send( mapid( ctx, 1 ), 14 );
+ T_log(T_NORMAL,"@@@ 3 CALL event_send 0 1 15 sendrc");
+ T_log( T_NORMAL, "Calling Send(%d,%d)", mapid( ctx, 1), 15 );
+ sendrc = ( *ctx->send )( mapid( ctx, 1 ), 15 );
T_log( T_NORMAL, "Returned 0x%x from Send", sendrc );
- T_eq_int( sendrc, 0 );
- pending[1] = GetPendingEvents( ctx );
- T_eq_int( pending[1], 14 );
-
+ T_log(T_NORMAL,"@@@ 3 SCALAR sendrc 0");
+ T_rsc_success( sendrc );
+ T_log(T_NORMAL,"@@@ 3 SIGNAL 1");
Wakeup( semaphore[1] );
+ T_log(T_NORMAL,"@@@ 3 STATE 0 Zombie");
/* Code to check that Task 0 has terminated */
}
/* ===== TEST CODE SEGMENT 4 =====*/
static void TestSegment4( Context* ctx ) {
+ T_log(T_NORMAL,"@@@ 4 TASK Runner");
checkTaskIs( ctx->runner_id );
+ T_log(T_NORMAL,"@@@ 4 SIGNAL 0");
Wakeup( semaphore[0] );
+ T_log(T_NORMAL,"@@@ 4 WAIT 1");
Wait( semaphore[1] );
+ T_log(T_NORMAL,"@@@ 4 SCALAR pending 1 15");
pending[1] = GetPendingEvents( ctx );
- T_eq_int( pending[1], 14 );
+ T_eq_int( pending[1], 15 );
- T_log( T_NORMAL, "Calling Receive(%d,%d,%d,%d)", 10, mergeopts( 1, 1 ) ,0 ,&recout );
- recrc = rtems_event_receive( 10, mergeopts( 1, 1 ), 0, &recout );
+ T_log(T_NORMAL,"@@@ 4 CALL event_receive 6 1 1 0 recout recrc");
+ T_log( T_NORMAL, "Calling Receive(%d,%d,%d,%d)", 6, mergeopts( 1, 1 ) ,0 ,&recout );
+ recrc = ( *ctx->receive )( 6, mergeopts( 1, 1 ), 0, &recout );
T_log( T_NORMAL, "Returned 0x%x from Receive", recrc );
- T_eq_int( recrc, 0 );
- T_eq_int( recout, 10 );
+ T_log(T_NORMAL,"@@@ 4 SCALAR recrc 0");
+ T_rsc_success( recrc );
+ T_log(T_NORMAL,"@@@ 4 SCALAR recout 6");
+ T_eq_int( recout, 6 );
+ T_log(T_NORMAL,"@@@ 4 SCALAR pending 1 9");
pending[1] = GetPendingEvents( ctx );
- T_eq_int( pending[1], 4 );
+ T_eq_int( pending[1], 9 );
+ T_log(T_NORMAL,"@@@ 4 SIGNAL 0");
Wakeup( semaphore[0] );
+ T_log(T_NORMAL,"@@@ 4 STATE 1 Zombie");
/* Code to check that Task 1 has terminated */
}
@@ -432,40 +363,6 @@ static void Worker( rtems_task_argument arg )
rtems_task_exit();
- // while(true) {
- // Wait( ctx->worker_wakeup );
- //
- // switch ( ctx->sender_prio ) {
- // case PRIO_NORMAL:
- // case PRIO_HIGH:
- // prio = 0;
- // sc = rtems_task_set_priority( RTEMS_SELF, ctx->sender_prio, &prio );
- // T_rsc_success( sc );
- // T_eq_u32( prio, PRIO_LOW );
- // break;
- // case PRIO_OTHER:
- // sc = rtems_task_set_scheduler(
- // RTEMS_SELF,
- // ctx->other_sched,
- // PRIO_LOW
- // );
- // T_rsc_success( sc );
- // break;
- // case PRIO_LOW:
- // break;
- // }
- //
- // Send( ctx, IsSatisfiedState );
- //
- // sc = rtems_task_set_scheduler(
- // RTEMS_SELF,
- // ctx->runner_sched,
- // PRIO_HIGH
- // );
- // T_rsc_success( sc );
- //
- // Wakeup( ctx->runner_wakeup );
- // }
}
@@ -510,8 +407,9 @@ static void RtemsModelEventsMgr_Setup(
T_log( T_NORMAL, "Construct Worker, sc = %x", sc );
T_assert_rsc_success( sc );
+ T_log( T_NORMAL, "Starting Worker..." );
sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
- T_log( T_NORMAL, "Start Worker, sc = %x", sc );
+ T_log( T_NORMAL, "Started Worker, sc = %x", sc );
T_assert_rsc_success( sc );
}
@@ -520,7 +418,6 @@ static void RtemsModelEventsMgr_Setup_Wrap( void *arg )
RtemsModelEventsMgr_Context *ctx;
ctx = arg;
- ctx->in_action_loop = false;
RtemsModelEventsMgr_Setup( ctx );
}
@@ -552,21 +449,15 @@ static void RtemsModelEventsMgr_Teardown_Wrap( void *arg )
RtemsModelEventsMgr_Context *ctx;
ctx = arg;
- ctx->in_action_loop = false;
RtemsModelEventsMgr_Teardown( ctx );
}
static size_t RtemsModelEventsMgr_Scope( void *arg, char *buf, size_t n )
{
- RtemsModelEventsMgr_Context *ctx;
+ size_t pme_size;
- ctx = arg;
-
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsModelEventsMgr_PreDesc, buf, n, ctx->pcs );
- }
-
- return 0;
+ pme_size = strlen(PromelaModelEventsMgr);
+ return T_str_copy(buf, PromelaModelEventsMgr, pme_size);
}
static T_fixture RtemsModelEventsMgr_Fixture = {
@@ -614,7 +505,11 @@ void RtemsModelEventsMgr_Run(
{
RtemsModelEventsMgr_Context *ctx;
- // T_set_verbosity( T_VERBOSE );
+ T_set_verbosity( T_NORMAL );
+
+ T_log( T_NORMAL, "Runner Invoked" );
+ T_log( T_NORMAL, "Runner Wait Class: %d", wait_class );
+ T_log( T_NORMAL, "Runner WaitForEvent: %d", waiting_for_event );
T_log( T_NORMAL, "Pushing Test Fixture..." );
@@ -630,7 +525,6 @@ void RtemsModelEventsMgr_Run(
ctx->get_pending_events = get_pending_events;
ctx->wait_class = wait_class;
ctx->waiting_for_event = waiting_for_event;
- ctx->in_action_loop = true;
// RtemsModelEventsMgr_Prepare( ctx );
ctx->events_to_send = 0;
@@ -638,10 +532,6 @@ void RtemsModelEventsMgr_Run(
ctx->received_events = 0xffffffff;
ctx->receive_option_set = 0;
ctx->receive_timeout = RTEMS_NO_TIMEOUT;
- ctx->sender_type = SENDER_NONE;
- ctx->sender_prio = PRIO_NORMAL;
- ctx->receive_type = RECEIVE_SKIP;
- ctx->receive_condition_state = RECEIVE_COND_UNKNOWN;
ctx->unsatisfied_pending = 0xffffffff;
memset( &ctx->thread_switch_log, 0, sizeof( ctx->thread_switch_log ) );
T_eq_u32( GetPendingEvents( ctx ), 0 );