summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-27 08:38:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-28 08:54:47 +0200
commit977b6bb507ac0d16e71144b8daec572c35207f80 (patch)
tree55d06c44f7e0e0d85455487a01addf3ac39b6ef7
parent8995312309ff0013838e2097ce317eb5e7f53761 (diff)
apbuart
-rw-r--r--testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c155
-rw-r--r--testsuites/validation/tc-dev-grlib-io.c125
2 files changed, 167 insertions, 113 deletions
diff --git a/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c b/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
index 6b7c75c72f..9544de23d3 100644
--- a/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
+++ b/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
@@ -3,7 +3,7 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseDevGrlibReqApbuartInbytePolled
+ * @ingroup RTEMSTestCaseDevGrlibReqApbuartInbyteNonblocking
*/
/*
@@ -58,8 +58,8 @@
#include <rtems/test.h>
/**
- * @defgroup RTEMSTestCaseDevGrlibReqApbuartInbytePolled \
- * spec:/dev/grlib/req/apbuart-inbyte-polled
+ * @defgroup RTEMSTestCaseDevGrlibReqApbuartInbyteNonblocking \
+ * spec:/dev/grlib/req/apbuart-inbyte-nonblocking
*
* @ingroup RTEMSTestSuiteTestsuitesValidationDev0
*
@@ -67,24 +67,25 @@
*/
typedef enum {
- DevGrlibReqApbuartInbytePolled_Pre_DataReady_Yes,
- DevGrlibReqApbuartInbytePolled_Pre_DataReady_No,
- DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA
-} DevGrlibReqApbuartInbytePolled_Pre_DataReady;
+ DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes,
+ DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No,
+ DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA
+} DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady;
typedef enum {
- DevGrlibReqApbuartInbytePolled_Post_Result_Data,
- DevGrlibReqApbuartInbytePolled_Post_Result_MinusOne,
- DevGrlibReqApbuartInbytePolled_Post_Result_NA
-} DevGrlibReqApbuartInbytePolled_Post_Result;
+ DevGrlibReqApbuartInbyteNonblocking_Post_Result_Data,
+ DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne,
+ DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA
+} DevGrlibReqApbuartInbyteNonblocking_Post_Result;
typedef enum {
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Cleared,
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_NA
-} DevGrlibReqApbuartInbytePolled_Post_ErrorFlags;
+ DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Cleared,
+ DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA
+} DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags;
/**
- * @brief Test context for spec:/dev/grlib/req/apbuart-inbyte-polled test case.
+ * @brief Test context for spec:/dev/grlib/req/apbuart-inbyte-nonblocking test
+ * case.
*/
typedef struct {
/**
@@ -108,29 +109,29 @@ typedef struct {
* executed.
*/
bool in_action_loop;
-} DevGrlibReqApbuartInbytePolled_Context;
+} DevGrlibReqApbuartInbyteNonblocking_Context;
-static DevGrlibReqApbuartInbytePolled_Context
- DevGrlibReqApbuartInbytePolled_Instance;
+static DevGrlibReqApbuartInbyteNonblocking_Context
+ DevGrlibReqApbuartInbyteNonblocking_Instance;
-static const char * const DevGrlibReqApbuartInbytePolled_PreDesc_DataReady[] = {
+static const char * const DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady[] = {
"Yes",
"No",
"NA"
};
-static const char * const * const DevGrlibReqApbuartInbytePolled_PreDesc[] = {
- DevGrlibReqApbuartInbytePolled_PreDesc_DataReady,
+static const char * const * const DevGrlibReqApbuartInbyteNonblocking_PreDesc[] = {
+ DevGrlibReqApbuartInbyteNonblocking_PreDesc_DataReady,
NULL
};
-static void DevGrlibReqApbuartInbytePolled_Pre_DataReady_Prepare(
- DevGrlibReqApbuartInbytePolled_Context *ctx,
- DevGrlibReqApbuartInbytePolled_Pre_DataReady state
+static void DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
+ DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady state
)
{
switch ( state ) {
- case DevGrlibReqApbuartInbytePolled_Pre_DataReady_Yes: {
+ case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes: {
/*
* While the data ready flag is set in the status register of the
* register block specified by ``regs`` parameter.
@@ -139,7 +140,7 @@ static void DevGrlibReqApbuartInbytePolled_Pre_DataReady_Prepare(
break;
}
- case DevGrlibReqApbuartInbytePolled_Pre_DataReady_No: {
+ case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_No: {
/*
* While the data ready flag is cleared in the status register of the
* register block specified by ``regs`` parameter.
@@ -148,18 +149,18 @@ static void DevGrlibReqApbuartInbytePolled_Pre_DataReady_Prepare(
break;
}
- case DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA:
+ case DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA:
break;
}
}
-static void DevGrlibReqApbuartInbytePolled_Post_Result_Check(
- DevGrlibReqApbuartInbytePolled_Context *ctx,
- DevGrlibReqApbuartInbytePolled_Post_Result state
+static void DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
+ DevGrlibReqApbuartInbyteNonblocking_Post_Result state
)
{
switch ( state ) {
- case DevGrlibReqApbuartInbytePolled_Post_Result_Data: {
+ 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
@@ -169,7 +170,7 @@ static void DevGrlibReqApbuartInbytePolled_Post_Result_Check(
break;
}
- case DevGrlibReqApbuartInbytePolled_Post_Result_MinusOne: {
+ case DevGrlibReqApbuartInbyteNonblocking_Post_Result_MinusOne: {
/*
* The return value of apbuart_inbyte_nonblocking() shall be minus one.
*/
@@ -177,18 +178,18 @@ static void DevGrlibReqApbuartInbytePolled_Post_Result_Check(
break;
}
- case DevGrlibReqApbuartInbytePolled_Post_Result_NA:
+ case DevGrlibReqApbuartInbyteNonblocking_Post_Result_NA:
break;
}
}
-static void DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Check(
- DevGrlibReqApbuartInbytePolled_Context *ctx,
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags state
+static void DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx,
+ DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags state
)
{
switch ( state ) {
- case DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Cleared: {
+ 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
@@ -198,13 +199,13 @@ static void DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Check(
break;
}
- case DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_NA:
+ case DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_NA:
break;
}
}
-static void DevGrlibReqApbuartInbytePolled_Prepare(
- DevGrlibReqApbuartInbytePolled_Context *ctx
+static void DevGrlibReqApbuartInbyteNonblocking_Prepare(
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx
)
{
memset( &ctx->regs, 0, sizeof( ctx->regs ) );
@@ -212,8 +213,8 @@ static void DevGrlibReqApbuartInbytePolled_Prepare(
ctx->regs.data = 0xff;
}
-static void DevGrlibReqApbuartInbytePolled_Action(
- DevGrlibReqApbuartInbytePolled_Context *ctx
+static void DevGrlibReqApbuartInbyteNonblocking_Action(
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx
)
{
ctx->result = apbuart_inbyte_nonblocking( &ctx->regs );
@@ -224,34 +225,34 @@ typedef struct {
uint8_t Pre_DataReady_NA : 1;
uint8_t Post_Result : 2;
uint8_t Post_ErrorFlags : 1;
-} DevGrlibReqApbuartInbytePolled_Entry;
-
-static const DevGrlibReqApbuartInbytePolled_Entry
-DevGrlibReqApbuartInbytePolled_Entries[] = {
- { 0, 0, DevGrlibReqApbuartInbytePolled_Post_Result_Data,
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Cleared },
- { 0, 0, DevGrlibReqApbuartInbytePolled_Post_Result_MinusOne,
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Cleared }
+} DevGrlibReqApbuartInbyteNonblocking_Entry;
+
+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
-DevGrlibReqApbuartInbytePolled_Map[] = {
+DevGrlibReqApbuartInbyteNonblocking_Map[] = {
0, 1
};
-static size_t DevGrlibReqApbuartInbytePolled_Scope(
+static size_t DevGrlibReqApbuartInbyteNonblocking_Scope(
void *arg,
char *buf,
size_t n
)
{
- DevGrlibReqApbuartInbytePolled_Context *ctx;
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
ctx = arg;
if ( ctx->in_action_loop ) {
return T_get_scope(
- DevGrlibReqApbuartInbytePolled_PreDesc,
+ DevGrlibReqApbuartInbyteNonblocking_PreDesc,
buf,
n,
ctx->pcs
@@ -261,31 +262,31 @@ static size_t DevGrlibReqApbuartInbytePolled_Scope(
return 0;
}
-static T_fixture DevGrlibReqApbuartInbytePolled_Fixture = {
+static T_fixture DevGrlibReqApbuartInbyteNonblocking_Fixture = {
.setup = NULL,
.stop = NULL,
.teardown = NULL,
- .scope = DevGrlibReqApbuartInbytePolled_Scope,
- .initial_context = &DevGrlibReqApbuartInbytePolled_Instance
+ .scope = DevGrlibReqApbuartInbyteNonblocking_Scope,
+ .initial_context = &DevGrlibReqApbuartInbyteNonblocking_Instance
};
-static inline DevGrlibReqApbuartInbytePolled_Entry
-DevGrlibReqApbuartInbytePolled_GetEntry( size_t index )
+static inline DevGrlibReqApbuartInbyteNonblocking_Entry
+DevGrlibReqApbuartInbyteNonblocking_GetEntry( size_t index )
{
- return DevGrlibReqApbuartInbytePolled_Entries[
- DevGrlibReqApbuartInbytePolled_Map[ index ]
+ return DevGrlibReqApbuartInbyteNonblocking_Entries[
+ DevGrlibReqApbuartInbyteNonblocking_Map[ index ]
];
}
/**
- * @fn void T_case_body_DevGrlibReqApbuartInbytePolled( void )
+ * @fn void T_case_body_DevGrlibReqApbuartInbyteNonblocking( void )
*/
T_TEST_CASE_FIXTURE(
- DevGrlibReqApbuartInbytePolled,
- &DevGrlibReqApbuartInbytePolled_Fixture
+ DevGrlibReqApbuartInbyteNonblocking,
+ &DevGrlibReqApbuartInbyteNonblocking_Fixture
)
{
- DevGrlibReqApbuartInbytePolled_Context *ctx;
+ DevGrlibReqApbuartInbyteNonblocking_Context *ctx;
size_t index;
ctx = T_fixture_context();
@@ -293,20 +294,26 @@ T_TEST_CASE_FIXTURE(
index = 0;
for (
- ctx->pcs[ 0 ] = DevGrlibReqApbuartInbytePolled_Pre_DataReady_Yes;
- ctx->pcs[ 0 ] < DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA;
+ ctx->pcs[ 0 ] = DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Yes;
+ ctx->pcs[ 0 ] < DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_NA;
++ctx->pcs[ 0 ]
) {
- DevGrlibReqApbuartInbytePolled_Entry entry;
+ DevGrlibReqApbuartInbyteNonblocking_Entry entry;
- entry = DevGrlibReqApbuartInbytePolled_GetEntry( index );
+ entry = DevGrlibReqApbuartInbyteNonblocking_GetEntry( index );
++index;
- DevGrlibReqApbuartInbytePolled_Prepare( ctx );
- DevGrlibReqApbuartInbytePolled_Pre_DataReady_Prepare( ctx, ctx->pcs[ 0 ] );
- DevGrlibReqApbuartInbytePolled_Action( ctx );
- DevGrlibReqApbuartInbytePolled_Post_Result_Check( ctx, entry.Post_Result );
- DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Check(
+ DevGrlibReqApbuartInbyteNonblocking_Prepare( ctx );
+ DevGrlibReqApbuartInbyteNonblocking_Pre_DataReady_Prepare(
+ ctx,
+ ctx->pcs[ 0 ]
+ );
+ DevGrlibReqApbuartInbyteNonblocking_Action( ctx );
+ DevGrlibReqApbuartInbyteNonblocking_Post_Result_Check(
+ ctx,
+ entry.Post_Result
+ );
+ DevGrlibReqApbuartInbyteNonblocking_Post_ErrorFlags_Check(
ctx,
entry.Post_ErrorFlags
);
diff --git a/testsuites/validation/tc-dev-grlib-io.c b/testsuites/validation/tc-dev-grlib-io.c
index 1b24ff714c..01a603ae68 100644
--- a/testsuites/validation/tc-dev-grlib-io.c
+++ b/testsuites/validation/tc-dev-grlib-io.c
@@ -3,7 +3,7 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseBspSparcValGrlibIo
+ * @ingroup RTEMSTestCaseDevGrlibValIo
*/
/*
@@ -52,58 +52,79 @@
#include "config.h"
#endif
+#include <string.h>
+#include <grlib/apbuart.h>
#include <grlib/io.h>
+#include "tx-support.h"
+
#include <rtems/test.h>
/**
- * @defgroup RTEMSTestCaseBspSparcValGrlibIo spec:/bsp/sparc/val/grlib-io
+ * @defgroup RTEMSTestCaseDevGrlibValIo spec:/dev/grlib/val/io
*
* @ingroup RTEMSTestSuiteTestsuitesValidationDev0
*
- * @brief Tests the SPARC-specific GRLIB API.
+ * @brief Tests some @ref RTEMSDeviceGRLIB directives.
*
* This test case performs the following actions:
*
- * - Call grlib_load_8() to load a prepared value.
+ * - 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.
+ * - 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.
+ * - 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.
+ * - 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.
+ * - Call grlib_load_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.
+ * - Call grlib_load_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.
+ * - Call grlib_load_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.
+ * - Call grlib_load_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.
+ * @brief Call grlib_load_8 to load a prepared value.
*/
-static void BspSparcValGrlibIo_Action_0( void )
+static void DevGrlibValIo_Action_0( void )
{
uint8_t reg_8;
uint8_t val_8;
@@ -118,9 +139,9 @@ static void BspSparcValGrlibIo_Action_0( void )
}
/**
- * @brief Call grlib_load_16() to load a prepared value.
+ * @brief Call grlib_load_16 to load a prepared value.
*/
-static void BspSparcValGrlibIo_Action_1( void )
+static void DevGrlibValIo_Action_1( void )
{
uint16_t reg_16;
uint16_t val_16;
@@ -135,9 +156,9 @@ static void BspSparcValGrlibIo_Action_1( void )
}
/**
- * @brief Call grlib_load_32() to load a prepared value.
+ * @brief Call grlib_load_32 to load a prepared value.
*/
-static void BspSparcValGrlibIo_Action_2( void )
+static void DevGrlibValIo_Action_2( void )
{
uint32_t reg_32;
uint32_t val_32;
@@ -152,9 +173,9 @@ static void BspSparcValGrlibIo_Action_2( void )
}
/**
- * @brief Call grlib_load_64() to load a prepared value.
+ * @brief Call grlib_load_64 to load a prepared value.
*/
-static void BspSparcValGrlibIo_Action_3( void )
+static void DevGrlibValIo_Action_3( void )
{
uint64_t reg_64;
uint64_t val_64;
@@ -169,9 +190,9 @@ static void BspSparcValGrlibIo_Action_3( void )
}
/**
- * @brief Call grlib_store_8() to store a value to an object.
+ * @brief Call grlib_load_8 to store a value to an object.
*/
-static void BspSparcValGrlibIo_Action_4( void )
+static void DevGrlibValIo_Action_4( void )
{
uint8_t reg_8;
@@ -184,9 +205,9 @@ static void BspSparcValGrlibIo_Action_4( void )
}
/**
- * @brief Call grlib_store_16() to store a value to an object.
+ * @brief Call grlib_load_16 to store a value to an object.
*/
-static void BspSparcValGrlibIo_Action_5( void )
+static void DevGrlibValIo_Action_5( void )
{
uint16_t reg_16;
@@ -199,9 +220,9 @@ static void BspSparcValGrlibIo_Action_5( void )
}
/**
- * @brief Call grlib_store_32() to store a value to an object.
+ * @brief Call grlib_load_32 to store a value to an object.
*/
-static void BspSparcValGrlibIo_Action_6( void )
+static void DevGrlibValIo_Action_6( void )
{
uint32_t reg_32;
@@ -214,9 +235,9 @@ static void BspSparcValGrlibIo_Action_6( void )
}
/**
- * @brief Call grlib_store_64() to store a value to an object.
+ * @brief Call grlib_load_64 to store a value to an object.
*/
-static void BspSparcValGrlibIo_Action_7( void )
+static void DevGrlibValIo_Action_7( void )
{
uint64_t reg_64;
@@ -229,20 +250,46 @@ static void BspSparcValGrlibIo_Action_7( void )
}
/**
- * @fn void T_case_body_BspSparcValGrlibIo( void )
+ * @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( &regs, 0, sizeof( regs ) );
+ SetIORelaxHandler( ApbuartIORelax, &regs );
+ apbuart_outbyte_polled( &regs, (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( BspSparcValGrlibIo )
+T_TEST_CASE( DevGrlibValIo )
{
- T_plan( 8 );
-
- BspSparcValGrlibIo_Action_0();
- BspSparcValGrlibIo_Action_1();
- BspSparcValGrlibIo_Action_2();
- BspSparcValGrlibIo_Action_3();
- BspSparcValGrlibIo_Action_4();
- BspSparcValGrlibIo_Action_5();
- BspSparcValGrlibIo_Action_6();
- BspSparcValGrlibIo_Action_7();
+ 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();
}
/** @} */