mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-21 12:48:29 +08:00
validation: Test Partition Manager
The test source code is generated from specification items by the "./spec2modules.py" script contained in the git://git.rtems.org/rtems-central.git Git repository. Please read the "How-To" section in the "Software Requirements Engineering" chapter of the RTEMS Software Engineering manual to get more information about the process. Update #3716.
This commit is contained in:
@@ -14,6 +14,7 @@ source:
|
||||
- testsuites/validation/tc-barrier-performance.c
|
||||
- testsuites/validation/tc-event-performance.c
|
||||
- testsuites/validation/tc-message-performance.c
|
||||
- testsuites/validation/tc-part-performance.c
|
||||
- testsuites/validation/ts-performance-no-clock-0.c
|
||||
stlib: []
|
||||
target: testsuites/validation/ts-performance-no-clock-0.exe
|
||||
|
||||
@@ -41,6 +41,12 @@ source:
|
||||
- testsuites/validation/tc-message-urgent-send.c
|
||||
- testsuites/validation/tc-modes.c
|
||||
- testsuites/validation/tc-options.c
|
||||
- testsuites/validation/tc-part.c
|
||||
- testsuites/validation/tc-part-create.c
|
||||
- testsuites/validation/tc-part-delete.c
|
||||
- testsuites/validation/tc-part-get.c
|
||||
- testsuites/validation/tc-part-ident.c
|
||||
- testsuites/validation/tc-part-return.c
|
||||
- testsuites/validation/tc-score-fatal.c
|
||||
- testsuites/validation/tr-event-constant.c
|
||||
- testsuites/validation/tr-mtx-seize-try.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,396 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSTestCaseRtemsPartReqDelete
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the RTEMS quality process and was automatically
|
||||
* generated. If you find something that needs to be fixed or
|
||||
* worded better please post a report or patch to an RTEMS mailing list
|
||||
* or raise a bug report:
|
||||
*
|
||||
* https://www.rtems.org/bugs.html
|
||||
*
|
||||
* For information on updating and regenerating please refer to the How-To
|
||||
* section in the Software Requirements Engineering chapter of the
|
||||
* RTEMS Software Engineering manual. The manual is provided as a part of
|
||||
* a release. For development sources please refer to the online
|
||||
* documentation at:
|
||||
*
|
||||
* https://docs.rtems.org
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup RTEMSTestCaseRtemsPartReqDelete spec:/rtems/part/req/delete
|
||||
*
|
||||
* @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqDelete_Pre_Id_NoObj,
|
||||
RtemsPartReqDelete_Pre_Id_Part,
|
||||
RtemsPartReqDelete_Pre_Id_NA
|
||||
} RtemsPartReqDelete_Pre_Id;
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqDelete_Pre_InUse_Yes,
|
||||
RtemsPartReqDelete_Pre_InUse_No,
|
||||
RtemsPartReqDelete_Pre_InUse_NA
|
||||
} RtemsPartReqDelete_Pre_InUse;
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqDelete_Post_Status_Ok,
|
||||
RtemsPartReqDelete_Post_Status_InvId,
|
||||
RtemsPartReqDelete_Post_Status_InUse,
|
||||
RtemsPartReqDelete_Post_Status_NA
|
||||
} RtemsPartReqDelete_Post_Status;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Skip : 1;
|
||||
uint8_t Pre_Id_NA : 1;
|
||||
uint8_t Pre_InUse_NA : 1;
|
||||
uint8_t Post_Status : 2;
|
||||
} RtemsPartReqDelete_Entry;
|
||||
|
||||
/**
|
||||
* @brief Test context for spec:/rtems/part/req/delete test case.
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_status_code status;
|
||||
|
||||
rtems_id id;
|
||||
|
||||
rtems_id id_value;
|
||||
|
||||
void *buffer;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* @brief This member defines the pre-condition states for the next action.
|
||||
*/
|
||||
size_t pcs[ 2 ];
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the test action loop is executed.
|
||||
*/
|
||||
bool in_action_loop;
|
||||
|
||||
/**
|
||||
* @brief This member contains the next transition map index.
|
||||
*/
|
||||
size_t index;
|
||||
|
||||
/**
|
||||
* @brief This member contains the current transition map entry.
|
||||
*/
|
||||
RtemsPartReqDelete_Entry entry;
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the current transition variant
|
||||
* should be skipped.
|
||||
*/
|
||||
bool skip;
|
||||
} Map;
|
||||
} RtemsPartReqDelete_Context;
|
||||
|
||||
static RtemsPartReqDelete_Context
|
||||
RtemsPartReqDelete_Instance;
|
||||
|
||||
static const char * const RtemsPartReqDelete_PreDesc_Id[] = {
|
||||
"NoObj",
|
||||
"Part",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const RtemsPartReqDelete_PreDesc_InUse[] = {
|
||||
"Yes",
|
||||
"No",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const * const RtemsPartReqDelete_PreDesc[] = {
|
||||
RtemsPartReqDelete_PreDesc_Id,
|
||||
RtemsPartReqDelete_PreDesc_InUse,
|
||||
NULL
|
||||
};
|
||||
|
||||
#define PART_NAME rtems_build_name( 'N', 'A', 'M', 'E' )
|
||||
|
||||
#define BUFFER_COUNT 1
|
||||
|
||||
#define BUFFER_SIZE ( 2 * sizeof( void * ) )
|
||||
|
||||
static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t
|
||||
buffers[ BUFFER_COUNT ][ BUFFER_SIZE ];
|
||||
|
||||
static void RtemsPartReqDelete_Pre_Id_Prepare(
|
||||
RtemsPartReqDelete_Context *ctx,
|
||||
RtemsPartReqDelete_Pre_Id state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case RtemsPartReqDelete_Pre_Id_NoObj: {
|
||||
/*
|
||||
* While the ``id`` parameter is not associated with a partition.
|
||||
*/
|
||||
ctx->id = 0xffffffff;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Pre_Id_Part: {
|
||||
/*
|
||||
* While the ``id`` parameter is associated with a partition.
|
||||
*/
|
||||
ctx->id = ctx->id_value;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Pre_Id_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_Pre_InUse_Prepare(
|
||||
RtemsPartReqDelete_Context *ctx,
|
||||
RtemsPartReqDelete_Pre_InUse state
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
switch ( state ) {
|
||||
case RtemsPartReqDelete_Pre_InUse_Yes: {
|
||||
/*
|
||||
* While the partition has at least one buffer in use.
|
||||
*/
|
||||
ctx->buffer = NULL;
|
||||
sc = rtems_partition_get_buffer( ctx->id_value, &ctx->buffer );
|
||||
T_rsc_success( sc );
|
||||
T_not_null( ctx->buffer );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Pre_InUse_No: {
|
||||
/*
|
||||
* While the partition does not have a buffer in use.
|
||||
*/
|
||||
ctx->buffer = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Pre_InUse_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_Post_Status_Check(
|
||||
RtemsPartReqDelete_Context *ctx,
|
||||
RtemsPartReqDelete_Post_Status state
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
|
||||
switch ( state ) {
|
||||
case RtemsPartReqDelete_Post_Status_Ok: {
|
||||
/*
|
||||
* The status shall be RTEMS_SUCCESSFUL. The deleted partition object
|
||||
* shall be inactive.
|
||||
*/
|
||||
T_rsc_success( ctx->status );
|
||||
ctx->id_value = 0xffffffff;
|
||||
|
||||
id = 0xffffffff;
|
||||
sc = rtems_partition_ident( PART_NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
|
||||
T_rsc( sc, RTEMS_INVALID_NAME );
|
||||
T_eq_u32( id, 0xffffffff );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Post_Status_InvId: {
|
||||
/*
|
||||
* The status shall be RTEMS_INVALID_ID.
|
||||
*/
|
||||
T_rsc( ctx->status, RTEMS_INVALID_ID );
|
||||
|
||||
id = 0xffffffff;
|
||||
sc = rtems_partition_ident( PART_NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
|
||||
T_rsc_success( sc);
|
||||
T_eq_u32( id, ctx->id_value );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Post_Status_InUse: {
|
||||
/*
|
||||
* The status shall be RTEMS_RESOURCE_IN_USE.
|
||||
*/
|
||||
T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE );
|
||||
|
||||
id = 0xffffffff;
|
||||
sc = rtems_partition_ident( PART_NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
|
||||
T_rsc_success( sc);
|
||||
T_eq_u32( id, ctx->id_value );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqDelete_Post_Status_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_Prepare( RtemsPartReqDelete_Context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
sc = rtems_partition_create(
|
||||
PART_NAME,
|
||||
buffers,
|
||||
sizeof( buffers ),
|
||||
sizeof( buffers[ 0 ] ),
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->id_value
|
||||
);
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_Action( RtemsPartReqDelete_Context *ctx )
|
||||
{
|
||||
ctx->status = rtems_partition_delete( ctx->id );
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_Cleanup( RtemsPartReqDelete_Context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
if ( ctx->buffer != NULL ) {
|
||||
sc = rtems_partition_return_buffer( ctx->id_value, ctx->buffer );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
if ( ctx->id_value != 0xffffffff ) {
|
||||
sc = rtems_partition_delete( ctx->id_value );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
}
|
||||
|
||||
static const RtemsPartReqDelete_Entry
|
||||
RtemsPartReqDelete_Entries[] = {
|
||||
{ 0, 0, 0, RtemsPartReqDelete_Post_Status_InvId },
|
||||
{ 0, 0, 0, RtemsPartReqDelete_Post_Status_InUse },
|
||||
{ 0, 0, 0, RtemsPartReqDelete_Post_Status_Ok }
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
RtemsPartReqDelete_Map[] = {
|
||||
0, 0, 1, 2
|
||||
};
|
||||
|
||||
static size_t RtemsPartReqDelete_Scope( void *arg, char *buf, size_t n )
|
||||
{
|
||||
RtemsPartReqDelete_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
|
||||
if ( ctx->Map.in_action_loop ) {
|
||||
return T_get_scope( RtemsPartReqDelete_PreDesc, buf, n, ctx->Map.pcs );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T_fixture RtemsPartReqDelete_Fixture = {
|
||||
.setup = NULL,
|
||||
.stop = NULL,
|
||||
.teardown = NULL,
|
||||
.scope = RtemsPartReqDelete_Scope,
|
||||
.initial_context = &RtemsPartReqDelete_Instance
|
||||
};
|
||||
|
||||
static inline RtemsPartReqDelete_Entry RtemsPartReqDelete_PopEntry(
|
||||
RtemsPartReqDelete_Context *ctx
|
||||
)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = ctx->Map.index;
|
||||
ctx->Map.index = index + 1;
|
||||
return RtemsPartReqDelete_Entries[
|
||||
RtemsPartReqDelete_Map[ index ]
|
||||
];
|
||||
}
|
||||
|
||||
static void RtemsPartReqDelete_TestVariant( RtemsPartReqDelete_Context *ctx )
|
||||
{
|
||||
RtemsPartReqDelete_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 0 ] );
|
||||
RtemsPartReqDelete_Pre_InUse_Prepare( ctx, ctx->Map.pcs[ 1 ] );
|
||||
RtemsPartReqDelete_Action( ctx );
|
||||
RtemsPartReqDelete_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_RtemsPartReqDelete( void )
|
||||
*/
|
||||
T_TEST_CASE_FIXTURE( RtemsPartReqDelete, &RtemsPartReqDelete_Fixture )
|
||||
{
|
||||
RtemsPartReqDelete_Context *ctx;
|
||||
|
||||
ctx = T_fixture_context();
|
||||
ctx->Map.in_action_loop = true;
|
||||
ctx->Map.index = 0;
|
||||
|
||||
for (
|
||||
ctx->Map.pcs[ 0 ] = RtemsPartReqDelete_Pre_Id_NoObj;
|
||||
ctx->Map.pcs[ 0 ] < RtemsPartReqDelete_Pre_Id_NA;
|
||||
++ctx->Map.pcs[ 0 ]
|
||||
) {
|
||||
for (
|
||||
ctx->Map.pcs[ 1 ] = RtemsPartReqDelete_Pre_InUse_Yes;
|
||||
ctx->Map.pcs[ 1 ] < RtemsPartReqDelete_Pre_InUse_NA;
|
||||
++ctx->Map.pcs[ 1 ]
|
||||
) {
|
||||
ctx->Map.entry = RtemsPartReqDelete_PopEntry( ctx );
|
||||
RtemsPartReqDelete_Prepare( ctx );
|
||||
RtemsPartReqDelete_TestVariant( ctx );
|
||||
RtemsPartReqDelete_Cleanup( ctx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,120 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSTestCaseRtemsPartValIdent
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the RTEMS quality process and was automatically
|
||||
* generated. If you find something that needs to be fixed or
|
||||
* worded better please post a report or patch to an RTEMS mailing list
|
||||
* or raise a bug report:
|
||||
*
|
||||
* https://www.rtems.org/bugs.html
|
||||
*
|
||||
* For information on updating and regenerating please refer to the How-To
|
||||
* section in the Software Requirements Engineering chapter of the
|
||||
* RTEMS Software Engineering manual. The manual is provided as a part of
|
||||
* a release. For development sources please refer to the online
|
||||
* documentation at:
|
||||
*
|
||||
* https://docs.rtems.org
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tr-object-ident.h"
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup RTEMSTestCaseRtemsPartValIdent spec:/rtems/part/val/ident
|
||||
*
|
||||
* @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
|
||||
*
|
||||
* @brief Test the rtems_partition_ident() directive.
|
||||
*
|
||||
* This test case performs the following actions:
|
||||
*
|
||||
* - Run the generic object identification tests for Classic API partition
|
||||
* class objects defined by /rtems/req/ident.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
static rtems_status_code ClassicPartIdentAction(
|
||||
rtems_name name,
|
||||
uint32_t node,
|
||||
rtems_id *id
|
||||
)
|
||||
{
|
||||
return rtems_partition_ident( name, node, id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Run the generic object identification tests for Classic API partition
|
||||
* class objects defined by /rtems/req/ident.
|
||||
*/
|
||||
static void RtemsPartValIdent_Action_0( void )
|
||||
{
|
||||
static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) long area[32];
|
||||
rtems_status_code sc;
|
||||
rtems_id id_local_object;
|
||||
|
||||
sc = rtems_partition_create(
|
||||
ClassicObjectIdentName,
|
||||
area,
|
||||
sizeof( area ),
|
||||
sizeof( area ),
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&id_local_object
|
||||
);
|
||||
T_assert_rsc_success( sc );
|
||||
|
||||
RtemsReqIdent_Run(
|
||||
id_local_object,
|
||||
ClassicPartIdentAction
|
||||
);
|
||||
|
||||
sc = rtems_partition_delete( id_local_object );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_RtemsPartValIdent( void )
|
||||
*/
|
||||
T_TEST_CASE( RtemsPartValIdent )
|
||||
{
|
||||
RtemsPartValIdent_Action_0();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSTestCaseRtemsPartValPerformance
|
||||
* @ingroup RTEMSTestCaseRtemsPartValPerf
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -58,19 +58,18 @@
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup RTEMSTestCaseRtemsPartValPerformance \
|
||||
* spec:/rtems/part/val/performance
|
||||
* @defgroup RTEMSTestCaseRtemsPartValPerf spec:/rtems/part/val/perf
|
||||
*
|
||||
* @ingroup RTEMSTestSuiteTestsuitesPerformance0
|
||||
* @ingroup RTEMSTestSuiteTestsuitesPerformanceNoClock0
|
||||
*
|
||||
* @brief This test case provides a context to run Partition Manager
|
||||
* @brief This test case provides a context to run @ref RTEMSAPIClassicPart
|
||||
* performance tests.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test context for spec:/rtems/part/val/performance test case.
|
||||
* @brief Test context for spec:/rtems/part/val/perf test case.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
@@ -79,8 +78,7 @@ typedef struct {
|
||||
rtems_id part_one;
|
||||
|
||||
/**
|
||||
* @brief This member provides a partition with exactly
|
||||
* ${.:/params/buffer-count} free buffers.
|
||||
* @brief This member provides a partition with exactly 100 free buffers.
|
||||
*/
|
||||
rtems_id part_many;
|
||||
|
||||
@@ -108,20 +106,29 @@ typedef struct {
|
||||
* @brief This member provides the measure runtime request.
|
||||
*/
|
||||
T_measure_runtime_request request;
|
||||
} RtemsPartValPerformance_Context;
|
||||
|
||||
static RtemsPartValPerformance_Context
|
||||
RtemsPartValPerformance_Instance;
|
||||
/**
|
||||
* @brief This member provides an optional measurement begin time point.
|
||||
*/
|
||||
T_ticks begin;
|
||||
|
||||
static void RtemsPartValPerformance_Setup_Context(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
/**
|
||||
* @brief This member provides an optional measurement end time point.
|
||||
*/
|
||||
T_ticks end;
|
||||
} RtemsPartValPerf_Context;
|
||||
|
||||
static RtemsPartValPerf_Context
|
||||
RtemsPartValPerf_Instance;
|
||||
|
||||
static void RtemsPartValPerf_Setup_Context( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
T_measure_runtime_config config;
|
||||
|
||||
memset( &config, 0, sizeof( config ) );
|
||||
config.sample_count = 1000;
|
||||
config.sample_count = 100;
|
||||
ctx->request.arg = ctx;
|
||||
ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES;
|
||||
ctx->context = T_measure_runtime_create( &config );
|
||||
T_assert_not_null( ctx->context );
|
||||
}
|
||||
@@ -129,9 +136,7 @@ static void RtemsPartValPerformance_Setup_Context(
|
||||
/**
|
||||
* @brief Creates the test partition.
|
||||
*/
|
||||
static void RtemsPartValPerformance_Setup(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartValPerf_Setup( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
size_t size;
|
||||
@@ -164,21 +169,19 @@ static void RtemsPartValPerformance_Setup(
|
||||
T_assert_rsc_success( sc );
|
||||
}
|
||||
|
||||
static void RtemsPartValPerformance_Setup_Wrap( void *arg )
|
||||
static void RtemsPartValPerf_Setup_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartValPerformance_Setup_Context( ctx );
|
||||
RtemsPartValPerformance_Setup( ctx );
|
||||
RtemsPartValPerf_Setup_Context( ctx );
|
||||
RtemsPartValPerf_Setup( ctx );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes the test partition.
|
||||
*/
|
||||
static void RtemsPartValPerformance_Teardown(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartValPerf_Teardown( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
@@ -193,35 +196,33 @@ static void RtemsPartValPerformance_Teardown(
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartValPerformance_Teardown_Wrap( void *arg )
|
||||
static void RtemsPartValPerf_Teardown_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartValPerformance_Teardown( ctx );
|
||||
RtemsPartValPerf_Teardown( ctx );
|
||||
}
|
||||
|
||||
static T_fixture RtemsPartValPerformance_Fixture = {
|
||||
.setup = RtemsPartValPerformance_Setup_Wrap,
|
||||
static T_fixture RtemsPartValPerf_Fixture = {
|
||||
.setup = RtemsPartValPerf_Setup_Wrap,
|
||||
.stop = NULL,
|
||||
.teardown = RtemsPartValPerformance_Teardown_Wrap,
|
||||
.teardown = RtemsPartValPerf_Teardown_Wrap,
|
||||
.scope = NULL,
|
||||
.initial_context = &RtemsPartValPerformance_Instance
|
||||
.initial_context = &RtemsPartValPerf_Instance
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Get a buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfGetBuffer_Body(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartReqPerfGetBuffer_Body( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
ctx->status = rtems_partition_get_buffer( ctx->part_many, &ctx->buffer );
|
||||
}
|
||||
|
||||
static void RtemsPartReqPerfGetBuffer_Body_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartReqPerfGetBuffer_Body( ctx );
|
||||
@@ -231,11 +232,11 @@ static void RtemsPartReqPerfGetBuffer_Body_Wrap( void *arg )
|
||||
* @brief Return the buffer.
|
||||
*/
|
||||
static bool RtemsPartReqPerfGetBuffer_Teardown(
|
||||
RtemsPartValPerformance_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
RtemsPartValPerf_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
@@ -256,7 +257,7 @@ static bool RtemsPartReqPerfGetBuffer_Teardown_Wrap(
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
return RtemsPartReqPerfGetBuffer_Teardown( ctx, delta, tic, toc, retry );
|
||||
@@ -266,7 +267,7 @@ static bool RtemsPartReqPerfGetBuffer_Teardown_Wrap(
|
||||
* @brief Get the buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfGetNoBuffer_Prepare(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
RtemsPartValPerf_Context *ctx
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
@@ -278,16 +279,14 @@ static void RtemsPartReqPerfGetNoBuffer_Prepare(
|
||||
/**
|
||||
* @brief Try to get a buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfGetNoBuffer_Body(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartReqPerfGetNoBuffer_Body( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
ctx->status = rtems_partition_get_buffer( ctx->part_one, &ctx->buffer );
|
||||
}
|
||||
|
||||
static void RtemsPartReqPerfGetNoBuffer_Body_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartReqPerfGetNoBuffer_Body( ctx );
|
||||
@@ -297,11 +296,11 @@ static void RtemsPartReqPerfGetNoBuffer_Body_Wrap( void *arg )
|
||||
* @brief Check the status code.
|
||||
*/
|
||||
static bool RtemsPartReqPerfGetNoBuffer_Teardown(
|
||||
RtemsPartValPerformance_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
RtemsPartValPerf_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
T_quiet_rsc( ctx->status, RTEMS_UNSATISFIED );
|
||||
@@ -317,7 +316,7 @@ static bool RtemsPartReqPerfGetNoBuffer_Teardown_Wrap(
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
return RtemsPartReqPerfGetNoBuffer_Teardown( ctx, delta, tic, toc, retry );
|
||||
@@ -327,7 +326,7 @@ static bool RtemsPartReqPerfGetNoBuffer_Teardown_Wrap(
|
||||
* @brief Return the buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfGetNoBuffer_Cleanup(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
RtemsPartValPerf_Context *ctx
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
@@ -339,9 +338,7 @@ static void RtemsPartReqPerfGetNoBuffer_Cleanup(
|
||||
/**
|
||||
* @brief Get the buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfReturnBuffer_Setup(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartReqPerfReturnBuffer_Setup( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
@@ -351,7 +348,7 @@ static void RtemsPartReqPerfReturnBuffer_Setup(
|
||||
|
||||
static void RtemsPartReqPerfReturnBuffer_Setup_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartReqPerfReturnBuffer_Setup( ctx );
|
||||
@@ -360,16 +357,14 @@ static void RtemsPartReqPerfReturnBuffer_Setup_Wrap( void *arg )
|
||||
/**
|
||||
* @brief Return the buffer.
|
||||
*/
|
||||
static void RtemsPartReqPerfReturnBuffer_Body(
|
||||
RtemsPartValPerformance_Context *ctx
|
||||
)
|
||||
static void RtemsPartReqPerfReturnBuffer_Body( RtemsPartValPerf_Context *ctx )
|
||||
{
|
||||
ctx->status = rtems_partition_return_buffer( ctx->part_many, ctx->buffer );
|
||||
}
|
||||
|
||||
static void RtemsPartReqPerfReturnBuffer_Body_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
RtemsPartReqPerfReturnBuffer_Body( ctx );
|
||||
@@ -379,11 +374,11 @@ static void RtemsPartReqPerfReturnBuffer_Body_Wrap( void *arg )
|
||||
* @brief Check the status code.
|
||||
*/
|
||||
static bool RtemsPartReqPerfReturnBuffer_Teardown(
|
||||
RtemsPartValPerformance_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
RtemsPartValPerf_Context *ctx,
|
||||
T_ticks *delta,
|
||||
uint32_t tic,
|
||||
uint32_t toc,
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL );
|
||||
@@ -399,21 +394,18 @@ static bool RtemsPartReqPerfReturnBuffer_Teardown_Wrap(
|
||||
unsigned int retry
|
||||
)
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
return RtemsPartReqPerfReturnBuffer_Teardown( ctx, delta, tic, toc, retry );
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_RtemsPartValPerformance( void )
|
||||
* @fn void T_case_body_RtemsPartValPerf( void )
|
||||
*/
|
||||
T_TEST_CASE_FIXTURE(
|
||||
RtemsPartValPerformance,
|
||||
&RtemsPartValPerformance_Fixture
|
||||
)
|
||||
T_TEST_CASE_FIXTURE( RtemsPartValPerf, &RtemsPartValPerf_Fixture )
|
||||
{
|
||||
RtemsPartValPerformance_Context *ctx;
|
||||
RtemsPartValPerf_Context *ctx;
|
||||
|
||||
ctx = T_fixture_context();
|
||||
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSTestCaseRtemsPartReqReturnBuffer
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the RTEMS quality process and was automatically
|
||||
* generated. If you find something that needs to be fixed or
|
||||
* worded better please post a report or patch to an RTEMS mailing list
|
||||
* or raise a bug report:
|
||||
*
|
||||
* https://www.rtems.org/bugs.html
|
||||
*
|
||||
* For information on updating and regenerating please refer to the How-To
|
||||
* section in the Software Requirements Engineering chapter of the
|
||||
* RTEMS Software Engineering manual. The manual is provided as a part of
|
||||
* a release. For development sources please refer to the online
|
||||
* documentation at:
|
||||
*
|
||||
* https://docs.rtems.org
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup RTEMSTestCaseRtemsPartReqReturnBuffer \
|
||||
* spec:/rtems/part/req/return-buffer
|
||||
*
|
||||
* @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqReturnBuffer_Pre_Id_NoObj,
|
||||
RtemsPartReqReturnBuffer_Pre_Id_Part,
|
||||
RtemsPartReqReturnBuffer_Pre_Id_NA
|
||||
} RtemsPartReqReturnBuffer_Pre_Id;
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_Valid,
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_BadAlign,
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_BelowArea,
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_AboveArea,
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_NA
|
||||
} RtemsPartReqReturnBuffer_Pre_Buf;
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqReturnBuffer_Post_Status_Ok,
|
||||
RtemsPartReqReturnBuffer_Post_Status_InvId,
|
||||
RtemsPartReqReturnBuffer_Post_Status_InvAddr,
|
||||
RtemsPartReqReturnBuffer_Post_Status_NA
|
||||
} RtemsPartReqReturnBuffer_Post_Status;
|
||||
|
||||
typedef enum {
|
||||
RtemsPartReqReturnBuffer_Post_Buf_Free,
|
||||
RtemsPartReqReturnBuffer_Post_Buf_InUse,
|
||||
RtemsPartReqReturnBuffer_Post_Buf_NA
|
||||
} RtemsPartReqReturnBuffer_Post_Buf;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Skip : 1;
|
||||
uint8_t Pre_Id_NA : 1;
|
||||
uint8_t Pre_Buf_NA : 1;
|
||||
uint8_t Post_Status : 2;
|
||||
uint8_t Post_Buf : 2;
|
||||
} RtemsPartReqReturnBuffer_Entry;
|
||||
|
||||
/**
|
||||
* @brief Test context for spec:/rtems/part/req/return-buffer test case.
|
||||
*/
|
||||
typedef struct {
|
||||
rtems_status_code status;
|
||||
|
||||
rtems_id id;
|
||||
|
||||
rtems_id id_value;
|
||||
|
||||
void *buffer;
|
||||
|
||||
void *buffer_in_use;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* @brief This member defines the pre-condition states for the next action.
|
||||
*/
|
||||
size_t pcs[ 2 ];
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the test action loop is executed.
|
||||
*/
|
||||
bool in_action_loop;
|
||||
|
||||
/**
|
||||
* @brief This member contains the next transition map index.
|
||||
*/
|
||||
size_t index;
|
||||
|
||||
/**
|
||||
* @brief This member contains the current transition map entry.
|
||||
*/
|
||||
RtemsPartReqReturnBuffer_Entry entry;
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the current transition variant
|
||||
* should be skipped.
|
||||
*/
|
||||
bool skip;
|
||||
} Map;
|
||||
} RtemsPartReqReturnBuffer_Context;
|
||||
|
||||
static RtemsPartReqReturnBuffer_Context
|
||||
RtemsPartReqReturnBuffer_Instance;
|
||||
|
||||
static const char * const RtemsPartReqReturnBuffer_PreDesc_Id[] = {
|
||||
"NoObj",
|
||||
"Part",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const RtemsPartReqReturnBuffer_PreDesc_Buf[] = {
|
||||
"Valid",
|
||||
"BadAlign",
|
||||
"BelowArea",
|
||||
"AboveArea",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const * const RtemsPartReqReturnBuffer_PreDesc[] = {
|
||||
RtemsPartReqReturnBuffer_PreDesc_Id,
|
||||
RtemsPartReqReturnBuffer_PreDesc_Buf,
|
||||
NULL
|
||||
};
|
||||
|
||||
#define BUFFER_COUNT 1
|
||||
|
||||
#define BUFFER_SIZE ( 2 * sizeof( void * ) )
|
||||
|
||||
static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t
|
||||
buffers[ BUFFER_COUNT ][ BUFFER_SIZE ];
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Pre_Id_Prepare(
|
||||
RtemsPartReqReturnBuffer_Context *ctx,
|
||||
RtemsPartReqReturnBuffer_Pre_Id state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case RtemsPartReqReturnBuffer_Pre_Id_NoObj: {
|
||||
/*
|
||||
* While the ``id`` parameter is invalid.
|
||||
*/
|
||||
ctx->id = 0xffffffff;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Id_Part: {
|
||||
/*
|
||||
* While the ``id`` parameter is associated with a partition.
|
||||
*/
|
||||
ctx->id = ctx->id_value;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Id_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Pre_Buf_Prepare(
|
||||
RtemsPartReqReturnBuffer_Context *ctx,
|
||||
RtemsPartReqReturnBuffer_Pre_Buf state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case RtemsPartReqReturnBuffer_Pre_Buf_Valid: {
|
||||
/*
|
||||
* While the ``buffer`` parameter references a buffer previously returned
|
||||
* by rtems_partition_get_buffer().
|
||||
*/
|
||||
ctx->buffer = ctx->buffer_in_use;
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Buf_BadAlign: {
|
||||
/*
|
||||
* While the ``buffer`` parameter is an address inside the buffer area of
|
||||
* the partition, while the address is not on a valid buffer boundary.
|
||||
*/
|
||||
ctx->buffer = (void *) ( (uintptr_t) ctx->buffer_in_use + 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Buf_BelowArea: {
|
||||
/*
|
||||
* While the ``buffer`` parameter is an address below the buffer area of
|
||||
* the partition.
|
||||
*/
|
||||
ctx->buffer = (void *) ( (uintptr_t) buffers - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Buf_AboveArea: {
|
||||
/*
|
||||
* While the ``buffer`` parameter is an address above the buffer area of
|
||||
* the partition.
|
||||
*/
|
||||
ctx->buffer = (void *) ( (uintptr_t) buffers + sizeof( buffers ) );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Pre_Buf_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Post_Status_Check(
|
||||
RtemsPartReqReturnBuffer_Context *ctx,
|
||||
RtemsPartReqReturnBuffer_Post_Status state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case RtemsPartReqReturnBuffer_Post_Status_Ok: {
|
||||
/*
|
||||
* The return status of rtems_partition_return_buffer() shall be
|
||||
* RTEMS_SUCCESSFUL.
|
||||
*/
|
||||
T_rsc_success( ctx->status );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Post_Status_InvId: {
|
||||
/*
|
||||
* The return status of rtems_partition_return_buffer() shall be
|
||||
* RTEMS_INVALID_ID.
|
||||
*/
|
||||
T_rsc( ctx->status, RTEMS_INVALID_ID );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Post_Status_InvAddr: {
|
||||
/*
|
||||
* The return status of rtems_partition_return_buffer() shall be
|
||||
* RTEMS_INVALID_ADDRESS.
|
||||
*/
|
||||
T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Post_Status_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Post_Buf_Check(
|
||||
RtemsPartReqReturnBuffer_Context *ctx,
|
||||
RtemsPartReqReturnBuffer_Post_Buf state
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
void *no_buffer;
|
||||
|
||||
switch ( state ) {
|
||||
case RtemsPartReqReturnBuffer_Post_Buf_Free: {
|
||||
/*
|
||||
* The buffer obtained from the partition shall be made available for
|
||||
* re-use by the rtems_partition_return_buffer() call.
|
||||
*/
|
||||
sc = rtems_partition_get_buffer( ctx->id_value, &ctx->buffer_in_use );
|
||||
T_rsc_success( sc );
|
||||
T_eq_ptr( ctx->buffer_in_use, buffers );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Post_Buf_InUse: {
|
||||
/*
|
||||
* The buffer obtained from the partition shall be still in use after the
|
||||
* rtems_partition_return_buffer() call.
|
||||
*/
|
||||
sc = rtems_partition_get_buffer( ctx->id_value, &no_buffer );
|
||||
T_rsc( sc, RTEMS_UNSATISFIED );
|
||||
break;
|
||||
}
|
||||
|
||||
case RtemsPartReqReturnBuffer_Post_Buf_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Setup(
|
||||
RtemsPartReqReturnBuffer_Context *ctx
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
ctx->buffer_in_use = NULL;
|
||||
ctx->id_value = 0;
|
||||
|
||||
sc = rtems_partition_create(
|
||||
rtems_build_name( 'N', 'A', 'M', 'E' ),
|
||||
buffers,
|
||||
sizeof( buffers ),
|
||||
sizeof( buffers[ 0 ] ),
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->id_value
|
||||
);
|
||||
T_assert_rsc_success( sc );
|
||||
|
||||
sc = rtems_partition_get_buffer( ctx->id_value, &ctx->buffer_in_use );
|
||||
T_assert_rsc_success( sc );
|
||||
T_assert_eq_ptr( ctx->buffer_in_use, buffers );
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Setup_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartReqReturnBuffer_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
ctx->Map.in_action_loop = false;
|
||||
RtemsPartReqReturnBuffer_Setup( ctx );
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Teardown(
|
||||
RtemsPartReqReturnBuffer_Context *ctx
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
|
||||
if ( ctx->buffer_in_use != NULL ) {
|
||||
sc = rtems_partition_return_buffer( ctx->id_value, ctx->buffer_in_use );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
|
||||
if ( ctx->id_value != 0 ) {
|
||||
sc = rtems_partition_delete( ctx->id_value );
|
||||
T_rsc_success( sc );
|
||||
}
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Teardown_Wrap( void *arg )
|
||||
{
|
||||
RtemsPartReqReturnBuffer_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
ctx->Map.in_action_loop = false;
|
||||
RtemsPartReqReturnBuffer_Teardown( ctx );
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_Action(
|
||||
RtemsPartReqReturnBuffer_Context *ctx
|
||||
)
|
||||
{
|
||||
ctx->status = rtems_partition_return_buffer( ctx->id, ctx->buffer );
|
||||
}
|
||||
|
||||
static const RtemsPartReqReturnBuffer_Entry
|
||||
RtemsPartReqReturnBuffer_Entries[] = {
|
||||
{ 0, 0, 0, RtemsPartReqReturnBuffer_Post_Status_InvId,
|
||||
RtemsPartReqReturnBuffer_Post_Buf_InUse },
|
||||
{ 0, 0, 0, RtemsPartReqReturnBuffer_Post_Status_InvAddr,
|
||||
RtemsPartReqReturnBuffer_Post_Buf_InUse },
|
||||
{ 0, 0, 0, RtemsPartReqReturnBuffer_Post_Status_Ok,
|
||||
RtemsPartReqReturnBuffer_Post_Buf_Free }
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
RtemsPartReqReturnBuffer_Map[] = {
|
||||
0, 0, 0, 0, 2, 1, 1, 1
|
||||
};
|
||||
|
||||
static size_t RtemsPartReqReturnBuffer_Scope( void *arg, char *buf, size_t n )
|
||||
{
|
||||
RtemsPartReqReturnBuffer_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
|
||||
if ( ctx->Map.in_action_loop ) {
|
||||
return T_get_scope(
|
||||
RtemsPartReqReturnBuffer_PreDesc,
|
||||
buf,
|
||||
n,
|
||||
ctx->Map.pcs
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T_fixture RtemsPartReqReturnBuffer_Fixture = {
|
||||
.setup = RtemsPartReqReturnBuffer_Setup_Wrap,
|
||||
.stop = NULL,
|
||||
.teardown = RtemsPartReqReturnBuffer_Teardown_Wrap,
|
||||
.scope = RtemsPartReqReturnBuffer_Scope,
|
||||
.initial_context = &RtemsPartReqReturnBuffer_Instance
|
||||
};
|
||||
|
||||
static inline RtemsPartReqReturnBuffer_Entry RtemsPartReqReturnBuffer_PopEntry(
|
||||
RtemsPartReqReturnBuffer_Context *ctx
|
||||
)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = ctx->Map.index;
|
||||
ctx->Map.index = index + 1;
|
||||
return RtemsPartReqReturnBuffer_Entries[
|
||||
RtemsPartReqReturnBuffer_Map[ index ]
|
||||
];
|
||||
}
|
||||
|
||||
static void RtemsPartReqReturnBuffer_TestVariant(
|
||||
RtemsPartReqReturnBuffer_Context *ctx
|
||||
)
|
||||
{
|
||||
RtemsPartReqReturnBuffer_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 0 ] );
|
||||
RtemsPartReqReturnBuffer_Pre_Buf_Prepare( ctx, ctx->Map.pcs[ 1 ] );
|
||||
RtemsPartReqReturnBuffer_Action( ctx );
|
||||
RtemsPartReqReturnBuffer_Post_Status_Check(
|
||||
ctx,
|
||||
ctx->Map.entry.Post_Status
|
||||
);
|
||||
RtemsPartReqReturnBuffer_Post_Buf_Check( ctx, ctx->Map.entry.Post_Buf );
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_RtemsPartReqReturnBuffer( void )
|
||||
*/
|
||||
T_TEST_CASE_FIXTURE(
|
||||
RtemsPartReqReturnBuffer,
|
||||
&RtemsPartReqReturnBuffer_Fixture
|
||||
)
|
||||
{
|
||||
RtemsPartReqReturnBuffer_Context *ctx;
|
||||
|
||||
ctx = T_fixture_context();
|
||||
ctx->Map.in_action_loop = true;
|
||||
ctx->Map.index = 0;
|
||||
|
||||
for (
|
||||
ctx->Map.pcs[ 0 ] = RtemsPartReqReturnBuffer_Pre_Id_NoObj;
|
||||
ctx->Map.pcs[ 0 ] < RtemsPartReqReturnBuffer_Pre_Id_NA;
|
||||
++ctx->Map.pcs[ 0 ]
|
||||
) {
|
||||
for (
|
||||
ctx->Map.pcs[ 1 ] = RtemsPartReqReturnBuffer_Pre_Buf_Valid;
|
||||
ctx->Map.pcs[ 1 ] < RtemsPartReqReturnBuffer_Pre_Buf_NA;
|
||||
++ctx->Map.pcs[ 1 ]
|
||||
) {
|
||||
ctx->Map.entry = RtemsPartReqReturnBuffer_PopEntry( ctx );
|
||||
RtemsPartReqReturnBuffer_TestVariant( ctx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,196 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSTestCaseRtemsPartValPart
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the RTEMS quality process and was automatically
|
||||
* generated. If you find something that needs to be fixed or
|
||||
* worded better please post a report or patch to an RTEMS mailing list
|
||||
* or raise a bug report:
|
||||
*
|
||||
* https://www.rtems.org/bugs.html
|
||||
*
|
||||
* For information on updating and regenerating please refer to the How-To
|
||||
* section in the Software Requirements Engineering chapter of the
|
||||
* RTEMS Software Engineering manual. The manual is provided as a part of
|
||||
* a release. For development sources please refer to the online
|
||||
* documentation at:
|
||||
*
|
||||
* https://docs.rtems.org
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup RTEMSTestCaseRtemsPartValPart spec:/rtems/part/val/part
|
||||
*
|
||||
* @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
|
||||
*
|
||||
* @brief This test case collection provides validation test cases for
|
||||
* requirements of the @ref RTEMSAPIClassicPart.
|
||||
*
|
||||
* This test case performs the following actions:
|
||||
*
|
||||
* - Create a partition with a buffer area length which is greater than three
|
||||
* times the buffer size and less than four times the buffer size.
|
||||
*
|
||||
* - Check that exactly three buffers can be obtained from the partition for
|
||||
* use in parallel.
|
||||
*
|
||||
* - Return the three buffers in use to the partition and check that they can
|
||||
* be obtained from the partition for use in parallel in FIFO order.
|
||||
*
|
||||
* - Assert that RTEMS_PARTITION_ALIGNMENT is a constant expression which
|
||||
* evaluates to the expected value.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create a partition with a buffer area length which is greater than
|
||||
* three times the buffer size and less than four times the buffer size.
|
||||
*/
|
||||
static void RtemsPartValPart_Action_0( void )
|
||||
{
|
||||
RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t
|
||||
buffers[ 4 ][ 2 * sizeof( void * ) ];
|
||||
void *pointers[ RTEMS_ARRAY_SIZE( buffers ) ];
|
||||
void *pointer;
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
|
||||
id = 0xffffffff;
|
||||
sc = rtems_partition_create(
|
||||
rtems_build_name( 'N', 'A', 'M', 'E' ),
|
||||
buffers,
|
||||
sizeof( buffers ) - 1,
|
||||
sizeof( buffers[ 0 ] ),
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&id
|
||||
);
|
||||
T_step_rsc_success( 0, sc );
|
||||
|
||||
/*
|
||||
* Check that exactly three buffers can be obtained from the partition for
|
||||
* use in parallel.
|
||||
*/
|
||||
pointers[ 0 ] = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointers[ 0 ] );
|
||||
T_step_rsc_success( 1, sc );
|
||||
T_step_not_null( 2, pointers[ 0 ] );
|
||||
|
||||
pointers[ 1 ] = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointers[ 1 ] );
|
||||
T_step_rsc_success( 3, sc );
|
||||
T_step_not_null( 4, pointers[ 1 ] );
|
||||
|
||||
pointers[ 2 ] = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointers[ 2 ] );
|
||||
T_step_rsc_success( 5, sc );
|
||||
T_step_not_null( 6, pointers[ 2 ] );
|
||||
|
||||
pointers[ 3 ] = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointers[ 3 ] );
|
||||
T_step_rsc( 7, sc, RTEMS_UNSATISFIED );
|
||||
T_step_null( 8, pointers[ 3 ] );
|
||||
|
||||
/*
|
||||
* Return the three buffers in use to the partition and check that they can
|
||||
* be obtained from the partition for use in parallel in FIFO order.
|
||||
*/
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 1 ] );
|
||||
T_step_rsc_success( 9, sc );
|
||||
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 2 ] );
|
||||
T_step_rsc_success( 10, sc );
|
||||
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 0 ] );
|
||||
T_step_rsc_success( 11, sc );
|
||||
|
||||
pointer = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointer );
|
||||
T_step_rsc_success( 12, sc );
|
||||
T_step_eq_ptr( 13, pointer, pointers[ 1 ] );
|
||||
|
||||
pointer = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointer );
|
||||
T_step_rsc_success( 14, sc );
|
||||
T_step_eq_ptr( 15, pointer, pointers[ 2 ] );
|
||||
|
||||
pointer = NULL;
|
||||
sc = rtems_partition_get_buffer( id, &pointer );
|
||||
T_step_rsc_success( 16, sc );
|
||||
T_step_eq_ptr( 17, pointer, pointers[ 0 ] );
|
||||
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 0 ] );
|
||||
T_step_rsc_success( 18, sc );
|
||||
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 1 ] );
|
||||
T_step_rsc_success( 19, sc );
|
||||
|
||||
sc = rtems_partition_return_buffer( id, pointers[ 2 ] );
|
||||
T_step_rsc_success( 20, sc );
|
||||
|
||||
sc = rtems_partition_delete( id );
|
||||
T_step_rsc_success( 21, sc );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assert that RTEMS_PARTITION_ALIGNMENT is a constant expression which
|
||||
* evaluates to the expected value.
|
||||
*/
|
||||
static void RtemsPartValPart_Action_1( void )
|
||||
{
|
||||
RTEMS_STATIC_ASSERT(
|
||||
RTEMS_PARTITION_ALIGNMENT == CPU_SIZEOF_POINTER,
|
||||
ALIGNMENT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_RtemsPartValPart( void )
|
||||
*/
|
||||
T_TEST_CASE( RtemsPartValPart )
|
||||
{
|
||||
T_plan( 22 );
|
||||
|
||||
RtemsPartValPart_Action_0();
|
||||
RtemsPartValPart_Action_1();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
Reference in New Issue
Block a user