SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2020 embedded brains GmbH & Co. KG
enabled-by: true
functional-type: action
links:
- role: interface-function
uid: ../if/create
post-conditions:
- name: Status
states:
- name: Ok
test-code: |
T_rsc_success( ctx->status );
text: |
The return status of ${../if/create:/name} shall be
${../../status/if/successful:/name}.
- name: InvAddr
test-code: |
T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
text: |
The return status of ${../if/create:/name} shall be
${../../status/if/invalid-address:/name}.
- name: InvName
test-code: |
T_rsc( ctx->status, RTEMS_INVALID_NAME );
text: |
The return status of ${../if/create:/name} shall be
${../../status/if/invalid-name:/name}.
- name: InvSize
test-code: |
T_rsc( ctx->status, RTEMS_INVALID_SIZE );
text: |
The return status of ${../if/create:/name} shall be
${../../status/if/invalid-size:/name}.
- name: TooMany
test-code: |
T_rsc( ctx->status, RTEMS_TOO_MANY );
text: |
The return status of ${../if/create:/name} shall be
${../../status/if/too-many:/name}.
test-epilogue: null
test-prologue: null
- name: Name
states:
- name: Valid
test-code: |
id = 0;
sc = rtems_partition_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
T_rsc_success( sc );
T_eq_u32( id, ctx->id_value );
text: |
The unique object name shall identify the partition created by the
${../if/create:/name} call.
- name: Invalid
test-code: |
sc = rtems_partition_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
T_rsc( sc, RTEMS_INVALID_NAME );
text: |
The unique object name shall not identify a partition.
test-epilogue: null
test-prologue: |
rtems_status_code sc;
rtems_id id;
- name: IdVar
states:
- name: Set
test-code: |
T_eq_ptr( ctx->id, &ctx->id_value );
T_ne_u32( ctx->id_value, INVALID_ID );
for ( i = 0; i < BUFFER_COUNT; ++i) {
sc = rtems_partition_get_buffer( ctx->id_value, &buffers[ i ] );
T_rsc_success( sc );
T_not_null( buffers[ i ] );
}
no_buffer = (void *) (uintptr_t) 1;
sc = rtems_partition_get_buffer( ctx->id_value, &no_buffer );
T_rsc( sc, RTEMS_UNSATISFIED );
T_eq_ptr( no_buffer, (void *) (uintptr_t) 1 );
for ( i = 0; i < BUFFER_COUNT; ++i) {
sc = rtems_partition_return_buffer( ctx->id_value, buffers[ i ] );
T_rsc_success( sc );
}
sc = rtems_partition_delete( ctx->id_value );
T_rsc_success( sc );
text: |
The value of the object referenced by the ${../if/create:/params[5]/name}
parameter shall be set to the object identifier of the created partition
after the return of the ${../if/create:/name} call.
- name: Nop
test-code: |
T_eq_u32( ctx->id_value, INVALID_ID );
text: |
Objects referenced by the ${../if/create:/params[5]/name} parameter in
past calls to ${../if/create:/name} shall not be accessed by the
${../if/create:/name} call.
test-epilogue: null
test-prologue: |
rtems_status_code sc;
size_t i;
void *buffers[ BUFFER_COUNT ];
void *no_buffer;
pre-conditions:
- name: Name
states:
- name: Valid
test-code: |
ctx->name = NAME;
text: |
While the ${../if/create:/params[0]/name} parameter is valid.
- name: Invalid
test-code: |
ctx->name = 0;
text: |
While the ${../if/create:/params[0]/name} parameter is invalid.
test-epilogue: null
test-prologue: null
- name: Id
states:
- name: Valid
test-code: |
ctx->id = &ctx->id_value;
text: |
While the ${../if/create:/params[5]/name} parameter references an object
of type ${../../type/if/id:/name}.
- name: 'Null'
test-code: |
ctx->id = NULL;
text: |
While the ${../if/create:/params[5]/name} parameter is
${/c/if/null:/name}.
test-epilogue: null
test-prologue: null
- name: Start
states:
- name: Valid
test-code: |
ctx->starting_address = buffers;
text: |
While the ${../if/create:/params[1]/name} parameter is valid.
- name: 'Null'
test-code: |
ctx->starting_address = NULL;
text: |
While the ${../if/create:/params[1]/name} parameter is
${/c/if/null:/name}.
- name: BadAlign
test-code: |
ctx->starting_address = &buffers[ 0 ][ 1 ];
text: |
While the ${../if/create:/params[1]/name} parameter is misaligned.
test-epilogue: null
test-prologue: null
- name: Length
states:
- name: Valid
test-code: |
ctx->length = sizeof( buffers );
text: |
While the ${../if/create:/params[2]/name} parameter is valid.
- name: Zero
test-code: |
ctx->length = 0;
text: |
While the ${../if/create:/params[2]/name} parameter is zero.
- name: Invalid
test-code: |
ctx->length = sizeof( buffers[ 0 ] ) - 1;
text: |
While the ${../if/create:/params[2]/name} parameter is less than the
buffer size.
test-epilogue: null
test-prologue: null
- name: Size
states:
- name: Valid
test-code: |
ctx->buffer_size = sizeof( buffers[ 0 ] );
text: |
While the ${../if/create:/params[3]/name} parameter is valid.
- name: Zero
test-code: |
ctx->buffer_size = 0;
text: |
While the ${../if/create:/params[3]/name} parameter is zero.
- name: Skew
test-code: |
ctx->buffer_size = 1;
text: |
The ${../if/create:/params[3]/name} parameter shall not an integral
multiple of the pointer size.
- name: Small
test-code: |
ctx->buffer_size = sizeof( uintptr_t );
text: |
The ${../if/create:/params[3]/name} parameter shall greater than zero and
an integral multiple of the pointer size and less than the size of two
pointers.
test-epilogue: null
test-prologue: null
- name: Free
states:
- name: 'Yes'
test-code: |
/* Nothing to do */
text: |
While the system has at least one inactive partition object available.
- name: 'No'
test-code: |
i = 0;
ctx->seized_objects = T_seize_objects( Create, &i );
text: |
While the system has no inactive partition object available.
test-epilogue: null
test-prologue: |
size_t i;
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
ctx->status = rtems_partition_create(
ctx->name,
ctx->starting_address,
ctx->length,
ctx->buffer_size,
ctx->attribute_set,
ctx->id
);
test-brief: null
test-cleanup: |
T_surrender_objects( &ctx->seized_objects, rtems_partition_delete );
test-context:
- brief: null
description: null
member: |
void *seized_objects
- brief: null
description: null
member: |
rtems_status_code status
- brief: null
description: null
member: |
rtems_name name
- brief: null
description: null
member: |
void *starting_address
- brief: null
description: null
member: |
uintptr_t length
- brief: null
description: null
member: |
size_t buffer_size
- brief: null
description: null
member: |
rtems_attribute attribute_set
- brief: null
description: null
member: |
rtems_id *id
- brief: null
description: null
member: |
rtems_id id_value
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- string.h
test-local-includes:
- ts-config.h
- tx-support.h
test-prepare: |
rtems_status_code sc;
rtems_id id;
ctx->id_value = INVALID_ID;
ctx->attribute_set = RTEMS_DEFAULT_ATTRIBUTES;
id = INVALID_ID;
sc = rtems_partition_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
T_rsc( sc, RTEMS_INVALID_NAME );
T_eq_u32( id, INVALID_ID );
test-setup: null
test-stop: null
test-support: |
#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
#define MAX_PARTITIONS ( TEST_MAXIMUM_PARTITIONS + 1 )
#define BUFFER_COUNT 2
#define BUFFER_SIZE ( 2 * sizeof( void * ) )
static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t
buffers_to_seize[ MAX_PARTITIONS ][ BUFFER_COUNT ][ BUFFER_SIZE ];
static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) uint8_t
buffers[ BUFFER_COUNT ][ BUFFER_SIZE ];
static rtems_status_code Create( void *arg, uint32_t *id )
{
size_t *i;
size_t j;
i = arg;
j = *i;
T_quiet_lt_sz( j, MAX_PARTITIONS );
*i = j + 1;
return rtems_partition_create(
rtems_build_name( 'S', 'I', 'Z', 'E' ),
buffers_to_seize[ j ],
sizeof( buffers_to_seize[ j ] ),
sizeof( buffers_to_seize[ j ][ 0 ] ),
RTEMS_DEFAULT_ATTRIBUTES,
id
);
}
test-target: testsuites/validation/tc-part-create.c
test-teardown: null
text: ${.:text-template}
transition-map:
- enabled-by: true
post-conditions:
Status: Ok
Name: Valid
IdVar: Set
pre-conditions:
Id:
- Valid
Length:
- Valid
Name:
- Valid
Free:
- 'Yes'
Size:
- Valid
Start:
- Valid
- enabled-by: true
post-conditions:
Status: InvName
Name: Invalid
IdVar: Nop
pre-conditions:
Id: all
Length: all
Name:
- Invalid
Free: all
Size: all
Start: all
- enabled-by: true
post-conditions:
Status: InvAddr
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- 'Null'
Length: all
Name:
- Valid
Free: all
Size: all
Start: all
- enabled-by: true
post-conditions:
Status: InvAddr
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- Valid
Length: all
Name:
- Valid
Free: all
Size: all
Start:
- 'Null'
- enabled-by: true
post-conditions:
Status: InvSize
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- Valid
Length:
- Zero
- Invalid
Name:
- Valid
Free: all
Size: all
Start:
- Valid
- BadAlign
- enabled-by: true
post-conditions:
Status: InvSize
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- Valid
Length:
- Valid
Name:
- Valid
Free: all
Size:
- Zero
- Skew
- Small
Start:
- Valid
- BadAlign
- enabled-by: true
post-conditions:
Status: InvAddr
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- Valid
Length:
- Valid
Name:
- Valid
Free: all
Size:
- Valid
Start:
- BadAlign
- enabled-by: true
post-conditions:
Status: TooMany
Name: Invalid
IdVar: Nop
pre-conditions:
Id:
- Valid
Length:
- Valid
Name:
- Valid
Free:
- 'No'
Size:
- Valid
Start:
- Valid
type: requirement