summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--spec/build/testsuites/validation/validation-no-clock-0.yml5
-rw-r--r--testsuites/validation/tc-clock-get-tod.c470
-rw-r--r--testsuites/validation/tc-clock-get-uptime.c339
-rw-r--r--testsuites/validation/tc-clock-nanosleep.c1039
-rw-r--r--testsuites/validation/tc-clock-set.c839
-rw-r--r--testsuites/validation/tc-clock.c134
6 files changed, 2826 insertions, 0 deletions
diff --git a/spec/build/testsuites/validation/validation-no-clock-0.yml b/spec/build/testsuites/validation/validation-no-clock-0.yml
index 3b456b8132..65e09fbc7c 100644
--- a/spec/build/testsuites/validation/validation-no-clock-0.yml
+++ b/spec/build/testsuites/validation/validation-no-clock-0.yml
@@ -20,6 +20,11 @@ source:
- testsuites/validation/tc-barrier-wait.c
- testsuites/validation/tc-basedefs.c
- testsuites/validation/tc-basedefs-pendant.c
+- testsuites/validation/tc-clock.c
+- testsuites/validation/tc-clock-get-tod.c
+- testsuites/validation/tc-clock-get-uptime.c
+- testsuites/validation/tc-clock-nanosleep.c
+- testsuites/validation/tc-clock-set.c
- testsuites/validation/tc-score-fatal.c
- testsuites/validation/tr-mtx-seize-try.c
- testsuites/validation/tr-mtx-seize-wait.c
diff --git a/testsuites/validation/tc-clock-get-tod.c b/testsuites/validation/tc-clock-get-tod.c
new file mode 100644
index 0000000000..f3ff4a3830
--- /dev/null
+++ b/testsuites/validation/tc-clock-get-tod.c
@@ -0,0 +1,470 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsClockReqGetTod
+ */
+
+/*
+ * 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 RTEMSTestCaseRtemsClockReqGetTod spec:/rtems/clock/req/get-tod
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsClockReqGetTod_Pre_ToD_Arbitrary,
+ RtemsClockReqGetTod_Pre_ToD_Leap4,
+ RtemsClockReqGetTod_Pre_ToD_Leap400,
+ RtemsClockReqGetTod_Pre_ToD_Youngest,
+ RtemsClockReqGetTod_Pre_ToD_Oldest,
+ RtemsClockReqGetTod_Pre_ToD_NotSet,
+ RtemsClockReqGetTod_Pre_ToD_NA
+} RtemsClockReqGetTod_Pre_ToD;
+
+typedef enum {
+ RtemsClockReqGetTod_Pre_Param_Valid,
+ RtemsClockReqGetTod_Pre_Param_Null,
+ RtemsClockReqGetTod_Pre_Param_NA
+} RtemsClockReqGetTod_Pre_Param;
+
+typedef enum {
+ RtemsClockReqGetTod_Post_Status_Ok,
+ RtemsClockReqGetTod_Post_Status_InvAddr,
+ RtemsClockReqGetTod_Post_Status_NotDef,
+ RtemsClockReqGetTod_Post_Status_NA
+} RtemsClockReqGetTod_Post_Status;
+
+typedef enum {
+ RtemsClockReqGetTod_Post_Value_TimeOfDay,
+ RtemsClockReqGetTod_Post_Value_Unchanged,
+ RtemsClockReqGetTod_Post_Value_NA
+} RtemsClockReqGetTod_Post_Value;
+
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_ToD_NA : 1;
+ uint8_t Pre_Param_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_Value : 2;
+} RtemsClockReqGetTod_Entry;
+
+/**
+ * @brief Test context for spec:/rtems/clock/req/get-tod test case.
+ */
+typedef struct {
+ rtems_status_code set_tod_status;
+
+ rtems_time_of_day set_tod_value;
+
+ rtems_time_of_day *get_tod_ref;
+
+ rtems_time_of_day get_tod_value;
+
+ rtems_status_code get_tod_status;
+
+ bool isDef;
+
+ struct {
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 2 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ RtemsClockReqGetTod_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
+} RtemsClockReqGetTod_Context;
+
+static RtemsClockReqGetTod_Context
+ RtemsClockReqGetTod_Instance;
+
+static const char * const RtemsClockReqGetTod_PreDesc_ToD[] = {
+ "Arbitrary",
+ "Leap4",
+ "Leap400",
+ "Youngest",
+ "Oldest",
+ "NotSet",
+ "NA"
+};
+
+static const char * const RtemsClockReqGetTod_PreDesc_Param[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsClockReqGetTod_PreDesc[] = {
+ RtemsClockReqGetTod_PreDesc_ToD,
+ RtemsClockReqGetTod_PreDesc_Param,
+ NULL
+};
+
+static void RtemsClockReqGetTod_Pre_ToD_Prepare(
+ RtemsClockReqGetTod_Context *ctx,
+ RtemsClockReqGetTod_Pre_ToD state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetTod_Pre_ToD_Arbitrary: {
+ /*
+ * While the CLOCK_REALTIME indicates an arbitrary valid date and time
+ * between 1988-01-01T00:00:00.000000000Z and
+ * 2514-05-30T01:53:03.999999999Z.
+ */
+ ctx->set_tod_value =
+ (rtems_time_of_day) { 2023, 12, 27, 6, 7, 8,
+ rtems_clock_get_ticks_per_second() / 4 };
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_Leap4: {
+ /*
+ * While the CLOCK_REALTIME indicates a date for a leap year with the
+ * value of 29th of February.
+ */
+ ctx->set_tod_value =
+ (rtems_time_of_day) { 2096, 2, 29, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_Leap400: {
+ /*
+ * While the CLOCK_REALTIME indicates a date for a leap year with the
+ * value of 29th of February.
+ */
+ ctx->set_tod_value =
+ (rtems_time_of_day) { 2000, 2, 29, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_Youngest: {
+ /*
+ * While the CLOCK_REALTIME indicates the youngest date and time accepted
+ * (1988-01-01T00:00:00.000000000Z).
+ */
+ ctx->set_tod_value =
+ (rtems_time_of_day) { 1988, 1, 1, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_Oldest: {
+ /*
+ * While the CLOCK_REALTIME indicates the oldest date and time accepted
+ * (2099-12-31T23:59:59.999999999Z).
+ */
+ ctx->set_tod_value =
+ (rtems_time_of_day) { 2099, 12, 31, 23, 59, 59,
+ rtems_clock_get_ticks_per_second() - 1 };
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_NotSet: {
+ /*
+ * While the CLOCK_REALTIME has not been set before.
+ */
+ ctx->isDef = false;
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_ToD_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetTod_Pre_Param_Prepare(
+ RtemsClockReqGetTod_Context *ctx,
+ RtemsClockReqGetTod_Pre_Param state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetTod_Pre_Param_Valid: {
+ /*
+ * While the ``time_of_day`` parameter references an object of type
+ * rtems_time_of_day.
+ */
+ ctx->get_tod_ref = &ctx->get_tod_value;
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_Param_Null: {
+ /*
+ * While the ``time_of_day`` parameter is NULL.
+ */
+ ctx->get_tod_ref = NULL;
+ break;
+ }
+
+ case RtemsClockReqGetTod_Pre_Param_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetTod_Post_Status_Check(
+ RtemsClockReqGetTod_Context *ctx,
+ RtemsClockReqGetTod_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetTod_Post_Status_Ok: {
+ /*
+ * The return status of rtems_clock_get_tod() shall be RTEMS_SUCCESSFUL
+ */
+ T_rsc_success( ctx->set_tod_status );
+ T_rsc_success( ctx->get_tod_status );
+ break;
+ }
+
+ case RtemsClockReqGetTod_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_clock_get_tod() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->get_tod_status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsClockReqGetTod_Post_Status_NotDef: {
+ /*
+ * The return status of rtems_clock_get_tod() shall be RTEMS_NOT_DEFINED.
+ */
+ T_rsc( ctx->get_tod_status, RTEMS_NOT_DEFINED );
+ break;
+ }
+
+ case RtemsClockReqGetTod_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetTod_Post_Value_Check(
+ RtemsClockReqGetTod_Context *ctx,
+ RtemsClockReqGetTod_Post_Value state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetTod_Post_Value_TimeOfDay: {
+ /*
+ * The value of the object referenced by the ``time_of_day`` parameter
+ * shall be set to the value of the CLOCK_REALTIME at a point in time
+ * during the call to rtems_clock_get_tod().
+ */
+ T_eq_ptr( ctx->get_tod_ref, &ctx->get_tod_value );
+ T_eq_u32( ctx->get_tod_value.year, ctx->set_tod_value.year );
+ T_eq_u32( ctx->get_tod_value.month, ctx->set_tod_value.month );
+ T_eq_u32( ctx->get_tod_value.day, ctx->set_tod_value.day );
+ T_eq_u32( ctx->get_tod_value.hour, ctx->set_tod_value.hour );
+ T_eq_u32( ctx->get_tod_value.minute, ctx->set_tod_value.minute );
+ T_eq_u32( ctx->get_tod_value.second, ctx->set_tod_value.second );
+ /* rtems_clock_set() or rtems_clock_get_tod() cause an error of 1 tick */
+ T_ge_u32( ctx->get_tod_value.ticks + 1, ctx->set_tod_value.ticks );
+ T_le_u32( ctx->get_tod_value.ticks, ctx->set_tod_value.ticks );
+ break;
+ }
+
+ case RtemsClockReqGetTod_Post_Value_Unchanged: {
+ /*
+ * Object referenced by the ``time_of_day`` parameter in past call to
+ * rtems_clock_get_tod() shall not be modified by the
+ * rtems_clock_get_tod() call.
+ */
+ T_eq_u32( ctx->get_tod_value.year, 1 );
+ T_eq_u32( ctx->get_tod_value.month, 1 );
+ T_eq_u32( ctx->get_tod_value.day, 1 );
+ T_eq_u32( ctx->get_tod_value.hour, 1 );
+ T_eq_u32( ctx->get_tod_value.minute, 1 );
+ T_eq_u32( ctx->get_tod_value.second, 1 );
+ T_eq_u32( ctx->get_tod_value.ticks, 1 );
+ break;
+ }
+
+ case RtemsClockReqGetTod_Post_Value_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetTod_Prepare( RtemsClockReqGetTod_Context *ctx )
+{
+ ctx->get_tod_value = (rtems_time_of_day) { 1, 1, 1, 1, 1, 1, 1 };
+ ctx->get_tod_ref = &ctx->get_tod_value;
+ ctx->set_tod_value = (rtems_time_of_day) { 2023, 4, 5, 6, 7, 8, 0 };
+ ctx->isDef = true;
+}
+
+static void RtemsClockReqGetTod_Action( RtemsClockReqGetTod_Context *ctx )
+{
+ if ( ctx->isDef ) {
+ ctx->set_tod_status = rtems_clock_set( &ctx->set_tod_value );
+ ctx->get_tod_status = rtems_clock_get_tod( ctx->get_tod_ref );
+ } else {
+ UnsetClock();
+ ctx->get_tod_status = rtems_clock_get_tod( ctx->get_tod_ref );
+ }
+}
+
+static void RtemsClockReqGetTod_Cleanup( RtemsClockReqGetTod_Context *ctx )
+{
+ UnsetClock();
+}
+
+static const RtemsClockReqGetTod_Entry
+RtemsClockReqGetTod_Entries[] = {
+ { 0, 0, 0, RtemsClockReqGetTod_Post_Status_InvAddr,
+ RtemsClockReqGetTod_Post_Value_Unchanged },
+ { 0, 0, 0, RtemsClockReqGetTod_Post_Status_Ok,
+ RtemsClockReqGetTod_Post_Value_TimeOfDay },
+ { 0, 0, 0, RtemsClockReqGetTod_Post_Status_NotDef,
+ RtemsClockReqGetTod_Post_Value_Unchanged }
+};
+
+static const uint8_t
+RtemsClockReqGetTod_Map[] = {
+ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0
+};
+
+static size_t RtemsClockReqGetTod_Scope( void *arg, char *buf, size_t n )
+{
+ RtemsClockReqGetTod_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsClockReqGetTod_PreDesc, buf, n, ctx->Map.pcs );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsClockReqGetTod_Fixture = {
+ .setup = NULL,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsClockReqGetTod_Scope,
+ .initial_context = &RtemsClockReqGetTod_Instance
+};
+
+static inline RtemsClockReqGetTod_Entry RtemsClockReqGetTod_PopEntry(
+ RtemsClockReqGetTod_Context *ctx
+)
+{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
+ return RtemsClockReqGetTod_Entries[
+ RtemsClockReqGetTod_Map[ index ]
+ ];
+}
+
+static void RtemsClockReqGetTod_TestVariant( RtemsClockReqGetTod_Context *ctx )
+{
+ RtemsClockReqGetTod_Pre_ToD_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsClockReqGetTod_Pre_Param_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsClockReqGetTod_Action( ctx );
+ RtemsClockReqGetTod_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ RtemsClockReqGetTod_Post_Value_Check( ctx, ctx->Map.entry.Post_Value );
+}
+
+/**
+ * @fn void T_case_body_RtemsClockReqGetTod( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsClockReqGetTod, &RtemsClockReqGetTod_Fixture )
+{
+ RtemsClockReqGetTod_Context *ctx;
+
+ ctx = T_fixture_context();
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
+
+ for (
+ ctx->Map.pcs[ 0 ] = RtemsClockReqGetTod_Pre_ToD_Arbitrary;
+ ctx->Map.pcs[ 0 ] < RtemsClockReqGetTod_Pre_ToD_NA;
+ ++ctx->Map.pcs[ 0 ]
+ ) {
+ for (
+ ctx->Map.pcs[ 1 ] = RtemsClockReqGetTod_Pre_Param_Valid;
+ ctx->Map.pcs[ 1 ] < RtemsClockReqGetTod_Pre_Param_NA;
+ ++ctx->Map.pcs[ 1 ]
+ ) {
+ ctx->Map.entry = RtemsClockReqGetTod_PopEntry( ctx );
+ RtemsClockReqGetTod_Prepare( ctx );
+ RtemsClockReqGetTod_TestVariant( ctx );
+ RtemsClockReqGetTod_Cleanup( ctx );
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-clock-get-uptime.c b/testsuites/validation/tc-clock-get-uptime.c
new file mode 100644
index 0000000000..ebc8b2de74
--- /dev/null
+++ b/testsuites/validation/tc-clock-get-uptime.c
@@ -0,0 +1,339 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsClockReqGetUptime
+ */
+
+/*
+ * 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 RTEMSTestCaseRtemsClockReqGetUptime \
+ * spec:/rtems/clock/req/get-uptime
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsClockReqGetUptime_Pre_Uptime_Valid,
+ RtemsClockReqGetUptime_Pre_Uptime_Null,
+ RtemsClockReqGetUptime_Pre_Uptime_NA
+} RtemsClockReqGetUptime_Pre_Uptime;
+
+typedef enum {
+ RtemsClockReqGetUptime_Post_Status_Ok,
+ RtemsClockReqGetUptime_Post_Status_InvAddr,
+ RtemsClockReqGetUptime_Post_Status_NA
+} RtemsClockReqGetUptime_Post_Status;
+
+typedef enum {
+ RtemsClockReqGetUptime_Post_Uptime_Set,
+ RtemsClockReqGetUptime_Post_Uptime_Unchanged,
+ RtemsClockReqGetUptime_Post_Uptime_NA
+} RtemsClockReqGetUptime_Post_Uptime;
+
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Uptime_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_Uptime : 2;
+} RtemsClockReqGetUptime_Entry;
+
+/**
+ * @brief Test context for spec:/rtems/clock/req/get-uptime test case.
+ */
+typedef struct {
+ rtems_status_code status;
+
+ struct timespec *uptime;
+
+ struct timespec uptime_value;
+
+ struct {
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 1 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ RtemsClockReqGetUptime_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
+} RtemsClockReqGetUptime_Context;
+
+static RtemsClockReqGetUptime_Context
+ RtemsClockReqGetUptime_Instance;
+
+static const char * const RtemsClockReqGetUptime_PreDesc_Uptime[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const RtemsClockReqGetUptime_PreDesc[] = {
+ RtemsClockReqGetUptime_PreDesc_Uptime,
+ NULL
+};
+
+static void RtemsClockReqGetUptime_Pre_Uptime_Prepare(
+ RtemsClockReqGetUptime_Context *ctx,
+ RtemsClockReqGetUptime_Pre_Uptime state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetUptime_Pre_Uptime_Valid: {
+ /*
+ * While the ``uptime`` parameter references an object of type struct
+ * timespec.
+ */
+ ctx->uptime = &ctx->uptime_value;
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Pre_Uptime_Null: {
+ /*
+ * While the ``uptime`` parameter is NULL.
+ */
+ ctx->uptime = NULL;
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Pre_Uptime_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetUptime_Post_Status_Check(
+ RtemsClockReqGetUptime_Context *ctx,
+ RtemsClockReqGetUptime_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetUptime_Post_Status_Ok: {
+ /*
+ * The return status of rtems_clock_get_uptime() shall be
+ * RTEMS_SUCCESSFUL
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_clock_get_uptime() shall be
+ * RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetUptime_Post_Uptime_Check(
+ RtemsClockReqGetUptime_Context *ctx,
+ RtemsClockReqGetUptime_Post_Uptime state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqGetUptime_Post_Uptime_Set: {
+ /*
+ * The value of the object referenced by the ``uptime`` parameter shall
+ * be set to seconds and nanoseconds elapsed since a point in time during
+ * the system initialization and a point in time during the call of
+ * rtems_clock_get_uptime() using CLOCK_MONOTONIC as result of the
+ * rtems_clock_get_uptime() call.
+ */
+ T_eq_ptr( ctx->uptime, &ctx->uptime_value );
+ T_ge_i64( ctx->uptime_value.tv_sec, 0LL );
+ T_ge_long( ctx->uptime_value.tv_nsec, 0L );
+ T_lt_long( ctx->uptime_value.tv_nsec, 1000000000L );
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Post_Uptime_Unchanged: {
+ /*
+ * Objects referenced by the ``uptime`` parameter in calls to
+ * rtems_clock_get_uptime() shall not be modified by the
+ * rtems_clock_get_uptime() call.
+ */
+ T_null( ctx->uptime );
+ break;
+ }
+
+ case RtemsClockReqGetUptime_Post_Uptime_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqGetUptime_Setup( RtemsClockReqGetUptime_Context *ctx )
+{
+ ctx->uptime_value.tv_sec = -1;
+ ctx->uptime_value.tv_nsec = -1;
+}
+
+static void RtemsClockReqGetUptime_Setup_Wrap( void *arg )
+{
+ RtemsClockReqGetUptime_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ RtemsClockReqGetUptime_Setup( ctx );
+}
+
+static void RtemsClockReqGetUptime_Action(
+ RtemsClockReqGetUptime_Context *ctx
+)
+{
+ ctx->status = rtems_clock_get_uptime( ctx->uptime );
+}
+
+static const RtemsClockReqGetUptime_Entry
+RtemsClockReqGetUptime_Entries[] = {
+ { 0, 0, RtemsClockReqGetUptime_Post_Status_Ok,
+ RtemsClockReqGetUptime_Post_Uptime_Set },
+ { 0, 0, RtemsClockReqGetUptime_Post_Status_InvAddr,
+ RtemsClockReqGetUptime_Post_Uptime_Unchanged }
+};
+
+static const uint8_t
+RtemsClockReqGetUptime_Map[] = {
+ 0, 1
+};
+
+static size_t RtemsClockReqGetUptime_Scope( void *arg, char *buf, size_t n )
+{
+ RtemsClockReqGetUptime_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsClockReqGetUptime_PreDesc, buf, n, ctx->Map.pcs );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsClockReqGetUptime_Fixture = {
+ .setup = RtemsClockReqGetUptime_Setup_Wrap,
+ .stop = NULL,
+ .teardown = NULL,
+ .scope = RtemsClockReqGetUptime_Scope,
+ .initial_context = &RtemsClockReqGetUptime_Instance
+};
+
+static inline RtemsClockReqGetUptime_Entry RtemsClockReqGetUptime_PopEntry(
+ RtemsClockReqGetUptime_Context *ctx
+)
+{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
+ return RtemsClockReqGetUptime_Entries[
+ RtemsClockReqGetUptime_Map[ index ]
+ ];
+}
+
+static void RtemsClockReqGetUptime_TestVariant(
+ RtemsClockReqGetUptime_Context *ctx
+)
+{
+ RtemsClockReqGetUptime_Pre_Uptime_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsClockReqGetUptime_Action( ctx );
+ RtemsClockReqGetUptime_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ RtemsClockReqGetUptime_Post_Uptime_Check( ctx, ctx->Map.entry.Post_Uptime );
+}
+
+/**
+ * @fn void T_case_body_RtemsClockReqGetUptime( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsClockReqGetUptime, &RtemsClockReqGetUptime_Fixture )
+{
+ RtemsClockReqGetUptime_Context *ctx;
+
+ ctx = T_fixture_context();
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
+
+ for (
+ ctx->Map.pcs[ 0 ] = RtemsClockReqGetUptime_Pre_Uptime_Valid;
+ ctx->Map.pcs[ 0 ] < RtemsClockReqGetUptime_Pre_Uptime_NA;
+ ++ctx->Map.pcs[ 0 ]
+ ) {
+ ctx->Map.entry = RtemsClockReqGetUptime_PopEntry( ctx );
+ RtemsClockReqGetUptime_TestVariant( ctx );
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-clock-nanosleep.c b/testsuites/validation/tc-clock-nanosleep.c
new file mode 100644
index 0000000000..2857d8e274
--- /dev/null
+++ b/testsuites/validation/tc-clock-nanosleep.c
@@ -0,0 +1,1039 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseCReqClockNanosleep
+ */
+
+/*
+ * 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 <errno.h>
+#include <limits.h>
+#include <rtems.h>
+#include <time.h>
+#include <rtems/test-scheduler.h>
+#include <rtems/score/timecounter.h>
+
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseCReqClockNanosleep spec:/c/req/clock-nanosleep
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
+ *
+ * @{
+ */
+
+typedef enum {
+ CReqClockNanosleep_Pre_ClockId_Monotonic,
+ CReqClockNanosleep_Pre_ClockId_Realtime,
+ CReqClockNanosleep_Pre_ClockId_Invalid,
+ CReqClockNanosleep_Pre_ClockId_NA
+} CReqClockNanosleep_Pre_ClockId;
+
+typedef enum {
+ CReqClockNanosleep_Pre_Abstime_Yes,
+ CReqClockNanosleep_Pre_Abstime_No,
+ CReqClockNanosleep_Pre_Abstime_NA
+} CReqClockNanosleep_Pre_Abstime;
+
+typedef enum {
+ CReqClockNanosleep_Pre_RQTp_Valid,
+ CReqClockNanosleep_Pre_RQTp_Null,
+ CReqClockNanosleep_Pre_RQTp_NA
+} CReqClockNanosleep_Pre_RQTp;
+
+typedef enum {
+ CReqClockNanosleep_Pre_RQTpNSec_Valid,
+ CReqClockNanosleep_Pre_RQTpNSec_Invalid,
+ CReqClockNanosleep_Pre_RQTpNSec_NA
+} CReqClockNanosleep_Pre_RQTpNSec;
+
+typedef enum {
+ CReqClockNanosleep_Pre_RQTpSec_Negative,
+ CReqClockNanosleep_Pre_RQTpSec_FarFuture,
+ CReqClockNanosleep_Pre_RQTpSec_Future,
+ CReqClockNanosleep_Pre_RQTpSec_PastOrNow,
+ CReqClockNanosleep_Pre_RQTpSec_NA
+} CReqClockNanosleep_Pre_RQTpSec;
+
+typedef enum {
+ CReqClockNanosleep_Pre_RMTp_Valid,
+ CReqClockNanosleep_Pre_RMTp_Null,
+ CReqClockNanosleep_Pre_RMTp_NA
+} CReqClockNanosleep_Pre_RMTp;
+
+typedef enum {
+ CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Status_ENOTSUP,
+ CReqClockNanosleep_Post_Status_EINVAL,
+ CReqClockNanosleep_Post_Status_NA
+} CReqClockNanosleep_Post_Status;
+
+typedef enum {
+ CReqClockNanosleep_Post_Timer_Inactive,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Timer_NA
+} CReqClockNanosleep_Post_Timer;
+
+typedef enum {
+ CReqClockNanosleep_Post_Expire_Last,
+ CReqClockNanosleep_Post_Expire_Absolute,
+ CReqClockNanosleep_Post_Expire_Relative,
+ CReqClockNanosleep_Post_Expire_NA
+} CReqClockNanosleep_Post_Expire;
+
+typedef enum {
+ CReqClockNanosleep_Post_Scheduler_Block,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_Scheduler_Nop,
+ CReqClockNanosleep_Post_Scheduler_NA
+} CReqClockNanosleep_Post_Scheduler;
+
+typedef enum {
+ CReqClockNanosleep_Post_RMTp_Zero,
+ CReqClockNanosleep_Post_RMTp_Nop,
+ CReqClockNanosleep_Post_RMTp_NA
+} CReqClockNanosleep_Post_RMTp;
+
+typedef struct {
+ uint32_t Skip : 1;
+ uint32_t Pre_ClockId_NA : 1;
+ uint32_t Pre_Abstime_NA : 1;
+ uint32_t Pre_RQTp_NA : 1;
+ uint32_t Pre_RQTpNSec_NA : 1;
+ uint32_t Pre_RQTpSec_NA : 1;
+ uint32_t Pre_RMTp_NA : 1;
+ uint32_t Post_Status : 2;
+ uint32_t Post_Timer : 2;
+ uint32_t Post_Expire : 2;
+ uint32_t Post_Scheduler : 2;
+ uint32_t Post_RMTp : 2;
+} CReqClockNanosleep_Entry;
+
+/**
+ * @brief Test context for spec:/c/req/clock-nanosleep test case.
+ */
+typedef struct {
+ /**
+ * @brief This member provides the scheduler operation records.
+ */
+ T_scheduler_log_4 scheduler_log;;
+
+ /**
+ * @brief This member contains the CLOCK_REALTIME value before the
+ * clock_nanosleep() call.
+ */
+ struct timespec now_realtime;;
+
+ /**
+ * @brief This member contains the CLOCK_MONOTONIC value before the
+ * clock_nanosleep() call.
+ */
+ struct timespec now_monotonic;;
+
+ /**
+ * @brief This member contains the worker task identifier.
+ */
+ rtems_id worker_id;;
+
+ /**
+ * @brief This member contains the timer information of the worker task.
+ */
+ TaskTimerInfo timer_info;;
+
+ /**
+ * @brief This member provides the object referenced by the ``rqtp``
+ * parameter.
+ */
+ struct timespec rqtp_obj;
+
+ /**
+ * @brief This member provides the object referenced by the ``rmtp``
+ * parameter.
+ */
+ struct timespec rmtp_obj;
+
+ /**
+ * @brief This member contains the return value of the clock_nanosleep()
+ * call.
+ */
+ int status;
+
+ /**
+ * @brief This member specifies the ``clock_id`` parameter value.
+ */
+ clockid_t clock_id;
+
+ /**
+ * @brief This member specifies the ``flags`` parameter value.
+ */
+ int flags;
+
+ /**
+ * @brief This member specifies the ``rqtp`` parameter value.
+ */
+ const struct timespec *rqtp;
+
+ /**
+ * @brief This member specifies the ``rmtp`` parameter value.
+ */
+ struct timespec *rmtp;
+
+ struct {
+ /**
+ * @brief This member defines the pre-condition indices for the next
+ * action.
+ */
+ size_t pci[ 6 ];
+
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 6 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ CReqClockNanosleep_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
+} CReqClockNanosleep_Context;
+
+static CReqClockNanosleep_Context
+ CReqClockNanosleep_Instance;
+
+static const char * const CReqClockNanosleep_PreDesc_ClockId[] = {
+ "Monotonic",
+ "Realtime",
+ "Invalid",
+ "NA"
+};
+
+static const char * const CReqClockNanosleep_PreDesc_Abstime[] = {
+ "Yes",
+ "No",
+ "NA"
+};
+
+static const char * const CReqClockNanosleep_PreDesc_RQTp[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const CReqClockNanosleep_PreDesc_RQTpNSec[] = {
+ "Valid",
+ "Invalid",
+ "NA"
+};
+
+static const char * const CReqClockNanosleep_PreDesc_RQTpSec[] = {
+ "Negative",
+ "FarFuture",
+ "Future",
+ "PastOrNow",
+ "NA"
+};
+
+static const char * const CReqClockNanosleep_PreDesc_RMTp[] = {
+ "Valid",
+ "Null",
+ "NA"
+};
+
+static const char * const * const CReqClockNanosleep_PreDesc[] = {
+ CReqClockNanosleep_PreDesc_ClockId,
+ CReqClockNanosleep_PreDesc_Abstime,
+ CReqClockNanosleep_PreDesc_RQTp,
+ CReqClockNanosleep_PreDesc_RQTpNSec,
+ CReqClockNanosleep_PreDesc_RQTpSec,
+ CReqClockNanosleep_PreDesc_RMTp,
+ NULL
+};
+
+typedef CReqClockNanosleep_Context Context;
+
+static void Worker( rtems_task_argument arg )
+{
+ Context *ctx;
+
+ ctx = (Context *) arg;
+
+ while ( true ) {
+ T_scheduler_log *log;
+
+ SuspendSelf();
+
+ log = T_scheduler_record_4( &ctx->scheduler_log );
+ T_null( log );
+
+ _Timecounter_Getnanotime( &ctx->now_realtime );
+ _Timecounter_Getnanouptime( &ctx->now_monotonic );
+
+ ctx->status = clock_nanosleep(
+ ctx->clock_id,
+ ctx->flags,
+ ctx->rqtp,
+ ctx->rmtp
+ );
+
+ (void) T_scheduler_record( NULL );
+ }
+}
+
+static void CReqClockNanosleep_Pre_ClockId_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_ClockId state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_ClockId_Monotonic: {
+ /*
+ * While the ``clock_id`` parameter is equal to CLOCK_MONOTONIC.
+ */
+ ctx->clock_id = CLOCK_MONOTONIC;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_ClockId_Realtime: {
+ /*
+ * While the ``clock_id`` parameter is equal to CLOCK_REALTIME.
+ */
+ ctx->clock_id = CLOCK_REALTIME;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_ClockId_Invalid: {
+ /*
+ * While the ``clock_id`` parameter is an invalid clock identifier.
+ */
+ ctx->clock_id = INT_MAX;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_ClockId_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Pre_Abstime_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_Abstime state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_Abstime_Yes: {
+ /*
+ * While the ``flags`` parameter indicates an absolute time.
+ */
+ ctx->flags |= TIMER_ABSTIME;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_Abstime_No: {
+ /*
+ * While the ``flags`` parameter does not indicate an absolute time.
+ */
+ /* This is the default */
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_Abstime_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Pre_RQTp_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_RQTp state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_RQTp_Valid: {
+ /*
+ * While the ``rqtp`` parameter references an object of type struct
+ * timespec.
+ */
+ ctx->rqtp = &ctx->rqtp_obj;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTp_Null: {
+ /*
+ * While the ``rqtp parameter is equal to NULL.
+ */
+ ctx->rqtp = NULL;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTp_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Pre_RQTpNSec_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_RQTpNSec state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_RQTpNSec_Valid: {
+ /*
+ * While the ``tv_nsec`` member of the object referenced by the ``rqtp``
+ * parameter is a valid nanoseconds value.
+ */
+ ctx->rqtp_obj.tv_nsec = 999999999;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpNSec_Invalid: {
+ /*
+ * While the ``tv_nsec`` member of the object referenced by the ``rqtp``
+ * parameter is an invalid nanoseconds value.
+ */
+ ctx->rqtp_obj.tv_nsec = -1;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpNSec_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Pre_RQTpSec_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_RQTpSec state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_RQTpSec_Negative: {
+ /*
+ * While the ``tv_sec`` member of the object referenced by the ``rqtp``
+ * parameter is negative.
+ */
+ ctx->rqtp_obj.tv_sec = -238479;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpSec_FarFuture: {
+ /*
+ * While the ``tv_sec`` member of the object referenced by the ``rqtp``
+ * parameter specifies a time point which is past the implementation
+ * limit.
+ */
+ ctx->rqtp_obj.tv_sec = INT64_MAX;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpSec_Future: {
+ /*
+ * While the ``tv_sec`` member of the object referenced by the ``rqtp``
+ * parameter specifies a time point which is after the current time of
+ * the clock specified by the ``clock_id`` parameter and is within the
+ * implementation limits.
+ */
+ ctx->rqtp_obj.tv_sec = 1621322302;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpSec_PastOrNow: {
+ /*
+ * While the ``tv_sec`` member of the object referenced by the ``rqtp``
+ * parameter is non-negative and specifies a time point which is before
+ * or at the current time of the clock specified by the ``clock_id``
+ * parameter.
+ */
+ ctx->rqtp_obj.tv_sec = 0;
+
+ if ( ctx->rqtp_obj.tv_nsec == 999999999 ) {
+ ctx->rqtp_obj.tv_nsec = 0;
+ }
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RQTpSec_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Pre_RMTp_Prepare(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Pre_RMTp state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Pre_RMTp_Valid: {
+ /*
+ * While the ``rmtp`` parameter references an object of type struct
+ * timespec.
+ */
+ ctx->rmtp = &ctx->rmtp_obj;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RMTp_Null: {
+ /*
+ * While the ``rmtp parameter is equal to NULL.
+ */
+ ctx->rmtp = NULL;
+ break;
+ }
+
+ case CReqClockNanosleep_Pre_RMTp_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Post_Status_Check(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Post_Status state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Post_Status_Zero: {
+ /*
+ * The return value of clock_nanosleep() shall be equal to zero.
+ */
+ T_eq_int( ctx->status, 0 );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Status_ENOTSUP: {
+ /*
+ * The return value of clock_nanosleep() shall be equal to ENOTSUP.
+ */
+ T_eq_int( ctx->status, ENOTSUP );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Status_EINVAL: {
+ /*
+ * The return value of clock_nanosleep() shall be equal to EINVAL.
+ */
+ T_eq_int( ctx->status, EINVAL );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Status_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Post_Timer_Check(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Post_Timer state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Post_Timer_Inactive: {
+ /*
+ * The timer of the calling task shall be inactive.
+ */
+ T_eq_int( ctx->timer_info.state, TASK_TIMER_INACTIVE );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Timer_Monotonic: {
+ /*
+ * The timer of the calling task shall be active using the
+ * CLOCK_MONOTONIC.
+ */
+ T_eq_int( ctx->timer_info.state, TASK_TIMER_MONOTONIC );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Timer_Realtime: {
+ /*
+ * The timer of the calling task shall be active using the
+ * CLOCK_REALTIME.
+ */
+ T_eq_int( ctx->timer_info.state, TASK_TIMER_REALTIME );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Timer_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Post_Expire_Check(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Post_Expire state
+)
+{
+ struct timespec expire;
+
+ switch ( state ) {
+ case CReqClockNanosleep_Post_Expire_Last: {
+ /*
+ * The timer of the calling task shall expire at the last valid time
+ * point of the clock specified by the ``clock_id`` parameter.
+ */
+ T_eq_u64( ctx->timer_info.expire_ticks, 0xffffffffffffffff );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Expire_Absolute: {
+ /*
+ * The timer of the calling task shall expire at the time point specified
+ * by the ``rqtp`` parameter.
+ */
+ T_eq_i64( ctx->timer_info.expire_timespec.tv_sec, ctx->rqtp_obj.tv_sec );
+ T_eq_long(
+ ctx->timer_info.expire_timespec.tv_nsec,
+ ctx->rqtp_obj.tv_nsec
+ );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Expire_Relative: {
+ /*
+ * The timer of the calling task shall expire at the time point specified
+ * by the sum of the current time of the clock specified by the
+ * ``clock_id`` parameter and the interval specified by the ``rqtp``
+ * parameter.
+ */
+ if ( ctx->clock_id == CLOCK_REALTIME ) {
+ expire = ctx->now_realtime;
+ } else {
+ expire = ctx->now_monotonic;
+ }
+
+ expire.tv_sec += ctx->rqtp_obj.tv_sec;
+ expire.tv_nsec += ctx->rqtp_obj.tv_nsec;
+
+ if ( expire.tv_nsec >= 1000000000 ) {
+ ++expire.tv_sec;
+ expire.tv_nsec -= 1000000000;
+ }
+
+ T_eq_i64( ctx->timer_info.expire_timespec.tv_sec, expire.tv_sec );
+ T_eq_long( ctx->timer_info.expire_timespec.tv_nsec, expire.tv_nsec );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Expire_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Post_Scheduler_Check(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Post_Scheduler state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Post_Scheduler_Block: {
+ /*
+ * The calling task shall be blocked by the scheduler exactly once by the
+ * clock_nanosleep() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 1 );
+ T_eq_int(
+ ctx->scheduler_log.events[ 0 ].operation,
+ T_SCHEDULER_BLOCK
+ );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Scheduler_BlockUnblock: {
+ /*
+ * The calling task shall be blocked exactly once by the scheduler and
+ * then unblocked in the same thread dispatch critical section by the
+ * clock_nanosleep() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 2 );
+ T_eq_int(
+ ctx->scheduler_log.events[ 0 ].operation,
+ T_SCHEDULER_BLOCK
+ );
+ T_eq_int(
+ ctx->scheduler_log.events[ 1 ].operation,
+ T_SCHEDULER_UNBLOCK
+ );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Scheduler_Nop: {
+ /*
+ * The calling task shall not be altered by the scheduler by the
+ * clock_nanosleep() call.
+ */
+ T_eq_sz( ctx->scheduler_log.header.recorded, 0 );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_Scheduler_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Post_RMTp_Check(
+ CReqClockNanosleep_Context *ctx,
+ CReqClockNanosleep_Post_RMTp state
+)
+{
+ switch ( state ) {
+ case CReqClockNanosleep_Post_RMTp_Zero: {
+ /*
+ * The object referenced by the ``rmtp`` parameter shall be cleared to
+ * zero after the return of the clock_nanosleep() call.
+ */
+ T_eq_i64( ctx->rmtp_obj.tv_sec, 0 );
+ T_eq_long( ctx->rmtp_obj.tv_nsec, 0 );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_RMTp_Nop: {
+ /*
+ * Objects referenced by the ``rmtp`` parameter in past calls to
+ * clock_nanosleep() shall not be accessed by the clock_nanosleep() call.
+ */
+ T_eq_i64( ctx->rmtp_obj.tv_sec, -1 );
+ T_eq_long( ctx->rmtp_obj.tv_nsec, -1 );
+ break;
+ }
+
+ case CReqClockNanosleep_Post_RMTp_NA:
+ break;
+ }
+}
+
+static void CReqClockNanosleep_Setup( CReqClockNanosleep_Context *ctx )
+{
+ rtems_time_of_day now = { 1988, 1, 1, 0, 0, 0, 0 };
+ T_rsc_success( rtems_clock_set( &now ) );
+ SetSelfPriority( PRIO_NORMAL );
+ ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
+ StartTask( ctx->worker_id, Worker, ctx );
+}
+
+static void CReqClockNanosleep_Setup_Wrap( void *arg )
+{
+ CReqClockNanosleep_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ CReqClockNanosleep_Setup( ctx );
+}
+
+static void CReqClockNanosleep_Teardown( CReqClockNanosleep_Context *ctx )
+{
+ DeleteTask( ctx->worker_id );
+ RestoreRunnerPriority();
+}
+
+static void CReqClockNanosleep_Teardown_Wrap( void *arg )
+{
+ CReqClockNanosleep_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ CReqClockNanosleep_Teardown( ctx );
+}
+
+static void CReqClockNanosleep_Prepare( CReqClockNanosleep_Context *ctx )
+{
+ ctx->status = -1;
+ ctx->flags = 0;
+ ctx->rmtp_obj.tv_sec = -1;
+ ctx->rmtp_obj.tv_nsec = -1;
+}
+
+static void CReqClockNanosleep_Action( CReqClockNanosleep_Context *ctx )
+{
+ ResumeTask( ctx->worker_id );
+ (void) T_scheduler_record( NULL );
+ GetTaskTimerInfo( ctx->worker_id, &ctx->timer_info );
+ ClockTick();
+ FinalClockTick();
+}
+
+static const CReqClockNanosleep_Entry
+CReqClockNanosleep_Entries[] = {
+ { 0, 0, 0, 0, 1, 1, 0, CReqClockNanosleep_Post_Status_EINVAL,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 1, 1, 0, CReqClockNanosleep_Post_Status_ENOTSUP,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_Nop, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_EINVAL,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 1, 1, 0, CReqClockNanosleep_Post_Status_EINVAL,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_ENOTSUP,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_Nop, CReqClockNanosleep_Post_RMTp_Nop },
+ { 1, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_NA,
+ CReqClockNanosleep_Post_Timer_NA, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_NA, CReqClockNanosleep_Post_RMTp_NA },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_EINVAL,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Expire_Last,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Expire_Last,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Expire_Absolute,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Inactive, CReqClockNanosleep_Post_Expire_NA,
+ CReqClockNanosleep_Post_Scheduler_BlockUnblock,
+ CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Expire_Absolute,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Expire_Last,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Expire_Relative,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Monotonic,
+ CReqClockNanosleep_Post_Expire_Relative,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Expire_Last,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Expire_Relative,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Zero },
+ { 0, 0, 0, 0, 0, 0, 0, CReqClockNanosleep_Post_Status_Zero,
+ CReqClockNanosleep_Post_Timer_Realtime,
+ CReqClockNanosleep_Post_Expire_Relative,
+ CReqClockNanosleep_Post_Scheduler_Block, CReqClockNanosleep_Post_RMTp_Nop }
+};
+
+static const uint8_t
+CReqClockNanosleep_Map[] = {
+ 6, 6, 8, 8, 10, 10, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 7, 2, 13, 8, 14, 15, 11, 6, 7, 2, 7, 2, 7, 2, 7, 2, 3,
+ 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 6, 6, 9, 9, 12, 12, 6, 6, 2, 2,
+ 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 2, 16,
+ 9, 17, 18, 11, 6, 7, 2, 7, 2, 7, 2, 7, 2, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0,
+ 3, 0, 3, 0, 4, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 5, 5, 5, 5,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+static size_t CReqClockNanosleep_Scope( void *arg, char *buf, size_t n )
+{
+ CReqClockNanosleep_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( CReqClockNanosleep_PreDesc, buf, n, ctx->Map.pcs );
+ }
+
+ return 0;
+}
+
+static T_fixture CReqClockNanosleep_Fixture = {
+ .setup = CReqClockNanosleep_Setup_Wrap,
+ .stop = NULL,
+ .teardown = CReqClockNanosleep_Teardown_Wrap,
+ .scope = CReqClockNanosleep_Scope,
+ .initial_context = &CReqClockNanosleep_Instance
+};
+
+static inline CReqClockNanosleep_Entry CReqClockNanosleep_PopEntry(
+ CReqClockNanosleep_Context *ctx
+)
+{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
+ return CReqClockNanosleep_Entries[
+ CReqClockNanosleep_Map[ index ]
+ ];
+}
+
+static void CReqClockNanosleep_SetPreConditionStates(
+ CReqClockNanosleep_Context *ctx
+)
+{
+ ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
+ ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
+ ctx->Map.pcs[ 2 ] = ctx->Map.pci[ 2 ];
+
+ if ( ctx->Map.entry.Pre_RQTpNSec_NA ) {
+ ctx->Map.pcs[ 3 ] = CReqClockNanosleep_Pre_RQTpNSec_NA;
+ } else {
+ ctx->Map.pcs[ 3 ] = ctx->Map.pci[ 3 ];
+ }
+
+ if ( ctx->Map.entry.Pre_RQTpSec_NA ) {
+ ctx->Map.pcs[ 4 ] = CReqClockNanosleep_Pre_RQTpSec_NA;
+ } else {
+ ctx->Map.pcs[ 4 ] = ctx->Map.pci[ 4 ];
+ }
+
+ ctx->Map.pcs[ 5 ] = ctx->Map.pci[ 5 ];
+}
+
+static void CReqClockNanosleep_TestVariant( CReqClockNanosleep_Context *ctx )
+{
+ CReqClockNanosleep_Pre_ClockId_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ CReqClockNanosleep_Pre_Abstime_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ CReqClockNanosleep_Pre_RQTp_Prepare( ctx, ctx->Map.pcs[ 2 ] );
+ CReqClockNanosleep_Pre_RQTpNSec_Prepare( ctx, ctx->Map.pcs[ 3 ] );
+ CReqClockNanosleep_Pre_RQTpSec_Prepare( ctx, ctx->Map.pcs[ 4 ] );
+ CReqClockNanosleep_Pre_RMTp_Prepare( ctx, ctx->Map.pcs[ 5 ] );
+ CReqClockNanosleep_Action( ctx );
+ CReqClockNanosleep_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ CReqClockNanosleep_Post_Timer_Check( ctx, ctx->Map.entry.Post_Timer );
+ CReqClockNanosleep_Post_Expire_Check( ctx, ctx->Map.entry.Post_Expire );
+ CReqClockNanosleep_Post_Scheduler_Check(
+ ctx,
+ ctx->Map.entry.Post_Scheduler
+ );
+ CReqClockNanosleep_Post_RMTp_Check( ctx, ctx->Map.entry.Post_RMTp );
+}
+
+/**
+ * @fn void T_case_body_CReqClockNanosleep( void )
+ */
+T_TEST_CASE_FIXTURE( CReqClockNanosleep, &CReqClockNanosleep_Fixture )
+{
+ CReqClockNanosleep_Context *ctx;
+
+ ctx = T_fixture_context();
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
+
+ for (
+ ctx->Map.pci[ 0 ] = CReqClockNanosleep_Pre_ClockId_Monotonic;
+ ctx->Map.pci[ 0 ] < CReqClockNanosleep_Pre_ClockId_NA;
+ ++ctx->Map.pci[ 0 ]
+ ) {
+ for (
+ ctx->Map.pci[ 1 ] = CReqClockNanosleep_Pre_Abstime_Yes;
+ ctx->Map.pci[ 1 ] < CReqClockNanosleep_Pre_Abstime_NA;
+ ++ctx->Map.pci[ 1 ]
+ ) {
+ for (
+ ctx->Map.pci[ 2 ] = CReqClockNanosleep_Pre_RQTp_Valid;
+ ctx->Map.pci[ 2 ] < CReqClockNanosleep_Pre_RQTp_NA;
+ ++ctx->Map.pci[ 2 ]
+ ) {
+ for (
+ ctx->Map.pci[ 3 ] = CReqClockNanosleep_Pre_RQTpNSec_Valid;
+ ctx->Map.pci[ 3 ] < CReqClockNanosleep_Pre_RQTpNSec_NA;
+ ++ctx->Map.pci[ 3 ]
+ ) {
+ for (
+ ctx->Map.pci[ 4 ] = CReqClockNanosleep_Pre_RQTpSec_Negative;
+ ctx->Map.pci[ 4 ] < CReqClockNanosleep_Pre_RQTpSec_NA;
+ ++ctx->Map.pci[ 4 ]
+ ) {
+ for (
+ ctx->Map.pci[ 5 ] = CReqClockNanosleep_Pre_RMTp_Valid;
+ ctx->Map.pci[ 5 ] < CReqClockNanosleep_Pre_RMTp_NA;
+ ++ctx->Map.pci[ 5 ]
+ ) {
+ ctx->Map.entry = CReqClockNanosleep_PopEntry( ctx );
+
+ if ( ctx->Map.entry.Skip ) {
+ continue;
+ }
+
+ CReqClockNanosleep_SetPreConditionStates( ctx );
+ CReqClockNanosleep_Prepare( ctx );
+ CReqClockNanosleep_TestVariant( ctx );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-clock-set.c b/testsuites/validation/tc-clock-set.c
new file mode 100644
index 0000000000..55012dffd3
--- /dev/null
+++ b/testsuites/validation/tc-clock-set.c
@@ -0,0 +1,839 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsClockReqSet
+ */
+
+/*
+ * 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/score/todimpl.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsClockReqSet spec:/rtems/clock/req/set
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
+ *
+ * @{
+ */
+
+typedef enum {
+ RtemsClockReqSet_Pre_ToD_Valid,
+ RtemsClockReqSet_Pre_ToD_ValidLeap4,
+ RtemsClockReqSet_Pre_ToD_ValidLeap400,
+ RtemsClockReqSet_Pre_ToD_Youngest,
+ RtemsClockReqSet_Pre_ToD_Oldest,
+ RtemsClockReqSet_Pre_ToD_TooJung,
+ RtemsClockReqSet_Pre_ToD_TooOld,
+ RtemsClockReqSet_Pre_ToD_InvMonth0,
+ RtemsClockReqSet_Pre_ToD_InvMonth,
+ RtemsClockReqSet_Pre_ToD_InvDay0,
+ RtemsClockReqSet_Pre_ToD_InvDay,
+ RtemsClockReqSet_Pre_ToD_InvHour,
+ RtemsClockReqSet_Pre_ToD_InvMinute,
+ RtemsClockReqSet_Pre_ToD_InvSecond,
+ RtemsClockReqSet_Pre_ToD_InvTicks,
+ RtemsClockReqSet_Pre_ToD_InvLeap4,
+ RtemsClockReqSet_Pre_ToD_InvLeap100,
+ RtemsClockReqSet_Pre_ToD_InvLeap400,
+ RtemsClockReqSet_Pre_ToD_AtTimer,
+ RtemsClockReqSet_Pre_ToD_BeforeTimer,
+ RtemsClockReqSet_Pre_ToD_AfterTimer,
+ RtemsClockReqSet_Pre_ToD_Null,
+ RtemsClockReqSet_Pre_ToD_NA
+} RtemsClockReqSet_Pre_ToD;
+
+typedef enum {
+ RtemsClockReqSet_Pre_Hook_None,
+ RtemsClockReqSet_Pre_Hook_Ok,
+ RtemsClockReqSet_Pre_Hook_NotOk,
+ RtemsClockReqSet_Pre_Hook_NA
+} RtemsClockReqSet_Pre_Hook;
+
+typedef enum {
+ RtemsClockReqSet_Post_Status_Ok,
+ RtemsClockReqSet_Post_Status_InvAddr,
+ RtemsClockReqSet_Post_Status_InvClk,
+ RtemsClockReqSet_Post_Status_Hook,
+ RtemsClockReqSet_Post_Status_NA
+} RtemsClockReqSet_Post_Status;
+
+typedef enum {
+ RtemsClockReqSet_Post_Clock_Set,
+ RtemsClockReqSet_Post_Clock_Nop,
+ RtemsClockReqSet_Post_Clock_NA
+} RtemsClockReqSet_Post_Clock;
+
+typedef enum {
+ RtemsClockReqSet_Post_Timer_Triggered,
+ RtemsClockReqSet_Post_Timer_Nop,
+ RtemsClockReqSet_Post_Timer_NA
+} RtemsClockReqSet_Post_Timer;
+
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_ToD_NA : 1;
+ uint16_t Pre_Hook_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_Clock : 2;
+ uint16_t Post_Timer : 2;
+} RtemsClockReqSet_Entry;
+
+/**
+ * @brief Test context for spec:/rtems/clock/req/set test case.
+ */
+typedef struct {
+ rtems_status_code status;
+
+ bool register_hook;
+
+ Status_Control hook_status;
+
+ rtems_time_of_day *target_tod;
+
+ rtems_time_of_day target_tod_value;
+
+ rtems_time_of_day tod_before;
+
+ rtems_status_code get_tod_before_status;
+
+ rtems_time_of_day tod_after;
+
+ rtems_status_code get_tod_after_status;
+
+ rtems_id timer_id;
+
+ int timer_routine_counter;
+
+ rtems_time_of_day timer_routine_tod;
+
+ struct {
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 2 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ RtemsClockReqSet_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
+} RtemsClockReqSet_Context;
+
+static RtemsClockReqSet_Context
+ RtemsClockReqSet_Instance;
+
+static const char * const RtemsClockReqSet_PreDesc_ToD[] = {
+ "Valid",
+ "ValidLeap4",
+ "ValidLeap400",
+ "Youngest",
+ "Oldest",
+ "TooJung",
+ "TooOld",
+ "InvMonth0",
+ "InvMonth",
+ "InvDay0",
+ "InvDay",
+ "InvHour",
+ "InvMinute",
+ "InvSecond",
+ "InvTicks",
+ "InvLeap4",
+ "InvLeap100",
+ "InvLeap400",
+ "AtTimer",
+ "BeforeTimer",
+ "AfterTimer",
+ "Null",
+ "NA"
+};
+
+static const char * const RtemsClockReqSet_PreDesc_Hook[] = {
+ "None",
+ "Ok",
+ "NotOk",
+ "NA"
+};
+
+static const char * const * const RtemsClockReqSet_PreDesc[] = {
+ RtemsClockReqSet_PreDesc_ToD,
+ RtemsClockReqSet_PreDesc_Hook,
+ NULL
+};
+
+typedef RtemsClockReqSet_Context Context;
+
+static rtems_timer_service_routine _TOD_timer_routine(
+ rtems_id timer_id,
+ void *user_data
+)
+{
+ Context *ctx = user_data;
+ rtems_status_code status;
+ ++ctx->timer_routine_counter;
+ status = rtems_clock_get_tod( &ctx->timer_routine_tod );
+ T_rsc_success( status );
+}
+
+static void _TOD_prepare_timer( Context *ctx )
+{
+ rtems_status_code status;
+ rtems_time_of_day tod = { 1988, 1, 1, 0, 0, 0, 0 };
+
+ status = rtems_clock_set( &tod );
+ T_rsc_success( status );
+
+ tod.year = 1989;
+ status = rtems_timer_fire_when(
+ ctx->timer_id,
+ &tod,
+ _TOD_timer_routine,
+ ctx
+ );
+ T_rsc_success( status );
+}
+
+static Status_Control TODHook(
+ TOD_Action action,
+ const struct timespec *tod
+)
+{
+ Context *ctx;
+
+ ctx = T_fixture_context();
+ T_eq_int( action, TOD_ACTION_SET_CLOCK );
+ T_not_null( tod );
+
+ return ctx->hook_status;
+}
+
+static void RtemsClockReqSet_Pre_ToD_Prepare(
+ RtemsClockReqSet_Context *ctx,
+ RtemsClockReqSet_Pre_ToD state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqSet_Pre_ToD_Valid: {
+ /*
+ * While the ``time_of_day`` parameter references an arbitrary valid date
+ * and time between 1988-01-01T00:00:00.000000000Z and
+ * 2105-12-31T23:59:59.999999999Z.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 11, 11, 10, 59,
+ rtems_clock_get_ticks_per_second() / 2 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_ValidLeap4: {
+ /*
+ * While the ``time_of_day`` parameter references a date for a leap year
+ * with the value of 29th of February.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2096, 2, 29, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_ValidLeap400: {
+ /*
+ * While the ``time_of_day`` parameter references a date for a leap year
+ * with the value of 29th of February.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2000, 2, 29, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_Youngest: {
+ /*
+ * While the ``time_of_day`` parameter references the youngest date and
+ * time accepted (1988-01-01T00:00:00.000000000Z).
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 1988, 1, 1, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_Oldest: {
+ /*
+ * While the ``time_of_day`` parameter references the oldest date and
+ * time accepted (2099-12-31T23:59:59.999999999Z).
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2099, 12, 31, 23, 59, 59,
+ rtems_clock_get_ticks_per_second() - 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_TooJung: {
+ /*
+ * While the ``time_of_day`` parameter references a valid date and time
+ * younger than 1988-01-01T00:00:00.000000000Z.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 1987, 12, 31, 23, 59, 59,
+ rtems_clock_get_ticks_per_second() - 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_TooOld: {
+ /*
+ * While the ``time_of_day`` parameter references a valid date and time
+ * older than 2105-12-31T23:59:59.999999999Z.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2106, 1, 1, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvMonth0: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the month is 0.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 0, 11, 11, 10, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvMonth: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the month is larger than 12.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 13, 11, 11, 10, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvDay0: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the day is 0.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 0, 11, 10, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvDay: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the day is larger than the days of the month.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 2, 29, 11, 10, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvHour: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the hour is larger than 23.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 11, 24, 10, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvMinute: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the minute is larger than 59.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 11, 11, 60, 59, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvSecond: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the second is larger than 59.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 11, 11, 10, 60, 1 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvTicks: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value of
+ * the ticks are larger or equal to the ticks per second.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2021, 3, 11, 11, 10, 60,
+ rtems_clock_get_ticks_per_second() };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvLeap4: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value 30th
+ * of February does not exist in a leap year.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2104, 2, 30, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvLeap100: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value 29th
+ * of February does not exist in a non-leap year.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2100, 2, 29, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_InvLeap400: {
+ /*
+ * While the ``time_of_day`` parameter is invalid because the value 30th
+ * of February does not exist in a leap year.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 2000, 2, 30, 0, 0, 0, 0 };
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_AtTimer: {
+ /*
+ * While the ``time_of_day`` parameter references the same point in time
+ * when a timer should fire.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 1989, 1, 1, 0, 0, 0, 0 };
+ _TOD_prepare_timer( ctx );
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_BeforeTimer: {
+ /*
+ * While the ``time_of_day`` parameter references a point in time before
+ * a timer should fire.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 1988, 12, 31, 23, 59, 59, 0 };
+ _TOD_prepare_timer( ctx );
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_AfterTimer: {
+ /*
+ * While the ``time_of_day`` parameter references a point in time after a
+ * timer should fire.
+ */
+ ctx->target_tod_value =
+ (rtems_time_of_day) { 1989, 1, 1, 1, 0, 0, 0 };
+ _TOD_prepare_timer( ctx );
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_Null: {
+ /*
+ * WHile the ``time_of_day`` parameter is NULL.
+ */
+ ctx->target_tod = NULL;
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_ToD_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqSet_Pre_Hook_Prepare(
+ RtemsClockReqSet_Context *ctx,
+ RtemsClockReqSet_Pre_Hook state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqSet_Pre_Hook_None: {
+ /*
+ * While no TOD hook is registered.
+ */
+ ctx->register_hook = false;
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_Hook_Ok: {
+ /*
+ * While all TOD hooks invoked by the rtems_clock_set() call return a
+ * status code equal to STATUS_SUCCESSFUL.
+ */
+ ctx->register_hook = true;
+ ctx->hook_status = STATUS_SUCCESSFUL;
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_Hook_NotOk: {
+ /*
+ * While at least one TOD hook invoked by the rtems_clock_set() call
+ * returns a status code not equal to STATUS_SUCCESSFUL.
+ */
+ ctx->register_hook = true;
+ ctx->hook_status = STATUS_UNAVAILABLE;
+ break;
+ }
+
+ case RtemsClockReqSet_Pre_Hook_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqSet_Post_Status_Check(
+ RtemsClockReqSet_Context *ctx,
+ RtemsClockReqSet_Post_Status state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqSet_Post_Status_Ok: {
+ /*
+ * The return status of rtems_clock_set() shall be RTEMS_SUCCESSFUL
+ */
+ T_rsc_success( ctx->status );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Status_InvAddr: {
+ /*
+ * The return status of rtems_clock_set() shall be RTEMS_INVALID_ADDRESS.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Status_InvClk: {
+ /*
+ * The return status of rtems_clock_set() shall be RTEMS_INVALID_CLOCK.
+ */
+ T_rsc( ctx->status, RTEMS_INVALID_CLOCK );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Status_Hook: {
+ /*
+ * The return status of rtems_clock_set() shall be derived from the
+ * status returned by the TOD hook.
+ */
+ T_rsc( ctx->status, RTEMS_UNSATISFIED );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Status_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqSet_Post_Clock_Check(
+ RtemsClockReqSet_Context *ctx,
+ RtemsClockReqSet_Post_Clock state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqSet_Post_Clock_Set: {
+ /*
+ * The CLOCK_REALTIME shall be set to the values of the object referenced
+ * by the ``time_of_day`` parameter during the rtems_clock_set() call.
+ */
+ T_eq_ptr( ctx->target_tod, &ctx->target_tod_value );
+ T_rsc_success( ctx->get_tod_after_status );
+ T_eq_u32( ctx->tod_after.year, ctx->target_tod_value.year );
+ T_eq_u32( ctx->tod_after.month, ctx->target_tod_value.month );
+ T_eq_u32( ctx->tod_after.day, ctx->target_tod_value.day );
+ T_eq_u32( ctx->tod_after.hour, ctx->target_tod_value.hour );
+ T_eq_u32( ctx->tod_after.minute, ctx->target_tod_value.minute );
+ T_eq_u32( ctx->tod_after.second, ctx->target_tod_value.second );
+ /* rtems_clock_set() or rtems_clock_get_tod() cause an error of 1 tick */
+ T_ge_u32( ctx->tod_after.ticks + 1, ctx->target_tod_value.ticks );
+ T_le_u32( ctx->tod_after.ticks, ctx->target_tod_value.ticks );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Clock_Nop: {
+ /*
+ * The state of the CLOCK_REALTIME shall not be changed by the
+ * rtems_clock_set() call.
+ */
+ T_rsc_success( ctx->get_tod_before_status );
+ T_eq_u32( ctx->tod_after.year, ctx->tod_before.year );
+ T_eq_u32( ctx->tod_after.month, ctx->tod_before.month );
+ T_eq_u32( ctx->tod_after.day, ctx->tod_before.day );
+ T_eq_u32( ctx->tod_after.hour, ctx->tod_before.hour );
+ T_eq_u32( ctx->tod_after.minute, ctx->tod_before.minute );
+ T_eq_u32( ctx->tod_after.second, ctx->tod_before.second );
+ T_eq_u32( ctx->tod_after.ticks, ctx->tod_before.ticks );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Clock_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqSet_Post_Timer_Check(
+ RtemsClockReqSet_Context *ctx,
+ RtemsClockReqSet_Post_Timer state
+)
+{
+ switch ( state ) {
+ case RtemsClockReqSet_Post_Timer_Triggered: {
+ /*
+ * The timer routine shall be executed once after the CLOCK_REALTIME has
+ * been set and before the execution of the rtems_clock_set() call
+ * terminates.
+ */
+ T_eq_int( ctx->timer_routine_counter, 1 );
+ T_eq_u32( ctx->timer_routine_tod.year, 1989 );
+ T_eq_u32( ctx->timer_routine_tod.month, 1 );
+ T_eq_u32( ctx->timer_routine_tod.day, 1 );
+ T_eq_u32( ctx->timer_routine_tod.minute, 0 );
+ T_eq_u32( ctx->timer_routine_tod.second, 0 );
+ T_eq_u32( ctx->timer_routine_tod.ticks, 0 );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Timer_Nop: {
+ /*
+ * The the timer routine shall not be invoked during the
+ * rtems_clock_set() call.
+ */
+ T_eq_int( ctx->timer_routine_counter, 0 );
+ break;
+ }
+
+ case RtemsClockReqSet_Post_Timer_NA:
+ break;
+ }
+}
+
+static void RtemsClockReqSet_Setup( RtemsClockReqSet_Context *ctx )
+{
+ rtems_status_code status;
+ rtems_name timer_name = rtems_build_name( 'T', 'M', 'R', '0' );
+ ctx->timer_id = RTEMS_ID_NONE;
+
+ ctx->target_tod = &ctx->target_tod_value;
+
+ status = rtems_timer_create( timer_name, &ctx->timer_id );
+ T_rsc_success( status );
+}
+
+static void RtemsClockReqSet_Setup_Wrap( void *arg )
+{
+ RtemsClockReqSet_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ RtemsClockReqSet_Setup( ctx );
+}
+
+static void RtemsClockReqSet_Teardown( RtemsClockReqSet_Context *ctx )
+{
+ rtems_status_code status;
+
+ if ( RTEMS_ID_NONE != ctx->timer_id ) {
+ status = rtems_timer_delete( ctx->timer_id );
+ T_rsc_success( status );
+ }
+}
+
+static void RtemsClockReqSet_Teardown_Wrap( void *arg )
+{
+ RtemsClockReqSet_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ RtemsClockReqSet_Teardown( ctx );
+}
+
+static void RtemsClockReqSet_Prepare( RtemsClockReqSet_Context *ctx )
+{
+ rtems_status_code status;
+
+ status = rtems_timer_cancel( ctx->timer_id );
+ T_rsc_success( status );
+ ctx->timer_routine_counter = 0;
+ ctx->timer_routine_tod = (rtems_time_of_day) { 0, 0, 0, 0, 0, 0, 0 };
+}
+
+static void RtemsClockReqSet_Action( RtemsClockReqSet_Context *ctx )
+{
+ TOD_Hook hook = {
+ .handler = TODHook
+ };
+
+ if ( ctx->register_hook ) {
+ _TOD_Hook_Register( &hook );
+ }
+
+ ctx->get_tod_before_status = rtems_clock_get_tod( &ctx->tod_before );
+ ctx->status = rtems_clock_set( ctx->target_tod );
+ ctx->get_tod_after_status = rtems_clock_get_tod( &ctx->tod_after );
+
+ if ( ctx->register_hook ) {
+ _TOD_Hook_Unregister( &hook );
+ }
+}
+
+static const RtemsClockReqSet_Entry
+RtemsClockReqSet_Entries[] = {
+ { 0, 0, 0, RtemsClockReqSet_Post_Status_InvClk,
+ RtemsClockReqSet_Post_Clock_Nop, RtemsClockReqSet_Post_Timer_Nop },
+ { 0, 0, 0, RtemsClockReqSet_Post_Status_Ok, RtemsClockReqSet_Post_Clock_Set,
+ RtemsClockReqSet_Post_Timer_Nop },
+ { 0, 0, 0, RtemsClockReqSet_Post_Status_Hook,
+ RtemsClockReqSet_Post_Clock_Nop, RtemsClockReqSet_Post_Timer_Nop },
+ { 0, 0, 0, RtemsClockReqSet_Post_Status_Ok, RtemsClockReqSet_Post_Clock_Set,
+ RtemsClockReqSet_Post_Timer_Triggered },
+ { 0, 0, 0, RtemsClockReqSet_Post_Status_InvAddr,
+ RtemsClockReqSet_Post_Clock_Nop, RtemsClockReqSet_Post_Timer_Nop }
+};
+
+static const uint8_t
+RtemsClockReqSet_Map[] = {
+ 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 3, 3, 2, 1, 1, 2, 3, 3, 2, 4, 4, 4
+};
+
+static size_t RtemsClockReqSet_Scope( void *arg, char *buf, size_t n )
+{
+ RtemsClockReqSet_Context *ctx;
+
+ ctx = arg;
+
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsClockReqSet_PreDesc, buf, n, ctx->Map.pcs );
+ }
+
+ return 0;
+}
+
+static T_fixture RtemsClockReqSet_Fixture = {
+ .setup = RtemsClockReqSet_Setup_Wrap,
+ .stop = NULL,
+ .teardown = RtemsClockReqSet_Teardown_Wrap,
+ .scope = RtemsClockReqSet_Scope,
+ .initial_context = &RtemsClockReqSet_Instance
+};
+
+static inline RtemsClockReqSet_Entry RtemsClockReqSet_PopEntry(
+ RtemsClockReqSet_Context *ctx
+)
+{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
+ return RtemsClockReqSet_Entries[
+ RtemsClockReqSet_Map[ index ]
+ ];
+}
+
+static void RtemsClockReqSet_TestVariant( RtemsClockReqSet_Context *ctx )
+{
+ RtemsClockReqSet_Pre_ToD_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsClockReqSet_Pre_Hook_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsClockReqSet_Action( ctx );
+ RtemsClockReqSet_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ RtemsClockReqSet_Post_Clock_Check( ctx, ctx->Map.entry.Post_Clock );
+ RtemsClockReqSet_Post_Timer_Check( ctx, ctx->Map.entry.Post_Timer );
+}
+
+/**
+ * @fn void T_case_body_RtemsClockReqSet( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsClockReqSet, &RtemsClockReqSet_Fixture )
+{
+ RtemsClockReqSet_Context *ctx;
+
+ ctx = T_fixture_context();
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
+
+ for (
+ ctx->Map.pcs[ 0 ] = RtemsClockReqSet_Pre_ToD_Valid;
+ ctx->Map.pcs[ 0 ] < RtemsClockReqSet_Pre_ToD_NA;
+ ++ctx->Map.pcs[ 0 ]
+ ) {
+ for (
+ ctx->Map.pcs[ 1 ] = RtemsClockReqSet_Pre_Hook_None;
+ ctx->Map.pcs[ 1 ] < RtemsClockReqSet_Pre_Hook_NA;
+ ++ctx->Map.pcs[ 1 ]
+ ) {
+ ctx->Map.entry = RtemsClockReqSet_PopEntry( ctx );
+ RtemsClockReqSet_Prepare( ctx );
+ RtemsClockReqSet_TestVariant( ctx );
+ }
+ }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-clock.c b/testsuites/validation/tc-clock.c
new file mode 100644
index 0000000000..b0592c2b26
--- /dev/null
+++ b/testsuites/validation/tc-clock.c
@@ -0,0 +1,134 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsClockValClock
+ */
+
+/*
+ * 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 RTEMSTestCaseRtemsClockValClock spec:/rtems/clock/val/clock
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0
+ *
+ * @brief Tests some @ref RTEMSAPIClassicClock directives.
+ *
+ * This test case performs the following actions:
+ *
+ * - Use the rtems_clock_get_ticks_since_boot() function.
+ *
+ * - Check that clock tick gets incremented.
+ *
+ * - Use the rtems_clock_get_ticks_per_second() function.
+ *
+ * - Check that rtems_clock_get_ticks_per_second() actually returns 1us /
+ * CONFIGURE_MICROSECONDS_PER_TICK.
+ *
+ * @{
+ */
+
+/**
+ * @brief Use the rtems_clock_get_ticks_since_boot() function.
+ */
+static void RtemsClockValClock_Action_0( void )
+{
+ rtems_interval result_0;
+ rtems_interval result_1;
+ int32_t difference; /* Note: rtems_interval = uint32_t (unsigned!) */
+
+ result_0 = rtems_clock_get_ticks_since_boot();
+ ClockTick();
+ result_1 = rtems_clock_get_ticks_since_boot();
+ /*
+ * Because of the ones-complement, the overflow
+ * is handled correctly. result_0 = 0xFFFFFFFF will become -1
+ * and result_1 = 0x0 will become 0.
+ */
+ difference = (int32_t) result_1 - (int32_t) result_0;
+
+ /*
+ * Check that clock tick gets incremented.
+ */
+ T_step_eq_i32( 0, difference, 1 );
+}
+
+/**
+ * @brief Use the rtems_clock_get_ticks_per_second() function.
+ */
+static void RtemsClockValClock_Action_1( void )
+{
+ rtems_interval result;
+ result = rtems_clock_get_ticks_per_second();
+
+ /*
+ * Check that rtems_clock_get_ticks_per_second() actually returns 1us /
+ * CONFIGURE_MICROSECONDS_PER_TICK.
+ */
+ T_step_eq_u32( 1, result, 1000000UL / TEST_MICROSECONDS_PER_TICK );
+}
+
+/**
+ * @fn void T_case_body_RtemsClockValClock( void )
+ */
+T_TEST_CASE( RtemsClockValClock )
+{
+ T_plan( 2 );
+
+ RtemsClockValClock_Action_0();
+ RtemsClockValClock_Action_1();
+}
+
+/** @} */