mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 22:55:36 +08:00
@@ -0,0 +1,16 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: objects
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2021 embedded brains GmbH & Co. KG
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: bsps/sparc/leon3
|
||||
includes: []
|
||||
install: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
|
||||
- testsuites/validation/tc-dev-grlib-io.c
|
||||
- testsuites/validation/tc-dev-grlib-irqamp-get-timestamp.c
|
||||
type: build
|
||||
@@ -0,0 +1,23 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2023 embedded brains GmbH & Co. KG
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: bsps/sparc/leon3
|
||||
features: c cprogram
|
||||
includes: []
|
||||
ldflags:
|
||||
- -Wl,--wrap=_IO_Relax
|
||||
links:
|
||||
- role: build-dependency
|
||||
uid: objgrlib
|
||||
source:
|
||||
- testsuites/validation/bsps/ts-validation-bsp-0.c
|
||||
stlib: []
|
||||
target: testsuites/validation/bsps/ts-validation-bsp-0.exe
|
||||
type: build
|
||||
use-after:
|
||||
- validation
|
||||
use-before: []
|
||||
@@ -10,6 +10,7 @@ enabled-by:
|
||||
- BUILD_VALIDATIONTESTS
|
||||
includes:
|
||||
- ${BSP_INCLUDES}
|
||||
- testsuites/validation
|
||||
install: []
|
||||
ldflags: []
|
||||
links:
|
||||
@@ -79,6 +80,8 @@ links:
|
||||
uid: validation-tls-0
|
||||
- role: build-dependency
|
||||
uid: validation-tls-1
|
||||
- role: build-dependency
|
||||
uid: bsps/validation-bsp-0
|
||||
type: build
|
||||
use-after:
|
||||
- validation
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup TestsuitesBspsValidationBsp0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* 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/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup TestsuitesBspsValidationBsp0 \
|
||||
* spec:/testsuites/bsps/validation-bsp-0
|
||||
*
|
||||
* @ingroup RTEMSTestSuitesValidation
|
||||
*
|
||||
* @brief This general purpose validation test suite provides enough resources
|
||||
* to run target-specific tests.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
const char rtems_test_name[] = "TestsuitesBspsValidationBsp0";
|
||||
|
||||
#include "ts-default.h"
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,348 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup DevGrlibReqApbuartInbyteNonblocking
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <grlib/apbuart.h>
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup DevGrlibReqApbuartInbyteNonblocking \
|
||||
* spec:/dev/grlib/req/apbuart-inbyte-nonblocking
|
||||
*
|
||||
* @ingroup TestsuitesBspsValidationBsp0
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA
|
||||
} DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady;
|
||||
|
||||
typedef enum {
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA
|
||||
} DevGrlibReqApbuartInbyteNonblocking_Post_Result;
|
||||
|
||||
typedef enum {
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA
|
||||
} DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Skip : 1;
|
||||
uint8_t Pre_DataReady_NA : 1;
|
||||
uint8_t Post_Result : 2;
|
||||
uint8_t Post_ErrorFlags : 1;
|
||||
} DevGrlibReqApbuartInbyteNonblocking_Entry;
|
||||
|
||||
/**
|
||||
* @brief Test context for spec:/dev/grlib/req/apbuart-inbyte-nonblocking test
|
||||
* case.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief This member provides the APBUART register block.
|
||||
*/
|
||||
apbuart regs;
|
||||
|
||||
/**
|
||||
* @brief This member contains the return value of the
|
||||
* apbuart_inbyte_nonblocking() call.
|
||||
*/
|
||||
int result;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* @brief This member defines the pre-condition states for the next action.
|
||||
*/
|
||||
size_t pcs[ 1 ];
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
DevGrlibReqApbuartInbyteNonblocking_Entry entry;
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the current transition variant
|
||||
* should be skipped.
|
||||
*/
|
||||
bool skip;
|
||||
} Map;
|
||||
} DevGrlibReqApbuartInbyteNonblocking_Context;
|
||||
|
||||
static DevGrlibReqApbuartInbyteNonblocking_Context
|
||||
DevGrlibReqApbuartInbyteNonblocking_Instance;
|
||||
|
||||
static const char * const DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady[] = {
|
||||
"Yes",
|
||||
"No",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const * const DevGrlibReqApbuartInbyteNonblocking_PreDesc[] = {
|
||||
DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes: {
|
||||
/*
|
||||
* While the data ready flag is set in the status register of the
|
||||
* register block specified by ``regs`` parameter.
|
||||
*/
|
||||
ctx->regs.status |= APBUART_STATUS_DR;
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No: {
|
||||
/*
|
||||
* While the data ready flag is cleared in the status register of the
|
||||
* register block specified by ``regs`` parameter.
|
||||
*/
|
||||
ctx->regs.status &= ~APBUART_STATUS_DR;
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_Result state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data: {
|
||||
/*
|
||||
* The return value of apbuart_inbyte_nonblocking() shall be the data
|
||||
* read from the data register of the register block specified by
|
||||
* ``regs``.
|
||||
*/
|
||||
T_eq_int( ctx->result, 0xff );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne: {
|
||||
/*
|
||||
* The return value of apbuart_inbyte_nonblocking() shall be minus one.
|
||||
*/
|
||||
T_eq_int( ctx->result, -1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared: {
|
||||
/*
|
||||
* The framing error, parity error, overrun, and break received flags in
|
||||
* the status register of the register block specified by ``regs`` shall
|
||||
* be cleared.
|
||||
*/
|
||||
T_eq_u32( ctx->regs.status & 0x78, 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_Prepare(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx
|
||||
)
|
||||
{
|
||||
memset( &ctx->regs, 0, sizeof( ctx->regs ) );
|
||||
ctx->regs.status = 0x78;
|
||||
ctx->regs.data = 0xff;
|
||||
}
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_Action(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx
|
||||
)
|
||||
{
|
||||
ctx->result = apbuart_inbyte_nonblocking( &ctx->regs );
|
||||
}
|
||||
|
||||
static const DevGrlibReqApbuartInbyteNonblocking_Entry
|
||||
DevGrlibReqApbuartInbyteNonblocking_Entries[] = {
|
||||
{ 0, 0, DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared },
|
||||
{ 0, 0, DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne,
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared }
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
DevGrlibReqApbuartInbyteNonblocking_Map[] = {
|
||||
0, 1
|
||||
};
|
||||
|
||||
static size_t DevGrlibReqApbuartInbyteNonblocking_Scope(
|
||||
void *arg,
|
||||
char *buf,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
|
||||
if ( ctx->Map.in_action_loop ) {
|
||||
return T_get_scope(
|
||||
DevGrlibReqApbuartInbyteNonblocking_PreDesc,
|
||||
buf,
|
||||
n,
|
||||
ctx->Map.pcs
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T_fixture DevGrlibReqApbuartInbyteNonblocking_Fixture = {
|
||||
.setup = NULL,
|
||||
.stop = NULL,
|
||||
.teardown = NULL,
|
||||
.scope = DevGrlibReqApbuartInbyteNonblocking_Scope,
|
||||
.initial_context = &DevGrlibReqApbuartInbyteNonblocking_Instance
|
||||
};
|
||||
|
||||
static inline DevGrlibReqApbuartInbyteNonblocking_Entry
|
||||
DevGrlibReqApbuartInbyteNonblocking_PopEntry(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx
|
||||
)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = ctx->Map.index;
|
||||
ctx->Map.index = index + 1;
|
||||
return DevGrlibReqApbuartInbyteNonblocking_Entries[
|
||||
DevGrlibReqApbuartInbyteNonblocking_Map[ index ]
|
||||
];
|
||||
}
|
||||
|
||||
static void DevGrlibReqApbuartInbyteNonblocking_TestVariant(
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx
|
||||
)
|
||||
{
|
||||
DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
|
||||
ctx,
|
||||
ctx->Map.pcs[ 0 ]
|
||||
);
|
||||
DevGrlibReqApbuartInbyteNonblocking_Action( ctx );
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
|
||||
ctx,
|
||||
ctx->Map.entry.Post_Result
|
||||
);
|
||||
DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
|
||||
ctx,
|
||||
ctx->Map.entry.Post_ErrorFlags
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_DevGrlibReqApbuartInbyteNonblocking( void )
|
||||
*/
|
||||
T_TEST_CASE_FIXTURE(
|
||||
DevGrlibReqApbuartInbyteNonblocking,
|
||||
&DevGrlibReqApbuartInbyteNonblocking_Fixture
|
||||
)
|
||||
{
|
||||
DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
|
||||
|
||||
ctx = T_fixture_context();
|
||||
ctx->Map.in_action_loop = true;
|
||||
ctx->Map.index = 0;
|
||||
|
||||
for (
|
||||
ctx->Map.pcs[ 0 ] = DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes;
|
||||
ctx->Map.pcs[ 0 ] < DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA;
|
||||
++ctx->Map.pcs[ 0 ]
|
||||
) {
|
||||
ctx->Map.entry = DevGrlibReqApbuartInbyteNonblocking_PopEntry( ctx );
|
||||
DevGrlibReqApbuartInbyteNonblocking_Prepare( ctx );
|
||||
DevGrlibReqApbuartInbyteNonblocking_TestVariant( ctx );
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,295 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup DevGrlibValIo
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <grlib/apbuart.h>
|
||||
#include <grlib/io.h>
|
||||
|
||||
#include "tx-support.h"
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup DevGrlibValIo spec:/dev/grlib/val/io
|
||||
*
|
||||
* @ingroup TestsuitesBspsValidationBsp0
|
||||
*
|
||||
* @brief Tests some @ref RTEMSDeviceGRLIB directives.
|
||||
*
|
||||
* This test case performs the following actions:
|
||||
*
|
||||
* - Call grlib_load_8() to load a prepared value.
|
||||
*
|
||||
* - Check that the returned value is equal to the prepared value.
|
||||
*
|
||||
* - Call grlib_load_16() to load a prepared value.
|
||||
*
|
||||
* - Check that the returned value is equal to the prepared value.
|
||||
*
|
||||
* - Call grlib_load_32() to load a prepared value.
|
||||
*
|
||||
* - Check that the returned value is equal to the prepared value.
|
||||
*
|
||||
* - Call grlib_load_64() to load a prepared value.
|
||||
*
|
||||
* - Check that the returned value is equal to the prepared value.
|
||||
*
|
||||
* - Call grlib_store_8() to store a value to an object.
|
||||
*
|
||||
* - Check that the value of the object is equal to the stored value.
|
||||
*
|
||||
* - Call grlib_store_16() to store a value to an object.
|
||||
*
|
||||
* - Check that the value of the object is equal to the stored value.
|
||||
*
|
||||
* - Call grlib_store_32() to store a value to an object.
|
||||
*
|
||||
* - Check that the value of the object is equal to the stored value.
|
||||
*
|
||||
* - Call grlib_store_64() to store a value to an object.
|
||||
*
|
||||
* - Check that the value of the object is equal to the stored value.
|
||||
*
|
||||
* - Call apbuart_outbyte_polled() to store a character to the data register.
|
||||
* The transmitter FIFO shall be initially non-empty. The status is checked
|
||||
* by apbuart_outbyte_wait().
|
||||
*
|
||||
* - Check that the transmitter FIFO empty flag was set by ApbuartIORelax().
|
||||
*
|
||||
* - Check that the data register was written by apbuart_outbyte_polled().
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void ApbuartIORelax( void *arg )
|
||||
{
|
||||
apbuart *regs;
|
||||
|
||||
regs = arg;
|
||||
regs->status = 0x4;
|
||||
T_quiet_eq_u32( regs->data, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_load_8() to load a prepared value.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_0( void )
|
||||
{
|
||||
uint8_t reg_8;
|
||||
uint8_t val_8;
|
||||
|
||||
reg_8 = 0x81;
|
||||
val_8 = grlib_load_8( ®_8 );
|
||||
|
||||
/*
|
||||
* Check that the returned value is equal to the prepared value.
|
||||
*/
|
||||
T_step_eq_u8( 0, val_8, 0x81 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_load_16() to load a prepared value.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_1( void )
|
||||
{
|
||||
uint16_t reg_16;
|
||||
uint16_t val_16;
|
||||
|
||||
reg_16 = 0x8001;
|
||||
val_16 = grlib_load_16( ®_16 );
|
||||
|
||||
/*
|
||||
* Check that the returned value is equal to the prepared value.
|
||||
*/
|
||||
T_step_eq_u16( 1, val_16, 0x8001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_load_32() to load a prepared value.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_2( void )
|
||||
{
|
||||
uint32_t reg_32;
|
||||
uint32_t val_32;
|
||||
|
||||
reg_32 = 0x80000001;
|
||||
val_32 = grlib_load_32( ®_32 );
|
||||
|
||||
/*
|
||||
* Check that the returned value is equal to the prepared value.
|
||||
*/
|
||||
T_step_eq_u32( 2, val_32, 0x80000001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_load_64() to load a prepared value.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_3( void )
|
||||
{
|
||||
uint64_t reg_64;
|
||||
uint64_t val_64;
|
||||
|
||||
reg_64 = 0x8000000000000001;
|
||||
val_64 = grlib_load_64( ®_64 );
|
||||
|
||||
/*
|
||||
* Check that the returned value is equal to the prepared value.
|
||||
*/
|
||||
T_step_eq_u64( 3, val_64, 0x8000000000000001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_store_8() to store a value to an object.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_4( void )
|
||||
{
|
||||
uint8_t reg_8;
|
||||
|
||||
grlib_store_8( ®_8, 0x81 );
|
||||
|
||||
/*
|
||||
* Check that the value of the object is equal to the stored value.
|
||||
*/
|
||||
T_step_eq_u8( 4, reg_8, 0x81 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_store_16() to store a value to an object.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_5( void )
|
||||
{
|
||||
uint16_t reg_16;
|
||||
|
||||
grlib_store_16( ®_16, 0x8001 );
|
||||
|
||||
/*
|
||||
* Check that the value of the object is equal to the stored value.
|
||||
*/
|
||||
T_step_eq_u16( 5, reg_16, 0x8001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_store_32() to store a value to an object.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_6( void )
|
||||
{
|
||||
uint32_t reg_32;
|
||||
|
||||
grlib_store_32( ®_32, 0x80000001 );
|
||||
|
||||
/*
|
||||
* Check that the value of the object is equal to the stored value.
|
||||
*/
|
||||
T_step_eq_u32( 6, reg_32, 0x80000001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call grlib_store_64() to store a value to an object.
|
||||
*/
|
||||
static void DevGrlibValIo_Action_7( void )
|
||||
{
|
||||
uint64_t reg_64;
|
||||
|
||||
grlib_store_64( ®_64, 0x8000000000000001 );
|
||||
|
||||
/*
|
||||
* Check that the value of the object is equal to the stored value.
|
||||
*/
|
||||
T_step_eq_u64( 7, reg_64, 0x8000000000000001 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call apbuart_outbyte_polled() to store a character to the data
|
||||
* register. The transmitter FIFO shall be initially non-empty. The status
|
||||
* is checked by apbuart_outbyte_wait().
|
||||
*/
|
||||
static void DevGrlibValIo_Action_8( void )
|
||||
{
|
||||
apbuart regs;
|
||||
|
||||
memset( ®s, 0, sizeof( regs ) );
|
||||
SetIORelaxHandler( ApbuartIORelax, ®s );
|
||||
apbuart_outbyte_polled( ®s, (char) 0xff );
|
||||
SetIORelaxHandler( NULL, NULL );
|
||||
|
||||
/*
|
||||
* Check that the transmitter FIFO empty flag was set by ApbuartIORelax().
|
||||
*/
|
||||
T_step_eq_u32( 8, regs.status, APBUART_STATUS_TE );
|
||||
|
||||
/*
|
||||
* Check that the data register was written by apbuart_outbyte_polled().
|
||||
*/
|
||||
T_step_eq_u32( 9, regs.data, 0xff );
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_DevGrlibValIo( void )
|
||||
*/
|
||||
T_TEST_CASE( DevGrlibValIo )
|
||||
{
|
||||
T_plan( 10 );
|
||||
|
||||
DevGrlibValIo_Action_0();
|
||||
DevGrlibValIo_Action_1();
|
||||
DevGrlibValIo_Action_2();
|
||||
DevGrlibValIo_Action_3();
|
||||
DevGrlibValIo_Action_4();
|
||||
DevGrlibValIo_Action_5();
|
||||
DevGrlibValIo_Action_6();
|
||||
DevGrlibValIo_Action_7();
|
||||
DevGrlibValIo_Action_8();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,304 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup DevGrlibReqIrqampGetTimestamp
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* 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 <grlib/irqamp.h>
|
||||
|
||||
#include <rtems/test.h>
|
||||
|
||||
/**
|
||||
* @defgroup DevGrlibReqIrqampGetTimestamp \
|
||||
* spec:/dev/grlib/req/irqamp-get-timestamp
|
||||
*
|
||||
* @ingroup TestsuitesBspsValidationBsp0
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero,
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Positive,
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA
|
||||
} DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets;
|
||||
|
||||
typedef enum {
|
||||
DevGrlibReqIrqampGetTimestamp_Post_Result_Registers,
|
||||
DevGrlibReqIrqampGetTimestamp_Post_Result_Null,
|
||||
DevGrlibReqIrqampGetTimestamp_Post_Result_NA
|
||||
} DevGrlibReqIrqampGetTimestamp_Post_Result;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Skip : 1;
|
||||
uint8_t Pre_NumberOfTimestampRegisterSets_NA : 1;
|
||||
uint8_t Post_Result : 2;
|
||||
} DevGrlibReqIrqampGetTimestamp_Entry;
|
||||
|
||||
/**
|
||||
* @brief Test context for spec:/dev/grlib/req/irqamp-get-timestamp test case.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief This member contains the return value of the
|
||||
* irqamp_get_timestamp_registers() call.
|
||||
*/
|
||||
irqamp_timestamp *result;
|
||||
|
||||
/**
|
||||
* @brief This member contains the IRQ(A)MP register block.
|
||||
*/
|
||||
irqamp irqamp_regs;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* @brief This member defines the pre-condition states for the next action.
|
||||
*/
|
||||
size_t pcs[ 1 ];
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
DevGrlibReqIrqampGetTimestamp_Entry entry;
|
||||
|
||||
/**
|
||||
* @brief If this member is true, then the current transition variant
|
||||
* should be skipped.
|
||||
*/
|
||||
bool skip;
|
||||
} Map;
|
||||
} DevGrlibReqIrqampGetTimestamp_Context;
|
||||
|
||||
static DevGrlibReqIrqampGetTimestamp_Context
|
||||
DevGrlibReqIrqampGetTimestamp_Instance;
|
||||
|
||||
static const char * const DevGrlibReqIrqampGetTimestamp_PreDesc_NumberOfTimestampRegisterSets[] = {
|
||||
"Zero",
|
||||
"Positive",
|
||||
"NA"
|
||||
};
|
||||
|
||||
static const char * const * const DevGrlibReqIrqampGetTimestamp_PreDesc[] = {
|
||||
DevGrlibReqIrqampGetTimestamp_PreDesc_NumberOfTimestampRegisterSets,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Prepare(
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx,
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero: {
|
||||
/*
|
||||
* While the number of timestamp register sets indicated by the IRQ(A)MP
|
||||
* register block specified by the ``irqamp_regs`` parameter is zero.
|
||||
*/
|
||||
ctx->irqamp_regs.itstmp[ 0 ].itstmpc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Positive: {
|
||||
/*
|
||||
* While the number of timestamp register sets indicated by the IRQ(A)MP
|
||||
* register block specified by the ``irqamp_regs`` parameter is positive.
|
||||
*/
|
||||
ctx->irqamp_regs.itstmp[ 0 ].itstmpc = IRQAMP_ITSTMPC_TSTAMP( 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DevGrlibReqIrqampGetTimestamp_Post_Result_Check(
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx,
|
||||
DevGrlibReqIrqampGetTimestamp_Post_Result state
|
||||
)
|
||||
{
|
||||
switch ( state ) {
|
||||
case DevGrlibReqIrqampGetTimestamp_Post_Result_Registers: {
|
||||
/*
|
||||
* The return value of irqamp_get_timestamp_registers() shall be address
|
||||
* of the timestamping register block contained in the IRQ(A)MP register
|
||||
* block specified by the ``irqamp_regs`` parameter.
|
||||
*/
|
||||
T_not_null( ctx->result );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqIrqampGetTimestamp_Post_Result_Null: {
|
||||
/*
|
||||
* The return value of irqamp_get_timestamp_registers() shall be false.
|
||||
*/
|
||||
T_null( ctx->result );
|
||||
break;
|
||||
}
|
||||
|
||||
case DevGrlibReqIrqampGetTimestamp_Post_Result_NA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DevGrlibReqIrqampGetTimestamp_Action(
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx
|
||||
)
|
||||
{
|
||||
ctx->result = irqamp_get_timestamp_registers( &ctx->irqamp_regs );
|
||||
}
|
||||
|
||||
static const DevGrlibReqIrqampGetTimestamp_Entry
|
||||
DevGrlibReqIrqampGetTimestamp_Entries[] = {
|
||||
{ 0, 0, DevGrlibReqIrqampGetTimestamp_Post_Result_Null },
|
||||
{ 0, 0, DevGrlibReqIrqampGetTimestamp_Post_Result_Registers }
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
DevGrlibReqIrqampGetTimestamp_Map[] = {
|
||||
0, 1
|
||||
};
|
||||
|
||||
static size_t DevGrlibReqIrqampGetTimestamp_Scope(
|
||||
void *arg,
|
||||
char *buf,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx;
|
||||
|
||||
ctx = arg;
|
||||
|
||||
if ( ctx->Map.in_action_loop ) {
|
||||
return T_get_scope(
|
||||
DevGrlibReqIrqampGetTimestamp_PreDesc,
|
||||
buf,
|
||||
n,
|
||||
ctx->Map.pcs
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T_fixture DevGrlibReqIrqampGetTimestamp_Fixture = {
|
||||
.setup = NULL,
|
||||
.stop = NULL,
|
||||
.teardown = NULL,
|
||||
.scope = DevGrlibReqIrqampGetTimestamp_Scope,
|
||||
.initial_context = &DevGrlibReqIrqampGetTimestamp_Instance
|
||||
};
|
||||
|
||||
static inline DevGrlibReqIrqampGetTimestamp_Entry
|
||||
DevGrlibReqIrqampGetTimestamp_PopEntry(
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx
|
||||
)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = ctx->Map.index;
|
||||
ctx->Map.index = index + 1;
|
||||
return DevGrlibReqIrqampGetTimestamp_Entries[
|
||||
DevGrlibReqIrqampGetTimestamp_Map[ index ]
|
||||
];
|
||||
}
|
||||
|
||||
static void DevGrlibReqIrqampGetTimestamp_TestVariant(
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx
|
||||
)
|
||||
{
|
||||
DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Prepare(
|
||||
ctx,
|
||||
ctx->Map.pcs[ 0 ]
|
||||
);
|
||||
DevGrlibReqIrqampGetTimestamp_Action( ctx );
|
||||
DevGrlibReqIrqampGetTimestamp_Post_Result_Check(
|
||||
ctx,
|
||||
ctx->Map.entry.Post_Result
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void T_case_body_DevGrlibReqIrqampGetTimestamp( void )
|
||||
*/
|
||||
T_TEST_CASE_FIXTURE(
|
||||
DevGrlibReqIrqampGetTimestamp,
|
||||
&DevGrlibReqIrqampGetTimestamp_Fixture
|
||||
)
|
||||
{
|
||||
DevGrlibReqIrqampGetTimestamp_Context *ctx;
|
||||
|
||||
ctx = T_fixture_context();
|
||||
ctx->Map.in_action_loop = true;
|
||||
ctx->Map.index = 0;
|
||||
|
||||
for (
|
||||
ctx->Map.pcs[ 0 ] = DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_Zero;
|
||||
ctx->Map.pcs[ 0 ] < DevGrlibReqIrqampGetTimestamp_Pre_NumberOfTimestampRegisterSets_NA;
|
||||
++ctx->Map.pcs[ 0 ]
|
||||
) {
|
||||
ctx->Map.entry = DevGrlibReqIrqampGetTimestamp_PopEntry( ctx );
|
||||
DevGrlibReqIrqampGetTimestamp_TestVariant( ctx );
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
Reference in New Issue
Block a user