diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-27 07:55:10 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-28 08:54:47 +0200 |
commit | 8995312309ff0013838e2097ce317eb5e7f53761 (patch) | |
tree | 9e99cadaad80e9b1d4ade9eb0a819a114c82a537 | |
parent | 6732e9b7c0984f1095b186c3da241629530db6ef (diff) |
validation: grlib
-rw-r--r-- | spec/build/testsuites/validation/grp.yml | 2 | ||||
-rw-r--r-- | spec/build/testsuites/validation/objgrlib.yml | 7 | ||||
-rw-r--r-- | testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c | 316 | ||||
-rw-r--r-- | testsuites/validation/tc-dev-grlib-apbuart-outbyte-polled.c | 0 | ||||
-rw-r--r-- | testsuites/validation/tc-dev-grlib-apbuart-outbyte-wait.c | 0 | ||||
-rw-r--r-- | testsuites/validation/tc-dev-grlib-io.c (renamed from testsuites/validation/tc-bsp-sparc-leon3.c) | 2 |
6 files changed, 324 insertions, 3 deletions
diff --git a/spec/build/testsuites/validation/grp.yml b/spec/build/testsuites/validation/grp.yml index 2585c58964..e8e8b2f765 100644 --- a/spec/build/testsuites/validation/grp.yml +++ b/spec/build/testsuites/validation/grp.yml @@ -25,6 +25,8 @@ links: - role: build-dependency uid: validation-2 - role: build-dependency + uid: validation-dev-0 +- role: build-dependency uid: validation-non-smp - role: build-dependency uid: validation-smp-only 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..6b7c75c72f --- /dev/null +++ b/testsuites/validation/tc-dev-grlib-apbuart-inbyte-nonblocking.c @@ -0,0 +1,316 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseDevGrlibReqApbuartInbytePolled + */ + +/* + * 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 RTEMSTestCaseDevGrlibReqApbuartInbytePolled \ + * spec:/dev/grlib/req/apbuart-inbyte-polled + * + * @ingroup RTEMSTestSuiteTestsuitesValidationDev0 + * + * @{ + */ + +typedef enum { + DevGrlibReqApbuartInbytePolled_Pre_DataReady_Yes, + DevGrlibReqApbuartInbytePolled_Pre_DataReady_No, + DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA +} DevGrlibReqApbuartInbytePolled_Pre_DataReady; + +typedef enum { + DevGrlibReqApbuartInbytePolled_Post_Result_Data, + DevGrlibReqApbuartInbytePolled_Post_Result_MinusOne, + DevGrlibReqApbuartInbytePolled_Post_Result_NA +} DevGrlibReqApbuartInbytePolled_Post_Result; + +typedef enum { + DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Cleared, + DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_NA +} DevGrlibReqApbuartInbytePolled_Post_ErrorFlags; + +/** + * @brief Test context for spec:/dev/grlib/req/apbuart-inbyte-polled 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; + + /** + * @brief This member defines the pre-condition states for the next action. + */ + size_t pcs[ 1 ]; + + /** + * @brief This member indicates if the test action loop is currently + * executed. + */ + bool in_action_loop; +} DevGrlibReqApbuartInbytePolled_Context; + +static DevGrlibReqApbuartInbytePolled_Context + DevGrlibReqApbuartInbytePolled_Instance; + +static const char * const DevGrlibReqApbuartInbytePolled_PreDesc_DataReady[] = { + "Yes", + "No", + "NA" +}; + +static const char * const * const DevGrlibReqApbuartInbytePolled_PreDesc[] = { + DevGrlibReqApbuartInbytePolled_PreDesc_DataReady, + NULL +}; + +static void DevGrlibReqApbuartInbytePolled_Pre_DataReady_Prepare( + DevGrlibReqApbuartInbytePolled_Context *ctx, + DevGrlibReqApbuartInbytePolled_Pre_DataReady state +) +{ + switch ( state ) { + case DevGrlibReqApbuartInbytePolled_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 DevGrlibReqApbuartInbytePolled_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 DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA: + break; + } +} + +static void DevGrlibReqApbuartInbytePolled_Post_Result_Check( + DevGrlibReqApbuartInbytePolled_Context *ctx, + DevGrlibReqApbuartInbytePolled_Post_Result state +) +{ + switch ( state ) { + case DevGrlibReqApbuartInbytePolled_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 DevGrlibReqApbuartInbytePolled_Post_Result_MinusOne: { + /* + * The return value of apbuart_inbyte_nonblocking() shall be minus one. + */ + T_eq_int( ctx->result, -1 ); + break; + } + + case DevGrlibReqApbuartInbytePolled_Post_Result_NA: + break; + } +} + +static void DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_Check( + DevGrlibReqApbuartInbytePolled_Context *ctx, + DevGrlibReqApbuartInbytePolled_Post_ErrorFlags state +) +{ + switch ( state ) { + case DevGrlibReqApbuartInbytePolled_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 DevGrlibReqApbuartInbytePolled_Post_ErrorFlags_NA: + break; + } +} + +static void DevGrlibReqApbuartInbytePolled_Prepare( + DevGrlibReqApbuartInbytePolled_Context *ctx +) +{ + memset( &ctx->regs, 0, sizeof( ctx->regs ) ); + ctx->regs.status = 0x78; + ctx->regs.data = 0xff; +} + +static void DevGrlibReqApbuartInbytePolled_Action( + DevGrlibReqApbuartInbytePolled_Context *ctx +) +{ + ctx->result = apbuart_inbyte_nonblocking( &ctx->regs ); +} + +typedef struct { + uint8_t Skip : 1; + 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 } +}; + +static const uint8_t +DevGrlibReqApbuartInbytePolled_Map[] = { + 0, 1 +}; + +static size_t DevGrlibReqApbuartInbytePolled_Scope( + void *arg, + char *buf, + size_t n +) +{ + DevGrlibReqApbuartInbytePolled_Context *ctx; + + ctx = arg; + + if ( ctx->in_action_loop ) { + return T_get_scope( + DevGrlibReqApbuartInbytePolled_PreDesc, + buf, + n, + ctx->pcs + ); + } + + return 0; +} + +static T_fixture DevGrlibReqApbuartInbytePolled_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = DevGrlibReqApbuartInbytePolled_Scope, + .initial_context = &DevGrlibReqApbuartInbytePolled_Instance +}; + +static inline DevGrlibReqApbuartInbytePolled_Entry +DevGrlibReqApbuartInbytePolled_GetEntry( size_t index ) +{ + return DevGrlibReqApbuartInbytePolled_Entries[ + DevGrlibReqApbuartInbytePolled_Map[ index ] + ]; +} + +/** + * @fn void T_case_body_DevGrlibReqApbuartInbytePolled( void ) + */ +T_TEST_CASE_FIXTURE( + DevGrlibReqApbuartInbytePolled, + &DevGrlibReqApbuartInbytePolled_Fixture +) +{ + DevGrlibReqApbuartInbytePolled_Context *ctx; + size_t index; + + ctx = T_fixture_context(); + ctx->in_action_loop = true; + index = 0; + + for ( + ctx->pcs[ 0 ] = DevGrlibReqApbuartInbytePolled_Pre_DataReady_Yes; + ctx->pcs[ 0 ] < DevGrlibReqApbuartInbytePolled_Pre_DataReady_NA; + ++ctx->pcs[ 0 ] + ) { + DevGrlibReqApbuartInbytePolled_Entry entry; + + entry = DevGrlibReqApbuartInbytePolled_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( + ctx, + entry.Post_ErrorFlags + ); + } +} + +/** @} */ 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..1b24ff714c 100644 --- a/testsuites/validation/tc-bsp-sparc-leon3.c +++ b/testsuites/validation/tc-dev-grlib-io.c @@ -52,7 +52,7 @@ #include "config.h" #endif -#include <dev/grlib/io.h> +#include <grlib/io.h> #include <rtems/test.h> |