summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-12 13:49:37 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-13 09:56:26 +0200
commit53088d03fe52b33fd89b647ea4af0dc5fade5448 (patch)
tree0664e119049ec278eb11ebf50ad37baca0ef156a
parent65e332d5533d78f5957a4ae0d24eab34feae20dd (diff)
validation: Test timecounter
-rw-r--r--spec/build/testsuites/validation/grp.yml6
-rw-r--r--spec/build/testsuites/validation/validation-timecounter-0.yml21
-rw-r--r--spec/build/testsuites/validation/validation-timecounter-1.yml21
-rw-r--r--spec/build/testsuites/validation/validation-timecounter-smp-0.yml21
-rw-r--r--testsuites/unit/tc-score-kern-tc.c171
-rw-r--r--testsuites/validation/tc-timecounter-get-smp.c227
-rw-r--r--testsuites/validation/tc-timecounter-get.c570
-rw-r--r--testsuites/validation/tc-timecounter-install.c843
-rw-r--r--testsuites/validation/ts-validation-timecounter-0.c77
-rw-r--r--testsuites/validation/ts-validation-timecounter-1.c75
-rw-r--r--testsuites/validation/ts-validation-timecounter-smp-0.c77
11 files changed, 1943 insertions, 166 deletions
diff --git a/spec/build/testsuites/validation/grp.yml b/spec/build/testsuites/validation/grp.yml
index 84f001fc59..d5c083efd6 100644
--- a/spec/build/testsuites/validation/grp.yml
+++ b/spec/build/testsuites/validation/grp.yml
@@ -73,6 +73,12 @@ links:
- role: build-dependency
uid: validation-smp-only-2
- role: build-dependency
+ uid: validation-timecounter-0
+- role: build-dependency
+ uid: validation-timecounter-1
+- role: build-dependency
+ uid: validation-timecounter-smp-0
+- role: build-dependency
uid: validation-tls-0
- role: build-dependency
uid: validation-tls-1
diff --git a/spec/build/testsuites/validation/validation-timecounter-0.yml b/spec/build/testsuites/validation/validation-timecounter-0.yml
new file mode 100644
index 0000000000..d6990e9570
--- /dev/null
+++ b/spec/build/testsuites/validation/validation-timecounter-0.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by: true
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/validation/tc-timecounter-install.c
+- testsuites/validation/ts-validation-timecounter-0.c
+stlib: []
+target: testsuites/validation/ts-validation-timecounter-0.exe
+type: build
+use-after:
+- validation
+use-before: []
diff --git a/spec/build/testsuites/validation/validation-timecounter-1.yml b/spec/build/testsuites/validation/validation-timecounter-1.yml
new file mode 100644
index 0000000000..9d10767f7b
--- /dev/null
+++ b/spec/build/testsuites/validation/validation-timecounter-1.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by: true
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/validation/tc-timecounter-get.c
+- testsuites/validation/ts-validation-timecounter-1.c
+stlib: []
+target: testsuites/validation/ts-validation-timecounter-1.exe
+type: build
+use-after:
+- validation
+use-before: []
diff --git a/spec/build/testsuites/validation/validation-timecounter-smp-0.yml b/spec/build/testsuites/validation/validation-timecounter-smp-0.yml
new file mode 100644
index 0000000000..b9e2cccc9e
--- /dev/null
+++ b/spec/build/testsuites/validation/validation-timecounter-smp-0.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by: RTEMS_SMP
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/validation/tc-timecounter-get-smp.c
+- testsuites/validation/ts-validation-timecounter-smp-0.c
+stlib: []
+target: testsuites/validation/ts-validation-timecounter-smp-0.exe
+type: build
+use-after:
+- validation
+use-before: []
diff --git a/testsuites/unit/tc-score-kern-tc.c b/testsuites/unit/tc-score-kern-tc.c
index 03fe373759..5f9d0ad796 100644
--- a/testsuites/unit/tc-score-kern-tc.c
+++ b/testsuites/unit/tc-score-kern-tc.c
@@ -53,7 +53,6 @@
#endif
#include <rtems/score/timecounter.h>
-#include <rtems/score/todimpl.h>
#include <rtems/test.h>
@@ -65,174 +64,22 @@
*
* @brief Unit tests for the time counter kern_tc part.
*
- * Parts of the file ``cpukit/score/src/kern_tc.c`` are only executed by the
- * POSIX API and certain device driver code. The space qualified code subset
- * does not contain those features. This test exercises the code parts
- * otherwise not reached in order to achieve full code coverage.
+ * Parts of the file ``cpukit/score/src/kern_tc.c`` are only executed by
+ * certain device driver code. The space qualified code subset does not
+ * contain those features. This test exercises the code parts otherwise not
+ * reached in order to achieve full code coverage.
*
* This test case performs the following actions:
*
- * - Call function _Timecounter_Getbintime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Getbinuptime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Getboottime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Getboottimebin().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Getmicrotime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Getmicrouptime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Microuptime().
- *
- * - Check value returned by function call.
- *
- * - Call function _Timecounter_Nanotime().
- *
- * - Check value returned by function call.
- *
* - Call function _Timecounter_Tick_simple().
*
* @{
*/
/**
- * @brief Call function _Timecounter_Getbintime().
- */
-static void ScoreTimecounterUnitKernTc_Action_0( void )
-{
- struct bintime bt;
- _Timecounter_Getbintime( &bt );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( bt.sec, TOD_SECONDS_1970_THROUGH_1988 );
- T_eq_long( bt.frac, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Getbinuptime().
- */
-static void ScoreTimecounterUnitKernTc_Action_1( void )
-{
- struct bintime bt;
- _Timecounter_Getbinuptime( &bt );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( bt.sec, 1 );
- T_eq_long( bt.frac, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Getboottime().
- */
-static void ScoreTimecounterUnitKernTc_Action_2( void )
-{
- struct timeval tv;
- _Timecounter_Getboottime( &tv );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( tv.tv_sec, TOD_SECONDS_1970_THROUGH_1988 - 1 );
- T_eq_long( tv.tv_usec, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Getboottimebin().
- */
-static void ScoreTimecounterUnitKernTc_Action_3( void )
-{
- struct bintime bt;
- _Timecounter_Getboottimebin( &bt );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( bt.sec, TOD_SECONDS_1970_THROUGH_1988 - 1 );
- T_eq_long( bt.frac, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Getmicrotime().
- */
-static void ScoreTimecounterUnitKernTc_Action_4( void )
-{
- struct timeval tv;
- _Timecounter_Getmicrotime( &tv );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( tv.tv_sec, TOD_SECONDS_1970_THROUGH_1988 );
- T_eq_long( tv.tv_usec, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Getmicrouptime().
- */
-static void ScoreTimecounterUnitKernTc_Action_5( void )
-{
- struct timeval tv;
- _Timecounter_Getmicrouptime( &tv );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( tv.tv_sec, 1 );
- T_eq_long( tv.tv_usec, 0 );
-}
-
-/**
- * @brief Call function _Timecounter_Microuptime().
- */
-static void ScoreTimecounterUnitKernTc_Action_6( void )
-{
- struct timeval tv;
- _Timecounter_Microuptime( &tv );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( tv.tv_sec, 1 );
- /* T_eq_long( tv.tv_usec, 0 ); is increased by other sources */
-}
-
-/**
- * @brief Call function _Timecounter_Nanotime().
- */
-static void ScoreTimecounterUnitKernTc_Action_7( void )
-{
- struct timespec ts;
- _Timecounter_Nanotime( &ts );
-
- /*
- * Check value returned by function call.
- */
- T_eq_u64( ts.tv_sec, TOD_SECONDS_1970_THROUGH_1988 );
- /* T_eq_long( ts.tv_nsec, 0 ); is increased by other sources */
-}
-
-/**
* @brief Call function _Timecounter_Tick_simple().
*/
-static void ScoreTimecounterUnitKernTc_Action_8( void )
+static void ScoreTimecounterUnitKernTc_Action_0( void )
{
ISR_lock_Context lock_context;
_Timecounter_Acquire( &lock_context );
@@ -245,14 +92,6 @@ static void ScoreTimecounterUnitKernTc_Action_8( void )
T_TEST_CASE( ScoreTimecounterUnitKernTc )
{
ScoreTimecounterUnitKernTc_Action_0();
- ScoreTimecounterUnitKernTc_Action_1();
- ScoreTimecounterUnitKernTc_Action_2();
- ScoreTimecounterUnitKernTc_Action_3();
- ScoreTimecounterUnitKernTc_Action_4();
- ScoreTimecounterUnitKernTc_Action_5();
- ScoreTimecounterUnitKernTc_Action_6();
- ScoreTimecounterUnitKernTc_Action_7();
- ScoreTimecounterUnitKernTc_Action_8();
}
/** @} */
diff --git a/testsuites/validation/tc-timecounter-get-smp.c b/testsuites/validation/tc-timecounter-get-smp.c
new file mode 100644
index 0000000000..02dedefab1
--- /dev/null
+++ b/testsuites/validation/tc-timecounter-get-smp.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseScoreTimecounterValGetSmp
+ */
+
+/*
+ * 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/timecounter.h>
+#include <rtems/score/smpbarrier.h>
+#include <rtems/score/threaddispatch.h>
+
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseScoreTimecounterValGetSmp \
+ * spec:/score/timecounter/val/get-smp
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounterSmp0
+ *
+ * @brief Tests directives to get a time value.
+ *
+ * This test case performs the following actions:
+ *
+ * - Install timecounter of different quality levels and frequencies.
+ *
+ * - Install a timecounter with a high quality level and normal frequency.
+ * Check that it was installed.
+ *
+ * @{
+ */
+
+typedef struct {
+ struct timecounter base;
+ bool delay;
+ uint32_t counter;
+ SMP_barrier_Control barrier;
+ SMP_barrier_State barrier_state[ 2 ];
+} Timecounter;
+
+static Timecounter test_timecounter;
+
+static uint32_t GetTimecount( struct timecounter *base )
+{
+ Timecounter *tc;
+
+ tc = (Timecounter *) base;
+
+ if ( rtems_scheduler_get_processor() == 0 ) {
+ if ( !tc->delay ) {
+ return 0;
+ }
+
+ /* B2 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ /* B3 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ return 0;
+ }
+
+ if ( tc->counter == 0 ) {
+ /* Do nothing */
+ } else if ( tc->counter == 1 ) {
+ tc->counter = 2;
+
+ /* B1 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+
+ /* B2 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+ } else if ( tc->counter == 2 ) {
+ tc->counter = 3;
+
+ /* B3 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+
+ /* B4 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+ }
+
+ return 0;
+}
+
+static uint32_t GetTimecountDummy( struct timecounter *base )
+{
+ (void) base;
+
+ return 0;
+}
+
+static void Worker( rtems_task_argument arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+
+ /* A */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+
+ tc->counter = 1;
+
+ /* B0 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+
+ rtems_clock_get_realtime_bintime( &bt );
+
+ /* B5 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 1 ], 2 );
+
+ ReceiveAnyEvents();
+}
+
+/**
+ * @brief Install timecounter of different quality levels and frequencies.
+ */
+static void ScoreTimecounterValGetSmp_Action_0( void )
+{
+ Timecounter *tc;
+ rtems_id worker_id;
+ Per_CPU_Control *cpu_self;
+
+ tc = &test_timecounter;
+ _SMP_barrier_Control_initialize( &tc->barrier );
+ _SMP_barrier_State_initialize( &tc->barrier_state[ 0 ] );
+ _SMP_barrier_State_initialize( &tc->barrier_state[ 1 ] );
+
+ worker_id = CreateTask( "WORK", PRIO_NORMAL );
+ SetScheduler( worker_id, SCHEDULER_B_ID, PRIO_NORMAL );
+ StartTask( worker_id, Worker, tc );
+
+ tc->base.tc_get_timecount = GetTimecount;
+ tc->base.tc_counter_mask = 0xffffffff;
+ tc->base.tc_frequency = 0x10000000;
+ tc->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
+ rtems_timecounter_install( &tc->base );
+
+ /* A */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ /*
+ * Install a timecounter with a high quality level and normal frequency.
+ * Check that it was installed.
+ */
+ /* B0 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ /* B1 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ cpu_self = _Thread_Dispatch_disable();
+ tc->delay = false;
+ rtems_timecounter_tick();
+ tc->delay = true;
+ rtems_timecounter_tick();
+ _Thread_Dispatch_enable( cpu_self );
+
+ /* B4 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ /* B5 */
+ _SMP_barrier_Wait( &tc->barrier, &tc->barrier_state[ 0 ], 2 );
+
+ tc->base.tc_get_timecount = GetTimecountDummy;
+ DeleteTask( worker_id );
+}
+
+/**
+ * @fn void T_case_body_ScoreTimecounterValGetSmp( void )
+ */
+T_TEST_CASE( ScoreTimecounterValGetSmp )
+{
+ ScoreTimecounterValGetSmp_Action_0();
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-timecounter-get.c b/testsuites/validation/tc-timecounter-get.c
new file mode 100644
index 0000000000..1124752995
--- /dev/null
+++ b/testsuites/validation/tc-timecounter-get.c
@@ -0,0 +1,570 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseScoreTimecounterValGet
+ */
+
+/*
+ * 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/counter.h>
+#include <rtems/timecounter.h>
+#include <rtems/score/timecounterimpl.h>
+
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseScoreTimecounterValGet \
+ * spec:/score/timecounter/val/get
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounter1
+ *
+ * @brief Tests directives to get a time value.
+ *
+ * This test case performs the following actions:
+ *
+ * - Install a timecounter which can be used to perform interrut tests for the
+ * get time directives.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime() directive to provoke a
+ * change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime_bintime() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime_timeval() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic() directive to provoke a
+ * change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_bintime() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_sbintime() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_timeval() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Prepare for the coarse get time directives.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime_coarse() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime_coarse_bintime() directive
+ * to provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_realtime_coarse_timeval() directive
+ * to provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_coarse() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_coarse_bintime()
+ * directive to provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_monotonic_coarse_timeval()
+ * directive to provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_boot_time() directive to provoke a
+ * change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_boot_time_bintime() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * - Try to interrupt the rtems_clock_get_boot_time_timeval() directive to
+ * provoke a change in the timehand generation number.
+ *
+ * @{
+ */
+
+typedef enum {
+ STATE_EARLY,
+ STATE_GET_TIMECOUNT_BEFORE,
+ STATE_GET_TIMECOUNT_BUSY,
+ STATE_GET_TIMECOUNT_DONE,
+ STATE_GET_TIMECOUNT_AFTER
+} State;
+
+typedef struct {
+ struct timecounter base;
+ State state;
+ uint_fast32_t busy;
+ struct bintime tod;
+} Timecounter;
+
+static Timecounter test_timecounter;
+
+static uint32_t GetTimecount( struct timecounter *base )
+{
+ Timecounter *tc;
+
+ tc = (Timecounter *) base;
+
+ if (
+ tc->state == STATE_GET_TIMECOUNT_BEFORE &&
+ !rtems_interrupt_is_in_progress()
+ ) {
+ tc->state = STATE_GET_TIMECOUNT_BUSY;
+ T_busy( tc->busy );
+ tc->state = STATE_GET_TIMECOUNT_DONE;
+ }
+
+ return rtems_counter_read();
+}
+
+static void InterruptPrepare( void *arg )
+{
+ Timecounter *tc;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_EARLY;
+}
+
+static void ActionRealtime( void *arg )
+{
+ Timecounter *tc;
+ struct timespec ts;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime( &ts );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionRealtimeBintime( void *arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime_bintime( &bt );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionRealtimeTimeval( void *arg )
+{
+ Timecounter *tc;
+ struct timeval tv;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime_timeval( &tv );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionMonotonic( void *arg )
+{
+ Timecounter *tc;
+ struct timespec ts;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic( &ts );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionMonotonicBintime( void *arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic_bintime( &bt );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionMonotonicSbintime( void *arg )
+{
+ Timecounter *tc;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ (void) rtems_clock_get_monotonic_sbintime();
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionMonotonicTimeval( void *arg )
+{
+ Timecounter *tc;
+ struct timeval tv;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic_timeval( &tv );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseRealtime( void *arg )
+{
+ Timecounter *tc;
+ struct timespec ts;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime_coarse( &ts );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseRealtimeBintime( void *arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime_coarse_bintime( &bt );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseRealtimeTimeval( void *arg )
+{
+ Timecounter *tc;
+ struct timeval tv;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_realtime_coarse_timeval( &tv );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseMonotonic( void *arg )
+{
+ Timecounter *tc;
+ struct timespec ts;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic_coarse( &ts );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseMonotonicBintime( void *arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic_coarse_bintime( &bt );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionCoarseMonotonicTimeval( void *arg )
+{
+ Timecounter *tc;
+ struct timeval tv;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_monotonic_coarse_timeval( &tv );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionBootTime( void *arg )
+{
+ Timecounter *tc;
+ struct timespec ts;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_boot_time( &ts );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionBootTimeBintime( void *arg )
+{
+ Timecounter *tc;
+ struct bintime bt;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_boot_time_bintime( &bt );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void ActionBootTimeTimeval( void *arg )
+{
+ Timecounter *tc;
+ struct timeval tv;
+
+ tc = (Timecounter *) arg;
+ tc->state = STATE_GET_TIMECOUNT_BEFORE;
+ rtems_clock_get_boot_time_timeval( &tv );
+ tc->state = STATE_GET_TIMECOUNT_AFTER;
+}
+
+static void CallTimcounterWindupTwice( const Timecounter *tc )
+{
+ ISR_lock_Context lock_context;
+
+ /*
+ * Make sure that tc_windup() was called at least twice to increment the
+ * generation number for * both timehands.
+ */
+
+ _Timecounter_Acquire( &lock_context );
+ _Timecounter_Set_clock( &tc->tod, &lock_context );
+
+ _Timecounter_Acquire( &lock_context );
+ _Timecounter_Set_clock( &tc->tod, &lock_context );
+}
+
+static T_interrupt_test_state Interrupt( void *arg )
+{
+ Timecounter *tc;
+ State state;
+
+ tc = (Timecounter *) arg;
+ state = tc->state;
+
+ if ( state == STATE_EARLY || state == STATE_GET_TIMECOUNT_BEFORE ) {
+ return T_INTERRUPT_TEST_EARLY;
+ }
+
+ if ( state == STATE_GET_TIMECOUNT_BUSY ) {
+ CallTimcounterWindupTwice( tc );
+
+ return T_INTERRUPT_TEST_DONE;
+ }
+
+ return T_INTERRUPT_TEST_LATE;
+}
+
+static T_interrupt_test_state InterruptCoarse( void *arg )
+{
+ Timecounter *tc;
+ State state;
+
+ tc = (Timecounter *) arg;
+ state = tc->state;
+
+ if ( state == STATE_EARLY ) {
+ return T_INTERRUPT_TEST_EARLY;
+ }
+
+ if ( state == STATE_GET_TIMECOUNT_BEFORE ) {
+ CallTimcounterWindupTwice( tc );
+
+ return T_INTERRUPT_TEST_DONE;
+ }
+
+ return T_INTERRUPT_TEST_LATE;
+}
+
+static void InterruptTest(
+ const T_interrupt_test_config *config,
+ void *arg,
+ uint32_t iterations
+)
+{
+ uint32_t i;
+
+ for ( i = 0; i < iterations; ++i ) {
+ T_interrupt_test_state test_state;
+
+ test_state = T_interrupt_test( config, arg );
+ T_eq_int( test_state, T_INTERRUPT_TEST_DONE );
+ }
+}
+
+/**
+ * @brief Install a timecounter which can be used to perform interrut tests for
+ * the get time directives.
+ */
+static void ScoreTimecounterValGet_Action_0( void )
+{
+ T_interrupt_test_config config = {
+ .prepare = InterruptPrepare,
+ .interrupt = Interrupt,
+ .max_iteration_count = 10000
+ };
+ Timecounter *tc;
+
+ tc = &test_timecounter;
+ tc->base.tc_get_timecount = GetTimecount;
+ tc->base.tc_counter_mask = 0xffffffff;
+ tc->base.tc_frequency = rtems_counter_frequency();
+ tc->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER + 1;
+ tc->busy = T_get_one_clock_tick_busy() / 10;
+ rtems_clock_get_realtime_bintime( &tc->tod );
+ rtems_timecounter_install( &tc->base );
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime() directive to provoke a
+ * change in the timehand generation number.
+ */
+ config.action = ActionRealtime;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime_bintime() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionRealtimeBintime;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime_timeval() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionRealtimeTimeval;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic() directive to provoke a
+ * change in the timehand generation number.
+ */
+ config.action = ActionMonotonic;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_bintime() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionMonotonicBintime;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_sbintime() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionMonotonicSbintime;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_timeval() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionMonotonicTimeval;
+ InterruptTest( &config, tc, 1 );
+
+ /*
+ * Prepare for the coarse get time directives.
+ */
+ config.interrupt = InterruptCoarse;
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime_coarse() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseRealtime;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime_coarse_bintime() directive
+ * to provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseRealtimeBintime;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_realtime_coarse_timeval() directive
+ * to provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseRealtimeTimeval;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_coarse() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseMonotonic;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_coarse_bintime() directive
+ * to provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseMonotonicBintime;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_monotonic_coarse_timeval() directive
+ * to provoke a change in the timehand generation number.
+ */
+ config.action = ActionCoarseMonotonicTimeval;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_boot_time() directive to provoke a
+ * change in the timehand generation number.
+ */
+ config.action = ActionBootTime;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_boot_time_bintime() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionBootTimeBintime;
+ InterruptTest( &config, tc, 10 );
+
+ /*
+ * Try to interrupt the rtems_clock_get_boot_time_timeval() directive to
+ * provoke a change in the timehand generation number.
+ */
+ config.action = ActionBootTimeTimeval;
+ InterruptTest( &config, tc, 10 );
+}
+
+/**
+ * @fn void T_case_body_ScoreTimecounterValGet( void )
+ */
+T_TEST_CASE( ScoreTimecounterValGet )
+{
+ ScoreTimecounterValGet_Action_0();
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-timecounter-install.c b/testsuites/validation/tc-timecounter-install.c
new file mode 100644
index 0000000000..344befdfd3
--- /dev/null
+++ b/testsuites/validation/tc-timecounter-install.c
@@ -0,0 +1,843 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseScoreTimecounterValInstall
+ */
+
+/*
+ * 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/timecounter.h>
+#include <rtems/score/atomic.h>
+
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseScoreTimecounterValInstall \
+ * spec:/score/timecounter/val/install
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounter0
+ *
+ * @brief Tests timecounter installation related functions and directives of
+ * the Clock Manager.
+ *
+ * This test case performs the following actions:
+ *
+ * - Call the directives to get the initial value of CLOCK_REALTIME and the
+ * initial boot time.
+ *
+ * - Check the initial CLOCK_REALTIME in seconds and nanoseconds format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in seconds and nanoseconds format.
+ *
+ * - Check the initial CLOCK_REALTIME in coarse precision in seconds and
+ * nanoseconds format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in coarse precision in seconds and
+ * nanoseconds format.
+ *
+ * - Check the initial CLOCK_REALTIME in binary time format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in binary time format.
+ *
+ * - Check the initial CLOCK_REALTIME in coarse precision in binary time
+ * format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in coarse precision in binary time
+ * format.
+ *
+ * - Check the initial CLOCK_REALTIME in seconds and microseconds format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in seconds and microseconds format.
+ *
+ * - Check the initial CLOCK_REALTIME in coarse precision in seconds and
+ * microseconds format.
+ *
+ * - Check that CLOCK_REALTIME is frozen in coarse precision in seconds and
+ * microseconds format.
+ *
+ * - Check the initial boot time in seconds and nanoseconds format.
+ *
+ * - Check the initial boot time in binary time format.
+ *
+ * - Check the initial boot time in seconds and microseconds format.
+ *
+ * - Call the directives to get the initial value of CLOCK_MONOTONIC and the
+ * initial boot time.
+ *
+ * - Check the initial CLOCK_MONOTONIC in seconds and nanoseconds format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in seconds and nanoseconds format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in coarse precision in seconds and
+ * nanoseconds format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in coarse precision in seconds and
+ * nanoseconds format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in binary time format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in binary time format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in coarse precision in binary time
+ * format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in coarse precision in binary time
+ * format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in signed binary time format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in signed binary time format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in seconds and microseconds format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in seconds and microseconds format.
+ *
+ * - Check the initial CLOCK_MONOTONIC in coarse precision in seconds and
+ * microseconds format.
+ *
+ * - Check that CLOCK_MONOTONIC is frozen in coarse precision in seconds and
+ * microseconds format.
+ *
+ * - Install timecounter of different quality levels and frequencies.
+ *
+ * - Install a timecounter with a high quality level and normal frequency.
+ * Check that it was installed.
+ *
+ * - Install a timecounter with a high quality level and low frequency. Check
+ * that it was not installed.
+ *
+ * - Install a timecounter with a high quality level and high frequency.
+ * Check that it was installed.
+ *
+ * - Install a timecounter with a low quality level. Check that it was not
+ * installed.
+ *
+ * - Call the directives to get the time in the highest precision available to
+ * the system.
+ *
+ * - Check that the timecounter was used by rtems_clock_get_realtime().
+ *
+ * - Check that the timecounter was used by
+ * rtems_clock_get_realtime_bintime().
+ *
+ * - Check that the timecounter was used by
+ * rtems_clock_get_realtime_timeval().
+ *
+ * - Check that the timecounter was used by rtems_clock_get_monotonic().
+ *
+ * - Check that the timecounter was used by
+ * rtems_clock_get_monotonic_bintime().
+ *
+ * - Check that the timecounter was used by
+ * rtems_clock_get_monotonic_sbintime().
+ *
+ * - Check that the timecounter was used by
+ * rtems_clock_get_monotonic_timeval().
+ *
+ * - Call the directives to get the time in a coarse precision.
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse_bintime().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse_timeval().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse_bintime().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse_timeval().
+ *
+ * - Check that the timecounter was not used by rtems_clock_get_boot_time().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_boot_time_bintime().
+ *
+ * - Check that the timecounter was not used by
+ * rtems_clock_get_boot_time_timeval().
+ *
+ * - Call the directives to get the time in the highest precision available to
+ * the system.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime_bintime() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime_timeval() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_bintime() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_sbintime() returns the correct time.
+ *
+ * - Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_timeval() returns the correct time.
+ *
+ * @{
+ */
+
+typedef struct {
+ struct timecounter base;
+ Atomic_Ulong counter;
+} Timecounter;
+
+static Timecounter high_quality_low_frequency;
+
+static Timecounter high_quality_normal_frequency;
+
+static Timecounter high_quality_high_frequency;
+
+static Timecounter low_quality;
+
+static uint32_t GetTimecount( struct timecounter *base )
+{
+ Timecounter *tc;
+
+ tc = (Timecounter *) base;
+
+ return (uint32_t) _Atomic_Fetch_add_ulong(
+ &tc->counter,
+ 1,
+ ATOMIC_ORDER_RELAXED
+ );
+}
+
+static uint32_t GetCounter( const Timecounter *tc )
+{
+ return (uint32_t) _Atomic_Load_ulong(
+ &tc->counter,
+ ATOMIC_ORDER_RELAXED
+ );
+}
+
+static void SetCounter( Timecounter *tc, uint32_t counter )
+{
+ _Atomic_Store_ulong(
+ &tc->counter,
+ counter,
+ ATOMIC_ORDER_RELAXED
+ );
+}
+
+/**
+ * @brief Call the directives to get the initial value of CLOCK_REALTIME and
+ * the initial boot time.
+ */
+static void ScoreTimecounterValInstall_Action_0( void )
+{
+ struct bintime bt;
+ struct timespec ts;
+ struct timeval tv;
+
+ /*
+ * Check the initial CLOCK_REALTIME in seconds and nanoseconds format.
+ */
+ rtems_clock_get_realtime( &ts );
+ T_eq_i64( ts.tv_sec, 567993600 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in seconds and nanoseconds format.
+ */
+ rtems_clock_get_realtime( &ts );
+ T_eq_i64( ts.tv_sec, 567993600 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check the initial CLOCK_REALTIME in coarse precision in seconds and
+ * nanoseconds format.
+ */
+ rtems_clock_get_realtime_coarse( &ts );
+ T_eq_i64( ts.tv_sec, 567993600 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in coarse precision in seconds and
+ * nanoseconds format.
+ */
+ rtems_clock_get_realtime_coarse( &ts );
+ T_eq_i64( ts.tv_sec, 567993600 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check the initial CLOCK_REALTIME in binary time format.
+ */
+ rtems_clock_get_realtime_bintime( &bt );
+ T_eq_i64( bt.sec, 567993600 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in binary time format.
+ */
+ rtems_clock_get_realtime_bintime( &bt );
+ T_eq_i64( bt.sec, 567993600 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check the initial CLOCK_REALTIME in coarse precision in binary time
+ * format.
+ */
+ rtems_clock_get_realtime_coarse_bintime( &bt );
+ T_eq_i64( bt.sec, 567993600 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in coarse precision in binary time
+ * format.
+ */
+ rtems_clock_get_realtime_coarse_bintime( &bt );
+ T_eq_i64( bt.sec, 567993600 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check the initial CLOCK_REALTIME in seconds and microseconds format.
+ */
+ rtems_clock_get_realtime_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993600 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in seconds and microseconds format.
+ */
+ rtems_clock_get_realtime_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993600 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check the initial CLOCK_REALTIME in coarse precision in seconds and
+ * microseconds format.
+ */
+ rtems_clock_get_realtime_coarse_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993600 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check that CLOCK_REALTIME is frozen in coarse precision in seconds and
+ * microseconds format.
+ */
+ rtems_clock_get_realtime_coarse_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993600 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check the initial boot time in seconds and nanoseconds format.
+ */
+ rtems_clock_get_boot_time( &ts );
+ T_eq_i64( ts.tv_sec, 567993599 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check the initial boot time in binary time format.
+ */
+ rtems_clock_get_boot_time_bintime( &bt );
+ T_eq_i64( bt.sec, 567993599 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check the initial boot time in seconds and microseconds format.
+ */
+ rtems_clock_get_boot_time_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993599 );
+ T_eq_long( tv.tv_usec, 0 );
+}
+
+/**
+ * @brief Call the directives to get the initial value of CLOCK_MONOTONIC and
+ * the initial boot time.
+ */
+static void ScoreTimecounterValInstall_Action_1( void )
+{
+ struct bintime bt;
+ sbintime_t sb;
+ struct timespec ts;
+ struct timeval tv;
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in seconds and nanoseconds format.
+ */
+ rtems_clock_get_monotonic( &ts );
+ T_eq_i64( ts.tv_sec, 1 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in seconds and nanoseconds format.
+ */
+ rtems_clock_get_monotonic( &ts );
+ T_eq_i64( ts.tv_sec, 1 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in coarse precision in seconds and
+ * nanoseconds format.
+ */
+ rtems_clock_get_monotonic_coarse( &ts );
+ T_eq_i64( ts.tv_sec, 1 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in coarse precision in seconds and
+ * nanoseconds format.
+ */
+ rtems_clock_get_monotonic_coarse( &ts );
+ T_eq_i64( ts.tv_sec, 1 );
+ T_eq_u64( ts.tv_nsec, 0 );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in binary time format.
+ */
+ rtems_clock_get_monotonic_bintime( &bt );
+ T_eq_i64( bt.sec, 1 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in binary time format.
+ */
+ rtems_clock_get_monotonic_bintime( &bt );
+ T_eq_i64( bt.sec, 1 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in coarse precision in binary time
+ * format.
+ */
+ rtems_clock_get_monotonic_coarse_bintime( &bt );
+ T_eq_i64( bt.sec, 1 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in coarse precision in binary time
+ * format.
+ */
+ rtems_clock_get_monotonic_coarse_bintime( &bt );
+ T_eq_i64( bt.sec, 1 );
+ T_eq_u64( bt.frac, 0 );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in signed binary time format.
+ */
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_i64( sb, SBT_1S );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in signed binary time format.
+ */
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_i64( sb, SBT_1S );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in seconds and microseconds format.
+ */
+ rtems_clock_get_monotonic_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 1 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in seconds and microseconds format.
+ */
+ rtems_clock_get_monotonic_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 1 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check the initial CLOCK_MONOTONIC in coarse precision in seconds and
+ * microseconds format.
+ */
+ rtems_clock_get_monotonic_coarse_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 1 );
+ T_eq_long( tv.tv_usec, 0 );
+
+ /*
+ * Check that CLOCK_MONOTONIC is frozen in coarse precision in seconds and
+ * microseconds format.
+ */
+ rtems_clock_get_monotonic_coarse_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 1 );
+ T_eq_long( tv.tv_usec, 0 );
+}
+
+/**
+ * @brief Install timecounter of different quality levels and frequencies.
+ */
+static void ScoreTimecounterValInstall_Action_2( void )
+{
+ Timecounter *hqlf;
+ Timecounter *hqnf;
+ Timecounter *hqhf;
+ Timecounter *lq;
+ sbintime_t sb;
+
+ hqlf = &high_quality_low_frequency;
+ hqnf = &high_quality_normal_frequency;
+ hqhf = &high_quality_high_frequency;
+ lq = &low_quality;
+
+ /*
+ * Install a timecounter with a high quality level and normal frequency.
+ * Check that it was installed.
+ */
+ hqnf->base.tc_get_timecount = GetTimecount;
+ hqnf->base.tc_counter_mask = 0xffffffff;
+ hqnf->base.tc_frequency = 0x20000000;
+ hqnf->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER + 1;
+ rtems_timecounter_install( &hqnf->base );
+
+ T_eq_u32( GetCounter( hqnf ), 1 );
+
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_u32( GetCounter( hqnf ), 2 );
+ T_eq_i64( sb, SBT_1S + 8 );
+
+ /*
+ * Install a timecounter with a high quality level and low frequency. Check
+ * that it was not installed.
+ */
+ hqlf->base.tc_get_timecount = GetTimecount;
+ hqlf->base.tc_counter_mask = 0xffffffff;
+ hqlf->base.tc_frequency = 0x10000000;
+ hqlf->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER + 1;
+ rtems_timecounter_install( &hqlf->base );
+
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 2 );
+
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 3 );
+ T_eq_i64( sb, SBT_1S + 16 );
+
+ /*
+ * Install a timecounter with a high quality level and high frequency. Check
+ * that it was installed.
+ */
+ hqhf->base.tc_get_timecount = GetTimecount;
+ hqhf->base.tc_counter_mask = 0xffffffff;
+ hqhf->base.tc_frequency = 0x40000000;
+ hqhf->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER + 1;
+ rtems_timecounter_install( &hqhf->base );
+
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 4 );
+ T_eq_u32( GetCounter( hqhf ), 1 );
+
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 4 );
+ T_eq_u32( GetCounter( hqhf ), 2 );
+ T_eq_i64( sb, SBT_1S + 28 );
+
+ /*
+ * Install a timecounter with a low quality level. Check that it was not
+ * installed.
+ */
+ lq->base.tc_get_timecount = GetTimecount;
+ lq->base.tc_counter_mask = 0xffffffff;
+ lq->base.tc_frequency = 0x80000000;
+ lq->base.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
+ rtems_timecounter_install( &lq->base );
+
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 4 );
+ T_eq_u32( GetCounter( hqhf ), 2 );
+ T_eq_u32( GetCounter( lq ), 0 );
+
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_u32( GetCounter( hqlf ), 0 );
+ T_eq_u32( GetCounter( hqnf ), 4 );
+ T_eq_u32( GetCounter( hqhf ), 3 );
+ T_eq_u32( GetCounter( lq ), 0 );
+ T_eq_i64( sb, SBT_1S + 32 );
+}
+
+/**
+ * @brief Call the directives to get the time in the highest precision
+ * available to the system.
+ */
+static void ScoreTimecounterValInstall_Action_3( void )
+{
+ Timecounter *tc;
+ uint32_t counter;
+ struct bintime bt;
+ struct timespec ts;
+ struct timeval tv;
+
+ tc = &high_quality_high_frequency;
+ counter = GetCounter( tc );
+
+ /*
+ * Check that the timecounter was used by rtems_clock_get_realtime().
+ */
+ rtems_clock_get_realtime( &ts );
+ T_eq_u32( GetCounter( tc ), counter + 1 );
+
+ /*
+ * Check that the timecounter was used by rtems_clock_get_realtime_bintime().
+ */
+ rtems_clock_get_realtime_bintime( &bt );
+ T_eq_u32( GetCounter( tc ), counter + 2 );
+
+ /*
+ * Check that the timecounter was used by rtems_clock_get_realtime_timeval().
+ */
+ rtems_clock_get_realtime_timeval( &tv );
+ T_eq_u32( GetCounter( tc ), counter + 3 );
+
+ /*
+ * Check that the timecounter was used by rtems_clock_get_monotonic().
+ */
+ rtems_clock_get_monotonic( &ts );
+ T_eq_u32( GetCounter( tc ), counter + 4 );
+
+ /*
+ * Check that the timecounter was used by
+ * rtems_clock_get_monotonic_bintime().
+ */
+ rtems_clock_get_monotonic_bintime( &bt );
+ T_eq_u32( GetCounter( tc ), counter + 5 );
+
+ /*
+ * Check that the timecounter was used by
+ * rtems_clock_get_monotonic_sbintime().
+ */
+ (void) rtems_clock_get_monotonic_sbintime();
+ T_eq_u32( GetCounter( tc ), counter + 6 );
+
+ /*
+ * Check that the timecounter was used by
+ * rtems_clock_get_monotonic_timeval().
+ */
+ rtems_clock_get_monotonic_timeval( &tv );
+ T_eq_u32( GetCounter( tc ), counter + 7 );
+}
+
+/**
+ * @brief Call the directives to get the time in a coarse precision.
+ */
+static void ScoreTimecounterValInstall_Action_4( void )
+{
+ Timecounter *tc;
+ uint32_t counter;
+ struct bintime bt;
+ struct timespec ts;
+ struct timeval tv;
+
+ tc = &high_quality_high_frequency;
+ counter = GetCounter( tc );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse().
+ */
+ rtems_clock_get_realtime_coarse( &ts );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse_bintime().
+ */
+ rtems_clock_get_realtime_coarse_bintime( &bt );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_realtime_coarse_timeval().
+ */
+ rtems_clock_get_realtime_coarse_timeval( &tv );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse().
+ */
+ rtems_clock_get_monotonic_coarse( &ts );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse_bintime().
+ */
+ rtems_clock_get_monotonic_coarse_bintime( &bt );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_monotonic_coarse_timeval().
+ */
+ rtems_clock_get_monotonic_coarse_timeval( &tv );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by rtems_clock_get_boot_time().
+ */
+ rtems_clock_get_boot_time( &ts );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_boot_time_bintime().
+ */
+ rtems_clock_get_boot_time_bintime( &bt );
+ T_eq_u32( GetCounter( tc ), counter );
+
+ /*
+ * Check that the timecounter was not used by
+ * rtems_clock_get_boot_time_timeval().
+ */
+ rtems_clock_get_boot_time_timeval( &tv );
+ T_eq_u32( GetCounter( tc ), counter );
+}
+
+/**
+ * @brief Call the directives to get the time in the highest precision
+ * available to the system.
+ */
+static void ScoreTimecounterValInstall_Action_5( void )
+{
+ Timecounter *tc;
+ uint32_t counter;
+ struct bintime bt;
+ sbintime_t sb;
+ struct timespec ts;
+ struct timeval tv;
+
+ tc = &high_quality_high_frequency;
+ counter = 3 * tc->base.tc_frequency + 123456789;
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_realtime( &ts );
+ T_eq_i64( ts.tv_sec, 567993603 );
+ T_eq_u64( ts.tv_nsec, 114978100 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime_bintime() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_realtime_bintime( &bt );
+ T_eq_i64( bt.sec, 567993603 );
+ T_eq_u64( bt.frac, 2120971587975905280 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_realtime_timeval() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_realtime_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 567993603 );
+ T_eq_long( tv.tv_usec, 114978 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_monotonic( &ts );
+ T_eq_i64( ts.tv_sec, 4 );
+ T_eq_u64( ts.tv_nsec, 114978100 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_bintime() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_monotonic_bintime( &bt );
+ T_eq_i64( bt.sec, 4 );
+ T_eq_u64( bt.frac, 2120971587975905280 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_sbintime() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ sb = rtems_clock_get_monotonic_sbintime();
+ T_eq_i64( sb, 17673696364 );
+
+ /*
+ * Prepare the timecounter to get a large time difference. Check that
+ * rtems_clock_get_monotonic_timeval() returns the correct time.
+ */
+ SetCounter( tc, counter );
+ rtems_clock_get_monotonic_timeval( &tv );
+ T_eq_i64( tv.tv_sec, 4 );
+ T_eq_long( tv.tv_usec, 114978 );
+}
+
+/**
+ * @fn void T_case_body_ScoreTimecounterValInstall( void )
+ */
+T_TEST_CASE( ScoreTimecounterValInstall )
+{
+ ScoreTimecounterValInstall_Action_0();
+ ScoreTimecounterValInstall_Action_1();
+ ScoreTimecounterValInstall_Action_2();
+ ScoreTimecounterValInstall_Action_3();
+ ScoreTimecounterValInstall_Action_4();
+ ScoreTimecounterValInstall_Action_5();
+}
+
+/** @} */
diff --git a/testsuites/validation/ts-validation-timecounter-0.c b/testsuites/validation/ts-validation-timecounter-0.c
new file mode 100644
index 0000000000..9e4abeeab0
--- /dev/null
+++ b/testsuites/validation/ts-validation-timecounter-0.c
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounter0
+ */
+
+/*
+ * 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/test.h>
+
+/**
+ * @defgroup RTEMSTestSuiteTestsuitesValidationTimecounter0 \
+ * spec:/testsuites/validation-timecounter-0
+ *
+ * @ingroup RTEMSTestSuites
+ *
+ * @brief This validation test suite is intended test cases related to the
+ * installation of timecouters. The Clock Driver is disabled.
+ *
+ * @{
+ */
+
+const char rtems_test_name[] = "ValidationTimecounter0";
+
+#define CONFIGURE_MAXIMUM_PROCESSORS 1
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#include "ts-default.h"
+
+/** @} */
diff --git a/testsuites/validation/ts-validation-timecounter-1.c b/testsuites/validation/ts-validation-timecounter-1.c
new file mode 100644
index 0000000000..ec0ff027ee
--- /dev/null
+++ b/testsuites/validation/ts-validation-timecounter-1.c
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounter1
+ */
+
+/*
+ * 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/test.h>
+
+/**
+ * @defgroup RTEMSTestSuiteTestsuitesValidationTimecounter1 \
+ * spec:/testsuites/validation-timecounter-1
+ *
+ * @ingroup RTEMSTestSuites
+ *
+ * @brief This validation test suite is intended test cases related to the use
+ * of timecouters. The Clock Driver is enabled.
+ *
+ * @{
+ */
+
+const char rtems_test_name[] = "ValidationTimecounter1";
+
+#define CONFIGURE_MAXIMUM_PROCESSORS 4
+
+#include "ts-default.h"
+
+/** @} */
diff --git a/testsuites/validation/ts-validation-timecounter-smp-0.c b/testsuites/validation/ts-validation-timecounter-smp-0.c
new file mode 100644
index 0000000000..6ae0311b59
--- /dev/null
+++ b/testsuites/validation/ts-validation-timecounter-smp-0.c
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidationTimecounterSmp0
+ */
+
+/*
+ * 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/test.h>
+
+/**
+ * @defgroup RTEMSTestSuiteTestsuitesValidationTimecounterSmp0 \
+ * spec:/testsuites/validation-timecounter-smp-0
+ *
+ * @ingroup RTEMSTestSuites
+ *
+ * @brief This validation test suite is intended test cases related to the use
+ * of timecouters. The Clock Driver is disabled.
+ *
+ * @{
+ */
+
+const char rtems_test_name[] = "ValidationTimecounterSmp0";
+
+#define CONFIGURE_MAXIMUM_PROCESSORS 4
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#include "ts-default.h"
+
+/** @} */