diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-24 15:33:41 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-25 09:24:32 +0100 |
commit | 22ceb9aa53a2b289a5fe31aeeca52fa2a5563ed4 (patch) | |
tree | 1223b01cb259c9a0acd790b307a7e70a090f1709 | |
parent | 18b8d897574a943d4f764b1e24a92a31e9134041 (diff) |
validation: Performance
-rw-r--r-- | spec/build/testsuites/validation/performance-0.yml | 5 | ||||
-rw-r--r-- | testsuites/validation/tc-barrier-performance.c | 617 | ||||
-rw-r--r-- | testsuites/validation/tc-event-performance.c | 141 | ||||
-rw-r--r-- | testsuites/validation/tc-message-performance.c | 143 | ||||
-rw-r--r-- | testsuites/validation/tc-part-performance.c | 12 | ||||
-rw-r--r-- | testsuites/validation/tc-sem-performance.c | 888 | ||||
-rw-r--r-- | testsuites/validation/tc-task-performance.c | 141 | ||||
-rw-r--r-- | testsuites/validation/ts-performance-0.c | 2 |
8 files changed, 1948 insertions, 1 deletions
diff --git a/spec/build/testsuites/validation/performance-0.yml b/spec/build/testsuites/validation/performance-0.yml index cf0aec1ed0..874ad3823c 100644 --- a/spec/build/testsuites/validation/performance-0.yml +++ b/spec/build/testsuites/validation/performance-0.yml @@ -11,7 +11,12 @@ includes: [] ldflags: [] links: [] source: +- testsuites/validation/tc-barrier-performance.c +- testsuites/validation/tc-event-performance.c +- testsuites/validation/tc-message-performance.c - testsuites/validation/tc-part-performance.c +- testsuites/validation/tc-sem-performance.c +- testsuites/validation/tc-task-performance.c - testsuites/validation/ts-performance-0.c stlib: [] target: testsuites/validation/ts-performance-0.exe diff --git a/testsuites/validation/tc-barrier-performance.c b/testsuites/validation/tc-barrier-performance.c new file mode 100644 index 0000000000..25cc6c9cf6 --- /dev/null +++ b/testsuites/validation/tc-barrier-performance.c @@ -0,0 +1,617 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsBarrierValPerf + */ + +/* + * 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 <rtems.h> + +#include "tx-support.h" + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsBarrierValPerf spec:/rtems/barrier/val/perf + * + * @ingroup RTEMSTestSuiteTestsuitesPerformance0 + * + * @brief This test case provides a context to run @ref RTEMSAPIClassicBarrier + * performance tests. + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/barrier/val/perf test case. + */ +typedef struct { + /** + * @brief This member provides a barrier identifier. + */ + rtems_id barrier_id; + + /** + * @brief This member provides a worker identifier. + */ + rtems_id worker_id; + + /** + * @brief This member provides a status code. + */ + rtems_status_code status; + + /** + * @brief This member references the measure runtime context. + */ + T_measure_runtime_context *context; + + /** + * @brief This member provides the measure runtime request. + */ + T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; +} RtemsBarrierValPerf_Context; + +static RtemsBarrierValPerf_Context + RtemsBarrierValPerf_Instance; + +typedef RtemsBarrierValPerf_Context Context; + +static void BarrierWaitWorker( rtems_task_argument arg ) +{ + Context *ctx; + + ctx = (Context *) arg; + + while ( true ) { + rtems_status_code sc; + + sc = rtems_barrier_wait( ctx->barrier_id, RTEMS_NO_TIMEOUT ); + ctx->end = T_tick(); + T_quiet_rsc_success( sc ); + } +} + +static void RtemsBarrierValPerf_Setup_Context( + RtemsBarrierValPerf_Context *ctx +) +{ + T_measure_runtime_config config; + + memset( &config, 0, sizeof( config ) ); + config.sample_count = 1000; + ctx->request.arg = ctx; + ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES; + ctx->context = T_measure_runtime_create( &config ); + T_assert_not_null( ctx->context ); +} + +static void RtemsBarrierValPerf_Setup_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierValPerf_Setup_Context( ctx ); +} + +static T_fixture RtemsBarrierValPerf_Fixture = { + .setup = RtemsBarrierValPerf_Setup_Wrap, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &RtemsBarrierValPerf_Instance +}; + +/** + * @brief Create an automatic release barrier. + */ +static void RtemsBarrierReqPerfReleaseAuto_Prepare( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + sc = rtems_barrier_create( + OBJECT_NAME, + RTEMS_BARRIER_AUTOMATIC_RELEASE, + 1, + &ctx->barrier_id + ); + T_rsc_success( sc ); +} + +/** + * @brief Automatically release the barrier. + */ +static void RtemsBarrierReqPerfReleaseAuto_Body( + RtemsBarrierValPerf_Context *ctx +) +{ + ctx->status = rtems_barrier_wait( ctx->barrier_id, RTEMS_NO_TIMEOUT ); +} + +static void RtemsBarrierReqPerfReleaseAuto_Body_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseAuto_Body( ctx ); +} + +/** + * @brief Discard samples interrupted by a clock tick. + */ +static bool RtemsBarrierReqPerfReleaseAuto_Teardown( + RtemsBarrierValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + return tic == toc; +} + +static bool RtemsBarrierReqPerfReleaseAuto_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + return RtemsBarrierReqPerfReleaseAuto_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Delete the barrier and the worker. + */ +static void RtemsBarrierReqPerfReleaseAuto_Cleanup( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + sc = rtems_barrier_delete( ctx->barrier_id ); + T_rsc_success( sc ); +} + +#if defined(RTEMS_SMP) +/** + * @brief Create an automatic release barrier. Create and start a worker task. + */ +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Prepare( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + sc = rtems_barrier_create( + OBJECT_NAME, + RTEMS_BARRIER_AUTOMATIC_RELEASE, + 2, + &ctx->barrier_id + ); + T_rsc_success( sc ); + + ctx->worker_id = CreateTask( "WORK", PRIO_NORMAL ); + SetScheduler( ctx->worker_id, SCHEDULER_B_ID, PRIO_NORMAL ); + StartTask( ctx->worker_id, BarrierWaitWorker, ctx ); +} + +/** + * @brief Make sure the worker task is fully blocked on the barrier. + */ +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Setup( + RtemsBarrierValPerf_Context *ctx +) +{ + WaitForNextTask( 1, ctx->worker_id ); +} + +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Setup_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseAutoOtherCpu_Setup( ctx ); +} + +/** + * @brief Automatically release the barrier. + */ +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Body( + RtemsBarrierValPerf_Context *ctx +) +{ + ctx->begin = T_tick(); + ctx->status = rtems_barrier_wait( ctx->barrier_id, RTEMS_NO_TIMEOUT ); +} + +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Body_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseAutoOtherCpu_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Discard samples interrupted by a clock + * tick. + */ +static bool RtemsBarrierReqPerfReleaseAutoOtherCpu_Teardown( + RtemsBarrierValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + *delta = ctx->end - ctx->begin; + + return tic == toc; +} + +static bool RtemsBarrierReqPerfReleaseAutoOtherCpu_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + return RtemsBarrierReqPerfReleaseAutoOtherCpu_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Delete the barrier and the worker. + */ +static void RtemsBarrierReqPerfReleaseAutoOtherCpu_Cleanup( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + DeleteTask( ctx->worker_id ); + + sc = rtems_barrier_delete( ctx->barrier_id ); + T_rsc_success( sc ); +} +#endif + +/** + * @brief Create a manual release barrier. Create and start a worker task. + */ +static void RtemsBarrierReqPerfReleaseManual_Prepare( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + sc = rtems_barrier_create( + OBJECT_NAME, + RTEMS_BARRIER_MANUAL_RELEASE, + 0, + &ctx->barrier_id + ); + T_rsc_success( sc ); + + SetSelfPriority( PRIO_NORMAL ); + ctx->worker_id = CreateTask( "WORK", PRIO_NORMAL ); + StartTask( ctx->worker_id, BarrierWaitWorker, ctx ); +} + +/** + * @brief Make sure the worker task is fully blocked on the barrier. + */ +static void RtemsBarrierReqPerfReleaseManual_Setup( + RtemsBarrierValPerf_Context *ctx +) +{ + Yield(); +} + +static void RtemsBarrierReqPerfReleaseManual_Setup_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseManual_Setup( ctx ); +} + +/** + * @brief Release the barrier. + */ +static void RtemsBarrierReqPerfReleaseManual_Body( + RtemsBarrierValPerf_Context *ctx +) +{ + uint32_t count; + + ctx->status = rtems_barrier_release( ctx->barrier_id, &count ); +} + +static void RtemsBarrierReqPerfReleaseManual_Body_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseManual_Body( ctx ); +} + +/** + * @brief Discard samples interrupted by a clock tick. + */ +static bool RtemsBarrierReqPerfReleaseManual_Teardown( + RtemsBarrierValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + return tic == toc; +} + +static bool RtemsBarrierReqPerfReleaseManual_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + return RtemsBarrierReqPerfReleaseManual_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Delete the barrier and the worker. + */ +static void RtemsBarrierReqPerfReleaseManual_Cleanup( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + DeleteTask( ctx->worker_id ); + + sc = rtems_barrier_delete( ctx->barrier_id ); + T_rsc_success( sc ); + + RestoreRunnerPriority(); +} + +/** + * @brief Create a manual release barrier. Create and start a worker task. + */ +static void RtemsBarrierReqPerfReleaseManualPreempt_Prepare( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + sc = rtems_barrier_create( + OBJECT_NAME, + RTEMS_BARRIER_MANUAL_RELEASE, + 0, + &ctx->barrier_id + ); + T_rsc_success( sc ); + + SetSelfPriority( PRIO_NORMAL ); + ctx->worker_id = CreateTask( "WORK", PRIO_HIGH ); + StartTask( ctx->worker_id, BarrierWaitWorker, ctx ); +} + +/** + * @brief Release the barrier. + */ +static void RtemsBarrierReqPerfReleaseManualPreempt_Body( + RtemsBarrierValPerf_Context *ctx +) +{ + uint32_t count; + + ctx->status = rtems_barrier_release( ctx->barrier_id, &count ); +} + +static void RtemsBarrierReqPerfReleaseManualPreempt_Body_Wrap( void *arg ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + RtemsBarrierReqPerfReleaseManualPreempt_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Discard samples interrupted by a clock + * tick. + */ +static bool RtemsBarrierReqPerfReleaseManualPreempt_Teardown( + RtemsBarrierValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + *delta = ctx->end - ctx->begin; + + return tic == toc; +} + +static bool RtemsBarrierReqPerfReleaseManualPreempt_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = arg; + return RtemsBarrierReqPerfReleaseManualPreempt_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Delete the barrier and the worker. + */ +static void RtemsBarrierReqPerfReleaseManualPreempt_Cleanup( + RtemsBarrierValPerf_Context *ctx +) +{ + rtems_status_code sc; + + DeleteTask( ctx->worker_id ); + + sc = rtems_barrier_delete( ctx->barrier_id ); + T_rsc_success( sc ); + + RestoreRunnerPriority(); +} + +/** + * @fn void T_case_body_RtemsBarrierValPerf( void ) + */ +T_TEST_CASE_FIXTURE( RtemsBarrierValPerf, &RtemsBarrierValPerf_Fixture ) +{ + RtemsBarrierValPerf_Context *ctx; + + ctx = T_fixture_context(); + + RtemsBarrierReqPerfReleaseAuto_Prepare( ctx ); + ctx->request.name = "RtemsBarrierReqPerfReleaseAuto"; + ctx->request.setup = NULL; + ctx->request.body = RtemsBarrierReqPerfReleaseAuto_Body_Wrap; + ctx->request.teardown = RtemsBarrierReqPerfReleaseAuto_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsBarrierReqPerfReleaseAuto_Cleanup( ctx ); + + #if defined(RTEMS_SMP) + RtemsBarrierReqPerfReleaseAutoOtherCpu_Prepare( ctx ); + ctx->request.name = "RtemsBarrierReqPerfReleaseAutoOtherCpu"; + ctx->request.setup = RtemsBarrierReqPerfReleaseAutoOtherCpu_Setup_Wrap; + ctx->request.body = RtemsBarrierReqPerfReleaseAutoOtherCpu_Body_Wrap; + ctx->request.teardown = RtemsBarrierReqPerfReleaseAutoOtherCpu_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsBarrierReqPerfReleaseAutoOtherCpu_Cleanup( ctx ); + #endif + + RtemsBarrierReqPerfReleaseManual_Prepare( ctx ); + ctx->request.name = "RtemsBarrierReqPerfReleaseManual"; + ctx->request.setup = RtemsBarrierReqPerfReleaseManual_Setup_Wrap; + ctx->request.body = RtemsBarrierReqPerfReleaseManual_Body_Wrap; + ctx->request.teardown = RtemsBarrierReqPerfReleaseManual_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsBarrierReqPerfReleaseManual_Cleanup( ctx ); + + RtemsBarrierReqPerfReleaseManualPreempt_Prepare( ctx ); + ctx->request.name = "RtemsBarrierReqPerfReleaseManualPreempt"; + ctx->request.setup = NULL; + ctx->request.body = RtemsBarrierReqPerfReleaseManualPreempt_Body_Wrap; + ctx->request.teardown = RtemsBarrierReqPerfReleaseManualPreempt_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsBarrierReqPerfReleaseManualPreempt_Cleanup( ctx ); +} + +/** @} */ diff --git a/testsuites/validation/tc-event-performance.c b/testsuites/validation/tc-event-performance.c new file mode 100644 index 0000000000..3c16211057 --- /dev/null +++ b/testsuites/validation/tc-event-performance.c @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsEventValPerf + */ + +/* + * 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 <rtems.h> + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsEventValPerf spec:/rtems/event/val/perf + * + * @ingroup RTEMSTestSuiteTestsuitesPerformance0 + * + * @brief This test case provides a context to run @ref RTEMSAPIClassicEvent + * performance tests. + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/event/val/perf test case. + */ +typedef struct { + /** + * @brief This member provides a status code. + */ + rtems_status_code status; + + /** + * @brief This member references the measure runtime context. + */ + T_measure_runtime_context *context; + + /** + * @brief This member provides the measure runtime request. + */ + T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; +} RtemsEventValPerf_Context; + +static RtemsEventValPerf_Context + RtemsEventValPerf_Instance; + +static void RtemsEventValPerf_Setup_Context( RtemsEventValPerf_Context *ctx ) +{ + T_measure_runtime_config config; + + memset( &config, 0, sizeof( config ) ); + config.sample_count = 1000; + ctx->request.arg = ctx; + ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES; + ctx->context = T_measure_runtime_create( &config ); + T_assert_not_null( ctx->context ); +} + +static void RtemsEventValPerf_Setup_Wrap( void *arg ) +{ + RtemsEventValPerf_Context *ctx; + + ctx = arg; + RtemsEventValPerf_Setup_Context( ctx ); +} + +static T_fixture RtemsEventValPerf_Fixture = { + .setup = RtemsEventValPerf_Setup_Wrap, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &RtemsEventValPerf_Instance +}; + +/** + * @fn void T_case_body_RtemsEventValPerf( void ) + */ +T_TEST_CASE_FIXTURE( RtemsEventValPerf, &RtemsEventValPerf_Fixture ) +{ + RtemsEventValPerf_Context *ctx; + + ctx = T_fixture_context(); +} + +/** @} */ diff --git a/testsuites/validation/tc-message-performance.c b/testsuites/validation/tc-message-performance.c new file mode 100644 index 0000000000..f540fac2ab --- /dev/null +++ b/testsuites/validation/tc-message-performance.c @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsMessageValPerf + */ + +/* + * 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 <rtems.h> + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsMessageValPerf spec:/rtems/message/val/perf + * + * @ingroup RTEMSTestSuiteTestsuitesPerformance0 + * + * @brief This test case provides a context to run @ref RTEMSAPIClassicMessage + * performance tests. + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/message/val/perf test case. + */ +typedef struct { + /** + * @brief This member provides a status code. + */ + rtems_status_code status; + + /** + * @brief This member references the measure runtime context. + */ + T_measure_runtime_context *context; + + /** + * @brief This member provides the measure runtime request. + */ + T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; +} RtemsMessageValPerf_Context; + +static RtemsMessageValPerf_Context + RtemsMessageValPerf_Instance; + +static void RtemsMessageValPerf_Setup_Context( + RtemsMessageValPerf_Context *ctx +) +{ + T_measure_runtime_config config; + + memset( &config, 0, sizeof( config ) ); + config.sample_count = 1000; + ctx->request.arg = ctx; + ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES; + ctx->context = T_measure_runtime_create( &config ); + T_assert_not_null( ctx->context ); +} + +static void RtemsMessageValPerf_Setup_Wrap( void *arg ) +{ + RtemsMessageValPerf_Context *ctx; + + ctx = arg; + RtemsMessageValPerf_Setup_Context( ctx ); +} + +static T_fixture RtemsMessageValPerf_Fixture = { + .setup = RtemsMessageValPerf_Setup_Wrap, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &RtemsMessageValPerf_Instance +}; + +/** + * @fn void T_case_body_RtemsMessageValPerf( void ) + */ +T_TEST_CASE_FIXTURE( RtemsMessageValPerf, &RtemsMessageValPerf_Fixture ) +{ + RtemsMessageValPerf_Context *ctx; + + ctx = T_fixture_context(); +} + +/** @} */ diff --git a/testsuites/validation/tc-part-performance.c b/testsuites/validation/tc-part-performance.c index 5156887015..baaddff06a 100644 --- a/testsuites/validation/tc-part-performance.c +++ b/testsuites/validation/tc-part-performance.c @@ -62,7 +62,7 @@ * * @ingroup RTEMSTestSuiteTestsuitesPerformance0 * - * @brief This test case provides a context to run Partition Manager + * @brief This test case provides a context to run @ref RTEMSAPIClassicPart * performance tests. * * @{ @@ -106,6 +106,16 @@ typedef struct { * @brief This member provides the measure runtime request. */ T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; } RtemsPartValPerf_Context; static RtemsPartValPerf_Context diff --git a/testsuites/validation/tc-sem-performance.c b/testsuites/validation/tc-sem-performance.c new file mode 100644 index 0000000000..7ef4debe30 --- /dev/null +++ b/testsuites/validation/tc-sem-performance.c @@ -0,0 +1,888 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsSemValPerf + */ + +/* + * 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 <rtems.h> + +#include "tx-support.h" + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsSemValPerf spec:/rtems/sem/val/perf + * + * @ingroup RTEMSTestSuiteTestsuitesPerformance0 + * + * @brief This test case provides a context to run @ref RTEMSAPIClassicSem + * performance tests. + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/sem/val/perf test case. + */ +typedef struct { + /** + * @brief This member provides a mutex identifier. + */ + rtems_id mutex_id; + + /** + * @brief This member provides a worker identifier. + */ + rtems_id worker_id; + + /** + * @brief This member provides a status code. + */ + rtems_status_code status; + + /** + * @brief This member references the measure runtime context. + */ + T_measure_runtime_context *context; + + /** + * @brief This member provides the measure runtime request. + */ + T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; +} RtemsSemValPerf_Context; + +static RtemsSemValPerf_Context + RtemsSemValPerf_Instance; + +typedef RtemsSemValPerf_Context Context; + +typedef enum { + EVENT_END = RTEMS_EVENT_0, + EVENT_OBTAIN = RTEMS_EVENT_1, + EVENT_OBTAIN_END = RTEMS_EVENT_2, + EVENT_RELEASE = RTEMS_EVENT_3, + EVENT_RELEASE_END = RTEMS_EVENT_4 +} Event; + +static void Send( const Context *ctx, rtems_event_set events ) +{ + SendEvents( ctx->worker_id, events ); +} + +static void Worker( rtems_task_argument arg ) +{ + Context *ctx; + + ctx = (Context *) arg; + + while ( true ) { + rtems_event_set events; + rtems_status_code sc; + T_ticks ticks; + + sc = rtems_event_receive( + RTEMS_ALL_EVENTS, + RTEMS_EVENT_ANY | RTEMS_WAIT, + RTEMS_NO_TIMEOUT, + &events + ); + ticks = T_tick(); + T_quiet_rsc_success( sc ); + + if ( ( events & EVENT_END ) != 0 ) { + ctx->end = ticks; + } + + if ( ( events & EVENT_OBTAIN ) != 0 ) { + sc = rtems_semaphore_obtain( + ctx->mutex_id, + RTEMS_WAIT, + RTEMS_NO_TIMEOUT + ); + ticks = T_tick(); + T_quiet_rsc_success( sc ); + + if ( ( events & EVENT_OBTAIN_END ) != 0 ) { + ctx->end = ticks; + } + } + + if ( ( events & EVENT_RELEASE ) != 0 ) { + sc = rtems_semaphore_release( ctx->mutex_id ); + ticks = T_tick(); + T_quiet_rsc_success( sc ); + + if ( ( events & EVENT_RELEASE_END ) != 0 ) { + ctx->end = ticks; + } + } + } +} + +static void RtemsSemValPerf_Setup_Context( RtemsSemValPerf_Context *ctx ) +{ + T_measure_runtime_config config; + + memset( &config, 0, sizeof( config ) ); + config.sample_count = 1000; + ctx->request.arg = ctx; + ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES; + ctx->context = T_measure_runtime_create( &config ); + T_assert_not_null( ctx->context ); +} + +/** + * @brief Create a mutex and a worker task. + */ +static void RtemsSemValPerf_Setup( RtemsSemValPerf_Context *ctx ) +{ + SetSelfPriority( PRIO_NORMAL ); + ctx->mutex_id = CreateMutex(); + ctx->worker_id = CreateTask( "WORK", PRIO_HIGH ); + StartTask( ctx->worker_id, Worker, ctx ); +} + +static void RtemsSemValPerf_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemValPerf_Setup_Context( ctx ); + RtemsSemValPerf_Setup( ctx ); +} + +/** + * @brief Delete the worker task and the mutex. + */ +static void RtemsSemValPerf_Teardown( RtemsSemValPerf_Context *ctx ) +{ + DeleteTask( ctx->worker_id ); + DeleteMutex( ctx->mutex_id ); + RestoreRunnerPriority(); +} + +static void RtemsSemValPerf_Teardown_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemValPerf_Teardown( ctx ); +} + +static T_fixture RtemsSemValPerf_Fixture = { + .setup = RtemsSemValPerf_Setup_Wrap, + .stop = NULL, + .teardown = RtemsSemValPerf_Teardown_Wrap, + .scope = NULL, + .initial_context = &RtemsSemValPerf_Instance +}; + +/** + * @brief Obtain the available mutex. + */ +static void RtemsSemReqPerfMtxPiObtain_Body( RtemsSemValPerf_Context *ctx ) +{ + ctx->status = rtems_semaphore_obtain( + ctx->mutex_id, + RTEMS_WAIT, + RTEMS_NO_TIMEOUT + ); +} + +static void RtemsSemReqPerfMtxPiObtain_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiObtain_Body( ctx ); +} + +/** + * @brief Release the mutex. Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiObtain_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + ReleaseMutex( ctx->mutex_id ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiObtain_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiObtain_Teardown( ctx, delta, tic, toc, retry ); +} + +/** + * @brief Obtain the mutex. + */ +static void RtemsSemReqPerfMtxPiRelease_Setup( RtemsSemValPerf_Context *ctx ) +{ + ObtainMutex( ctx->mutex_id ); +} + +static void RtemsSemReqPerfMtxPiRelease_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiRelease_Setup( ctx ); +} + +/** + * @brief Release the mutex. + */ +static void RtemsSemReqPerfMtxPiRelease_Body( RtemsSemValPerf_Context *ctx ) +{ + ctx->status = rtems_semaphore_release( ctx->mutex_id ); +} + +static void RtemsSemReqPerfMtxPiRelease_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiRelease_Body( ctx ); +} + +/** + * @brief Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiRelease_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc_success( ctx->status ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiRelease_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiRelease_Teardown( ctx, delta, tic, toc, retry ); +} + +/** + * @brief Let one task wait on the mutex. + */ +static void RtemsSemReqPerfMtxPiReleaseOne_Setup( + RtemsSemValPerf_Context *ctx +) +{ + ObtainMutex( ctx->mutex_id ); + Send( ctx, EVENT_OBTAIN ); + SetPriority( ctx->worker_id, PRIO_LOW ); + Send( ctx, EVENT_RELEASE ); +} + +static void RtemsSemReqPerfMtxPiReleaseOne_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleaseOne_Setup( ctx ); +} + +/** + * @brief Release the mutex. + */ +static void RtemsSemReqPerfMtxPiReleaseOne_Body( RtemsSemValPerf_Context *ctx ) +{ + ctx->status = rtems_semaphore_release( ctx->mutex_id ); +} + +static void RtemsSemReqPerfMtxPiReleaseOne_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleaseOne_Body( ctx ); +} + +/** + * @brief Restore the worker priority. Discard samples interrupted by a clock + * tick. + */ +static bool RtemsSemReqPerfMtxPiReleaseOne_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL ); + + SetPriority( ctx->worker_id, PRIO_HIGH ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiReleaseOne_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiReleaseOne_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +#if defined(RTEMS_SMP) +/** + * @brief Move worker to scheduler B. + */ +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Prepare( + RtemsSemValPerf_Context *ctx +) +{ + SetScheduler( ctx->worker_id, SCHEDULER_B_ID, PRIO_NORMAL ); +} + +/** + * @brief Let one task wait on the mutex. + */ +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Setup( + RtemsSemValPerf_Context *ctx +) +{ + ObtainMutex( ctx->mutex_id ); + Send( ctx, EVENT_OBTAIN | EVENT_OBTAIN_END | EVENT_RELEASE ); + WaitForNextTask( 1, ctx->worker_id ); +} + +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleaseOtherCpu_Setup( ctx ); +} + +/** + * @brief Release the mutex. + */ +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Body( + RtemsSemValPerf_Context *ctx +) +{ + ctx->status = rtems_semaphore_release( ctx->mutex_id ); +} + +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleaseOtherCpu_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Make sure the worker waits for the next + * event. Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiReleaseOtherCpu_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL ); + + *delta = ctx->end - ctx->begin; + WaitForNextTask( 1, ctx->worker_id ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiReleaseOtherCpu_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiReleaseOtherCpu_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Move worker to scheduler A. + */ +static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Cleanup( + RtemsSemValPerf_Context *ctx +) +{ + SetScheduler( ctx->worker_id, SCHEDULER_A_ID, PRIO_HIGH ); +} +#endif + +/** + * @brief Let one task wait on the mutex. + */ +static void RtemsSemReqPerfMtxPiReleasePreempt_Setup( + RtemsSemValPerf_Context *ctx +) +{ + ObtainMutex( ctx->mutex_id ); + Send( ctx, EVENT_OBTAIN | EVENT_OBTAIN_END | EVENT_RELEASE ); +} + +static void RtemsSemReqPerfMtxPiReleasePreempt_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleasePreempt_Setup( ctx ); +} + +/** + * @brief Release the mutex. + */ +static void RtemsSemReqPerfMtxPiReleasePreempt_Body( + RtemsSemValPerf_Context *ctx +) +{ + ctx->status = rtems_semaphore_release( ctx->mutex_id ); +} + +static void RtemsSemReqPerfMtxPiReleasePreempt_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiReleasePreempt_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Discard samples interrupted by a clock + * tick. + */ +static bool RtemsSemReqPerfMtxPiReleasePreempt_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL ); + + *delta = ctx->end - ctx->begin; + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiReleasePreempt_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiReleasePreempt_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Make the mutex unavailable. + */ +static void RtemsSemReqPerfMtxPiTry_Prepare( RtemsSemValPerf_Context *ctx ) +{ + Send( ctx, EVENT_OBTAIN ); +} + +/** + * @brief Try to obtain the unavailable mutex. + */ +static void RtemsSemReqPerfMtxPiTry_Body( RtemsSemValPerf_Context *ctx ) +{ + ctx->status = rtems_semaphore_obtain( ctx->mutex_id, RTEMS_NO_WAIT, 0 ); +} + +static void RtemsSemReqPerfMtxPiTry_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiTry_Body( ctx ); +} + +/** + * @brief Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiTry_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_UNSATISFIED ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiTry_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiTry_Teardown( ctx, delta, tic, toc, retry ); +} + +/** + * @brief Make the mutex available. + */ +static void RtemsSemReqPerfMtxPiTry_Cleanup( RtemsSemValPerf_Context *ctx ) +{ + Send( ctx, EVENT_RELEASE ); +} + +/** + * @brief Make the mutex unavailable. + */ +static void RtemsSemReqPerfMtxPiWaitForever_Setup( + RtemsSemValPerf_Context *ctx +) +{ + Send( ctx, EVENT_OBTAIN ); + SetPriority( ctx->worker_id, PRIO_LOW ); + Send( ctx, EVENT_END | EVENT_RELEASE ); +} + +static void RtemsSemReqPerfMtxPiWaitForever_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiWaitForever_Setup( ctx ); +} + +/** + * @brief Obtain the unavailable mutex and wait forever. + */ +static void RtemsSemReqPerfMtxPiWaitForever_Body( + RtemsSemValPerf_Context *ctx +) +{ + ctx->begin = T_tick(); + ctx->status = rtems_semaphore_obtain( + ctx->mutex_id, + RTEMS_WAIT, + RTEMS_NO_TIMEOUT + ); +} + +static void RtemsSemReqPerfMtxPiWaitForever_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiWaitForever_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Restore the worker priority. Release the + * mutex. Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiWaitForever_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL ); + + *delta = ctx->end - ctx->begin; + SetPriority( ctx->worker_id, PRIO_HIGH ); + ReleaseMutex( ctx->mutex_id ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiWaitForever_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiWaitForever_Teardown( + ctx, + delta, + tic, + toc, + retry + ); +} + +/** + * @brief Make the mutex unavailable. + */ +static void RtemsSemReqPerfMtxPiWaitTimed_Setup( RtemsSemValPerf_Context *ctx ) +{ + Send( ctx, EVENT_OBTAIN ); + SetPriority( ctx->worker_id, PRIO_LOW ); + Send( ctx, EVENT_END | EVENT_RELEASE ); +} + +static void RtemsSemReqPerfMtxPiWaitTimed_Setup_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiWaitTimed_Setup( ctx ); +} + +/** + * @brief Obtain the unavailable mutex and wait forever. + */ +static void RtemsSemReqPerfMtxPiWaitTimed_Body( RtemsSemValPerf_Context *ctx ) +{ + ctx->begin = T_tick(); + ctx->status = rtems_semaphore_obtain( + ctx->mutex_id, + RTEMS_WAIT, + UINT32_MAX + ); +} + +static void RtemsSemReqPerfMtxPiWaitTimed_Body_Wrap( void *arg ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + RtemsSemReqPerfMtxPiWaitTimed_Body( ctx ); +} + +/** + * @brief Set the measured runtime. Restore the worker priority. Release the + * mutex. Discard samples interrupted by a clock tick. + */ +static bool RtemsSemReqPerfMtxPiWaitTimed_Teardown( + RtemsSemValPerf_Context *ctx, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL ); + + *delta = ctx->end - ctx->begin; + SetPriority( ctx->worker_id, PRIO_HIGH ); + ReleaseMutex( ctx->mutex_id ); + + return tic == toc; +} + +static bool RtemsSemReqPerfMtxPiWaitTimed_Teardown_Wrap( + void *arg, + T_ticks *delta, + uint32_t tic, + uint32_t toc, + unsigned int retry +) +{ + RtemsSemValPerf_Context *ctx; + + ctx = arg; + return RtemsSemReqPerfMtxPiWaitTimed_Teardown( ctx, delta, tic, toc, retry ); +} + +/** + * @fn void T_case_body_RtemsSemValPerf( void ) + */ +T_TEST_CASE_FIXTURE( RtemsSemValPerf, &RtemsSemValPerf_Fixture ) +{ + RtemsSemValPerf_Context *ctx; + + ctx = T_fixture_context(); + + ctx->request.name = "RtemsSemReqPerfMtxPiObtain"; + ctx->request.setup = NULL; + ctx->request.body = RtemsSemReqPerfMtxPiObtain_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiObtain_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + + ctx->request.name = "RtemsSemReqPerfMtxPiRelease"; + ctx->request.setup = RtemsSemReqPerfMtxPiRelease_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiRelease_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiRelease_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + + ctx->request.name = "RtemsSemReqPerfMtxPiReleaseOne"; + ctx->request.setup = RtemsSemReqPerfMtxPiReleaseOne_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiReleaseOne_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiReleaseOne_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + + #if defined(RTEMS_SMP) + RtemsSemReqPerfMtxPiReleaseOtherCpu_Prepare( ctx ); + ctx->request.name = "RtemsSemReqPerfMtxPiReleaseOtherCpu"; + ctx->request.setup = RtemsSemReqPerfMtxPiReleaseOtherCpu_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiReleaseOtherCpu_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiReleaseOtherCpu_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsSemReqPerfMtxPiReleaseOtherCpu_Cleanup( ctx ); + #endif + + ctx->request.name = "RtemsSemReqPerfMtxPiReleasePreempt"; + ctx->request.setup = RtemsSemReqPerfMtxPiReleasePreempt_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiReleasePreempt_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiReleasePreempt_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + + RtemsSemReqPerfMtxPiTry_Prepare( ctx ); + ctx->request.name = "RtemsSemReqPerfMtxPiTry"; + ctx->request.setup = NULL; + ctx->request.body = RtemsSemReqPerfMtxPiTry_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiTry_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + RtemsSemReqPerfMtxPiTry_Cleanup( ctx ); + + ctx->request.name = "RtemsSemReqPerfMtxPiWaitForever"; + ctx->request.setup = RtemsSemReqPerfMtxPiWaitForever_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiWaitForever_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiWaitForever_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); + + ctx->request.name = "RtemsSemReqPerfMtxPiWaitTimed"; + ctx->request.setup = RtemsSemReqPerfMtxPiWaitTimed_Setup_Wrap; + ctx->request.body = RtemsSemReqPerfMtxPiWaitTimed_Body_Wrap; + ctx->request.teardown = RtemsSemReqPerfMtxPiWaitTimed_Teardown_Wrap; + T_measure_runtime( ctx->context, &ctx->request ); +} + +/** @} */ diff --git a/testsuites/validation/tc-task-performance.c b/testsuites/validation/tc-task-performance.c new file mode 100644 index 0000000000..f343fc8bec --- /dev/null +++ b/testsuites/validation/tc-task-performance.c @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsTaskValPerf + */ + +/* + * 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 <rtems.h> + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsTaskValPerf spec:/rtems/task/val/perf + * + * @ingroup RTEMSTestSuiteTestsuitesPerformance0 + * + * @brief This test case provides a context to run @ref RTEMSAPIClassicTasks + * performance tests. + * + * @{ + */ + +/** + * @brief Test context for spec:/rtems/task/val/perf test case. + */ +typedef struct { + /** + * @brief This member provides a status code. + */ + rtems_status_code status; + + /** + * @brief This member references the measure runtime context. + */ + T_measure_runtime_context *context; + + /** + * @brief This member provides the measure runtime request. + */ + T_measure_runtime_request request; + + /** + * @brief This member provides an optional measurement begin time point. + */ + T_ticks begin; + + /** + * @brief This member provides an optional measurement end time point. + */ + T_ticks end; +} RtemsTaskValPerf_Context; + +static RtemsTaskValPerf_Context + RtemsTaskValPerf_Instance; + +static void RtemsTaskValPerf_Setup_Context( RtemsTaskValPerf_Context *ctx ) +{ + T_measure_runtime_config config; + + memset( &config, 0, sizeof( config ) ); + config.sample_count = 1000; + ctx->request.arg = ctx; + ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES; + ctx->context = T_measure_runtime_create( &config ); + T_assert_not_null( ctx->context ); +} + +static void RtemsTaskValPerf_Setup_Wrap( void *arg ) +{ + RtemsTaskValPerf_Context *ctx; + + ctx = arg; + RtemsTaskValPerf_Setup_Context( ctx ); +} + +static T_fixture RtemsTaskValPerf_Fixture = { + .setup = RtemsTaskValPerf_Setup_Wrap, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &RtemsTaskValPerf_Instance +}; + +/** + * @fn void T_case_body_RtemsTaskValPerf( void ) + */ +T_TEST_CASE_FIXTURE( RtemsTaskValPerf, &RtemsTaskValPerf_Fixture ) +{ + RtemsTaskValPerf_Context *ctx; + + ctx = T_fixture_context(); +} + +/** @} */ diff --git a/testsuites/validation/ts-performance-0.c b/testsuites/validation/ts-performance-0.c index 1fb15ecfce..2c35a4d7c2 100644 --- a/testsuites/validation/ts-performance-0.c +++ b/testsuites/validation/ts-performance-0.c @@ -73,6 +73,8 @@ const char rtems_test_name[] = "Performance0"; +#define CONFIGURE_MAXIMUM_PROCESSORS 4 + #include "ts-default.h" /** @} */ |