From b503e96006cb96e05c60dbd60c8b0706af96fa5c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 25 Jun 2020 11:37:40 +0200 Subject: validation: Add tests for object identification --- spec/build/testsuites/validation/validation-0.yml | 10 + testsuites/validation/tc-barrier-ident.c | 116 +++++ testsuites/validation/tc-message-ident.c | 126 +++++ testsuites/validation/tc-part-ident.c | 120 +++++ testsuites/validation/tc-ratemon-ident.c | 114 ++++ testsuites/validation/tc-sem-ident.c | 118 +++++ testsuites/validation/tc-task-ident.c | 338 ++++++++++++ testsuites/validation/tc-timer-ident.c | 114 ++++ testsuites/validation/tc-userext-ident.c | 116 +++++ testsuites/validation/tr-object-ident-local.c | 377 ++++++++++++++ testsuites/validation/tr-object-ident-local.h | 114 ++++ testsuites/validation/tr-object-ident.c | 609 ++++++++++++++++++++++ testsuites/validation/tr-object-ident.h | 126 +++++ 13 files changed, 2398 insertions(+) create mode 100644 testsuites/validation/tc-barrier-ident.c create mode 100644 testsuites/validation/tc-message-ident.c create mode 100644 testsuites/validation/tc-part-ident.c create mode 100644 testsuites/validation/tc-ratemon-ident.c create mode 100644 testsuites/validation/tc-sem-ident.c create mode 100644 testsuites/validation/tc-task-ident.c create mode 100644 testsuites/validation/tc-timer-ident.c create mode 100644 testsuites/validation/tc-userext-ident.c create mode 100644 testsuites/validation/tr-object-ident-local.c create mode 100644 testsuites/validation/tr-object-ident-local.h create mode 100644 testsuites/validation/tr-object-ident.c create mode 100644 testsuites/validation/tr-object-ident.h diff --git a/spec/build/testsuites/validation/validation-0.yml b/spec/build/testsuites/validation/validation-0.yml index 653e34824e..7805078779 100644 --- a/spec/build/testsuites/validation/validation-0.yml +++ b/spec/build/testsuites/validation/validation-0.yml @@ -13,14 +13,24 @@ links: [] source: - testsuites/validation/tc-barrier-create.c - testsuites/validation/tc-barrier-delete.c +- testsuites/validation/tc-barrier-ident.c - testsuites/validation/tc-barrier-release.c - testsuites/validation/tc-barrier-wait.c - testsuites/validation/tc-message-construct-errors.c +- testsuites/validation/tc-message-ident.c - testsuites/validation/tc-object.c +- testsuites/validation/tc-part-ident.c +- testsuites/validation/tc-ratemon-ident.c +- testsuites/validation/tc-sem-ident.c - testsuites/validation/tc-signal-catch.c - testsuites/validation/tc-signal-send.c - testsuites/validation/tc-task-construct-errors.c - testsuites/validation/tc-task-create-errors.c +- testsuites/validation/tc-task-ident.c +- testsuites/validation/tc-timer-ident.c +- testsuites/validation/tc-userext-ident.c +- testsuites/validation/tr-object-ident.c +- testsuites/validation/tr-object-ident-local.c - testsuites/validation/ts-validation-0.c stlib: [] target: testsuites/validation/ts-validation-0.exe diff --git a/testsuites/validation/tc-barrier-ident.c b/testsuites/validation/tc-barrier-ident.c new file mode 100644 index 0000000000..5380429252 --- /dev/null +++ b/testsuites/validation/tc-barrier-ident.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsBarrierValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident-local.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsBarrierValIdent spec:/rtems/barrier/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_barrier_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API partition + * class objects defined by /rtems/req/ident-local. + * + * @{ + */ + +static rtems_status_code ClassicBarrierIdentAction( + rtems_name name, + rtems_id *id +) +{ + return rtems_barrier_ident( name, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API partition + * class objects defined by /rtems/req/ident-local. + */ +static void RtemsBarrierValIdent_Action_0( void ) +{ + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_barrier_create( + ClassicObjectLocalIdentName, + RTEMS_DEFAULT_ATTRIBUTES, + 1, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdentLocal_Run( + id_local_object, + ClassicBarrierIdentAction + ); + + sc = rtems_barrier_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsBarrierValIdent( void ) + */ +T_TEST_CASE( RtemsBarrierValIdent ) +{ + RtemsBarrierValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-message-ident.c b/testsuites/validation/tc-message-ident.c new file mode 100644 index 0000000000..51ff5688de --- /dev/null +++ b/testsuites/validation/tc-message-ident.c @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsMessageValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsMessageValIdent spec:/rtems/message/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_message_queue_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API message queue + * class objects defined by /rtems/req/ident. + * + * @{ + */ + +static RTEMS_MESSAGE_QUEUE_BUFFER( 1 ) ClassicMessageIdentBuffers[ 1 ]; + +static rtems_message_queue_config ClassicObjectIdentConfig = { + .name = ClassicObjectIdentName, + .maximum_pending_messages = RTEMS_ARRAY_SIZE( ClassicMessageIdentBuffers ), + .maximum_message_size = 1, + .storage_area = ClassicMessageIdentBuffers, + .storage_size = sizeof( ClassicMessageIdentBuffers ), + .attributes = RTEMS_DEFAULT_ATTRIBUTES +}; + +static rtems_status_code ClassicMessageIdentAction( + rtems_name name, + uint32_t node, + rtems_id *id +) +{ + return rtems_message_queue_ident( name, node, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API message + * queue class objects defined by /rtems/req/ident. + */ +static void RtemsMessageValIdent_Action_0( void ) +{ + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_message_queue_construct( + &ClassicObjectIdentConfig, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdent_Run( + id_local_object, + ClassicMessageIdentAction + ); + + sc = rtems_message_queue_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsMessageValIdent( void ) + */ +T_TEST_CASE( RtemsMessageValIdent ) +{ + RtemsMessageValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-part-ident.c b/testsuites/validation/tc-part-ident.c new file mode 100644 index 0000000000..268a91555b --- /dev/null +++ b/testsuites/validation/tc-part-ident.c @@ -0,0 +1,120 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsPartValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsPartValIdent spec:/rtems/part/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_partition_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API partition + * class objects defined by /rtems/req/ident. + * + * @{ + */ + +static rtems_status_code ClassicPartIdentAction( + rtems_name name, + uint32_t node, + rtems_id *id +) +{ + return rtems_partition_ident( name, node, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API partition + * class objects defined by /rtems/req/ident. + */ +static void RtemsPartValIdent_Action_0( void ) +{ + static RTEMS_ALIGNED( RTEMS_PARTITION_ALIGNMENT ) long area[32]; + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_partition_create( + ClassicObjectIdentName, + area, + sizeof( area ), + sizeof( area ), + RTEMS_DEFAULT_ATTRIBUTES, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdent_Run( + id_local_object, + ClassicPartIdentAction + ); + + sc = rtems_partition_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsPartValIdent( void ) + */ +T_TEST_CASE( RtemsPartValIdent ) +{ + RtemsPartValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-ratemon-ident.c b/testsuites/validation/tc-ratemon-ident.c new file mode 100644 index 0000000000..72eaee8583 --- /dev/null +++ b/testsuites/validation/tc-ratemon-ident.c @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsRatemonValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident-local.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsRatemonValIdent spec:/rtems/ratemon/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_rate_monotonic_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API rate monotonic + * class objects defined by /rtems/req/ident-local. + * + * @{ + */ + +static rtems_status_code ClassicRatemonIdentAction( + rtems_name name, + rtems_id *id +) +{ + return rtems_rate_monotonic_ident( name, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API rate + * monotonic class objects defined by /rtems/req/ident-local. + */ +static void RtemsRatemonValIdent_Action_0( void ) +{ + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_rate_monotonic_create( + ClassicObjectLocalIdentName, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdentLocal_Run( + id_local_object, + ClassicRatemonIdentAction + ); + + sc = rtems_rate_monotonic_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsRatemonValIdent( void ) + */ +T_TEST_CASE( RtemsRatemonValIdent ) +{ + RtemsRatemonValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-sem-ident.c b/testsuites/validation/tc-sem-ident.c new file mode 100644 index 0000000000..76630111d1 --- /dev/null +++ b/testsuites/validation/tc-sem-ident.c @@ -0,0 +1,118 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsSemValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsSemValIdent spec:/rtems/sem/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_semaphore_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API semaphore + * class objects defined by /rtems/req/ident. + * + * @{ + */ + +static rtems_status_code ClassicSemIdentAction( + rtems_name name, + uint32_t node, + rtems_id *id +) +{ + return rtems_semaphore_ident( name, node, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API semaphore + * class objects defined by /rtems/req/ident. + */ +static void RtemsSemValIdent_Action_0( void ) +{ + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_semaphore_create( + ClassicObjectIdentName, + 0, + RTEMS_DEFAULT_ATTRIBUTES, + 0, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdent_Run( + id_local_object, + ClassicSemIdentAction + ); + + sc = rtems_semaphore_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsSemValIdent( void ) + */ +T_TEST_CASE( RtemsSemValIdent ) +{ + RtemsSemValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-task-ident.c b/testsuites/validation/tc-task-ident.c new file mode 100644 index 0000000000..a084493a07 --- /dev/null +++ b/testsuites/validation/tc-task-ident.c @@ -0,0 +1,338 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsTaskReqIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsTaskReqIdent spec:/rtems/task/req/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @{ + */ + +typedef enum { + RtemsTaskReqIdent_Pre_Name_Self, + RtemsTaskReqIdent_Pre_Name_NotSelf, + RtemsTaskReqIdent_Pre_Name_NA +} RtemsTaskReqIdent_Pre_Name; + +typedef enum { + RtemsTaskReqIdent_Post_Status_OkAndSelfId, + RtemsTaskReqIdent_Post_Status_Skip, + RtemsTaskReqIdent_Post_Status_NA +} RtemsTaskReqIdent_Post_Status; + +/** + * @brief Test context for spec:/rtems/task/req/ident test case. + */ +typedef struct { + rtems_status_code status; + + rtems_id *id; + + rtems_id id_value; + + rtems_id id_local_object; + + /** + * @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; +} RtemsTaskReqIdent_Context; + +static RtemsTaskReqIdent_Context + RtemsTaskReqIdent_Instance; + +static const char * const RtemsTaskReqIdent_PreDesc_Name[] = { + "Self", + "NotSelf", + "NA" +}; + +static const char * const * const RtemsTaskReqIdent_PreDesc[] = { + RtemsTaskReqIdent_PreDesc_Name, + NULL +}; + +static rtems_status_code ClassicTaskIdentAction( + rtems_name name, + uint32_t node, + rtems_id *id +) +{ + return rtems_task_ident( name, node, id ); +} + +#define TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES + +#define MAX_TLS_SIZE RTEMS_ALIGN_UP( 64, RTEMS_TASK_STORAGE_ALIGNMENT ) + +RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT ) +static char ClassicTaskIdentStorage[ + RTEMS_TASK_STORAGE_SIZE( + MAX_TLS_SIZE + RTEMS_MINIMUM_STACK_SIZE, + TASK_ATTRIBUTES + ) +]; + +static const rtems_task_config ClassicTaskIdentConfig = { + .name = ClassicObjectIdentName, + .initial_priority = 1, + .storage_area = ClassicTaskIdentStorage, + .storage_size = sizeof( ClassicTaskIdentStorage ), + .maximum_thread_local_storage_size = MAX_TLS_SIZE, + .initial_modes = RTEMS_DEFAULT_MODES, + .attributes = TASK_ATTRIBUTES +}; + +static void RtemsTaskReqIdent_Pre_Name_Prepare( + RtemsTaskReqIdent_Context *ctx, + RtemsTaskReqIdent_Pre_Name state +) +{ + switch ( state ) { + case RtemsTaskReqIdent_Pre_Name_Self: { + /* + * The ``name`` parameter shall be rtems_task_self(). + */ + ctx->id_value = 0xffffffff; + ctx->id = &ctx->id_value; + break; + } + + case RtemsTaskReqIdent_Pre_Name_NotSelf: { + /* + * When the ``name`` is not rtems_task_self() or ``id`` parameter is + * NULL, the behaviour of rtems_task_ident() shall be specified by + * /rtems/req/ident. + */ + ctx->id = NULL; + /* Preparation performed by RtemsReqIdent_Run() */ + break; + } + + case RtemsTaskReqIdent_Pre_Name_NA: + break; + } +} + +static void RtemsTaskReqIdent_Post_Status_Check( + RtemsTaskReqIdent_Context *ctx, + RtemsTaskReqIdent_Post_Status state +) +{ + switch ( state ) { + case RtemsTaskReqIdent_Post_Status_OkAndSelfId: { + /* + * The return status of rtems_task_ident() shall be RTEMS_SUCCESSFUL. + * The value of the object identifier referenced by the ``name`` + * parameter shall be the identifier of the executing thread. + */ + T_rsc( ctx->status, RTEMS_SUCCESSFUL ); + T_eq_ptr( ctx->id, &ctx->id_value ); + T_eq_u32( ctx->id_value, rtems_task_self() ); + break; + } + + case RtemsTaskReqIdent_Post_Status_Skip: { + /* + * There is no status to validate. + */ + /* Checks performed by RtemsReqIdent_Run() */ + break; + } + + case RtemsTaskReqIdent_Post_Status_NA: + break; + } +} + +static void RtemsTaskReqIdent_Setup( RtemsTaskReqIdent_Context *ctx ) +{ + rtems_status_code sc; + + sc = rtems_task_construct( + &ClassicTaskIdentConfig, + &ctx->id_local_object + ); + T_assert_rsc_success( sc ); +} + +static void RtemsTaskReqIdent_Setup_Wrap( void *arg ) +{ + RtemsTaskReqIdent_Context *ctx; + + ctx = arg; + ctx->in_action_loop = false; + RtemsTaskReqIdent_Setup( ctx ); +} + +static void RtemsTaskReqIdent_Teardown( RtemsTaskReqIdent_Context *ctx ) +{ + if ( ctx->id_local_object != 0 ) { + rtems_status_code sc; + + sc = rtems_task_delete( ctx->id_local_object ); + T_rsc_success( sc ); + } +} + +static void RtemsTaskReqIdent_Teardown_Wrap( void *arg ) +{ + RtemsTaskReqIdent_Context *ctx; + + ctx = arg; + ctx->in_action_loop = false; + RtemsTaskReqIdent_Teardown( ctx ); +} + +static size_t RtemsTaskReqIdent_Scope( void *arg, char *buf, size_t n ) +{ + RtemsTaskReqIdent_Context *ctx; + + ctx = arg; + + if ( ctx->in_action_loop ) { + return T_get_scope( RtemsTaskReqIdent_PreDesc, buf, n, ctx->pcs ); + } + + return 0; +} + +static T_fixture RtemsTaskReqIdent_Fixture = { + .setup = RtemsTaskReqIdent_Setup_Wrap, + .stop = NULL, + .teardown = RtemsTaskReqIdent_Teardown_Wrap, + .scope = RtemsTaskReqIdent_Scope, + .initial_context = &RtemsTaskReqIdent_Instance +}; + +static const uint8_t RtemsTaskReqIdent_TransitionMap[][ 1 ] = { + { + RtemsTaskReqIdent_Post_Status_OkAndSelfId + }, { + RtemsTaskReqIdent_Post_Status_Skip + } +}; + +static const struct { + uint8_t Skip : 1; + uint8_t Pre_Name_NA : 1; +} RtemsTaskReqIdent_TransitionInfo[] = { + { + 0, 0 + }, { + 0, 0 + } +}; + +static void RtemsTaskReqIdent_Action( RtemsTaskReqIdent_Context *ctx ) +{ + if ( ctx->id != NULL ) { + ctx->status = rtems_task_ident( RTEMS_SELF, 0xdeadbeef, ctx->id ); + } else { + RtemsReqIdent_Run( + ctx->id_local_object, + ClassicTaskIdentAction + ); + } +} + +/** + * @fn void T_case_body_RtemsTaskReqIdent( void ) + */ +T_TEST_CASE_FIXTURE( RtemsTaskReqIdent, &RtemsTaskReqIdent_Fixture ) +{ + RtemsTaskReqIdent_Context *ctx; + size_t index; + + ctx = T_fixture_context(); + ctx->in_action_loop = true; + index = 0; + + for ( + ctx->pcs[ 0 ] = RtemsTaskReqIdent_Pre_Name_Self; + ctx->pcs[ 0 ] < RtemsTaskReqIdent_Pre_Name_NA; + ++ctx->pcs[ 0 ] + ) { + if ( RtemsTaskReqIdent_TransitionInfo[ index ].Pre_Name_NA ) { + ctx->pcs[ 0 ] = RtemsTaskReqIdent_Pre_Name_NA; + index += ( RtemsTaskReqIdent_Pre_Name_NA - 1 ); + } + + if ( RtemsTaskReqIdent_TransitionInfo[ index ].Skip ) { + ++index; + continue; + } + + RtemsTaskReqIdent_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] ); + RtemsTaskReqIdent_Action( ctx ); + RtemsTaskReqIdent_Post_Status_Check( + ctx, + RtemsTaskReqIdent_TransitionMap[ index ][ 0 ] + ); + ++index; + } +} + +/** @} */ diff --git a/testsuites/validation/tc-timer-ident.c b/testsuites/validation/tc-timer-ident.c new file mode 100644 index 0000000000..f45ec70af3 --- /dev/null +++ b/testsuites/validation/tc-timer-ident.c @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsTimerValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident-local.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsTimerValIdent spec:/rtems/timer/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_timer_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API timer class + * objects defined by /rtems/req/ident-local. + * + * @{ + */ + +static rtems_status_code ClassicTimerIdentAction( + rtems_name name, + rtems_id *id +) +{ + return rtems_timer_ident( name, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API timer + * class objects defined by /rtems/req/ident-local. + */ +static void RtemsTimerValIdent_Action_0( void ) +{ + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_timer_create( + ClassicObjectLocalIdentName, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdentLocal_Run( + id_local_object, + ClassicTimerIdentAction + ); + + sc = rtems_timer_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsTimerValIdent( void ) + */ +T_TEST_CASE( RtemsTimerValIdent ) +{ + RtemsTimerValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-userext-ident.c b/testsuites/validation/tc-userext-ident.c new file mode 100644 index 0000000000..5c5a5c1acc --- /dev/null +++ b/testsuites/validation/tc-userext-ident.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsUserextValIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident-local.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsUserextValIdent spec:/rtems/userext/val/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @brief Test the rtems_extension_ident() directive. + * + * This test case performs the following actions: + * + * - Run the generic object identification tests for Classic API user extension + * class objects defined by /rtems/req/ident-local. + * + * @{ + */ + +static rtems_status_code ClassicUserExtIdentAction( + rtems_name name, + rtems_id *id +) +{ + return rtems_extension_ident( name, id ); +} + +/** + * @brief Run the generic object identification tests for Classic API user + * extension class objects defined by /rtems/req/ident-local. + */ +static void RtemsUserextValIdent_Action_0( void ) +{ + static const rtems_extensions_table table; + rtems_status_code sc; + rtems_id id_local_object; + + sc = rtems_extension_create( + ClassicObjectLocalIdentName, + &table, + &id_local_object + ); + T_assert_rsc_success( sc ); + + RtemsReqIdentLocal_Run( + id_local_object, + ClassicUserExtIdentAction + ); + + sc = rtems_extension_delete( id_local_object ); + T_rsc_success( sc ); +} + +/** + * @fn void T_case_body_RtemsUserextValIdent( void ) + */ +T_TEST_CASE( RtemsUserextValIdent ) +{ + RtemsUserextValIdent_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tr-object-ident-local.c b/testsuites/validation/tr-object-ident-local.c new file mode 100644 index 0000000000..a7d22fa629 --- /dev/null +++ b/testsuites/validation/tr-object-ident-local.c @@ -0,0 +1,377 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsReqIdentLocal + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident-local.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsReqIdentLocal spec:/rtems/req/ident-local + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/req/ident-local test case. + */ +typedef struct { + rtems_status_code status; + + rtems_name name; + + rtems_id *id; + + rtems_id id_value; + + /** + * @brief This member contains a copy of the corresponding + * RtemsReqIdentLocal_Run() parameter. + */ + rtems_id id_local_object; + + /** + * @brief This member contains a copy of the corresponding + * RtemsReqIdentLocal_Run() parameter. + */ + rtems_status_code ( *action )( rtems_name, rtems_id * ); + + /** + * @brief This member defines the pre-condition states for the next action. + */ + size_t pcs[ 2 ]; + + /** + * @brief This member indicates if the test action loop is currently + * executed. + */ + bool in_action_loop; +} RtemsReqIdentLocal_Context; + +static RtemsReqIdentLocal_Context + RtemsReqIdentLocal_Instance; + +static const char * const RtemsReqIdentLocal_PreDesc_Name[] = { + "Invalid", + "Valid", + "NA" +}; + +static const char * const RtemsReqIdentLocal_PreDesc_Id[] = { + "NullPtr", + "Valid", + "NA" +}; + +static const char * const * const RtemsReqIdentLocal_PreDesc[] = { + RtemsReqIdentLocal_PreDesc_Name, + RtemsReqIdentLocal_PreDesc_Id, + NULL +}; + +static void RtemsReqIdentLocal_Pre_Name_Prepare( + RtemsReqIdentLocal_Context *ctx, + RtemsReqIdentLocal_Pre_Name state +) +{ + switch ( state ) { + case RtemsReqIdentLocal_Pre_Name_Invalid: { + /* + * The name parameter shall not equal to a name of an active Classic API + * object of the specified class. + */ + ctx->name = 1; + break; + } + + case RtemsReqIdentLocal_Pre_Name_Valid: { + /* + * The name parameter shall equal to a name of an active Classic API + * object of the specified class. + */ + ctx->name = ClassicObjectLocalIdentName; + break; + } + + case RtemsReqIdentLocal_Pre_Name_NA: + break; + } +} + +static void RtemsReqIdentLocal_Pre_Id_Prepare( + RtemsReqIdentLocal_Context *ctx, + RtemsReqIdentLocal_Pre_Id state +) +{ + switch ( state ) { + case RtemsReqIdentLocal_Pre_Id_NullPtr: { + /* + * The id parameter shall be NULL. + */ + ctx->id = NULL; + break; + } + + case RtemsReqIdentLocal_Pre_Id_Valid: { + /* + * The id parameter shall point to an object identifier. + */ + ctx->id_value = 0xffffffff; + ctx->id = &ctx->id_value; + break; + } + + case RtemsReqIdentLocal_Pre_Id_NA: + break; + } +} + +static void RtemsReqIdentLocal_Post_Status_Check( + RtemsReqIdentLocal_Context *ctx, + RtemsReqIdentLocal_Post_Status state +) +{ + switch ( state ) { + case RtemsReqIdentLocal_Post_Status_Ok: { + /* + * The status shall be RTEMS_SUCCESSFUL. + */ + T_rsc( ctx->status, RTEMS_SUCCESSFUL ); + break; + } + + case RtemsReqIdentLocal_Post_Status_InvAddr: { + /* + * The status shall be RTEMS_INVALID_ADDRESS. + */ + T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); + break; + } + + case RtemsReqIdentLocal_Post_Status_InvName: { + /* + * The status shall be RTEMS_INVALID_NAME. + */ + T_rsc( ctx->status, RTEMS_INVALID_NAME ); + break; + } + + case RtemsReqIdentLocal_Post_Status_NA: + break; + } +} + +static void RtemsReqIdentLocal_Post_Id_Check( + RtemsReqIdentLocal_Context *ctx, + RtemsReqIdentLocal_Post_Id state +) +{ + switch ( state ) { + case RtemsReqIdentLocal_Post_Id_Nop: { + /* + * The value of the object identifier referenced by the id parameter + * shall be the value before the action. + */ + T_eq_ptr( ctx->id, &ctx->id_value ); + T_eq_u32( ctx->id_value, 0xffffffff ); + break; + } + + case RtemsReqIdentLocal_Post_Id_NullPtr: { + /* + * The id parameter shall be NULL. + */ + T_null( ctx->id ) + break; + } + + case RtemsReqIdentLocal_Post_Id_Id: { + /* + * The value of the object identifier referenced by the id parameter + * shall be the identifier of a local object of the specified class with + * a name equal to the name parameter. If more than one local object of + * the specified class with such a name exists, then it shall be the + * identifier of the object with the lowest object index. + */ + T_eq_ptr( ctx->id, &ctx->id_value ); + T_eq_u32( ctx->id_value, ctx->id_local_object ); + break; + } + + case RtemsReqIdentLocal_Post_Id_NA: + break; + } +} + +static size_t RtemsReqIdentLocal_Scope( void *arg, char *buf, size_t n ) +{ + RtemsReqIdentLocal_Context *ctx; + + ctx = arg; + + if ( ctx->in_action_loop ) { + return T_get_scope( RtemsReqIdentLocal_PreDesc, buf, n, ctx->pcs ); + } + + return 0; +} + +static T_fixture RtemsReqIdentLocal_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = RtemsReqIdentLocal_Scope, + .initial_context = &RtemsReqIdentLocal_Instance +}; + +static const uint8_t RtemsReqIdentLocal_TransitionMap[][ 2 ] = { + { + RtemsReqIdentLocal_Post_Status_InvAddr, + RtemsReqIdentLocal_Post_Id_NullPtr + }, { + RtemsReqIdentLocal_Post_Status_InvName, + RtemsReqIdentLocal_Post_Id_Nop + }, { + RtemsReqIdentLocal_Post_Status_InvAddr, + RtemsReqIdentLocal_Post_Id_NullPtr + }, { + RtemsReqIdentLocal_Post_Status_Ok, + RtemsReqIdentLocal_Post_Id_Id + } +}; + +static const struct { + uint8_t Skip : 1; + uint8_t Pre_Name_NA : 1; + uint8_t Pre_Id_NA : 1; +} RtemsReqIdentLocal_TransitionInfo[] = { + { + 0, 0, 0 + }, { + 0, 0, 0 + }, { + 0, 0, 0 + }, { + 0, 0, 0 + } +}; + +static void RtemsReqIdentLocal_Action( RtemsReqIdentLocal_Context *ctx ) +{ + ctx->status = ( *ctx->action )( ctx->name, ctx->id ); +} + +static T_fixture_node RtemsReqIdentLocal_Node; + +void RtemsReqIdentLocal_Run( + rtems_id id_local_object, + rtems_status_code ( *action )( rtems_name, rtems_id * ) +) +{ + RtemsReqIdentLocal_Context *ctx; + size_t index; + + ctx = T_push_fixture( &RtemsReqIdentLocal_Node, &RtemsReqIdentLocal_Fixture ); + + ctx->id_local_object = id_local_object; + ctx->action = action; + ctx->in_action_loop = true; + index = 0; + + for ( + ctx->pcs[ 0 ] = RtemsReqIdentLocal_Pre_Name_Invalid; + ctx->pcs[ 0 ] < RtemsReqIdentLocal_Pre_Name_NA; + ++ctx->pcs[ 0 ] + ) { + if ( RtemsReqIdentLocal_TransitionInfo[ index ].Pre_Name_NA ) { + ctx->pcs[ 0 ] = RtemsReqIdentLocal_Pre_Name_NA; + index += ( RtemsReqIdentLocal_Pre_Name_NA - 1 ) + * RtemsReqIdentLocal_Pre_Id_NA; + } + + for ( + ctx->pcs[ 1 ] = RtemsReqIdentLocal_Pre_Id_NullPtr; + ctx->pcs[ 1 ] < RtemsReqIdentLocal_Pre_Id_NA; + ++ctx->pcs[ 1 ] + ) { + if ( RtemsReqIdentLocal_TransitionInfo[ index ].Pre_Id_NA ) { + ctx->pcs[ 1 ] = RtemsReqIdentLocal_Pre_Id_NA; + index += ( RtemsReqIdentLocal_Pre_Id_NA - 1 ); + } + + if ( RtemsReqIdentLocal_TransitionInfo[ index ].Skip ) { + ++index; + continue; + } + + RtemsReqIdentLocal_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] ); + RtemsReqIdentLocal_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] ); + RtemsReqIdentLocal_Action( ctx ); + RtemsReqIdentLocal_Post_Status_Check( + ctx, + RtemsReqIdentLocal_TransitionMap[ index ][ 0 ] + ); + RtemsReqIdentLocal_Post_Id_Check( + ctx, + RtemsReqIdentLocal_TransitionMap[ index ][ 1 ] + ); + ++index; + } + } + + T_pop_fixture(); +} + +/** @} */ diff --git a/testsuites/validation/tr-object-ident-local.h b/testsuites/validation/tr-object-ident-local.h new file mode 100644 index 0000000000..019b7c2e83 --- /dev/null +++ b/testsuites/validation/tr-object-ident-local.h @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsReqIdentLocal + */ + +/* + * Copyright (C) 2020 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 + */ + +#ifndef _TR_OBJECT_IDENT_LOCAL_H +#define _TR_OBJECT_IDENT_LOCAL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseRtemsReqIdentLocal + * + * @{ + */ + +typedef enum { + RtemsReqIdentLocal_Pre_Name_Invalid, + RtemsReqIdentLocal_Pre_Name_Valid, + RtemsReqIdentLocal_Pre_Name_NA +} RtemsReqIdentLocal_Pre_Name; + +typedef enum { + RtemsReqIdentLocal_Pre_Id_NullPtr, + RtemsReqIdentLocal_Pre_Id_Valid, + RtemsReqIdentLocal_Pre_Id_NA +} RtemsReqIdentLocal_Pre_Id; + +typedef enum { + RtemsReqIdentLocal_Post_Status_Ok, + RtemsReqIdentLocal_Post_Status_InvAddr, + RtemsReqIdentLocal_Post_Status_InvName, + RtemsReqIdentLocal_Post_Status_NA +} RtemsReqIdentLocal_Post_Status; + +typedef enum { + RtemsReqIdentLocal_Post_Id_Nop, + RtemsReqIdentLocal_Post_Id_NullPtr, + RtemsReqIdentLocal_Post_Id_Id, + RtemsReqIdentLocal_Post_Id_NA +} RtemsReqIdentLocal_Post_Id; + +#define ClassicObjectLocalIdentName \ + rtems_build_name( 'I', 'D', 'N', 'T' ) + +/** + * @brief Runs the parameterized test case. + * + * @param id_local_object is the identifier of an active object of the class + * under test with the name ClassicObjectLocalIdentName. + * + * @param action is the action handler. + */ +void RtemsReqIdentLocal_Run( + rtems_id id_local_object, + rtems_status_code ( *action )( rtems_name, rtems_id * ) +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_OBJECT_IDENT_LOCAL_H */ diff --git a/testsuites/validation/tr-object-ident.c b/testsuites/validation/tr-object-ident.c new file mode 100644 index 0000000000..b84e1b12cf --- /dev/null +++ b/testsuites/validation/tr-object-ident.c @@ -0,0 +1,609 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsReqIdent + */ + +/* + * Copyright (C) 2020 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 "tr-object-ident.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsReqIdent spec:/rtems/req/ident + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/req/ident test case. + */ +typedef struct { + rtems_status_code status; + + rtems_name name; + + uint32_t node; + + rtems_id *id; + + rtems_id id_value; + + rtems_id id_remote_object; + + /** + * @brief This member contains a copy of the corresponding + * RtemsReqIdent_Run() parameter. + */ + rtems_id id_local_object; + + /** + * @brief This member contains a copy of the corresponding + * RtemsReqIdent_Run() parameter. + */ + rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * ); + + /** + * @brief This member defines the pre-condition states for the next action. + */ + size_t pcs[ 3 ]; + + /** + * @brief This member indicates if the test action loop is currently + * executed. + */ + bool in_action_loop; +} RtemsReqIdent_Context; + +static RtemsReqIdent_Context + RtemsReqIdent_Instance; + +static const char * const RtemsReqIdent_PreDesc_Name[] = { + "Invalid", + "Valid", + "NA" +}; + +static const char * const RtemsReqIdent_PreDesc_Node[] = { + "Local", + "Remote", + "Invalid", + "SearchAll", + "SearchOther", + "SearchLocal", + "NA" +}; + +static const char * const RtemsReqIdent_PreDesc_Id[] = { + "NullPtr", + "Valid", + "NA" +}; + +static const char * const * const RtemsReqIdent_PreDesc[] = { + RtemsReqIdent_PreDesc_Name, + RtemsReqIdent_PreDesc_Node, + RtemsReqIdent_PreDesc_Id, + NULL +}; + +static void RtemsReqIdent_Pre_Name_Prepare( + RtemsReqIdent_Context *ctx, + RtemsReqIdent_Pre_Name state +) +{ + switch ( state ) { + case RtemsReqIdent_Pre_Name_Invalid: { + /* + * The name parameter shall not equal to a name of an active Classic API + * object of the specified class. + */ + ctx->name = 1; + break; + } + + case RtemsReqIdent_Pre_Name_Valid: { + /* + * The name parameter shall equal to a name of an active Classic API + * object of the specified class. + */ + ctx->name = ClassicObjectIdentName; + break; + } + + case RtemsReqIdent_Pre_Name_NA: + break; + } +} + +static void RtemsReqIdent_Pre_Node_Prepare( + RtemsReqIdent_Context *ctx, + RtemsReqIdent_Pre_Node state +) +{ + switch ( state ) { + case RtemsReqIdent_Pre_Node_Local: { + /* + * The node parameter shall be the local node number. + */ + ctx->node = 1; + break; + } + + case RtemsReqIdent_Pre_Node_Remote: { + /* + * The node parameter shall be a remote node number. + */ + ctx->node = 2; + break; + } + + case RtemsReqIdent_Pre_Node_Invalid: { + /* + * The node parameter shall be an invalid node number. + */ + ctx->node = 256; + break; + } + + case RtemsReqIdent_Pre_Node_SearchAll: { + /* + * The node parameter shall be RTEMS_SEARCH_ALL_NODES. + */ + ctx->node = RTEMS_SEARCH_ALL_NODES; + break; + } + + case RtemsReqIdent_Pre_Node_SearchOther: { + /* + * The node parameter shall be RTEMS_SEARCH_OTHER_NODES. + */ + ctx->node = RTEMS_SEARCH_OTHER_NODES; + break; + } + + case RtemsReqIdent_Pre_Node_SearchLocal: { + /* + * The node parameter shall be RTEMS_SEARCH_LOCAL_NODE. + */ + ctx->node = RTEMS_SEARCH_LOCAL_NODE; + break; + } + + case RtemsReqIdent_Pre_Node_NA: + break; + } +} + +static void RtemsReqIdent_Pre_Id_Prepare( + RtemsReqIdent_Context *ctx, + RtemsReqIdent_Pre_Id state +) +{ + switch ( state ) { + case RtemsReqIdent_Pre_Id_NullPtr: { + /* + * The id parameter shall be NULL. + */ + ctx->id = NULL; + break; + } + + case RtemsReqIdent_Pre_Id_Valid: { + /* + * The id parameter shall point to an object identifier. + */ + ctx->id_value = 0xffffffff; + ctx->id = &ctx->id_value; + break; + } + + case RtemsReqIdent_Pre_Id_NA: + break; + } +} + +static void RtemsReqIdent_Post_Status_Check( + RtemsReqIdent_Context *ctx, + RtemsReqIdent_Post_Status state +) +{ + switch ( state ) { + case RtemsReqIdent_Post_Status_Ok: { + /* + * The status shall be RTEMS_SUCCESSFUL. + */ + T_rsc(ctx->status, RTEMS_SUCCESSFUL); + break; + } + + case RtemsReqIdent_Post_Status_InvAddr: { + /* + * The status shall be RTEMS_INVALID_ADDRESS. + */ + T_rsc(ctx->status, RTEMS_INVALID_ADDRESS); + break; + } + + case RtemsReqIdent_Post_Status_InvName: { + /* + * The status shall be RTEMS_INVALID_NAME. + */ + T_rsc(ctx->status, RTEMS_INVALID_NAME); + break; + } + + case RtemsReqIdent_Post_Status_InvNode: { + /* + * The status shall be RTEMS_INVALID_NODE. + */ + T_rsc(ctx->status, RTEMS_INVALID_NODE); + break; + } + + case RtemsReqIdent_Post_Status_NA: + break; + } +} + +static void RtemsReqIdent_Post_Id_Check( + RtemsReqIdent_Context *ctx, + RtemsReqIdent_Post_Id state +) +{ + switch ( state ) { + case RtemsReqIdent_Post_Id_Nop: { + /* + * The value of the object identifier referenced by the id parameter + * shall be the value before the action. + */ + T_eq_ptr(ctx->id, &ctx->id_value); + T_eq_u32(ctx->id_value, 0xffffffff); + break; + } + + case RtemsReqIdent_Post_Id_NullPtr: { + /* + * The id parameter shall be NULL. + */ + T_null(ctx->id) + break; + } + + case RtemsReqIdent_Post_Id_LocalObj: { + /* + * The value of the object identifier referenced by the id parameter + * shall be the identifier of a local object of the specified class with + * a name equal to the name parameter. If more than one local object of + * the specified class with such a name exists, then it shall be the + * identifier of the object with the lowest object index. + */ + T_eq_ptr(ctx->id, &ctx->id_value); + T_eq_u32(ctx->id_value, ctx->id_local_object); + break; + } + + case RtemsReqIdent_Post_Id_RemoteObj: { + /* + * The value of the object identifier referenced by the id parameter + * shall be the identifier of a remote object of the specified class on a + * eligible node defined by the node parameter with a name equal to the + * name parameter. If more than one local object of the specified class + * with such a name exists, then it shall be the identifier of the object + * with the lowest object index. Otherwise, if more than one object of + * the specified class with such a name exists on remote eligible nodes, + * then it shall be the identifier of the object with the lowest node + * index and the lowest object index on this node. + */ + T_eq_ptr(ctx->id, &ctx->id_value); + T_eq_u32(ctx->id_value, ctx->id_remote_object); + break; + } + + case RtemsReqIdent_Post_Id_NA: + break; + } +} + +static size_t RtemsReqIdent_Scope( void *arg, char *buf, size_t n ) +{ + RtemsReqIdent_Context *ctx; + + ctx = arg; + + if ( ctx->in_action_loop ) { + return T_get_scope( RtemsReqIdent_PreDesc, buf, n, ctx->pcs ); + } + + return 0; +} + +static T_fixture RtemsReqIdent_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = RtemsReqIdent_Scope, + .initial_context = &RtemsReqIdent_Instance +}; + +static const uint8_t RtemsReqIdent_TransitionMap[][ 2 ] = { + { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Id_LocalObj + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { +#if defined(RTEMS_MULTIPROCESSING) + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Id_RemoteObj +#else + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop +#endif + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Id_LocalObj + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { +#if defined(RTEMS_MULTIPROCESSING) + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Id_RemoteObj +#else + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Id_Nop +#endif + }, { + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Id_NullPtr + }, { + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Id_LocalObj + } +}; + +static const struct { + uint8_t Skip : 1; + uint8_t Pre_Name_NA : 1; + uint8_t Pre_Node_NA : 1; + uint8_t Pre_Id_NA : 1; +} RtemsReqIdent_TransitionInfo[] = { + { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { +#if defined(RTEMS_MULTIPROCESSING) + 0, 0, 0, 0 +#else + 0, 0, 0, 0 +#endif + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + }, { +#if defined(RTEMS_MULTIPROCESSING) + 0, 0, 0, 0 +#else + 0, 0, 0, 0 +#endif + }, { + 0, 0, 0, 0 + }, { + 0, 0, 0, 0 + } +}; + +static void RtemsReqIdent_Action( RtemsReqIdent_Context *ctx ) +{ + ctx->status = ( *ctx->action )( ctx->name, ctx->node, ctx->id ); +} + +static T_fixture_node RtemsReqIdent_Node; + +void RtemsReqIdent_Run( + rtems_id id_local_object, + rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * ) +) +{ + RtemsReqIdent_Context *ctx; + size_t index; + + ctx = T_push_fixture( &RtemsReqIdent_Node, &RtemsReqIdent_Fixture ); + + ctx->id_local_object = id_local_object; + ctx->action = action; + ctx->in_action_loop = true; + index = 0; + + for ( + ctx->pcs[ 0 ] = RtemsReqIdent_Pre_Name_Invalid; + ctx->pcs[ 0 ] < RtemsReqIdent_Pre_Name_NA; + ++ctx->pcs[ 0 ] + ) { + if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Name_NA ) { + ctx->pcs[ 0 ] = RtemsReqIdent_Pre_Name_NA; + index += ( RtemsReqIdent_Pre_Name_NA - 1 ) + * RtemsReqIdent_Pre_Node_NA + * RtemsReqIdent_Pre_Id_NA; + } + + for ( + ctx->pcs[ 1 ] = RtemsReqIdent_Pre_Node_Local; + ctx->pcs[ 1 ] < RtemsReqIdent_Pre_Node_NA; + ++ctx->pcs[ 1 ] + ) { + if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Node_NA ) { + ctx->pcs[ 1 ] = RtemsReqIdent_Pre_Node_NA; + index += ( RtemsReqIdent_Pre_Node_NA - 1 ) + * RtemsReqIdent_Pre_Id_NA; + } + + for ( + ctx->pcs[ 2 ] = RtemsReqIdent_Pre_Id_NullPtr; + ctx->pcs[ 2 ] < RtemsReqIdent_Pre_Id_NA; + ++ctx->pcs[ 2 ] + ) { + if ( RtemsReqIdent_TransitionInfo[ index ].Pre_Id_NA ) { + ctx->pcs[ 2 ] = RtemsReqIdent_Pre_Id_NA; + index += ( RtemsReqIdent_Pre_Id_NA - 1 ); + } + + if ( RtemsReqIdent_TransitionInfo[ index ].Skip ) { + ++index; + continue; + } + + RtemsReqIdent_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] ); + RtemsReqIdent_Pre_Node_Prepare( ctx, ctx->pcs[ 1 ] ); + RtemsReqIdent_Pre_Id_Prepare( ctx, ctx->pcs[ 2 ] ); + RtemsReqIdent_Action( ctx ); + RtemsReqIdent_Post_Status_Check( + ctx, + RtemsReqIdent_TransitionMap[ index ][ 0 ] + ); + RtemsReqIdent_Post_Id_Check( + ctx, + RtemsReqIdent_TransitionMap[ index ][ 1 ] + ); + ++index; + } + } + } + + T_pop_fixture(); +} + +/** @} */ diff --git a/testsuites/validation/tr-object-ident.h b/testsuites/validation/tr-object-ident.h new file mode 100644 index 0000000000..d506b66b95 --- /dev/null +++ b/testsuites/validation/tr-object-ident.h @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsReqIdent + */ + +/* + * Copyright (C) 2020 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 + */ + +#ifndef _TR_OBJECT_IDENT_H +#define _TR_OBJECT_IDENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseRtemsReqIdent + * + * @{ + */ + +typedef enum { + RtemsReqIdent_Pre_Name_Invalid, + RtemsReqIdent_Pre_Name_Valid, + RtemsReqIdent_Pre_Name_NA +} RtemsReqIdent_Pre_Name; + +typedef enum { + RtemsReqIdent_Pre_Node_Local, + RtemsReqIdent_Pre_Node_Remote, + RtemsReqIdent_Pre_Node_Invalid, + RtemsReqIdent_Pre_Node_SearchAll, + RtemsReqIdent_Pre_Node_SearchOther, + RtemsReqIdent_Pre_Node_SearchLocal, + RtemsReqIdent_Pre_Node_NA +} RtemsReqIdent_Pre_Node; + +typedef enum { + RtemsReqIdent_Pre_Id_NullPtr, + RtemsReqIdent_Pre_Id_Valid, + RtemsReqIdent_Pre_Id_NA +} RtemsReqIdent_Pre_Id; + +typedef enum { + RtemsReqIdent_Post_Status_Ok, + RtemsReqIdent_Post_Status_InvAddr, + RtemsReqIdent_Post_Status_InvName, + RtemsReqIdent_Post_Status_InvNode, + RtemsReqIdent_Post_Status_NA +} RtemsReqIdent_Post_Status; + +typedef enum { + RtemsReqIdent_Post_Id_Nop, + RtemsReqIdent_Post_Id_NullPtr, + RtemsReqIdent_Post_Id_LocalObj, + RtemsReqIdent_Post_Id_RemoteObj, + RtemsReqIdent_Post_Id_NA +} RtemsReqIdent_Post_Id; + +#define ClassicObjectIdentName \ + rtems_build_name( 'I', 'D', 'N', 'T' ) + +/** + * @brief Runs the parameterized test case. + * + * @param id_local_object is the identifier of an active object of the class + * under test with the name ClassicObjectIdentName. + * + * @param action is the action handler. + */ +void RtemsReqIdent_Run( + rtems_id id_local_object, + rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * ) +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_OBJECT_IDENT_H */ -- cgit v1.2.3