[PATCH 1/4] validation: Add comments to barrier tests
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Mar 1 09:27:07 UTC 2021
Unify code sections across tests.
---
testsuites/validation/tc-barrier-create.c | 86 +++++++++++++++++++++-
testsuites/validation/tc-barrier-delete.c | 27 +++++++
testsuites/validation/tc-barrier-release.c | 44 +++++++++++
testsuites/validation/tc-barrier-wait.c | 53 +++++++++++++
4 files changed, 207 insertions(+), 3 deletions(-)
diff --git a/testsuites/validation/tc-barrier-create.c b/testsuites/validation/tc-barrier-create.c
index 3b8a4d3ea0..f55e3311d1 100644
--- a/testsuites/validation/tc-barrier-create.c
+++ b/testsuites/validation/tc-barrier-create.c
@@ -54,8 +54,6 @@
#include <rtems.h>
#include <string.h>
-#include <rtems/score/chainimpl.h>
-#include <rtems/score/objectimpl.h>
#include <rtems/test.h>
@@ -252,11 +250,17 @@ static void RtemsBarrierReqCreate_Pre_Name_Prepare(
{
switch ( state ) {
case RtemsBarrierReqCreate_Pre_Name_Valid: {
+ /*
+ * The ``name`` parameter shall be valid.
+ */
ctx->name = NAME;
break;
}
case RtemsBarrierReqCreate_Pre_Name_Invalid: {
+ /*
+ * The ``name`` parameter shall be invalid.
+ */
ctx->name = 0;
break;
}
@@ -273,16 +277,28 @@ static void RtemsBarrierReqCreate_Pre_Class_Prepare(
{
switch ( state ) {
case RtemsBarrierReqCreate_Pre_Class_Default: {
+ /*
+ * The ``attribute_set`` parameter shall specify the default
+ * class.
+ */
/* Nothing to do */
break;
}
case RtemsBarrierReqCreate_Pre_Class_Manual: {
+ /*
+ * The ``attribute_set`` parameter shall specify the manual
+ * release class.
+ */
ctx->attribute_set |= RTEMS_BARRIER_MANUAL_RELEASE;
break;
}
case RtemsBarrierReqCreate_Pre_Class_Auto: {
+ /*
+ * The ``attribute_set`` parameter shall specify the
+ * automatic release class.
+ */
ctx->attribute_set |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
break;
}
@@ -299,11 +315,17 @@ static void RtemsBarrierReqCreate_Pre_MaxWait_Prepare(
{
switch ( state ) {
case RtemsBarrierReqCreate_Pre_MaxWait_Zero: {
+ /*
+ * The ``maximum_waiters`` parameter shall be zero.
+ */
ctx->maximum_waiters = 0;
break;
}
case RtemsBarrierReqCreate_Pre_MaxWait_Positive: {
+ /*
+ * The ``maximum_waiters`` parameter shall be positive.
+ */
ctx->maximum_waiters = 1;
break;
}
@@ -320,11 +342,19 @@ static void RtemsBarrierReqCreate_Pre_Id_Prepare(
{
switch ( state ) {
case RtemsBarrierReqCreate_Pre_Id_Valid: {
+ /*
+ * The ``id`` parameter shall reference an object
+ * identifier value.
+ */
ctx->id = &ctx->id_value;
break;
}
case RtemsBarrierReqCreate_Pre_Id_Null: {
+ /*
+ * The ``id`` parameter shall be
+ * NULL.
+ */
ctx->id = NULL;
break;
}
@@ -341,11 +371,17 @@ static void RtemsBarrierReqCreate_Pre_Free_Prepare(
{
switch ( state ) {
case RtemsBarrierReqCreate_Pre_Free_Yes: {
+ /*
+ * The system shall have at least one inactive barrier object available.
+ */
/* Nothing to do */
break;
}
case RtemsBarrierReqCreate_Pre_Free_No: {
+ /*
+ * The system shall have no inactive partition object available.
+ */
ctx->seized_objects = T_seize_objects( Create, NULL );
break;
}
@@ -362,26 +398,46 @@ static void RtemsBarrierReqCreate_Post_Status_Check(
{
switch ( state ) {
case RtemsBarrierReqCreate_Post_Status_Ok: {
+ /*
+ * The return status of rtems_barrier_create() shall be
+ * RTEMS_SUCCESSFUL.
+ */
T_rsc_success( ctx->status );
break;
}
case RtemsBarrierReqCreate_Post_Status_InvName: {
+ /*
+ * The return status of rtems_barrier_create() shall be
+ * RTEMS_INVALID_NAME.
+ */
T_rsc( ctx->status, RTEMS_INVALID_NAME );
break;
}
case RtemsBarrierReqCreate_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_barrier_create() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
break;
}
case RtemsBarrierReqCreate_Post_Status_InvNum: {
+ /*
+ * The return status of rtems_barrier_create() shall be
+ * RTEMS_INVALID_NUMBER.
+ */
T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
break;
}
case RtemsBarrierReqCreate_Post_Status_TooMany: {
+ /*
+ * The return status of rtems_barrier_create() shall be
+ * RTEMS_TOO_MANY.
+ */
T_rsc( ctx->status, RTEMS_TOO_MANY );
break;
}
@@ -401,7 +457,11 @@ static void RtemsBarrierReqCreate_Post_Name_Check(
switch ( state ) {
case RtemsBarrierReqCreate_Post_Name_Valid: {
- id = INVALID_ID;
+ /*
+ * The unique object name shall identify the barrier created by the
+ * rtems_barrier_create() call.
+ */
+ id = 0;
sc = rtems_barrier_ident( NAME, &id );
T_rsc_success( sc );
T_eq_u32( id, ctx->id_value );
@@ -409,6 +469,9 @@ static void RtemsBarrierReqCreate_Post_Name_Check(
}
case RtemsBarrierReqCreate_Post_Name_Invalid: {
+ /*
+ * The unique object name shall not identify a barrier.
+ */
sc = rtems_barrier_ident( NAME, &id );
T_rsc( sc, RTEMS_INVALID_NAME );
break;
@@ -428,11 +491,17 @@ static void RtemsBarrierReqCreate_Post_Class_Check(
switch ( state ) {
case RtemsBarrierReqCreate_Post_Class_NoObj: {
+ /*
+ * The barrier class is not applicable since there was no barrier created.
+ */
/* Not applicable */
break;
}
case RtemsBarrierReqCreate_Post_Class_Manual: {
+ /*
+ * The class of the barrier shall be manual release.
+ */
sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
T_rsc_success( sc );
@@ -442,6 +511,9 @@ static void RtemsBarrierReqCreate_Post_Class_Check(
}
case RtemsBarrierReqCreate_Post_Class_Auto: {
+ /*
+ * The class of the barrier shall be automatic release.
+ */
sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
T_rsc_success( sc );
@@ -461,12 +533,20 @@ static void RtemsBarrierReqCreate_Post_IdValue_Check(
{
switch ( state ) {
case RtemsBarrierReqCreate_Post_IdValue_Assigned: {
+ /*
+ * The value of the object identifier variable shall be equal to the object
+ * identifier of the barrier created by the rtems_barrier_create() call.
+ */
T_eq_ptr( ctx->id, &ctx->id_value );
T_ne_u32( ctx->id_value, INVALID_ID );
break;
}
case RtemsBarrierReqCreate_Post_IdValue_Unchanged: {
+ /*
+ * The value of the object identifier variable shall be unchanged by the
+ * rtems_barrier_create() call.
+ */
T_eq_u32( ctx->id_value, INVALID_ID );
break;
}
diff --git a/testsuites/validation/tc-barrier-delete.c b/testsuites/validation/tc-barrier-delete.c
index f02ddadbce..a65e3d4c91 100644
--- a/testsuites/validation/tc-barrier-delete.c
+++ b/testsuites/validation/tc-barrier-delete.c
@@ -183,11 +183,18 @@ static void RtemsBarrierReqDelete_Pre_Id_Prepare(
{
switch ( state ) {
case RtemsBarrierReqDelete_Pre_Id_Valid: {
+ /*
+ * The ``id`` parameter shall be associated with
+ * the barrier.
+ */
ctx->id = ctx->barrier_id;
break;
}
case RtemsBarrierReqDelete_Pre_Id_Invalid: {
+ /*
+ * The ``id`` parameter shall be invalid.
+ */
ctx->id = 0;
break;
}
@@ -204,12 +211,20 @@ static void RtemsBarrierReqDelete_Post_Status_Check(
{
switch ( state ) {
case RtemsBarrierReqDelete_Post_Status_Ok: {
+ /*
+ * The return status of rtems_barrier_delete() shall be
+ * RTEMS_SUCCESSFUL.
+ */
ctx->barrier_id = 0;
T_rsc_success( ctx->status );
break;
}
case RtemsBarrierReqDelete_Post_Status_InvId: {
+ /*
+ * The return status of rtems_barrier_delete() shall be
+ * RTEMS_INVALID_ID.
+ */
T_rsc( ctx->status, RTEMS_INVALID_ID );
break;
}
@@ -229,6 +244,9 @@ static void RtemsBarrierReqDelete_Post_Id_Check(
switch ( state ) {
case RtemsBarrierReqDelete_Post_Id_Valid: {
+ /*
+ * The unique object name shall identify the barrier.
+ */
id = 0;
sc = rtems_barrier_ident( NAME, &id );
T_rsc_success( sc );
@@ -237,6 +255,9 @@ static void RtemsBarrierReqDelete_Post_Id_Check(
}
case RtemsBarrierReqDelete_Post_Id_Invalid: {
+ /*
+ * The unique object name shall not identify the barrier.
+ */
sc = rtems_barrier_ident( NAME, &id );
T_rsc( sc, RTEMS_INVALID_NAME );
break;
@@ -254,12 +275,18 @@ static void RtemsBarrierReqDelete_Post_Flush_Check(
{
switch ( state ) {
case RtemsBarrierReqDelete_Post_Flush_Yes: {
+ /*
+ * Tasks waiting at the barrier shall be unblocked.
+ */
++ctx->wait_expected;
T_eq_u32( ctx->wait_done, ctx->wait_expected );
break;
}
case RtemsBarrierReqDelete_Post_Flush_No: {
+ /*
+ * Tasks waiting at the barrier shall remain blocked.
+ */
T_eq_u32( ctx->wait_done, ctx->wait_expected );
break;
}
diff --git a/testsuites/validation/tc-barrier-release.c b/testsuites/validation/tc-barrier-release.c
index 7b1064c247..3fcf8f13e9 100644
--- a/testsuites/validation/tc-barrier-release.c
+++ b/testsuites/validation/tc-barrier-release.c
@@ -213,16 +213,27 @@ static void RtemsBarrierReqRelease_Pre_Barrier_Prepare(
{
switch ( state ) {
case RtemsBarrierReqRelease_Pre_Barrier_NoObj: {
+ /*
+ * The ``id`` parameter shall be invalid.
+ */
ctx->id = 0xffffffff;
break;
}
case RtemsBarrierReqRelease_Pre_Barrier_Manual: {
+ /*
+ * The ``id`` parameter shall be associated with a
+ * manual release barrier.
+ */
ctx->id = ctx->manual_release_id;
break;
}
case RtemsBarrierReqRelease_Pre_Barrier_Auto: {
+ /*
+ * The ``id`` parameter shall be associated with an
+ * automatic release barrier.
+ */
ctx->id = ctx->auto_release_id;
break;
}
@@ -241,11 +252,18 @@ static void RtemsBarrierReqRelease_Pre_Released_Prepare(
switch ( state ) {
case RtemsBarrierReqRelease_Pre_Released_Valid: {
+ /*
+ * The ``released`` parameter shall reference an integer variable.
+ */
ctx->released = &ctx->released_value;
break;
}
case RtemsBarrierReqRelease_Pre_Released_Null: {
+ /*
+ * The ``released`` parameter shall be
+ * NULL.
+ */
ctx->released = NULL;
break;
}
@@ -262,11 +280,17 @@ static void RtemsBarrierReqRelease_Pre_Waiting_Prepare(
{
switch ( state ) {
case RtemsBarrierReqRelease_Pre_Waiting_Zero: {
+ /*
+ * The number of tasks waiting at the barrier shall be zero.
+ */
ctx->waiting_tasks = 0;
break;
}
case RtemsBarrierReqRelease_Pre_Waiting_Positive: {
+ /*
+ * The number of tasks waiting at the barrier shall be positive.
+ */
ctx->waiting_tasks = 1;
SendEvents( ctx->worker_id, EVENT_WAIT );
break;
@@ -284,16 +308,28 @@ static void RtemsBarrierReqRelease_Post_Status_Check(
{
switch ( state ) {
case RtemsBarrierReqRelease_Post_Status_Ok: {
+ /*
+ * The return status of rtems_barrier_release() shall be
+ * RTEMS_SUCCESSFUL.
+ */
T_rsc_success( ctx->status );
break;
}
case RtemsBarrierReqRelease_Post_Status_InvId: {
+ /*
+ * The return status of rtems_barrier_release() shall be
+ * RTEMS_INVALID_ID.
+ */
T_rsc( ctx->status, RTEMS_INVALID_ID );
break;
}
case RtemsBarrierReqRelease_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_barrier_release() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
break;
}
@@ -310,11 +346,19 @@ static void RtemsBarrierReqRelease_Post_Released_Check(
{
switch ( state ) {
case RtemsBarrierReqRelease_Post_Released_Valid: {
+ /*
+ * The value of the variable for the number of released tasks shall equal
+ * the number of tasks released by the rtems_barrier_release() call.
+ */
T_eq_u32( ctx->released_value, ctx->waiting_tasks );
break;
}
case RtemsBarrierReqRelease_Post_Released_Unchanged: {
+ /*
+ * The value of variable for the number of released tasks shall be unchanged
+ * by the rtems_barrier_release() call.
+ */
T_eq_u32( ctx->released_value, RELEASED_INVALID_VALUE );
break;
}
diff --git a/testsuites/validation/tc-barrier-wait.c b/testsuites/validation/tc-barrier-wait.c
index d290332207..f66452a5e0 100644
--- a/testsuites/validation/tc-barrier-wait.c
+++ b/testsuites/validation/tc-barrier-wait.c
@@ -263,16 +263,27 @@ static void RtemsBarrierReqWait_Pre_Barrier_Prepare(
{
switch ( state ) {
case RtemsBarrierReqWait_Pre_Barrier_NoObj: {
+ /*
+ * The ``id`` parameter shall be invalid.
+ */
ctx->id = 0xffffffff;
break;
}
case RtemsBarrierReqWait_Pre_Barrier_Manual: {
+ /*
+ * The ``id`` parameter shall be associated with a
+ * manual release barrier.
+ */
ctx->id = ctx->manual_release_id;
break;
}
case RtemsBarrierReqWait_Pre_Barrier_Auto: {
+ /*
+ * The ``id`` parameter shall be associated with an
+ * automatic release barrier.
+ */
ctx->id = ctx->auto_release_id;
break;
}
@@ -289,11 +300,19 @@ static void RtemsBarrierReqWait_Pre_Timeout_Prepare(
{
switch ( state ) {
case RtemsBarrierReqWait_Pre_Timeout_Ticks: {
+ /*
+ * The ``released`` parameter shall be a clock tick
+ * interval.
+ */
ctx->timeout = 2;
break;
}
case RtemsBarrierReqWait_Pre_Timeout_Forever: {
+ /*
+ * The ``released`` parameter shall be
+ * RTEMS_NO_TIMEOUT.
+ */
ctx->timeout = RTEMS_NO_TIMEOUT;
break;
}
@@ -310,6 +329,10 @@ static void RtemsBarrierReqWait_Pre_Satisfy_Prepare(
{
switch ( state ) {
case RtemsBarrierReqWait_Pre_Satisfy_Never: {
+ /*
+ * While the calling task waits at the barrier, the barrier shall not be
+ * released or deleted.
+ */
if ( ctx->timeout == RTEMS_NO_TIMEOUT ) {
SendEvents( ctx->low_worker_id, EVENT_CHECK_TIMER | EVENT_RELEASE );
}
@@ -317,16 +340,27 @@ static void RtemsBarrierReqWait_Pre_Satisfy_Prepare(
}
case RtemsBarrierReqWait_Pre_Satisfy_Wait: {
+ /*
+ * Calling the directive shall release the barrier.
+ */
SendEvents( ctx->high_worker_id, EVENT_WAIT );
break;
}
case RtemsBarrierReqWait_Pre_Satisfy_Release: {
+ /*
+ * While the calling task waits at the barrier, the barrier shall be
+ * released.
+ */
SendEvents( ctx->low_worker_id, EVENT_RELEASE );
break;
}
case RtemsBarrierReqWait_Pre_Satisfy_Delete: {
+ /*
+ * While the calling task waits at the barrier, the barrier shall be
+ * deleted.
+ */
SendEvents( ctx->low_worker_id, EVENT_DELETE );
break;
}
@@ -343,26 +377,45 @@ static void RtemsBarrierReqWait_Post_Status_Check(
{
switch ( state ) {
case RtemsBarrierReqWait_Post_Status_Ok: {
+ /*
+ * The return status of rtems_barrier_wait() shall be
+ * RTEMS_SUCCESSFUL.
+ */
T_rsc_success( ctx->status );
break;
}
case RtemsBarrierReqWait_Post_Status_InvId: {
+ /*
+ * The return status of rtems_barrier_wait() shall be
+ * RTEMS_INVALID_ID.
+ */
T_rsc( ctx->status, RTEMS_INVALID_ID );
break;
}
case RtemsBarrierReqWait_Post_Status_Timeout: {
+ /*
+ * The return status of rtems_barrier_wait() shall be
+ * RTEMS_TIMEOUT.
+ */
T_rsc( ctx->status, RTEMS_TIMEOUT );
break;
}
case RtemsBarrierReqWait_Post_Status_ObjDel: {
+ /*
+ * The return status of rtems_barrier_wait() shall be
+ * RTEMS_OBJECT_WAS_DELETED.
+ */
T_rsc( ctx->status, RTEMS_OBJECT_WAS_DELETED );
break;
}
case RtemsBarrierReqWait_Post_Status_NoReturn: {
+ /*
+ * The call to rtems_barrier_wait() shall not return to the calling task.
+ */
T_rsc_success( ctx->status );
break;
}
--
2.26.2
More information about the devel
mailing list