[rtems-central commit] spec: Fix rate monotonic statistics
Sebastian Huber
sebh at rtems.org
Wed Oct 13 07:58:20 UTC 2021
Module: rtems-central
Branch: master
Commit: 2e19aacf5f8cf37cb452e7479548685801fdd91f
Changeset: http://git.rtems.org/rtems-central/commit/?id=2e19aacf5f8cf37cb452e7479548685801fdd91f
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Oct 12 13:17:32 2021 +0200
spec: Fix rate monotonic statistics
---
spec/rtems/cpuuse/val/cpuuse.yml | 24 ++++---
spec/rtems/ratemon/req/get-status.yml | 71 --------------------
spec/rtems/ratemon/unit/statistics.yml | 114 ---------------------------------
3 files changed, 14 insertions(+), 195 deletions(-)
diff --git a/spec/rtems/cpuuse/val/cpuuse.yml b/spec/rtems/cpuuse/val/cpuuse.yml
index 5b53898..970f0ca 100644
--- a/spec/rtems/cpuuse/val/cpuuse.yml
+++ b/spec/rtems/cpuuse/val/cpuuse.yml
@@ -10,7 +10,8 @@ test-actions:
rtems_id id;
Thread_Control *self;
Thread_Control *other;
- Timestamp_Control timestamp;
+ Timestamp_Control cpu_usage_self;
+ Timestamp_Control cpu_usage_other;
id = CreateTask( "WORK", GetSelfPriority() );
StartTask( id, Worker, NULL );
@@ -27,20 +28,23 @@ test-actions:
code: |
TimecounterTick();
- _Thread_Get_CPU_time_used( self, ×tamp );
- T_gt_i64( timestamp, 0 );
+ cpu_usage_self = _Thread_Get_CPU_time_used( self );
+ cpu_usage_other = _Thread_Get_CPU_time_used( other );
- _Thread_Get_CPU_time_used( other, ×tamp );
- T_gt_i64( timestamp, 0 );
+ T_gt_i64( _Thread_Get_CPU_time_used_after_last_reset( self ), 0 );
+ T_gt_i64( _Thread_Get_CPU_time_used_after_last_reset( other ), 0 );
rtems_cpu_usage_reset();
- /* Our CPU usage is now exactly one tick of the software timecounter */
- _Thread_Get_CPU_time_used( self, ×tamp );
- T_eq_i64( timestamp, 4295 );
+ /*
+ * Our CPU usage after the last reset is now exactly one tick of the
+ * software timecounter.
+ */
+ T_eq_i64( _Thread_Get_CPU_time_used_after_last_reset( self ), 4295 );
+ T_eq_i64( _Thread_Get_CPU_time_used( self ), cpu_usage_self + 30065 );
- _Thread_Get_CPU_time_used( other, ×tamp );
- T_eq_i64( timestamp, 0 );
+ T_eq_i64( _Thread_Get_CPU_time_used_after_last_reset( other ), 0 );
+ T_eq_i64( _Thread_Get_CPU_time_used( other ), cpu_usage_other );
links:
- role: validation
uid: ../req/reset
diff --git a/spec/rtems/ratemon/req/get-status.yml b/spec/rtems/ratemon/req/get-status.yml
index a6446f4..8b79848 100644
--- a/spec/rtems/ratemon/req/get-status.yml
+++ b/spec/rtems/ratemon/req/get-status.yml
@@ -27,12 +27,6 @@ post-conditions:
text: |
The return status of ${../if/get-status:/name} shall be
${../../status/if/invalid-id:/name}.
- - name: NotDef
- test-code: |
- T_rsc( ctx->status, RTEMS_NOT_DEFINED );
- text: |
- The return status of ${../if/get-status:/name} shall be
- ${../../status/if/not-defined:/name}.
test-epilogue: null
test-prologue: null
- name: Owner
@@ -283,22 +277,6 @@ pre-conditions:
While the ${../if/get-status:/params[0]/name} parameter is invalid.
test-epilogue: null
test-prologue: null
-- name: CpuUse
- states:
- - name: Kept
- test-code: |
- ctx->do_reset = NULL;
- text: |
- While the CPU usage statistics in not changed.
- - name: Reset
- test-code: |
- ctx->do_reset = rtems_cpu_usage_reset;
- text: |
- While the ${../../cpuuse/if/reset:/name} directive is called between the
- call to ${../if/period:/name} which started the period and
- the call to ${../if/get-status:/name}.
- test-epilogue: null
- test-prologue: null
- name: State
states:
- name: Inactive
@@ -382,10 +360,6 @@ skip-reasons:
NeverInExpiredState: |
There must be ${../glossary/postponedjob:/plural} in
${../glossary/expired:/term} ${../glossary/state:/term}.
- ResetOnlyWhenActive: |
- The directive ${../../cpuuse/if/reset:/name} affects only periods
- in ${../glossary/active:/term} or ${../glossary/expired:/term}
- ${../glossary/state:/term}.
test-action: |
if ( ctx->do_reset != NULL ) {
ctx->do_reset();
@@ -572,8 +546,6 @@ transition-map:
- Valid
Id:
- Valid
- CpuUse:
- - Kept
State:
- Inactive
Elapsed: N/A
@@ -594,8 +566,6 @@ transition-map:
- Valid
Id:
- Valid
- CpuUse:
- - Kept
State:
- Active
- Expired
@@ -616,7 +586,6 @@ transition-map:
StatusAddr:
- 'Null'
Id: all
- CpuUse: all
State:
- Inactive
Elapsed: all
@@ -634,7 +603,6 @@ transition-map:
StatusAddr:
- 'Null'
Id: all
- CpuUse: all
State:
- Active
- Expired
@@ -654,7 +622,6 @@ transition-map:
- Valid
Id:
- Invalid
- CpuUse: all
State:
- Inactive
Elapsed: all
@@ -673,30 +640,6 @@ transition-map:
- Valid
Id:
- Invalid
- CpuUse: all
- State:
- - Active
- - Expired
- Elapsed: all
- Consumed: all
- Postponed: all
-- enabled-by: true
- post-conditions:
- Status: NotDef
- Owner: OwnerTask
- State:
- - specified-by: State
- Elapsed: Nop
- Consumed: Nop
- Postponed:
- - specified-by: Postponed
- pre-conditions:
- StatusAddr:
- - Valid
- Id:
- - Valid
- CpuUse:
- - Reset
State:
- Active
- Expired
@@ -708,7 +651,6 @@ transition-map:
pre-conditions:
StatusAddr: all
Id: all
- CpuUse: all
State:
- Inactive
Elapsed: all
@@ -721,23 +663,10 @@ transition-map:
pre-conditions:
StatusAddr: all
Id: all
- CpuUse: all
State:
- Expired
Elapsed: all
Consumed: all
Postponed:
- Zero
-- enabled-by: true
- post-conditions: ResetOnlyWhenActive
- pre-conditions:
- StatusAddr: all
- Id: all
- CpuUse:
- - Reset
- State:
- - Inactive
- Elapsed: all
- Consumed: all
- Postponed: all
type: requirement
diff --git a/spec/rtems/ratemon/unit/statistics.yml b/spec/rtems/ratemon/unit/statistics.yml
deleted file mode 100644
index 1328b87..0000000
--- a/spec/rtems/ratemon/unit/statistics.yml
+++ /dev/null
@@ -1,114 +0,0 @@
-SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
-copyrights:
-- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
-enabled-by: true
-links: []
-test-actions:
-- action-brief: |
- Start a period, reset the CPU usage counters and then
- call ${../if/period:/name} again. This second call will
- invoke ``_Rate_monotonic_Update_statistics()`` and enter the
- ``if()`` otherwise not reached.
-
- After each call to ${../if/period:/name}, ${../if/period-status:/name}
- will be called in order to check that the period status recovers from
- the reset with the start of the second period.
- action-code: |
- rtems_status_code status_0;
- rtems_status_code status_1;
- rtems_status_code status_code_0;
- rtems_status_code status_code_1;
- rtems_rate_monotonic_period_status status_data;
-
- status_0 = rtems_rate_monotonic_period( ctx->period_id, PERIOD_LENGTH );
- rtems_cpu_usage_reset();
-
- status_code_0 = rtems_rate_monotonic_get_status(
- ctx->period_id,
- &status_data
- );
-
- TimecounterTick();
- status_1 = rtems_rate_monotonic_period( ctx->period_id, PERIOD_LENGTH );
- status_code_1 = rtems_rate_monotonic_get_status(
- ctx->period_id,
- &status_data
- );
- checks:
- - brief: |
- Check status returned by the two calls to ${../if/period:/name}.
- code: |
- T_rsc_success( status_0 );
- T_rsc( status_1, RTEMS_TIMEOUT );
- links: []
- - brief: |
- Check the first call to ${../if/period-status:/name} is not
- defined due to the preceding reset of the CUP usage counters.
- code: |
- T_rsc( status_code_0, RTEMS_NOT_DEFINED );
- links: []
- - brief: |
- Check that the second call to ${../if/period-status:/name} is not
- longer affected by the reset of the CUP usage counters in the
- previous period.
- code: |
- T_rsc_success( status_code_1 );
- links: []
- links:
- - name: _Rate_monotonic_Update_statistics
- role: unit-test
- uid: ../../../score/if/domain
-test-brief: |
- Unit tests for the Rate Monotonic Manager.
-test-context:
-- brief: |
- This member contains a valid identifier of a period.
- description: null
- member: |
- rtems_id period_id
-- brief: |
- This member contains the previous timecounter handler to restore.
- description: null
- member: |
- GetTimecountHandler previous_timecounter_handler
-test-context-support: |
- static uint32_t FreezeTime( void );
- #define PERIOD_LENGTH 1
-test-description: |
- A line in the file ``cpukit/rtems/src/ratemonperiod.c`` is not reached
- by validation tests. The space qualified code subset does not
- contain ${../if/get-statistics:/name}. This test exercises the
- code parts otherwise not reached in order to achieve full code coverage.
-test-header: null
-test-includes:
-- rtems.h
-- rtems/cpuuse.h
-test-local-includes:
-- ../validation/tx-support.h
-test-setup:
- brief: null
- code: |
- rtems_status_code status;
- ctx->previous_timecounter_handler = SetGetTimecountHandler( FreezeTime );
-
- status = rtems_rate_monotonic_create(
- rtems_build_name( 'R', 'M', 'O', 'N' ),
- &ctx->period_id
- );
- T_rsc_success( status );
- description: null
-test-stop: null
-test-support: |
- static uint32_t FreezeTime( void )
- {
- return GetTimecountCounter() - 1;
- }
-test-target: testsuites/unit/tc-ratemon-statistics.c
-test-teardown:
- brief: null
- code: |
- T_rsc_success( rtems_rate_monotonic_delete( ctx->period_id ) );
- SetGetTimecountHandler( ctx->previous_timecounter_handler );
- description: null
-
-type: test-case
More information about the vc
mailing list