summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-05 09:24:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-12 15:09:24 +0200
commit5544439ac511b862adadcbb536042f0cb497edab (patch)
treec5f58af3d116213df48b814a48714cb980bb4e65
parent4b13420dd3ab97f984804f35c9a87809c0b3ad39 (diff)
validation: Test scheduler manager directives
-rw-r--r--spec/build/testsuites/validation/validation-0.yml7
-rw-r--r--spec/build/testsuites/validation/validation-non-smp.yml1
-rw-r--r--spec/build/testsuites/validation/validation-smp-only.yml1
-rw-r--r--testsuites/validation/tc-scheduler-add-processor.c759
-rw-r--r--testsuites/validation/tc-scheduler-get-maximum-priority.c438
-rw-r--r--testsuites/validation/tc-scheduler-get-processor-set.c525
-rw-r--r--testsuites/validation/tc-scheduler-ident-by-processor-set.c700
-rw-r--r--testsuites/validation/tc-scheduler-ident-by-processor.c554
-rw-r--r--testsuites/validation/tc-scheduler-ident.c383
-rw-r--r--testsuites/validation/tc-scheduler-non-smp.c109
-rw-r--r--testsuites/validation/tc-scheduler-remove-processor.c587
-rw-r--r--testsuites/validation/tc-scheduler-smp-only.c156
-rw-r--r--testsuites/validation/ts-default.h8
13 files changed, 4225 insertions, 3 deletions
diff --git a/spec/build/testsuites/validation/validation-0.yml b/spec/build/testsuites/validation/validation-0.yml
index 3011d27ccd..ffc070972e 100644
--- a/spec/build/testsuites/validation/validation-0.yml
+++ b/spec/build/testsuites/validation/validation-0.yml
@@ -56,6 +56,13 @@ source:
- testsuites/validation/tc-ratemon-create.c
- testsuites/validation/tc-ratemon-delete.c
- testsuites/validation/tc-ratemon-ident.c
+- testsuites/validation/tc-scheduler-add-processor.c
+- testsuites/validation/tc-scheduler-get-maximum-priority.c
+- testsuites/validation/tc-scheduler-get-processor-set.c
+- testsuites/validation/tc-scheduler-ident.c
+- testsuites/validation/tc-scheduler-ident-by-processor.c
+- testsuites/validation/tc-scheduler-ident-by-processor-set.c
+- testsuites/validation/tc-scheduler-remove-processor.c
- testsuites/validation/tc-sem-create.c
- testsuites/validation/tc-sem-ident.c
- testsuites/validation/tc-sem-obtain.c
diff --git a/spec/build/testsuites/validation/validation-non-smp.yml b/spec/build/testsuites/validation/validation-non-smp.yml
index 9c7ec5bb03..193baf7cc0 100644
--- a/spec/build/testsuites/validation/validation-non-smp.yml
+++ b/spec/build/testsuites/validation/validation-non-smp.yml
@@ -12,6 +12,7 @@ includes: []
ldflags: []
links: []
source:
+- testsuites/validation/tc-scheduler-non-smp.c
- testsuites/validation/ts-validation-non-smp.c
stlib: []
target: testsuites/validation/ts-validation-non-smp.exe
diff --git a/spec/build/testsuites/validation/validation-smp-only.yml b/spec/build/testsuites/validation/validation-smp-only.yml
index 73a77af18a..ea13c050e7 100644
--- a/spec/build/testsuites/validation/validation-smp-only.yml
+++ b/spec/build/testsuites/validation/validation-smp-only.yml
@@ -11,6 +11,7 @@ includes: []
ldflags: []
links: []
source:
+- testsuites/validation/tc-scheduler-smp-only.c
- testsuites/validation/ts-validation-smp-only.c
stlib: []
target: testsuites/validation/ts-validation-smp-only.exe
diff --git a/testsuites/validation/tc-scheduler-add-processor.c b/testsuites/validation/tc-scheduler-add-processor.c
new file mode 100644
index 0000000000..101bb09d12
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-add-processor.c
@@ -0,0 +1,759 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqAddProcessor
+ */
+
+/*
+ * 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-scheduler.h>
+#include <rtems/score/percpu.h>
+
+#include "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqAddProcessor \
+ * spec:/rtems/scheduler/req/add-processor
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Pre_HasReady_Ready,
+ RtemsSchedulerReqAddProcessor_Pre_HasReady_Empty,
+ RtemsSchedulerReqAddProcessor_Pre_HasReady_NA
+} RtemsSchedulerReqAddProcessor_Pre_HasReady;
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Pre_Id_Invalid,
+ RtemsSchedulerReqAddProcessor_Pre_Id_Scheduler,
+ RtemsSchedulerReqAddProcessor_Pre_Id_NA
+} RtemsSchedulerReqAddProcessor_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Valid,
+ RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Invalid,
+ RtemsSchedulerReqAddProcessor_Pre_CPUIndex_NA
+} RtemsSchedulerReqAddProcessor_Pre_CPUIndex;
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_Idle,
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_InUse,
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_NotOnline,
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_NotUsable,
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_NA
+} RtemsSchedulerReqAddProcessor_Pre_CPUState;
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Post_Status_Ok,
+ RtemsSchedulerReqAddProcessor_Post_Status_InvId,
+ RtemsSchedulerReqAddProcessor_Post_Status_NotConf,
+ RtemsSchedulerReqAddProcessor_Post_Status_IncStat,
+ RtemsSchedulerReqAddProcessor_Post_Status_InUse,
+ RtemsSchedulerReqAddProcessor_Post_Status_NA
+} RtemsSchedulerReqAddProcessor_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqAddProcessor_Post_Added_Yes,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop,
+ RtemsSchedulerReqAddProcessor_Post_Added_NA
+} RtemsSchedulerReqAddProcessor_Post_Added;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/add-processor test case.
+ */
+typedef struct {
+ /**
+ * @brief This member specifies the scheduler used to add the processor.
+ */
+ rtems_id scheduler_id;
+
+ /**
+ * @brief This member contains the identifier of scheduler A.
+ */
+ rtems_id scheduler_a_id;
+
+ /**
+ * @brief This member contains the identifier of scheduler B.
+ */
+ rtems_id scheduler_b_id;
+
+ /**
+ * @brief This member contains the identifier of scheduler C.
+ */
+ rtems_id scheduler_c_id;
+
+ /**
+ * @brief This member references the processor control of the processor to
+ * add.
+ */
+ Per_CPU_Control *cpu;
+
+ /**
+ * @brief This member contains the online status of the processor to add
+ * before the rtems_scheduler_add_processor() call is prepared.
+ */
+ bool online;;
+
+ /**
+ * @brief If this member is true, then the processor should be added to the
+ * scheduler B during cleanup.
+ */
+ bool add_cpu_to_scheduler_b;;
+
+ /**
+ * @brief This member provides the scheduler operation records.
+ */
+ T_scheduler_log_2 scheduler_log;;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_add_processor() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``scheduler_id`` parameter value.
+ */
+ rtems_id id;
+
+ /**
+ * @brief This member specifies if the ``cpu_index`` parameter value.
+ */
+ uint32_t cpu_index;
+
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 4 ];
+
+ /**
+ * @brief This member indicates if the test action loop is currently
+ * executed.
+ */
+ bool in_action_loop;
+} RtemsSchedulerReqAddProcessor_Context;
+
+static RtemsSchedulerReqAddProcessor_Context
+ RtemsSchedulerReqAddProcessor_Instance;
+
+static const char * const RtemsSchedulerReqAddProcessor_PreDesc_HasReady[] = {
+ "Ready",
+ "Empty",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqAddProcessor_PreDesc_Id[] = {
+ "Invalid",
+ "Scheduler",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqAddProcessor_PreDesc_CPUIndex[] = {
+ "Valid",
+ "Invalid",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqAddProcessor_PreDesc_CPUState[] = {
+ "Idle",
+ "InUse",
+ "NotOnline",
+ "NotUsable",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqAddProcessor_PreDesc[] = {
+ RtemsSchedulerReqAddProcessor_PreDesc_HasReady,
+ RtemsSchedulerReqAddProcessor_PreDesc_Id,
+ RtemsSchedulerReqAddProcessor_PreDesc_CPUIndex,
+ RtemsSchedulerReqAddProcessor_PreDesc_CPUState,
+ NULL
+};
+
+#define CPU_TO_ADD 1
+
+static void RtemsSchedulerReqAddProcessor_Pre_HasReady_Prepare(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Pre_HasReady state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Pre_HasReady_Ready: {
+ /*
+ * While the scheduler has at least one ready thread.
+ */
+ ctx->scheduler_id = ctx->scheduler_a_id;
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_HasReady_Empty: {
+ /*
+ * While the scheduler has no ready threads.
+ */
+ #if defined(RTEMS_SMP)
+ ctx->scheduler_id = ctx->scheduler_c_id;
+ #else
+ ctx->scheduler_id = ctx->scheduler_a_id;
+ #endif
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_HasReady_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Pre_Id_Prepare(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Pre_Id_Invalid: {
+ /*
+ * While the ``scheduler_id`` parameter is not associated with a
+ * scheduler.
+ */
+ ctx->id = INVALID_ID;
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_Id_Scheduler: {
+ /*
+ * While the ``scheduler_id`` parameter is associated with a scheduler.
+ */
+ ctx->id = ctx->scheduler_id;
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Prepare(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Pre_CPUIndex state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Valid: {
+ /*
+ * While the ``cpu_index`` parameter is less than the configured
+ * processor maximum.
+ */
+ #if defined(RTEMS_SMP)
+ ctx->cpu_index = CPU_TO_ADD;
+ #else
+ ctx->cpu_index = 0;
+ #endif
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Invalid: {
+ /*
+ * While the ``cpu_index`` parameter is greater than or equal to the
+ * configured processor maximum.
+ */
+ ctx->cpu_index = rtems_configuration_get_maximum_processors();
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUIndex_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Pre_CPUState_Prepare(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Pre_CPUState state
+)
+{
+ rtems_status_code sc;
+
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Pre_CPUState_Idle: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is
+ * configured to be used by a scheduler, while the processor associated
+ * with the ``cpu_index`` parameter is online, while the processor
+ * associated with the ``cpu_index`` parameter is not owned by a
+ * scheduler.
+ */
+ sc = rtems_scheduler_remove_processor(
+ ctx->scheduler_b_id,
+ CPU_TO_ADD
+ );
+ T_rsc_success( sc );
+ ctx->add_cpu_to_scheduler_b = true;
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUState_InUse: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is
+ * owned by a scheduler.
+ */
+ /* Nothing to do */
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUState_NotOnline: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is not
+ * online.
+ */
+ sc = rtems_scheduler_remove_processor(
+ ctx->scheduler_b_id,
+ CPU_TO_ADD
+ );
+ T_rsc_success( sc );
+ ctx->add_cpu_to_scheduler_b = true;
+ #if defined(RTEMS_SMP)
+ ctx->cpu->online = false;
+ #endif
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUState_NotUsable: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is not
+ * configured to be used by a scheduler.
+ */
+ ctx->cpu_index = rtems_configuration_get_maximum_processors() - 1;
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Pre_CPUState_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Post_Status_Check(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_add_processor() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Status_InvId: {
+ /*
+ * The return status of rtems_scheduler_add_processor() shall be
+ * RTEMS_INVALID_ID.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Status_NotConf: {
+ /*
+ * The return status of rtems_scheduler_add_processor() shall be
+ * RTEMS_NOT_CONFIGURED.
+ */
+ T_rsc( ctx->status, RTEMS_NOT_CONFIGURED );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Status_IncStat: {
+ /*
+ * The return status of rtems_scheduler_add_processor() shall be
+ * RTEMS_INCORRECT_STATE.
+ */
+ T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Status_InUse: {
+ /*
+ * The return status of rtems_scheduler_add_processor() shall be
+ * RTEMS_RESOURCE_IN_USE.
+ */
+ T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Post_Added_Check(
+ RtemsSchedulerReqAddProcessor_Context *ctx,
+ RtemsSchedulerReqAddProcessor_Post_Added state
+)
+{
+ rtems_status_code sc;
+ cpu_set_t set;
+ rtems_task_priority priority;
+
+ switch ( state ) {
+ case RtemsSchedulerReqAddProcessor_Post_Added_Yes: {
+ /*
+ * The processor specified by the ``cpu_index`` parameter shall be added
+ * to the scheduler specified by the ``scheduler_id`` by the
+ * rtems_scheduler_add_processor() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 2 );
+ T_eq_int(
+ ctx->scheduler_log.events[ 0 ].operation,
+ T_SCHEDULER_MAP_PRIORITY
+ );
+ T_eq_int(
+ ctx->scheduler_log.events[ 1 ].operation,
+ T_SCHEDULER_ADD_PROCESSOR
+ );
+
+ priority = GetSelfPriority();
+
+ if ( ctx->scheduler_id == ctx->scheduler_c_id ) {
+ SetSelfScheduler( ctx->scheduler_c_id, priority );
+ }
+
+ SetSelfAffinityOne( CPU_TO_ADD );
+ T_eq_u32( rtems_scheduler_get_processor(), CPU_TO_ADD );
+ SetSelfAffinityAll();
+
+ if ( ctx->scheduler_id == ctx->scheduler_c_id ) {
+ SetSelfScheduler( ctx->scheduler_a_id, priority );
+ }
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Added_Nop: {
+ /*
+ * No processor shall be added to a scheduler by the
+ * rtems_scheduler_add_processor() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 0 );
+
+ CPU_ZERO( &set );
+ CPU_SET( CPU_TO_ADD, &set );
+ sc = rtems_task_set_affinity( RTEMS_SELF, sizeof( set ), &set );
+ T_rsc( sc, RTEMS_INVALID_NUMBER );
+ break;
+ }
+
+ case RtemsSchedulerReqAddProcessor_Post_Added_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqAddProcessor_Setup(
+ RtemsSchedulerReqAddProcessor_Context *ctx
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_A_NAME,
+ &ctx->scheduler_a_id
+ );
+ T_rsc_success( sc );
+
+ #if defined(RTEMS_SMP)
+ ctx->cpu = _Per_CPU_Get_by_index( CPU_TO_ADD );
+
+ sc = rtems_scheduler_ident( TEST_SCHEDULER_B_NAME, &ctx->scheduler_b_id );
+ T_rsc_success( sc );
+
+ sc = rtems_scheduler_ident( TEST_SCHEDULER_C_NAME, &ctx->scheduler_c_id );
+ T_rsc_success( sc );
+ #else
+ ctx->scheduler_b_id = INVALID_ID;
+ ctx->scheduler_c_id = INVALID_ID;
+ #endif
+}
+
+static void RtemsSchedulerReqAddProcessor_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqAddProcessor_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqAddProcessor_Setup( ctx );
+}
+
+static void RtemsSchedulerReqAddProcessor_Prepare(
+ RtemsSchedulerReqAddProcessor_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ ctx->add_cpu_to_scheduler_b = false;
+ ctx->online = _Per_CPU_Is_processor_online( ctx->cpu );
+ #endif
+}
+
+static void RtemsSchedulerReqAddProcessor_Action(
+ RtemsSchedulerReqAddProcessor_Context *ctx
+)
+{
+ T_scheduler_log *log;
+
+ log = T_scheduler_record_2( &ctx->scheduler_log );
+ T_null( log );
+
+ ctx->status = rtems_scheduler_add_processor( ctx->id, ctx->cpu_index );
+
+ log = T_scheduler_record( NULL );
+ T_eq_ptr( &log->header, &ctx->scheduler_log.header );
+}
+
+static void RtemsSchedulerReqAddProcessor_Cleanup(
+ RtemsSchedulerReqAddProcessor_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ rtems_status_code sc;
+
+ ctx->cpu->online = ctx->online;
+
+ if ( ctx->status == RTEMS_SUCCESSFUL ) {
+ sc = rtems_scheduler_remove_processor( ctx->scheduler_id, CPU_TO_ADD );
+ T_rsc_success( sc );
+ }
+
+ if ( ctx->add_cpu_to_scheduler_b ) {
+ sc = rtems_scheduler_add_processor( ctx->scheduler_b_id, CPU_TO_ADD );
+ T_rsc_success( sc );
+ }
+ #endif
+}
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_HasReady_NA : 1;
+ uint16_t Pre_Id_NA : 1;
+ uint16_t Pre_CPUIndex_NA : 1;
+ uint16_t Pre_CPUState_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_Added : 2;
+} RtemsSchedulerReqAddProcessor_Entry;
+
+static const RtemsSchedulerReqAddProcessor_Entry
+RtemsSchedulerReqAddProcessor_Entries[] = {
+ { 0, 0, 0, 0, 1, RtemsSchedulerReqAddProcessor_Post_Status_InvId,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+ { 0, 0, 0, 0, 1, RtemsSchedulerReqAddProcessor_Post_Status_NotConf,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_InvId,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+#else
+ { 1, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_NA,
+ RtemsSchedulerReqAddProcessor_Post_Added_NA },
+#endif
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_InvId,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_Ok,
+ RtemsSchedulerReqAddProcessor_Post_Added_Yes },
+#else
+ { 1, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_NA,
+ RtemsSchedulerReqAddProcessor_Post_Added_NA },
+#endif
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_InUse,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_IncStat,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop },
+#else
+ { 1, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_NA,
+ RtemsSchedulerReqAddProcessor_Post_Added_NA },
+#endif
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_NotConf,
+ RtemsSchedulerReqAddProcessor_Post_Added_Nop }
+#else
+ { 1, 0, 0, 0, 0, RtemsSchedulerReqAddProcessor_Post_Status_NA,
+ RtemsSchedulerReqAddProcessor_Post_Added_NA }
+#endif
+};
+
+static const uint8_t
+RtemsSchedulerReqAddProcessor_Map[] = {
+ 2, 3, 2, 2, 0, 0, 0, 0, 4, 5, 6, 7, 1, 1, 1, 1, 2, 3, 2, 2, 0, 0, 0, 0, 4, 5,
+ 6, 7, 1, 1, 1, 1
+};
+
+static size_t RtemsSchedulerReqAddProcessor_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqAddProcessor_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqAddProcessor_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqAddProcessor_Fixture = {
+ .setup = RtemsSchedulerReqAddProcessor_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqAddProcessor_Scope,
+ .initial_context = &RtemsSchedulerReqAddProcessor_Instance
+};
+
+static inline RtemsSchedulerReqAddProcessor_Entry
+RtemsSchedulerReqAddProcessor_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqAddProcessor_Entries[
+ RtemsSchedulerReqAddProcessor_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqAddProcessor( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqAddProcessor,
+ &RtemsSchedulerReqAddProcessor_Fixture
+)
+{
+ RtemsSchedulerReqAddProcessor_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqAddProcessor_Pre_HasReady_Ready;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqAddProcessor_Pre_HasReady_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqAddProcessor_Pre_Id_Invalid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqAddProcessor_Pre_Id_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ for (
+ ctx->pcs[ 2 ] = RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Valid;
+ ctx->pcs[ 2 ] < RtemsSchedulerReqAddProcessor_Pre_CPUIndex_NA;
+ ++ctx->pcs[ 2 ]
+ ) {
+ for (
+ ctx->pcs[ 3 ] = RtemsSchedulerReqAddProcessor_Pre_CPUState_Idle;
+ ctx->pcs[ 3 ] < RtemsSchedulerReqAddProcessor_Pre_CPUState_NA;
+ ++ctx->pcs[ 3 ]
+ ) {
+ RtemsSchedulerReqAddProcessor_Entry entry;
+ size_t pcs[ 4 ];
+
+ entry = RtemsSchedulerReqAddProcessor_GetEntry( index );
+ ++index;
+
+ if ( entry.Skip ) {
+ continue;
+ }
+
+ memcpy( pcs, ctx->pcs, sizeof( pcs ) );
+
+ if ( entry.Pre_CPUState_NA ) {
+ ctx->pcs[ 3 ] = RtemsSchedulerReqAddProcessor_Pre_CPUState_NA;
+ }
+
+ RtemsSchedulerReqAddProcessor_Prepare( ctx );
+ RtemsSchedulerReqAddProcessor_Pre_HasReady_Prepare(
+ ctx,
+ ctx->pcs[ 0 ]
+ );
+ RtemsSchedulerReqAddProcessor_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] );
+ RtemsSchedulerReqAddProcessor_Pre_CPUIndex_Prepare(
+ ctx,
+ ctx->pcs[ 2 ]
+ );
+ RtemsSchedulerReqAddProcessor_Pre_CPUState_Prepare(
+ ctx,
+ ctx->pcs[ 3 ]
+ );
+ RtemsSchedulerReqAddProcessor_Action( ctx );
+ RtemsSchedulerReqAddProcessor_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqAddProcessor_Post_Added_Check(
+ ctx,
+ entry.Post_Added
+ );
+ RtemsSchedulerReqAddProcessor_Cleanup( ctx );
+ memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ }
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-get-maximum-priority.c b/testsuites/validation/tc-scheduler-get-maximum-priority.c
new file mode 100644
index 0000000000..22f6cfd67f
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-get-maximum-priority.c
@@ -0,0 +1,438 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqGetMaximumPriority
+ */
+
+/*
+ * 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 <limits.h>
+#include <rtems.h>
+
+#include "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqGetMaximumPriority \
+ * spec:/rtems/scheduler/req/get-maximum-priority
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Id_Scheduler,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA
+} RtemsSchedulerReqGetMaximumPriority_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Null,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA
+} RtemsSchedulerReqGetMaximumPriority_Pre_Prio;
+
+typedef enum {
+ RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok,
+ RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr,
+ RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId,
+ RtemsSchedulerReqGetMaximumPriority_Post_Status_NA
+} RtemsSchedulerReqGetMaximumPriority_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_NA
+} RtemsSchedulerReqGetMaximumPriority_Post_PrioObj;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/get-maximum-priority test
+ * case.
+ */
+typedef struct {
+ /**
+ * @brief This member contains the identifier of a scheduler.
+ */
+ rtems_id scheduler_id;
+
+ /**
+ * @brief This member provides the object referenced by the ``priority``
+ * parameter.
+ */
+ rtems_task_priority priority_obj;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_get_maximum_priority() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``scheduler_id`` parameter value.
+ */
+ rtems_id id;
+
+ /**
+ * @brief This member specifies if the ``priority`` parameter value.
+ */
+ rtems_task_priority *priority;
+
+ /**
+ * @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;
+} RtemsSchedulerReqGetMaximumPriority_Context;
+
+static RtemsSchedulerReqGetMaximumPriority_Context
+ RtemsSchedulerReqGetMaximumPriority_Instance;
+
+static const char * const RtemsSchedulerReqGetMaximumPriority_PreDesc_Id[] = {
+ "Invalid",
+ "Scheduler",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqGetMaximumPriority_PreDesc_Prio[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqGetMaximumPriority_PreDesc[] = {
+ RtemsSchedulerReqGetMaximumPriority_PreDesc_Id,
+ RtemsSchedulerReqGetMaximumPriority_PreDesc_Prio,
+ NULL
+};
+
+static void RtemsSchedulerReqGetMaximumPriority_Pre_Id_Prepare(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid: {
+ /*
+ * While the ``scheduler_id`` parameter is not associated with a
+ * scheduler.
+ */
+ ctx->id = INVALID_ID;
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Id_Scheduler: {
+ /*
+ * While the ``scheduler_id`` parameter is associated with a scheduler.
+ */
+ ctx->id = ctx->scheduler_id;
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Prepare(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx,
+ RtemsSchedulerReqGetMaximumPriority_Pre_Prio state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid: {
+ /*
+ * While the ``priority`` parameter references an object of type
+ * rtems_task_priority.
+ */
+ ctx->priority = &ctx->priority_obj;
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Null: {
+ /*
+ * While the ``priority`` parameter is equal to NULL.
+ */
+ ctx->priority = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Post_Status_Check(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx,
+ RtemsSchedulerReqGetMaximumPriority_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_get_maximum_priority() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_scheduler_get_maximum_priority() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId: {
+ /*
+ * The return status of rtems_scheduler_get_maximum_priority() shall be
+ * RTEMS_INVALID_ID.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Check(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set: {
+ /*
+ * The value of the object referenced by the ``priority`` parameter shall
+ * be set to the maximum priority value of the scheduler specified by the
+ * ``scheduler_id`` parameter after the return of the
+ * rtems_scheduler_get_maximum_priority() call.
+ */
+ #if defined(RTEMS_SMP)
+ T_eq_u32( ctx->priority_obj, INT_MAX );
+ #else
+ T_eq_u32( ctx->priority_obj, 255 );
+ #endif
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop: {
+ /*
+ * Objects referenced by the ``priority`` parameter in past calls to
+ * rtems_scheduler_get_maximum_priority() shall not be accessed by the
+ * rtems_scheduler_get_maximum_priority() call.
+ */
+ T_eq_u32( ctx->priority_obj, PRIO_INVALID );
+ break;
+ }
+
+ case RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Setup(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_A_NAME,
+ &ctx->scheduler_id
+ );
+ T_rsc_success( sc );
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqGetMaximumPriority_Setup( ctx );
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Prepare(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx
+)
+{
+ ctx->priority_obj = PRIO_INVALID;
+}
+
+static void RtemsSchedulerReqGetMaximumPriority_Action(
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx
+)
+{
+ ctx->status = rtems_scheduler_get_maximum_priority( ctx->id, ctx->priority );
+}
+
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Id_NA : 1;
+ uint8_t Pre_Prio_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_PrioObj : 2;
+} RtemsSchedulerReqGetMaximumPriority_Entry;
+
+static const RtemsSchedulerReqGetMaximumPriority_Entry
+RtemsSchedulerReqGetMaximumPriority_Entries[] = {
+ { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_InvAddr,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop },
+ { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_InvId,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Nop },
+ { 0, 0, 0, RtemsSchedulerReqGetMaximumPriority_Post_Status_Ok,
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Set }
+};
+
+static const uint8_t
+RtemsSchedulerReqGetMaximumPriority_Map[] = {
+ 1, 0, 2, 0
+};
+
+static size_t RtemsSchedulerReqGetMaximumPriority_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqGetMaximumPriority_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqGetMaximumPriority_Fixture = {
+ .setup = RtemsSchedulerReqGetMaximumPriority_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqGetMaximumPriority_Scope,
+ .initial_context = &RtemsSchedulerReqGetMaximumPriority_Instance
+};
+
+static inline RtemsSchedulerReqGetMaximumPriority_Entry
+RtemsSchedulerReqGetMaximumPriority_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqGetMaximumPriority_Entries[
+ RtemsSchedulerReqGetMaximumPriority_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqGetMaximumPriority( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqGetMaximumPriority,
+ &RtemsSchedulerReqGetMaximumPriority_Fixture
+)
+{
+ RtemsSchedulerReqGetMaximumPriority_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqGetMaximumPriority_Pre_Id_Invalid;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqGetMaximumPriority_Pre_Id_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Valid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqGetMaximumPriority_Pre_Prio_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ RtemsSchedulerReqGetMaximumPriority_Entry entry;
+
+ entry = RtemsSchedulerReqGetMaximumPriority_GetEntry( index );
+ ++index;
+
+ RtemsSchedulerReqGetMaximumPriority_Prepare( ctx );
+ RtemsSchedulerReqGetMaximumPriority_Pre_Id_Prepare( ctx, ctx->pcs[ 0 ] );
+ RtemsSchedulerReqGetMaximumPriority_Pre_Prio_Prepare(
+ ctx,
+ ctx->pcs[ 1 ]
+ );
+ RtemsSchedulerReqGetMaximumPriority_Action( ctx );
+ RtemsSchedulerReqGetMaximumPriority_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqGetMaximumPriority_Post_PrioObj_Check(
+ ctx,
+ entry.Post_PrioObj
+ );
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-get-processor-set.c b/testsuites/validation/tc-scheduler-get-processor-set.c
new file mode 100644
index 0000000000..4d37d374c1
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-get-processor-set.c
@@ -0,0 +1,525 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqGetProcessorSet
+ */
+
+/*
+ * 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 "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqGetProcessorSet \
+ * spec:/rtems/scheduler/req/get-processor-set
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqGetProcessorSet_Pre_Id_Invalid,
+ RtemsSchedulerReqGetProcessorSet_Pre_Id_Scheduler,
+ RtemsSchedulerReqGetProcessorSet_Pre_Id_NA
+} RtemsSchedulerReqGetProcessorSet_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Valid,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_TooSmall,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Askew,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_NA
+} RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize;
+
+typedef enum {
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Valid,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Null,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_NA
+} RtemsSchedulerReqGetProcessorSet_Pre_CPUSet;
+
+typedef enum {
+ RtemsSchedulerReqGetProcessorSet_Post_Status_Ok,
+ RtemsSchedulerReqGetProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqGetProcessorSet_Post_Status_InvId,
+ RtemsSchedulerReqGetProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqGetProcessorSet_Post_Status_NA
+} RtemsSchedulerReqGetProcessorSet_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Set,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Nop,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_NA
+} RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/get-processor-set test
+ * case.
+ */
+typedef struct {
+ /**
+ * @brief This member contains the identifier of a scheduler.
+ */
+ rtems_id scheduler_id;
+
+ /**
+ * @brief This member provides the object referenced by the ``cpusetsize``
+ * parameter.
+ */
+ cpu_set_t cpuset_value;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_get_processor_set() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``scheduler_id`` parameter value.
+ */
+ rtems_id id;
+
+ /**
+ * @brief This member specifies if the ``cpusetsize`` parameter value.
+ */
+ size_t cpusetsize;
+
+ /**
+ * @brief This member specifies if the ``cpuset`` parameter value.
+ */
+ cpu_set_t *cpuset;
+
+ /**
+ * @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;
+} RtemsSchedulerReqGetProcessorSet_Context;
+
+static RtemsSchedulerReqGetProcessorSet_Context
+ RtemsSchedulerReqGetProcessorSet_Instance;
+
+static const char * const RtemsSchedulerReqGetProcessorSet_PreDesc_Id[] = {
+ "Invalid",
+ "Scheduler",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqGetProcessorSet_PreDesc_CPUSetSize[] = {
+ "Valid",
+ "TooSmall",
+ "Askew",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqGetProcessorSet_PreDesc_CPUSet[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqGetProcessorSet_PreDesc[] = {
+ RtemsSchedulerReqGetProcessorSet_PreDesc_Id,
+ RtemsSchedulerReqGetProcessorSet_PreDesc_CPUSetSize,
+ RtemsSchedulerReqGetProcessorSet_PreDesc_CPUSet,
+ NULL
+};
+
+static void RtemsSchedulerReqGetProcessorSet_Pre_Id_Prepare(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx,
+ RtemsSchedulerReqGetProcessorSet_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetProcessorSet_Pre_Id_Invalid: {
+ /*
+ * While the ``scheduler_id`` parameter is not associated with a
+ * scheduler.
+ */
+ ctx->id = INVALID_ID;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_Id_Scheduler: {
+ /*
+ * While the ``scheduler_id`` parameter is associated with a scheduler.
+ */
+ ctx->id = ctx->scheduler_id;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Prepare(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Valid: {
+ /*
+ * While the ``cpusetsize`` parameter is an integral multiple of the size
+ * of long, while the ``cpusetsize`` parameter specifies a processor set
+ * which is large enough to contain the processor set of the scheduler.
+ */
+ ctx->cpusetsize = sizeof( ctx->cpuset_value );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_TooSmall: {
+ /*
+ * While the ``cpusetsize`` parameter is an integral multiple of the size
+ * of long, while the ``cpusetsize`` parameter specifies a processor set
+ * which is not large enough to contain the processor set of the
+ * scheduler.
+ */
+ ctx->cpusetsize = 0;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Askew: {
+ /*
+ * While the ``cpusetsize`` parameter is not an integral multiple of the
+ * size of long.
+ */
+ ctx->cpusetsize = SIZE_MAX;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Prepare(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx,
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSet state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Valid: {
+ /*
+ * While the ``cpuset`` parameter references an object of type cpu_set_t.
+ */
+ ctx->cpuset = &ctx->cpuset_value;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Null: {
+ /*
+ * While the ``cpuset`` parameter is equal to NULL.
+ */
+ ctx->cpuset = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Post_Status_Check(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx,
+ RtemsSchedulerReqGetProcessorSet_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqGetProcessorSet_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_get_processor_set() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_scheduler_get_processor_set() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_Status_InvId: {
+ /*
+ * The return status of rtems_scheduler_get_processor_set() shall be
+ * RTEMS_INVALID_ID.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_Status_InvSize: {
+ /*
+ * The return status of rtems_scheduler_get_processor_set() shall be
+ * RTEMS_INVALID_SIZE.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_SIZE );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Check(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar state
+)
+{
+ cpu_set_t set;
+
+ switch ( state ) {
+ case RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Set: {
+ /*
+ * The value of the object referenced by the ``cpuset`` parameter shall
+ * be set to the processor set owned by the scheduler specified by the
+ * ``scheduler_id`` parameter at some point during the call after the
+ * return of the rtems_scheduler_get_processor_set() call.
+ */
+ CPU_ZERO( &set );
+ CPU_SET( 0, &set );
+ T_eq_int( CPU_CMP( &ctx->cpuset_value, &set ), 0 );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Nop: {
+ /*
+ * Objects referenced by the ``cpuset`` parameter in past calls to
+ * rtems_scheduler_get_processor_set() shall not be accessed by the
+ * rtems_scheduler_get_processor_set() call.
+ */
+ CPU_FILL( &set );
+ T_eq_int( CPU_CMP( &ctx->cpuset_value, &set ), 0 );
+ break;
+ }
+
+ case RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Setup(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_A_NAME,
+ &ctx->scheduler_id
+ );
+ T_rsc_success( sc );
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqGetProcessorSet_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqGetProcessorSet_Setup( ctx );
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Prepare(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx
+)
+{
+ CPU_FILL( &ctx->cpuset_value );
+}
+
+static void RtemsSchedulerReqGetProcessorSet_Action(
+ RtemsSchedulerReqGetProcessorSet_Context *ctx
+)
+{
+ ctx->status = rtems_scheduler_get_processor_set(
+ ctx->id,
+ ctx->cpusetsize,
+ ctx->cpuset
+ );
+}
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_Id_NA : 1;
+ uint16_t Pre_CPUSetSize_NA : 1;
+ uint16_t Pre_CPUSet_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_CPUSetVar : 2;
+} RtemsSchedulerReqGetProcessorSet_Entry;
+
+static const RtemsSchedulerReqGetProcessorSet_Entry
+RtemsSchedulerReqGetProcessorSet_Entries[] = {
+ { 0, 0, 0, 0, RtemsSchedulerReqGetProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Nop },
+ { 0, 0, 0, 0, RtemsSchedulerReqGetProcessorSet_Post_Status_InvId,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Nop },
+ { 0, 0, 0, 0, RtemsSchedulerReqGetProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Nop },
+ { 0, 0, 0, 0, RtemsSchedulerReqGetProcessorSet_Post_Status_Ok,
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Set }
+};
+
+static const uint8_t
+RtemsSchedulerReqGetProcessorSet_Map[] = {
+ 1, 0, 1, 0, 1, 0, 3, 0, 2, 0, 2, 0
+};
+
+static size_t RtemsSchedulerReqGetProcessorSet_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqGetProcessorSet_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqGetProcessorSet_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqGetProcessorSet_Fixture = {
+ .setup = RtemsSchedulerReqGetProcessorSet_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqGetProcessorSet_Scope,
+ .initial_context = &RtemsSchedulerReqGetProcessorSet_Instance
+};
+
+static inline RtemsSchedulerReqGetProcessorSet_Entry
+RtemsSchedulerReqGetProcessorSet_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqGetProcessorSet_Entries[
+ RtemsSchedulerReqGetProcessorSet_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqGetProcessorSet( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqGetProcessorSet,
+ &RtemsSchedulerReqGetProcessorSet_Fixture
+)
+{
+ RtemsSchedulerReqGetProcessorSet_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqGetProcessorSet_Pre_Id_Invalid;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqGetProcessorSet_Pre_Id_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Valid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ for (
+ ctx->pcs[ 2 ] = RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Valid;
+ ctx->pcs[ 2 ] < RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_NA;
+ ++ctx->pcs[ 2 ]
+ ) {
+ RtemsSchedulerReqGetProcessorSet_Entry entry;
+
+ entry = RtemsSchedulerReqGetProcessorSet_GetEntry( index );
+ ++index;
+
+ RtemsSchedulerReqGetProcessorSet_Prepare( ctx );
+ RtemsSchedulerReqGetProcessorSet_Pre_Id_Prepare( ctx, ctx->pcs[ 0 ] );
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSetSize_Prepare(
+ ctx,
+ ctx->pcs[ 1 ]
+ );
+ RtemsSchedulerReqGetProcessorSet_Pre_CPUSet_Prepare(
+ ctx,
+ ctx->pcs[ 2 ]
+ );
+ RtemsSchedulerReqGetProcessorSet_Action( ctx );
+ RtemsSchedulerReqGetProcessorSet_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqGetProcessorSet_Post_CPUSetVar_Check(
+ ctx,
+ entry.Post_CPUSetVar
+ );
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-ident-by-processor-set.c b/testsuites/validation/tc-scheduler-ident-by-processor-set.c
new file mode 100644
index 0000000000..f5fd158042
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-ident-by-processor-set.c
@@ -0,0 +1,700 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqIdentByProcessorSet
+ */
+
+/*
+ * 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 "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqIdentByProcessorSet \
+ * spec:/rtems/scheduler/req/ident-by-processor-set
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_Yes,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_No,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_NA
+} RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Invalid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Valid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_NA
+} RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Valid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Invalid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_NA
+} RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Valid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Null,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_NA
+} RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Valid,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Null,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_Id_NA
+} RtemsSchedulerReqIdentByProcessorSet_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_Ok,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvName,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_IncStat,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_NA
+} RtemsSchedulerReqIdentByProcessorSet_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Set,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_NA
+} RtemsSchedulerReqIdentByProcessorSet_Post_IdVar;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/ident-by-processor-set
+ * test case.
+ */
+typedef struct {
+ /**
+ * @brief This member contains the identifier of a second scheduler.
+ */
+ rtems_id second_scheduler_id;
+
+ /**
+ * @brief This member provides the object referenced by the ``cpuset``
+ * parameter.
+ */
+ cpu_set_t cpuset_value;
+
+ /**
+ * @brief This member provides the object referenced by the ``id`` parameter.
+ */
+ rtems_id id_value;
+
+ /**
+ * @brief If this member is true, then the processor specified by the
+ * ``cpusetsize`` parameter shall be owned by a scheduler.
+ */
+ bool cpu_has_scheduler;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_ident_by_processor_set() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``cpusetsize`` parameter value.
+ */
+ size_t cpusetsize;
+
+ /**
+ * @brief This member specifies if the ``cpuset`` parameter value.
+ */
+ const cpu_set_t *cpuset;
+
+ /**
+ * @brief This member specifies if the ``id`` parameter value.
+ */
+ rtems_id *id;
+
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 5 ];
+
+ /**
+ * @brief This member indicates if the test action loop is currently
+ * executed.
+ */
+ bool in_action_loop;
+} RtemsSchedulerReqIdentByProcessorSet_Context;
+
+static RtemsSchedulerReqIdentByProcessorSet_Context
+ RtemsSchedulerReqIdentByProcessorSet_Instance;
+
+static const char * const RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUOwnedByScheduler[] = {
+ "Yes",
+ "No",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSetObj[] = {
+ "Invalid",
+ "Valid",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSetSize[] = {
+ "Valid",
+ "Invalid",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSet[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessorSet_PreDesc_Id[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqIdentByProcessorSet_PreDesc[] = {
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUOwnedByScheduler,
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSetObj,
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSetSize,
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc_CPUSet,
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc_Id,
+ NULL
+};
+
+static void
+RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_Yes: {
+ /*
+ * While the highest numbered online processor specified by the processor
+ * set is owned by a scheduler.
+ */
+ ctx->cpu_has_scheduler = true;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_No: {
+ /*
+ * While the highest numbered online processor specified by the processor
+ * set is not owned by a scheduler.
+ */
+ ctx->cpu_has_scheduler = false;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Invalid: {
+ /*
+ * While the processor set contains no online processor.
+ */
+ CPU_ZERO( &ctx->cpuset_value );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Valid: {
+ /*
+ * While the processor set contains at least one online processor.
+ */
+ CPU_ZERO( &ctx->cpuset_value );
+
+ if ( ctx->cpu_has_scheduler ) {
+ CPU_SET( 0, &ctx->cpuset_value );
+ } else {
+ CPU_SET( 1, &ctx->cpuset_value );
+ }
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Valid: {
+ /*
+ * While the ``cpusetsize`` parameter is an integral multiple of the size
+ * of long.
+ */
+ ctx->cpusetsize = sizeof( ctx->cpuset_value );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Invalid: {
+ /*
+ * While the ``cpusetsize`` parameter is not an integral multiple of the
+ * size of long.
+ */
+ ctx->cpusetsize = 1;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Valid: {
+ /*
+ * While the ``cpuset`` parameter references an object of type cpu_set_t.
+ */
+ ctx->cpuset = &ctx->cpuset_value;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Null: {
+ /*
+ * While the ``cpuset`` parameter is equal to NULL.
+ */
+ ctx->cpuset = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Valid: {
+ /*
+ * While the ``id`` parameter references an object of type rtems_id.
+ */
+ ctx->id_value = INVALID_ID;
+ ctx->id = &ctx->id_value;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Null: {
+ /*
+ * While the ``id`` parameter is equal to NULL.
+ */
+ ctx->id = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Post_Status_Check(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor_set() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor_set() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvSize: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor_set() shall be
+ * RTEMS_INVALID_SIZE.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_SIZE );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvName: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor_set() shall be
+ * RTEMS_INVALID_NAME.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_NAME );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_IncStat: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor_set() shall be
+ * RTEMS_INVALID_NAME.
+ */
+ T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Check(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Set: {
+ /*
+ * The value of the object referenced by the ``id`` parameter shall be
+ * set to the identifier of the scheduler which owned the highest
+ * numbered online processor specified by the ``cpusetsize`` ``cpuset``
+ * parameters at some point during the call after the return of the
+ * rtems_scheduler_ident_by_processor_set() call.
+ */
+ T_eq_u32( ctx->id_value, 0x0f010001 );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop: {
+ /*
+ * Objects referenced by the ``id`` parameter in past calls to
+ * rtems_scheduler_ident_by_processor_set() shall not be accessed by the
+ * rtems_scheduler_ident_by_processor_set() call.
+ */
+ T_eq_u32( ctx->id_value, INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Setup(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_B_NAME,
+ &ctx->second_scheduler_id
+ );
+ T_rsc_success( sc );
+ #else
+ ctx->second_scheduler_id = INVALID_ID;
+ #endif
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqIdentByProcessorSet_Setup( ctx );
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Prepare(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx
+)
+{
+ ctx->id_value = INVALID_ID;
+}
+
+static void RtemsSchedulerReqIdentByProcessorSet_Action(
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ rtems_status_code sc;
+
+ if ( !ctx->cpu_has_scheduler ) {
+ sc = rtems_scheduler_remove_processor( ctx->second_scheduler_id, 1 );
+ T_rsc_success( sc );
+ }
+ #endif
+
+ ctx->status = rtems_scheduler_ident_by_processor_set(
+ ctx->cpusetsize,
+ ctx->cpuset,
+ ctx->id
+ );
+
+ #if defined(RTEMS_SMP)
+ if ( !ctx->cpu_has_scheduler ) {
+ sc = rtems_scheduler_add_processor( ctx->second_scheduler_id, 1 );
+ T_rsc_success( sc );
+ }
+ #endif
+}
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_CPUOwnedByScheduler_NA : 1;
+ uint16_t Pre_CPUSetObj_NA : 1;
+ uint16_t Pre_CPUSetSize_NA : 1;
+ uint16_t Pre_CPUSet_NA : 1;
+ uint16_t Pre_Id_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_IdVar : 2;
+} RtemsSchedulerReqIdentByProcessorSet_Entry;
+
+static const RtemsSchedulerReqIdentByProcessorSet_Entry
+RtemsSchedulerReqIdentByProcessorSet_Entries[] = {
+ { 0, 1, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+#else
+ { 1, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_NA,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_NA },
+#endif
+ { 0, 1, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvName,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+ { 0, 1, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_Ok,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Set },
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_IncStat,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop },
+#else
+ { 1, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_NA,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_NA },
+#endif
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_InvSize,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Nop }
+#else
+ { 1, 0, 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessorSet_Post_Status_NA,
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_NA }
+#endif
+};
+
+static const uint8_t
+RtemsSchedulerReqIdentByProcessorSet_Map[] = {
+ 3, 0, 0, 0, 4, 0, 0, 0, 5, 1, 1, 1, 6, 1, 1, 1, 3, 0, 0, 0, 4, 0, 0, 0, 7, 2,
+ 2, 2, 8, 2, 2, 2
+};
+
+static size_t RtemsSchedulerReqIdentByProcessorSet_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqIdentByProcessorSet_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqIdentByProcessorSet_Fixture = {
+ .setup = RtemsSchedulerReqIdentByProcessorSet_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqIdentByProcessorSet_Scope,
+ .initial_context = &RtemsSchedulerReqIdentByProcessorSet_Instance
+};
+
+static inline RtemsSchedulerReqIdentByProcessorSet_Entry
+RtemsSchedulerReqIdentByProcessorSet_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqIdentByProcessorSet_Entries[
+ RtemsSchedulerReqIdentByProcessorSet_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqIdentByProcessorSet( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqIdentByProcessorSet,
+ &RtemsSchedulerReqIdentByProcessorSet_Fixture
+)
+{
+ RtemsSchedulerReqIdentByProcessorSet_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_Yes;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Invalid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ for (
+ ctx->pcs[ 2 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Valid;
+ ctx->pcs[ 2 ] < RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_NA;
+ ++ctx->pcs[ 2 ]
+ ) {
+ for (
+ ctx->pcs[ 3 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Valid;
+ ctx->pcs[ 3 ] < RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_NA;
+ ++ctx->pcs[ 3 ]
+ ) {
+ for (
+ ctx->pcs[ 4 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Valid;
+ ctx->pcs[ 4 ] < RtemsSchedulerReqIdentByProcessorSet_Pre_Id_NA;
+ ++ctx->pcs[ 4 ]
+ ) {
+ RtemsSchedulerReqIdentByProcessorSet_Entry entry;
+ size_t pcs[ 5 ];
+
+ entry = RtemsSchedulerReqIdentByProcessorSet_GetEntry( index );
+ ++index;
+
+ if ( entry.Skip ) {
+ continue;
+ }
+
+ memcpy( pcs, ctx->pcs, sizeof( pcs ) );
+
+ if ( entry.Pre_CPUOwnedByScheduler_NA ) {
+ ctx->pcs[ 0 ] = RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_NA;
+ }
+
+ RtemsSchedulerReqIdentByProcessorSet_Prepare( ctx );
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUOwnedByScheduler_Prepare(
+ ctx,
+ ctx->pcs[ 0 ]
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetObj_Prepare(
+ ctx,
+ ctx->pcs[ 1 ]
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSetSize_Prepare(
+ ctx,
+ ctx->pcs[ 2 ]
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Pre_CPUSet_Prepare(
+ ctx,
+ ctx->pcs[ 3 ]
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Pre_Id_Prepare(
+ ctx,
+ ctx->pcs[ 4 ]
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Action( ctx );
+ RtemsSchedulerReqIdentByProcessorSet_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqIdentByProcessorSet_Post_IdVar_Check(
+ ctx,
+ entry.Post_IdVar
+ );
+ memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ }
+ }
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-ident-by-processor.c b/testsuites/validation/tc-scheduler-ident-by-processor.c
new file mode 100644
index 0000000000..ec7a82a4fb
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-ident-by-processor.c
@@ -0,0 +1,554 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqIdentByProcessor
+ */
+
+/*
+ * 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 "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqIdentByProcessor \
+ * spec:/rtems/scheduler/req/ident-by-processor
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_Yes,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_No,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_NA
+} RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Invalid,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Valid,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_NA
+} RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessor_Pre_Id_Valid,
+ RtemsSchedulerReqIdentByProcessor_Pre_Id_Null,
+ RtemsSchedulerReqIdentByProcessor_Pre_Id_NA
+} RtemsSchedulerReqIdentByProcessor_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessor_Post_Status_Ok,
+ RtemsSchedulerReqIdentByProcessor_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessor_Post_Status_InvName,
+ RtemsSchedulerReqIdentByProcessor_Post_Status_IncStat,
+ RtemsSchedulerReqIdentByProcessor_Post_Status_NA
+} RtemsSchedulerReqIdentByProcessor_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Set,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_NA
+} RtemsSchedulerReqIdentByProcessor_Post_IdVar;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/ident-by-processor test
+ * case.
+ */
+typedef struct {
+ /**
+ * @brief This member contains the identifier of a second scheduler.
+ */
+ rtems_id second_scheduler_id;
+
+ /**
+ * @brief This member provides the object referenced by the ``id`` parameter.
+ */
+ rtems_id id_value;
+
+ /**
+ * @brief If this member is true, then the processor specified by the
+ * ``cpu_index`` parameter shall be owned by a scheduler.
+ */
+ bool cpu_has_scheduler;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_ident_by_processor() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``cpu_index`` parameter value.
+ */
+ uint32_t cpu_index;
+
+ /**
+ * @brief This member specifies if the ``id`` parameter value.
+ */
+ rtems_id *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;
+} RtemsSchedulerReqIdentByProcessor_Context;
+
+static RtemsSchedulerReqIdentByProcessor_Context
+ RtemsSchedulerReqIdentByProcessor_Instance;
+
+static const char * const RtemsSchedulerReqIdentByProcessor_PreDesc_CPUOwnedByScheduler[] = {
+ "Yes",
+ "No",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessor_PreDesc_CPUIndex[] = {
+ "Invalid",
+ "Valid",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdentByProcessor_PreDesc_Id[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqIdentByProcessor_PreDesc[] = {
+ RtemsSchedulerReqIdentByProcessor_PreDesc_CPUOwnedByScheduler,
+ RtemsSchedulerReqIdentByProcessor_PreDesc_CPUIndex,
+ RtemsSchedulerReqIdentByProcessor_PreDesc_Id,
+ NULL
+};
+
+static void RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_Prepare(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_Yes: {
+ /*
+ * While the processor specified by the ``cpu_index`` parameter is owned
+ * by a scheduler.
+ */
+ ctx->cpu_has_scheduler = true;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_No: {
+ /*
+ * While the processor specified by the ``cpu_index`` parameter is not
+ * owned by a scheduler.
+ */
+ ctx->cpu_has_scheduler = false;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Prepare(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx,
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Invalid: {
+ /*
+ * While the ``cpu_index`` parameter greater than or equal to the
+ * processor maximum.
+ */
+ ctx->cpu_index = rtems_scheduler_get_processor_maximum();
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Valid: {
+ /*
+ * While the ``cpu_index`` parameter less than the processor maximum.
+ */
+ if ( ctx->cpu_has_scheduler ) {
+ ctx->cpu_index = 0;
+ } else {
+ ctx->cpu_index = 1;
+ }
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Pre_Id_Prepare(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx,
+ RtemsSchedulerReqIdentByProcessor_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessor_Pre_Id_Valid: {
+ /*
+ * While the ``id`` parameter references an object of type rtems_id.
+ */
+ ctx->id_value = INVALID_ID;
+ ctx->id = &ctx->id_value;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_Id_Null: {
+ /*
+ * While the ``id`` parameter is equal to NULL.
+ */
+ ctx->id = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Post_Status_Check(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx,
+ RtemsSchedulerReqIdentByProcessor_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessor_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_Status_InvName: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor() shall be
+ * RTEMS_INVALID_NAME.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_NAME );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_Status_IncStat: {
+ /*
+ * The return status of rtems_scheduler_ident_by_processor() shall be
+ * RTEMS_INVALID_NAME.
+ */
+ T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Post_IdVar_Check(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdentByProcessor_Post_IdVar_Set: {
+ /*
+ * The value of the object referenced by the ``id`` parameter shall be
+ * set to the identifier of the scheduler which owned the processor
+ * specified by the ``cpu_index`` parameter at some point during the call
+ * after the return of the rtems_scheduler_ident_by_processor() call.
+ */
+ T_eq_ptr( ctx->id, &ctx->id_value );
+ T_eq_u32( ctx->id_value, 0x0f010001 );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop: {
+ /*
+ * Objects referenced by the ``id`` parameter in past calls to
+ * rtems_scheduler_ident_by_processor() shall not be accessed by the
+ * rtems_scheduler_ident_by_processor() call.
+ */
+ T_eq_u32( ctx->id_value, INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqIdentByProcessor_Post_IdVar_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Setup(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_B_NAME,
+ &ctx->second_scheduler_id
+ );
+ T_rsc_success( sc );
+ #else
+ ctx->second_scheduler_id = INVALID_ID;
+ #endif
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqIdentByProcessor_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqIdentByProcessor_Setup( ctx );
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Prepare(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx
+)
+{
+ ctx->id_value = INVALID_ID;
+}
+
+static void RtemsSchedulerReqIdentByProcessor_Action(
+ RtemsSchedulerReqIdentByProcessor_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ rtems_status_code sc;
+
+ if ( !ctx->cpu_has_scheduler ) {
+ sc = rtems_scheduler_remove_processor( ctx->second_scheduler_id, 1 );
+ T_rsc_success( sc );
+ }
+ #endif
+
+ ctx->status = rtems_scheduler_ident_by_processor( ctx->cpu_index, ctx->id );
+
+ #if defined(RTEMS_SMP)
+ if ( !ctx->cpu_has_scheduler ) {
+ sc = rtems_scheduler_add_processor( ctx->second_scheduler_id, 1 );
+ T_rsc_success( sc );
+ }
+ #endif
+}
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_CPUOwnedByScheduler_NA : 1;
+ uint16_t Pre_CPUIndex_NA : 1;
+ uint16_t Pre_Id_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_IdVar : 2;
+} RtemsSchedulerReqIdentByProcessor_Entry;
+
+static const RtemsSchedulerReqIdentByProcessor_Entry
+RtemsSchedulerReqIdentByProcessor_Entries[] = {
+ { 0, 1, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_InvName,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop },
+ { 0, 1, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop },
+ { 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_Ok,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Set },
+ { 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_IncStat,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop },
+#else
+ { 1, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_NA,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_NA },
+#endif
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_InvAddr,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Nop }
+#else
+ { 1, 0, 0, 0, RtemsSchedulerReqIdentByProcessor_Post_Status_NA,
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_NA }
+#endif
+};
+
+static const uint8_t
+RtemsSchedulerReqIdentByProcessor_Map[] = {
+ 0, 1, 2, 3, 0, 1, 4, 5
+};
+
+static size_t RtemsSchedulerReqIdentByProcessor_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqIdentByProcessor_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqIdentByProcessor_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqIdentByProcessor_Fixture = {
+ .setup = RtemsSchedulerReqIdentByProcessor_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqIdentByProcessor_Scope,
+ .initial_context = &RtemsSchedulerReqIdentByProcessor_Instance
+};
+
+static inline RtemsSchedulerReqIdentByProcessor_Entry
+RtemsSchedulerReqIdentByProcessor_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqIdentByProcessor_Entries[
+ RtemsSchedulerReqIdentByProcessor_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqIdentByProcessor( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqIdentByProcessor,
+ &RtemsSchedulerReqIdentByProcessor_Fixture
+)
+{
+ RtemsSchedulerReqIdentByProcessor_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_Yes;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Invalid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ for (
+ ctx->pcs[ 2 ] = RtemsSchedulerReqIdentByProcessor_Pre_Id_Valid;
+ ctx->pcs[ 2 ] < RtemsSchedulerReqIdentByProcessor_Pre_Id_NA;
+ ++ctx->pcs[ 2 ]
+ ) {
+ RtemsSchedulerReqIdentByProcessor_Entry entry;
+ size_t pcs[ 3 ];
+
+ entry = RtemsSchedulerReqIdentByProcessor_GetEntry( index );
+ ++index;
+
+ if ( entry.Skip ) {
+ continue;
+ }
+
+ memcpy( pcs, ctx->pcs, sizeof( pcs ) );
+
+ if ( entry.Pre_CPUOwnedByScheduler_NA ) {
+ ctx->pcs[ 0 ] = RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_NA;
+ }
+
+ RtemsSchedulerReqIdentByProcessor_Prepare( ctx );
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUOwnedByScheduler_Prepare(
+ ctx,
+ ctx->pcs[ 0 ]
+ );
+ RtemsSchedulerReqIdentByProcessor_Pre_CPUIndex_Prepare(
+ ctx,
+ ctx->pcs[ 1 ]
+ );
+ RtemsSchedulerReqIdentByProcessor_Pre_Id_Prepare( ctx, ctx->pcs[ 2 ] );
+ RtemsSchedulerReqIdentByProcessor_Action( ctx );
+ RtemsSchedulerReqIdentByProcessor_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqIdentByProcessor_Post_IdVar_Check(
+ ctx,
+ entry.Post_IdVar
+ );
+ memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-ident.c b/testsuites/validation/tc-scheduler-ident.c
new file mode 100644
index 0000000000..74c15a2695
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-ident.c
@@ -0,0 +1,383 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqIdent
+ */
+
+/*
+ * 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 "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqIdent \
+ * spec:/rtems/scheduler/req/ident
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqIdent_Pre_Name_Invalid,
+ RtemsSchedulerReqIdent_Pre_Name_Valid,
+ RtemsSchedulerReqIdent_Pre_Name_NA
+} RtemsSchedulerReqIdent_Pre_Name;
+
+typedef enum {
+ RtemsSchedulerReqIdent_Pre_Id_Valid,
+ RtemsSchedulerReqIdent_Pre_Id_Null,
+ RtemsSchedulerReqIdent_Pre_Id_NA
+} RtemsSchedulerReqIdent_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqIdent_Post_Status_Ok,
+ RtemsSchedulerReqIdent_Post_Status_InvAddr,
+ RtemsSchedulerReqIdent_Post_Status_InvName,
+ RtemsSchedulerReqIdent_Post_Status_NA
+} RtemsSchedulerReqIdent_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqIdent_Post_IdVar_Set,
+ RtemsSchedulerReqIdent_Post_IdVar_Nop,
+ RtemsSchedulerReqIdent_Post_IdVar_NA
+} RtemsSchedulerReqIdent_Post_IdVar;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/ident test case.
+ */
+typedef struct {
+ /**
+ * @brief This member provides the object referenced by the ``id`` parameter.
+ */
+ rtems_id id_value;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_ident() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``name`` parameter value.
+ */
+ rtems_name name;
+
+ /**
+ * @brief This member specifies if the ``id`` parameter value.
+ */
+ rtems_id *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;
+} RtemsSchedulerReqIdent_Context;
+
+static RtemsSchedulerReqIdent_Context
+ RtemsSchedulerReqIdent_Instance;
+
+static const char * const RtemsSchedulerReqIdent_PreDesc_Name[] = {
+ "Invalid",
+ "Valid",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqIdent_PreDesc_Id[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqIdent_PreDesc[] = {
+ RtemsSchedulerReqIdent_PreDesc_Name,
+ RtemsSchedulerReqIdent_PreDesc_Id,
+ NULL
+};
+
+static void RtemsSchedulerReqIdent_Pre_Name_Prepare(
+ RtemsSchedulerReqIdent_Context *ctx,
+ RtemsSchedulerReqIdent_Pre_Name state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdent_Pre_Name_Invalid: {
+ /*
+ * While the ``name`` parameter is not associated with a scheduler.
+ */
+ ctx->name = 0;
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Pre_Name_Valid: {
+ /*
+ * While the ``name`` parameter is associated with a scheduler.
+ */
+ ctx->name = TEST_SCHEDULER_A_NAME;
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Pre_Name_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdent_Pre_Id_Prepare(
+ RtemsSchedulerReqIdent_Context *ctx,
+ RtemsSchedulerReqIdent_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdent_Pre_Id_Valid: {
+ /*
+ * While the ``id`` parameter references an object of type rtems_id.
+ */
+ ctx->id = &ctx->id_value;
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Pre_Id_Null: {
+ /*
+ * While the ``id`` parameter is equal to NULL.
+ */
+ ctx->id = NULL;
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdent_Post_Status_Check(
+ RtemsSchedulerReqIdent_Context *ctx,
+ RtemsSchedulerReqIdent_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdent_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_ident() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_scheduler_ident() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Post_Status_InvName: {
+ /*
+ * The return status of rtems_scheduler_ident() shall be
+ * RTEMS_INVALID_NAME.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_NAME );
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdent_Post_IdVar_Check(
+ RtemsSchedulerReqIdent_Context *ctx,
+ RtemsSchedulerReqIdent_Post_IdVar state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqIdent_Post_IdVar_Set: {
+ /*
+ * The value of the object referenced by the ``id`` parameter shall be
+ * set to the identifier of the scheduler with the lowest scheduler index
+ * and a name equal to the ``name`` parameter after the return of the
+ * rtems_scheduler_ident() call.
+ */
+ T_eq_ptr( ctx->id, &ctx->id_value );
+ T_eq_u32( ctx->id_value, 0x0f010001 );
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Post_IdVar_Nop: {
+ /*
+ * Objects referenced by the ``id`` parameter in past calls to
+ * rtems_scheduler_ident() shall not be accessed by the
+ * rtems_scheduler_ident() call.
+ */
+ T_eq_u32( ctx->id_value, INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqIdent_Post_IdVar_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqIdent_Prepare(
+ RtemsSchedulerReqIdent_Context *ctx
+)
+{
+ ctx->id_value = INVALID_ID;
+}
+
+static void RtemsSchedulerReqIdent_Action(
+ RtemsSchedulerReqIdent_Context *ctx
+)
+{
+ ctx->status = rtems_scheduler_ident( ctx->name, ctx->id );
+}
+
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Name_NA : 1;
+ uint8_t Pre_Id_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_IdVar : 2;
+} RtemsSchedulerReqIdent_Entry;
+
+static const RtemsSchedulerReqIdent_Entry
+RtemsSchedulerReqIdent_Entries[] = {
+ { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_InvAddr,
+ RtemsSchedulerReqIdent_Post_IdVar_Nop },
+ { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_InvName,
+ RtemsSchedulerReqIdent_Post_IdVar_Nop },
+ { 0, 0, 0, RtemsSchedulerReqIdent_Post_Status_Ok,
+ RtemsSchedulerReqIdent_Post_IdVar_Set }
+};
+
+static const uint8_t
+RtemsSchedulerReqIdent_Map[] = {
+ 1, 0, 2, 0
+};
+
+static size_t RtemsSchedulerReqIdent_Scope( void *arg, char *buf, size_t n )
+{
+ RtemsSchedulerReqIdent_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope( RtemsSchedulerReqIdent_PreDesc, buf, n, ctx->pcs );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqIdent_Fixture = {
+ .setup = NULL,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqIdent_Scope,
+ .initial_context = &RtemsSchedulerReqIdent_Instance
+};
+
+static inline RtemsSchedulerReqIdent_Entry RtemsSchedulerReqIdent_GetEntry(
+ size_t index
+)
+{
+ return RtemsSchedulerReqIdent_Entries[
+ RtemsSchedulerReqIdent_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqIdent( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsSchedulerReqIdent, &RtemsSchedulerReqIdent_Fixture )
+{
+ RtemsSchedulerReqIdent_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqIdent_Pre_Name_Invalid;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqIdent_Pre_Name_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqIdent_Pre_Id_Valid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqIdent_Pre_Id_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ RtemsSchedulerReqIdent_Entry entry;
+
+ entry = RtemsSchedulerReqIdent_GetEntry( index );
+ ++index;
+
+ RtemsSchedulerReqIdent_Prepare( ctx );
+ RtemsSchedulerReqIdent_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
+ RtemsSchedulerReqIdent_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] );
+ RtemsSchedulerReqIdent_Action( ctx );
+ RtemsSchedulerReqIdent_Post_Status_Check( ctx, entry.Post_Status );
+ RtemsSchedulerReqIdent_Post_IdVar_Check( ctx, entry.Post_IdVar );
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-non-smp.c b/testsuites/validation/tc-scheduler-non-smp.c
new file mode 100644
index 0000000000..a3eec8fd2d
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-non-smp.c
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerValNonSmp
+ */
+
+/*
+ * 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 RTEMSTestCaseRtemsSchedulerValNonSmp \
+ * spec:/rtems/scheduler/val/non-smp
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNonSmp
+ *
+ * @brief This test case collection provides validation test cases for non-SMP
+ * requirements of the @ref RTEMSAPIClassicScheduler.
+ *
+ * This test case performs the following actions:
+ *
+ * - Check that calling rtems_scheduler_get_processor() is a constant
+ * expression which evaluates to zero.
+ *
+ * - Check that calling rtems_scheduler_get_processor_maximum() is a constant
+ * expression which evaluates to zero.
+ *
+ * @{
+ */
+
+/**
+ * @brief Check that calling rtems_scheduler_get_processor() is a constant
+ * expression which evaluates to zero.
+ */
+static void RtemsSchedulerValNonSmp_Action_0( void )
+{
+ RTEMS_STATIC_ASSERT( rtems_scheduler_get_processor() == 0, GET_PROCESSOR );
+}
+
+/**
+ * @brief Check that calling rtems_scheduler_get_processor_maximum() is a
+ * constant expression which evaluates to zero.
+ */
+static void RtemsSchedulerValNonSmp_Action_1( void )
+{
+ RTEMS_STATIC_ASSERT(
+ rtems_scheduler_get_processor_maximum() == 1,
+ GET_PROCESSOR_MAXIMUM
+ );
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerValNonSmp( void )
+ */
+T_TEST_CASE( RtemsSchedulerValNonSmp )
+{
+ RtemsSchedulerValNonSmp_Action_0();
+ RtemsSchedulerValNonSmp_Action_1();
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-remove-processor.c b/testsuites/validation/tc-scheduler-remove-processor.c
new file mode 100644
index 0000000000..aa13d1e2ee
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-remove-processor.c
@@ -0,0 +1,587 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerReqRemoveProcessor
+ */
+
+/*
+ * 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-scheduler.h>
+
+#include "ts-config.h"
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsSchedulerReqRemoveProcessor \
+ * spec:/rtems/scheduler/req/remove-processor
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState_Idle,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState_InUse,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NotOwned,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NA
+} RtemsSchedulerReqRemoveProcessor_Pre_CPUState;
+
+typedef enum {
+ RtemsSchedulerReqRemoveProcessor_Pre_Id_Invalid,
+ RtemsSchedulerReqRemoveProcessor_Pre_Id_Scheduler,
+ RtemsSchedulerReqRemoveProcessor_Pre_Id_NA
+} RtemsSchedulerReqRemoveProcessor_Pre_Id;
+
+typedef enum {
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Valid,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Invalid,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_NA
+} RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex;
+
+typedef enum {
+ RtemsSchedulerReqRemoveProcessor_Post_Status_Ok,
+ RtemsSchedulerReqRemoveProcessor_Post_Status_InvId,
+ RtemsSchedulerReqRemoveProcessor_Post_Status_InvNum,
+ RtemsSchedulerReqRemoveProcessor_Post_Status_InUse,
+ RtemsSchedulerReqRemoveProcessor_Post_Status_NA
+} RtemsSchedulerReqRemoveProcessor_Post_Status;
+
+typedef enum {
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Yes,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_NA
+} RtemsSchedulerReqRemoveProcessor_Post_Removed;
+
+/**
+ * @brief Test context for spec:/rtems/scheduler/req/remove-processor test
+ * case.
+ */
+typedef struct {
+ /**
+ * @brief This member specifies the scheduler used to add the processor.
+ */
+ rtems_id scheduler_id;
+
+ /**
+ * @brief This member contains the identifier of scheduler A.
+ */
+ rtems_id scheduler_a_id;
+
+ /**
+ * @brief This member contains the identifier of scheduler B.
+ */
+ rtems_id scheduler_b_id;
+
+ /**
+ * @brief This member specifies the processor to remove.
+ */
+ uint32_t cpu_to_remove;
+
+ /**
+ * @brief This member provides the scheduler operation records.
+ */
+ T_scheduler_log_2 scheduler_log;;
+
+ /**
+ * @brief This member contains the return value of the
+ * rtems_scheduler_remove_processor() call.
+ */
+ rtems_status_code status;
+
+ /**
+ * @brief This member specifies if the ``scheduler_id`` parameter value.
+ */
+ rtems_id id;
+
+ /**
+ * @brief This member specifies if the ``cpu_index`` parameter value.
+ */
+ uint32_t cpu_index;
+
+ /**
+ * @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;
+} RtemsSchedulerReqRemoveProcessor_Context;
+
+static RtemsSchedulerReqRemoveProcessor_Context
+ RtemsSchedulerReqRemoveProcessor_Instance;
+
+static const char * const RtemsSchedulerReqRemoveProcessor_PreDesc_CPUState[] = {
+ "Idle",
+ "InUse",
+ "NotOwned",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqRemoveProcessor_PreDesc_Id[] = {
+ "Invalid",
+ "Scheduler",
+ "NA"
+};
+
+static const char * const RtemsSchedulerReqRemoveProcessor_PreDesc_CPUIndex[] = {
+ "Valid",
+ "Invalid",
+ "NA"
+};
+
+static const char * const * const RtemsSchedulerReqRemoveProcessor_PreDesc[] = {
+ RtemsSchedulerReqRemoveProcessor_PreDesc_CPUState,
+ RtemsSchedulerReqRemoveProcessor_PreDesc_Id,
+ RtemsSchedulerReqRemoveProcessor_PreDesc_CPUIndex,
+ NULL
+};
+
+static void RtemsSchedulerReqRemoveProcessor_Pre_CPUState_Prepare(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState state
+)
+{
+ ctx->scheduler_id = ctx->scheduler_a_id;
+ ctx->cpu_to_remove = 0;
+
+ switch ( state ) {
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUState_Idle: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is
+ * owned by the scheduler specified by the ``scheduler_id`` parameter,
+ * while no task exists which uses the scheduler as its home scheduler
+ * and the affinity set of this task would require the processor
+ * specified by the ``cpu_index`` parameter.
+ */
+ ctx->scheduler_id = ctx->scheduler_b_id;
+ ctx->cpu_to_remove = 1;
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUState_InUse: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is
+ * owned by the scheduler specified by the ``scheduler_id`` parameter,
+ * while the scheduler is used by at least one task as its home scheduler
+ * and the affinity set of this task requires the processor specified by
+ * the ``cpu_index`` parameter.
+ */
+ /* Set by prologue */
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NotOwned: {
+ /*
+ * While the processor associated with the ``cpu_index`` parameter is not
+ * owned by the scheduler specified by the ``scheduler_id`` parameter.
+ */
+ ctx->scheduler_id = ctx->scheduler_a_id;
+ ctx->cpu_to_remove = 1;
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Pre_Id_Prepare(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx,
+ RtemsSchedulerReqRemoveProcessor_Pre_Id state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqRemoveProcessor_Pre_Id_Invalid: {
+ /*
+ * While the ``scheduler_id`` parameter is not associated with a
+ * scheduler.
+ */
+ ctx->id = INVALID_ID;
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_Id_Scheduler: {
+ /*
+ * While the ``scheduler_id`` parameter is associated with a scheduler.
+ */
+ ctx->id = ctx->scheduler_id;
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_Id_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Prepare(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx,
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Valid: {
+ /*
+ * While the ``cpu_index`` parameter is less than the configured
+ * processor maximum.
+ */
+ ctx->cpu_index = ctx->cpu_to_remove;
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Invalid: {
+ /*
+ * While the ``cpu_index`` parameter is greater than or equal to the
+ * configured processor maximum.
+ */
+ ctx->cpu_index = rtems_configuration_get_maximum_processors();
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Post_Status_Check(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx,
+ RtemsSchedulerReqRemoveProcessor_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqRemoveProcessor_Post_Status_Ok: {
+ /*
+ * The return status of rtems_scheduler_remove_processor() shall be
+ * RTEMS_SUCCESSFUL.
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Status_InvId: {
+ /*
+ * The return status of rtems_scheduler_remove_processor() shall be
+ * RTEMS_INVALID_ID.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ID );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Status_InvNum: {
+ /*
+ * The return status of rtems_scheduler_remove_processor() shall be
+ * RTEMS_INVALID_NUMBER.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Status_InUse: {
+ /*
+ * The return status of rtems_scheduler_remove_processor() shall be
+ * RTEMS_RESOURCE_IN_USE.
+ */
+ T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Post_Removed_Check(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed state
+)
+{
+ switch ( state ) {
+ case RtemsSchedulerReqRemoveProcessor_Post_Removed_Yes: {
+ /*
+ * The processor specified by the ``cpu_index`` parameter shall be
+ * removed from the scheduler specified by the ``scheduler_id`` by the
+ * rtems_scheduler_remove_processor() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 1 );
+ T_eq_int(
+ ctx->scheduler_log.events[ 0 ].operation,
+ T_SCHEDULER_REMOVE_PROCESSOR
+ );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop: {
+ /*
+ * No processor shall be removed from a scheduler by the
+ * rtems_scheduler_remove_processor() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 0 );
+ break;
+ }
+
+ case RtemsSchedulerReqRemoveProcessor_Post_Removed_NA:
+ break;
+ }
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Setup(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_ident(
+ TEST_SCHEDULER_A_NAME,
+ &ctx->scheduler_a_id
+ );
+ T_rsc_success( sc );
+
+ #if defined(RTEMS_SMP)
+ sc = rtems_scheduler_ident( TEST_SCHEDULER_B_NAME, &ctx->scheduler_b_id );
+ T_rsc_success( sc );
+ #else
+ ctx->scheduler_b_id = INVALID_ID;
+ #endif
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Setup_Wrap( void *arg )
+{
+ RtemsSchedulerReqRemoveProcessor_Context *ctx;
+
+ ctx = arg;
+ ctx->in_action_loop = false;
+ RtemsSchedulerReqRemoveProcessor_Setup( ctx );
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Action(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx
+)
+{
+ T_scheduler_log *log;
+
+ log = T_scheduler_record_2( &ctx->scheduler_log );
+ T_null( log );
+
+ ctx->status = rtems_scheduler_remove_processor( ctx->id, ctx->cpu_index );
+
+ log = T_scheduler_record( NULL );
+ T_eq_ptr( &log->header, &ctx->scheduler_log.header );
+}
+
+static void RtemsSchedulerReqRemoveProcessor_Cleanup(
+ RtemsSchedulerReqRemoveProcessor_Context *ctx
+)
+{
+ #if defined(RTEMS_SMP)
+ if ( ctx->status == RTEMS_SUCCESSFUL ) {
+ rtems_status_code sc;
+
+ sc = rtems_scheduler_add_processor(
+ ctx->scheduler_id,
+ ctx->cpu_to_remove
+ );
+ T_rsc_success( sc );
+ }
+ #endif
+}
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_CPUState_NA : 1;
+ uint16_t Pre_Id_NA : 1;
+ uint16_t Pre_CPUIndex_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_Removed : 2;
+} RtemsSchedulerReqRemoveProcessor_Entry;
+
+static const RtemsSchedulerReqRemoveProcessor_Entry
+RtemsSchedulerReqRemoveProcessor_Entries[] = {
+ { 0, 1, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_InvId,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop },
+ { 0, 1, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_InvNum,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_Ok,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Yes },
+#else
+ { 1, 0, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_NA,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_NA },
+#endif
+ { 0, 0, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_InUse,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop },
+#if defined(RTEMS_SMP)
+ { 0, 0, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_InvNum,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Nop }
+#else
+ { 1, 0, 0, 0, RtemsSchedulerReqRemoveProcessor_Post_Status_NA,
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_NA }
+#endif
+};
+
+static const uint8_t
+RtemsSchedulerReqRemoveProcessor_Map[] = {
+ 0, 0, 2, 1, 0, 0, 3, 1, 0, 0, 4, 1
+};
+
+static size_t RtemsSchedulerReqRemoveProcessor_Scope(
+ void *arg,
+ char *buf,
+ size_t n
+)
+{
+ RtemsSchedulerReqRemoveProcessor_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->in_action_loop ) {
+ return T_get_scope(
+ RtemsSchedulerReqRemoveProcessor_PreDesc,
+ buf,
+ n,
+ ctx->pcs
+ );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsSchedulerReqRemoveProcessor_Fixture = {
+ .setup = RtemsSchedulerReqRemoveProcessor_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsSchedulerReqRemoveProcessor_Scope,
+ .initial_context = &RtemsSchedulerReqRemoveProcessor_Instance
+};
+
+static inline RtemsSchedulerReqRemoveProcessor_Entry
+RtemsSchedulerReqRemoveProcessor_GetEntry( size_t index )
+{
+ return RtemsSchedulerReqRemoveProcessor_Entries[
+ RtemsSchedulerReqRemoveProcessor_Map[ index ]
+ ];
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerReqRemoveProcessor( void )
+ */
+T_TEST_CASE_FIXTURE(
+ RtemsSchedulerReqRemoveProcessor,
+ &RtemsSchedulerReqRemoveProcessor_Fixture
+)
+{
+ RtemsSchedulerReqRemoveProcessor_Context *ctx;
+ size_t index;
+
+ ctx = T_fixture_context();
+ ctx->in_action_loop = true;
+ index = 0;
+
+ for (
+ ctx->pcs[ 0 ] = RtemsSchedulerReqRemoveProcessor_Pre_CPUState_Idle;
+ ctx->pcs[ 0 ] < RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NA;
+ ++ctx->pcs[ 0 ]
+ ) {
+ for (
+ ctx->pcs[ 1 ] = RtemsSchedulerReqRemoveProcessor_Pre_Id_Invalid;
+ ctx->pcs[ 1 ] < RtemsSchedulerReqRemoveProcessor_Pre_Id_NA;
+ ++ctx->pcs[ 1 ]
+ ) {
+ for (
+ ctx->pcs[ 2 ] = RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Valid;
+ ctx->pcs[ 2 ] < RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_NA;
+ ++ctx->pcs[ 2 ]
+ ) {
+ RtemsSchedulerReqRemoveProcessor_Entry entry;
+ size_t pcs[ 3 ];
+
+ entry = RtemsSchedulerReqRemoveProcessor_GetEntry( index );
+ ++index;
+
+ if ( entry.Skip ) {
+ continue;
+ }
+
+ memcpy( pcs, ctx->pcs, sizeof( pcs ) );
+
+ if ( entry.Pre_CPUState_NA ) {
+ ctx->pcs[ 0 ] = RtemsSchedulerReqRemoveProcessor_Pre_CPUState_NA;
+ }
+
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUState_Prepare(
+ ctx,
+ ctx->pcs[ 0 ]
+ );
+ RtemsSchedulerReqRemoveProcessor_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] );
+ RtemsSchedulerReqRemoveProcessor_Pre_CPUIndex_Prepare(
+ ctx,
+ ctx->pcs[ 2 ]
+ );
+ RtemsSchedulerReqRemoveProcessor_Action( ctx );
+ RtemsSchedulerReqRemoveProcessor_Post_Status_Check(
+ ctx,
+ entry.Post_Status
+ );
+ RtemsSchedulerReqRemoveProcessor_Post_Removed_Check(
+ ctx,
+ entry.Post_Removed
+ );
+ RtemsSchedulerReqRemoveProcessor_Cleanup( ctx );
+ memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-scheduler-smp-only.c b/testsuites/validation/tc-scheduler-smp-only.c
new file mode 100644
index 0000000000..9b95040fed
--- /dev/null
+++ b/testsuites/validation/tc-scheduler-smp-only.c
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsSchedulerValSmpOnly
+ */
+
+/*
+ * 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 RTEMSTestCaseRtemsSchedulerValSmpOnly \
+ * spec:/rtems/scheduler/val/smp-only
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationSmpOnly
+ *
+ * @brief This test case collection provides validation test cases for SMP-only
+ * requirements of the @ref RTEMSAPIClassicScheduler.
+ *
+ * This test case performs the following actions:
+ *
+ * - Call rtems_scheduler_get_processor() on all online processors and check
+ * the returned value.
+ *
+ * - Call rtems_scheduler_get_processor_maximum() and check the returned value.
+ *
+ * - Check that the returned value is greater than or equal to one.
+ *
+ * - Check that the returned value is less than or equal to
+ * rtems_configuration_get_maximum_processors().
+ *
+ * @{
+ */
+
+/**
+ * @brief Call rtems_scheduler_get_processor() on all online processors and
+ * check the returned value.
+ */
+static void RtemsSchedulerValSmpOnly_Action_0( void )
+{
+ rtems_id scheduler_id;
+ rtems_task_priority priority;
+ uint32_t cpu_index;
+ uint32_t cpu_max;
+
+ scheduler_id = GetSelfScheduler();
+ priority = GetSelfPriority();
+ cpu_max = rtems_scheduler_get_processor_maximum();
+ T_step_ge_u32( 0, cpu_max, 1 );
+
+ for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
+ rtems_status_code sc;
+ rtems_id id;
+
+ sc = rtems_scheduler_ident_by_processor( cpu_index, &id );
+ T_quiet_rsc_success( sc );
+
+ SetSelfScheduler( id, priority );
+ SetSelfAffinityOne( cpu_index );
+
+ T_quiet_eq_u32( rtems_scheduler_get_processor(), cpu_index );
+
+ SetSelfAffinityAll();
+ }
+
+ SetSelfScheduler( scheduler_id, priority );
+}
+
+/**
+ * @brief Call rtems_scheduler_get_processor_maximum() and check the returned
+ * value.
+ */
+static void RtemsSchedulerValSmpOnly_Action_1( void )
+{
+ uint32_t cpu_max;
+
+ cpu_max = rtems_scheduler_get_processor_maximum();
+
+ /*
+ * Check that the returned value is greater than or equal to one.
+ */
+ T_step_ge_u32( 1, cpu_max, 1 );
+
+ /*
+ * Check that the returned value is less than or equal to
+ * rtems_configuration_get_maximum_processors().
+ */
+ T_step_le_u32(
+ 2,
+ cpu_max,
+ rtems_configuration_get_maximum_processors()
+ );
+}
+
+/**
+ * @fn void T_case_body_RtemsSchedulerValSmpOnly( void )
+ */
+T_TEST_CASE( RtemsSchedulerValSmpOnly )
+{
+ T_plan( 3 );
+
+ RtemsSchedulerValSmpOnly_Action_0();
+ RtemsSchedulerValSmpOnly_Action_1();
+}
+
+/** @} */
diff --git a/testsuites/validation/ts-default.h b/testsuites/validation/ts-default.h
index 6e48ce4980..dcfd5d31a7 100644
--- a/testsuites/validation/ts-default.h
+++ b/testsuites/validation/ts-default.h
@@ -211,11 +211,11 @@ T_scheduler_operations[ CONFIGURE_MAXIMUM_PROCESSORS ] = {
#include <rtems/scheduler.h>
-RTEMS_SCHEDULER_EDF_SMP(a);
+RTEMS_SCHEDULER_EDF_SMP( a );
-RTEMS_SCHEDULER_EDF_SMP(b);
+RTEMS_SCHEDULER_EDF_SMP( b );
-RTEMS_SCHEDULER_EDF_SMP(c);
+RTEMS_SCHEDULER_EDF_SMP( c );
RTEMS_SCHEDULER_EDF_SMP( d );
@@ -256,6 +256,8 @@ T_scheduler_operations[ CONFIGURE_MAXIMUM_PROCESSORS ] = {
#define SCHEDULER_PRIORITY_ENTRY_POINTS T_SCHEDULER_ENTRY_POINTS
+#define CONFIGURE_SCHEDULER_NAME TEST_SCHEDULER_A_NAME
+
#endif /* RTEMS_SMP */
#define CONFIGURE_INIT