summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-27 07:55:10 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-01-18 14:35:47 +0100
commit86236b21a31d68cb006fd3de9326f710ce48882e (patch)
tree7a4baaf8049f7427ed30bf3d75bbb66bb511a1ac
parent4d35c8af39e061cc9a89ebece451be44c437d220 (diff)
validation: grlib
-rw-r--r--spec/build/testsuites/validation/grp.yml2
-rw-r--r--spec/build/testsuites/validation/objgrlib.yml7
-rw-r--r--testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c348
-rw-r--r--testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c0
-rw-r--r--testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c0
-rw-r--r--testsuites/validation/tc-dev-grlib-io.c (renamed from testsuites/validation/tc-bsp-sparc-leon3.c)111
6 files changed, 434 insertions, 34 deletions
diff --git a/spec/build/testsuites/validation/grp.yml b/spec/build/testsuites/validation/grp.yml
index bf5d5c95a9..d134472e86 100644
--- a/spec/build/testsuites/validation/grp.yml
+++ b/spec/build/testsuites/validation/grp.yml
@@ -59,6 +59,8 @@ links:
- role: build-dependency
uid: validation-cache
- role: build-dependency
+ uid: validation-dev-0
+- role: build-dependency
uid: validation-intr
- role: build-dependency
uid: validation-io-kernel
diff --git a/spec/build/testsuites/validation/objgrlib.yml b/spec/build/testsuites/validation/objgrlib.yml
index bf6ac3e4d4..5cebc22bf9 100644
--- a/spec/build/testsuites/validation/objgrlib.yml
+++ b/spec/build/testsuites/validation/objgrlib.yml
@@ -5,10 +5,13 @@ copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
cppflags: []
cxxflags: []
-enabled-by: sparc/leon3
+enabled-by: bsps/sparc/leon3
includes: []
install: []
links: []
source:
-- testsuites/validation/tc-bsp-sparc-leon3.c
+- testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
+- testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c
+- testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c
+- testsuites/validation/tc-dev-grlib-io.c
type: build
diff --git a/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c b/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
new file mode 100644
index 0000000000..d255811197
--- /dev/null
+++ b/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c
@@ -0,0 +1,348 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseDevGrlibReqApbuartInbyteNonblocking
+ */
+
+/*
+ * Copyright (C) 2021 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 <string.h>
+#include <grlib/apbuart.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseDevGrlibReqApbuartInbyteNonblocking \
+ * spec:/dev/grlib/req/apbuart-inbyte-nonblocking
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationDev0
+ *
+ * @{
+ */
+
+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 );
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c b/testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c
diff --git a/testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c b/testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c
diff --git a/testsuites/validation/tc-bsp-sparc-leon3.c b/testsuites/validation/tc-dev-grlib-io.c
index 8eb3fc1e95..9e5457e4d8 100644
--- a/testsuites/validation/tc-bsp-sparc-leon3.c
+++ b/testsuites/validation/tc-dev-grlib-io.c
@@ -3,7 +3,7 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseBspSparcValGrlibIo
+ * @ingroup RTEMSTestCaseDevGrlibValIo
*/
/*
@@ -52,16 +52,20 @@
#include "config.h"
#endif
-#include <dev/grlib/io.h>
+#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:
*
@@ -81,29 +85,46 @@
*
* - 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.
*/
-static void BspSparcValGrlibIo_Action_0( void )
+static void DevGrlibValIo_Action_0( void )
{
uint8_t reg_8;
uint8_t val_8;
@@ -120,7 +141,7 @@ static void BspSparcValGrlibIo_Action_0( void )
/**
* @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;
@@ -137,7 +158,7 @@ static void BspSparcValGrlibIo_Action_1( void )
/**
* @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;
@@ -154,7 +175,7 @@ static void BspSparcValGrlibIo_Action_2( void )
/**
* @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();
}
/** @} */