54 #include <rtems/test.h> 65 RtemsPartReqGetBuffer_Pre_Id_Id,
66 RtemsPartReqGetBuffer_Pre_Id_Invalid,
67 RtemsPartReqGetBuffer_Pre_Id_NA
68 } RtemsPartReqGetBuffer_Pre_Id;
71 RtemsPartReqGetBuffer_Pre_InUse_True,
72 RtemsPartReqGetBuffer_Pre_InUse_False,
73 RtemsPartReqGetBuffer_Pre_InUse_NA
74 } RtemsPartReqGetBuffer_Pre_InUse;
77 RtemsPartReqGetBuffer_Post_Status_Ok,
78 RtemsPartReqGetBuffer_Post_Status_InvId,
79 RtemsPartReqGetBuffer_Post_Status_InUse,
80 RtemsPartReqGetBuffer_Post_Status_NA
81 } RtemsPartReqGetBuffer_Post_Status;
108 RtemsPartReqGetBuffer_Instance;
110 static const char *
const RtemsPartReqGetBuffer_PreDesc_Id[] = {
116 static const char *
const RtemsPartReqGetBuffer_PreDesc_InUse[] = {
122 static const char *
const *
const RtemsPartReqGetBuffer_PreDesc[] = {
123 RtemsPartReqGetBuffer_PreDesc_Id,
124 RtemsPartReqGetBuffer_PreDesc_InUse,
128 #define PART_NAME rtems_build_name( 'N', 'A', 'M', 'E' ) 130 #define BUFFER_COUNT 1 132 #define BUFFER_SIZE ( 2 * sizeof( void * ) ) 135 buffers[ BUFFER_COUNT ][ BUFFER_SIZE ];
137 static void RtemsPartReqGetBuffer_Pre_Id_Prepare(
139 RtemsPartReqGetBuffer_Pre_Id state
143 case RtemsPartReqGetBuffer_Pre_Id_Id: {
144 ctx->id = ctx->id_value;
148 case RtemsPartReqGetBuffer_Pre_Id_Invalid: {
153 case RtemsPartReqGetBuffer_Pre_Id_NA:
158 static void RtemsPartReqGetBuffer_Pre_InUse_Prepare(
160 RtemsPartReqGetBuffer_Pre_InUse state
166 case RtemsPartReqGetBuffer_Pre_InUse_True: {
170 T_not_null( ctx->buffer );
174 case RtemsPartReqGetBuffer_Pre_InUse_False: {
179 case RtemsPartReqGetBuffer_Pre_InUse_NA:
184 static void RtemsPartReqGetBuffer_Post_Status_Check(
186 RtemsPartReqGetBuffer_Post_Status state
193 case RtemsPartReqGetBuffer_Post_Status_Ok: {
194 T_rsc_success( ctx->status );
195 T_not_null( ctx->buffer );
199 case RtemsPartReqGetBuffer_Post_Status_InvId: {
205 T_eq_u32(
id, ctx->id_value );
209 case RtemsPartReqGetBuffer_Post_Status_InUse: {
215 T_eq_u32(
id, ctx->id_value );
219 case RtemsPartReqGetBuffer_Post_Status_NA:
224 static size_t RtemsPartReqGetBuffer_Scope(
void *arg,
char *buf,
size_t n )
231 return T_get_scope( RtemsPartReqGetBuffer_PreDesc, buf, n, ctx->
pcs );
237 static T_fixture RtemsPartReqGetBuffer_Fixture = {
241 .scope = RtemsPartReqGetBuffer_Scope,
242 .initial_context = &RtemsPartReqGetBuffer_Instance
245 static const uint8_t RtemsPartReqGetBuffer_TransitionMap[][ 1 ] = {
247 RtemsPartReqGetBuffer_Post_Status_InUse
249 RtemsPartReqGetBuffer_Post_Status_Ok
251 RtemsPartReqGetBuffer_Post_Status_InvId
253 RtemsPartReqGetBuffer_Post_Status_InvId
257 static const struct {
259 uint8_t Pre_Id_NA : 1;
260 uint8_t Pre_InUse_NA : 1;
261 } RtemsPartReqGetBuffer_TransitionInfo[] = {
281 sizeof( buffers[ 0 ] ),
297 if ( ctx->buffer != NULL ) {
302 if ( ctx->id_value != 0xffffffff ) {
311 T_TEST_CASE_FIXTURE( RtemsPartReqGetBuffer, &RtemsPartReqGetBuffer_Fixture )
316 ctx = T_fixture_context();
321 ctx->
pcs[ 0 ] = RtemsPartReqGetBuffer_Pre_Id_Id;
322 ctx->
pcs[ 0 ] < RtemsPartReqGetBuffer_Pre_Id_NA;
325 if ( RtemsPartReqGetBuffer_TransitionInfo[ index ].Pre_Id_NA ) {
326 ctx->
pcs[ 0 ] = RtemsPartReqGetBuffer_Pre_Id_NA;
327 index += ( RtemsPartReqGetBuffer_Pre_Id_NA - 1 )
328 * RtemsPartReqGetBuffer_Pre_InUse_NA;
332 ctx->
pcs[ 1 ] = RtemsPartReqGetBuffer_Pre_InUse_True;
333 ctx->
pcs[ 1 ] < RtemsPartReqGetBuffer_Pre_InUse_NA;
336 if ( RtemsPartReqGetBuffer_TransitionInfo[ index ].Pre_InUse_NA ) {
337 ctx->
pcs[ 1 ] = RtemsPartReqGetBuffer_Pre_InUse_NA;
338 index += ( RtemsPartReqGetBuffer_Pre_InUse_NA - 1 );
341 if ( RtemsPartReqGetBuffer_TransitionInfo[ index ].Skip ) {
346 RtemsPartReqGetBuffer_Prepare( ctx );
347 RtemsPartReqGetBuffer_Pre_Id_Prepare( ctx, ctx->
pcs[ 0 ] );
348 RtemsPartReqGetBuffer_Pre_InUse_Prepare( ctx, ctx->
pcs[ 1 ] );
349 RtemsPartReqGetBuffer_Action( ctx );
350 RtemsPartReqGetBuffer_Post_Status_Check(
352 RtemsPartReqGetBuffer_TransitionMap[ index ][ 0 ]
354 RtemsPartReqGetBuffer_Cleanup( ctx );
rtems_status_code rtems_partition_get_buffer(rtems_id id, void **buffer)
Tries to get a buffer from the specified partition.
This status code indicates that the object still had resources in use.
#define RTEMS_DEFAULT_ATTRIBUTES
This is the default value for an attribute set.
rtems_status_code rtems_partition_create(rtems_name name, void *starting_address, uintptr_t length, size_t buffer_size, rtems_attribute attribute_set, rtems_id *id)
Creates a partition.
rtems_status_code rtems_partition_delete(rtems_id id)
Deletes the specified partition.
rtems_status_code rtems_partition_return_buffer(rtems_id id, void *buffer)
Returns a buffer to the specified partition.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
#define RTEMS_ALIGNED(_alignment)
Instructs the compiler in a declaration or definition to enforce the specified alignment.
bool in_action_loop
This member indicates if the test action loop is currently executed.
This header file defines the RTEMS Classic API.
This status code indicates that an object identifier was invalid.
Objects_Id rtems_id
Values of this type identify an RTEMS object.
rtems_status_code rtems_partition_ident(rtems_name name, uint32_t node, rtems_id *id)
Identifies a partition object by the specified object name.
size_t pcs[2]
This member defines the pre-condition states for the next action.
Test context for spec:/rtems/part/req/get-buffer test case.
#define RTEMS_SEARCH_LOCAL_NODE
%
#define RTEMS_PARTITION_ALIGNMENT
This constant defines the minimum alignment of a partition buffer in bytes.