From 4696cd14333be679c340efa9977b408258f5e909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20K=C3=BChndel?= Date: Wed, 9 Jun 2021 14:12:22 +0200 Subject: spec: Adding a test for timer_[server_]fire_when() Extending the validation test of specification items for the directives rtems_timer_fire_when() and rtems_timer_server_fire_when() of the timer manager. The case for trying to create a timer with a trigger time in the past is tested. --- spec/rtems/timer/req/fire-when.yml | 27 +++++++++++++++++--- spec/rtems/timer/req/server-fire-when.yml | 41 +++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/spec/rtems/timer/req/fire-when.yml b/spec/rtems/timer/req/fire-when.yml index 5b9f3e9d..aa3b5fae 100644 --- a/spec/rtems/timer/req/fire-when.yml +++ b/spec/rtems/timer/req/fire-when.yml @@ -131,8 +131,8 @@ post-conditions: ); text: | The ${../glossary/timerserviceroutine:/term} shall be invoked at the - wall time (see ${../glossary/realtimeclock:/term}), which was provided by - the ${../if/fire-when:/params[1]/name} parameter + wall time (see ${../glossary/realtimeclock:/term}) (ignoring ticks), + which was provided by the ${../if/fire-when:/params[1]/name} parameter in the past call to ${../if/fire-when:/name}. - name: Nop test-code: | @@ -233,13 +233,21 @@ pre-conditions: test-code: | ctx->wall_time_param = &tod_schedule; text: | - While the ${../if/fire-when:/params[1]/name} parameter is a positive - (greater than 0) number. + While the ${../if/fire-when:/params[1]/name} parameter references + a time at least one second in the future but not later than the last + second of the year 2105. (Times after 2105 are invalid.) - name: Invalid test-code: | ctx->wall_time_param = &tod_invalid; text: | While the ${../if/fire-when:/params[1]/name} parameter is invalid. + - name: Past + test-code: | + ctx->wall_time_param = &tod_past; + text: | + While the ${../if/fire-when:/params[1]/name} parameter references + a time in the current second or in the past but not earlier than 1988. + (Times before 1988 are invalid.) - name: 'Null' test-code: | ctx->wall_time_param = NULL; @@ -549,6 +557,11 @@ test-support: | static const rtems_time_of_day tod_now = { 2000, 1, 1, 0, 0, 0, 0 }; static const rtems_time_of_day tod_schedule = { 2000, 1, 1, 5, 0, 0, 0 }; static const rtems_time_of_day tod_invalid = { 1985, 1, 1, 0, 0, 0, 0 }; + /* + * rtems_fire_when() ignores ticks and treads all wall times in the + * current second like being in the "past". This border case is tested. + */ + static const rtems_time_of_day tod_past = { 2000, 1, 1, 0, 0, 0, 50 }; static void TriggerTimer( const RtemsTimerReqFireWhen_Context *ctx, @@ -904,6 +917,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - None @@ -928,6 +942,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - Server @@ -952,6 +967,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - Interrupt @@ -977,6 +993,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - None @@ -1000,6 +1017,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - Server @@ -1023,6 +1041,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - Interrupt diff --git a/spec/rtems/timer/req/server-fire-when.yml b/spec/rtems/timer/req/server-fire-when.yml index 00cbf649..5dfc2f56 100644 --- a/spec/rtems/timer/req/server-fire-when.yml +++ b/spec/rtems/timer/req/server-fire-when.yml @@ -137,9 +137,9 @@ post-conditions: ); text: | The ${../glossary/timerserviceroutine:/term} shall be invoked at the - wall time (see ${../glossary/realtimeclock:/term}), which was provided by - the ${../if/server-fire-when:/params[1]/name} parameter - in the past call to ${../if/server-fire-when:/name}. + wall time (see ${../glossary/realtimeclock:/term}) (ignoring ticks), + which was provided by the ${../if/server-fire-when:/params[1]/name} + parameter in the past call to ${../if/server-fire-when:/name}. - name: Nop test-code: | /* @@ -244,8 +244,8 @@ pre-conditions: test-code: | ctx->routine_param = TimerServiceRoutine; text: | - While the ${../if/server-fire-when:/params[2]/name} parameter references an - object of type ${../if/service-routine-entry:/name}. + While the ${../if/server-fire-when:/params[2]/name} parameter references + an object of type ${../if/service-routine-entry:/name}. - name: 'Null' test-code: | ctx->routine_param = NULL; @@ -260,13 +260,21 @@ pre-conditions: test-code: | ctx->wall_time_param = &tod_schedule; text: | - While the ${../if/server-fire-when:/params[1]/name} parameter is a positive - (greater than 0) number. + While the ${../if/server-fire-when:/params[1]/name} parameter references + a time at least one second in the future but not later than the last + second of the year 2105. (Times after 2105 are invalid.) - name: Invalid test-code: | ctx->wall_time_param = &tod_invalid; text: | While the ${../if/server-fire-when:/params[1]/name} parameter is invalid. + - name: Past + test-code: | + ctx->wall_time_param = &tod_past; + text: | + While the ${../if/server-fire-when:/params[1]/name} parameter references + a time in the current second or in the past but not earlier than 1988. + (Times before 1988 are invalid.) - name: 'Null' test-code: | ctx->wall_time_param = NULL; @@ -445,20 +453,20 @@ test-context: member: | rtems_id timer_id - brief: | - This member specifies the ${../if/server-fire-when:/params[0]/name} parameter - for the action. + This member specifies the ${../if/server-fire-when:/params[0]/name} + parameter for the action. description: null member: | rtems_id id_param - brief: | - This member specifies the ${../if/server-fire-when:/params[1]/name} parameter - for the action. + This member specifies the ${../if/server-fire-when:/params[1]/name} + parameter for the action. description: null member: | const rtems_time_of_day *wall_time_param - brief: | - This member specifies the ${../if/server-fire-when:/params[2]/name} parameter - for the action. + This member specifies the ${../if/server-fire-when:/params[2]/name} + parameter for the action. description: null member: | rtems_timer_service_routine_entry routine_param @@ -570,6 +578,7 @@ test-support: | static const rtems_time_of_day tod_now = { 2000, 1, 1, 0, 0, 0, 0 }; static const rtems_time_of_day tod_schedule = { 2000, 1, 1, 5, 0, 0, 0 }; static const rtems_time_of_day tod_invalid = { 1985, 1, 1, 0, 0, 0, 0 }; + static const rtems_time_of_day tod_past = { 1999, 12, 31, 23, 59, 59, 1 }; static void TriggerTimer( const RtemsTimerReqServerFireWhen_Context *ctx, @@ -981,6 +990,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - None @@ -1007,6 +1017,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - Server @@ -1033,6 +1044,7 @@ transition-map: WallTime: - Valid - Invalid + - Past Id: all Context: - Interrupt @@ -1060,6 +1072,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - None @@ -1085,6 +1098,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - Server @@ -1110,6 +1124,7 @@ transition-map: - Valid WallTime: - Invalid + - Past Id: all Context: - Interrupt -- cgit v1.2.3