summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-03 11:09:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-06 12:24:04 +0200
commitad41c17933e40f277d78b0f9d36b691c00bb8ca5 (patch)
treeeea4439c0ec3753cc129492fbc9f0e4c5d669423 /testsuites
parentscore: Simplify _TOD_Validate() (diff)
downloadrtems-ad41c17933e40f277d78b0f9d36b691c00bb8ca5.tar.bz2
score: Change TOD_LATEST_YEAR to 2099
This simplifies the implementation a bit. Declare _TOD_Days_to_date[] in <rtems/score/todimpl.h>. Make _TOD_Days_per_month[] and _TOD_Days_since_last_leap_year[] static. Update #4338.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/sp2038/init.c43
-rw-r--r--testsuites/sptests/spclock_err02/init.c8
2 files changed, 9 insertions, 42 deletions
diff --git a/testsuites/sptests/sp2038/init.c b/testsuites/sptests/sp2038/init.c
index dedd66d2c3..02789e55a5 100644
--- a/testsuites/sptests/sp2038/init.c
+++ b/testsuites/sptests/sp2038/init.c
@@ -143,13 +143,7 @@ static const uint32_t sample_seconds [] = {
3979434495UL,
4011056895UL,
4042592895UL,
- 4074128895UL,
- 4105664895UL,
- 4137200895UL,
- 4168736895UL,
- 4200272895UL,
- 4231808895UL,
- 4263431295UL
+ 4074128895UL
};
static const rtems_time_of_day nearly_problem_2038 = {
@@ -179,24 +173,6 @@ static const rtems_time_of_day tod_to_seconds_base = {
.second = 15
};
-static const rtems_time_of_day nearly_problem_2106 = {
- .year = 2105,
- .month = 12,
- .day = 31,
- .hour = 23,
- .minute = 59,
- .second = 59
-};
-
-static const rtems_time_of_day problem_2106 = {
- .year = 2106,
- .month = 1,
- .day = 1,
- .hour = 0,
- .minute = 0,
- .second = 0
-};
-
static const rtems_time_of_day problem_2100 = {
.year = 2100,
.month = 2,
@@ -242,24 +218,15 @@ static void test_tod_to_seconds(void)
static void test_problem_year(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
- time_t zero = 0;
- time_t one = 1;
- time_t maybe_negative = zero - one;
bool time_t_is_32_bit = sizeof(time_t) == 4;
- bool time_t_is_signed = maybe_negative < zero;
if (time_t_is_32_bit) {
const rtems_time_of_day *nearly_problem = NULL;
const rtems_time_of_day *problem = NULL;
rtems_time_of_day now;
- if (time_t_is_signed) {
- nearly_problem = &nearly_problem_2038;
- problem = &problem_2038;
- } else {
- nearly_problem = &nearly_problem_2106;
- problem = &problem_2106;
- }
+ nearly_problem = &nearly_problem_2038;
+ problem = &problem_2038;
sc = rtems_clock_set(nearly_problem);
ASSERT_SC(sc);
@@ -282,7 +249,7 @@ static void test_leap_year(void)
const rtems_time_of_day *problem2 = &problem_2100_2;
// 2100 is not a leap year, so it should have 28 days
test_status = _TOD_Validate(problem, TOD_ENABLE_TICKS_VALIDATION);
- rtems_test_assert(test_status == RTEMS_SUCCESSFUL);
+ rtems_test_assert(test_status == RTEMS_INVALID_CLOCK);
test_status = _TOD_Validate(problem2, TOD_ENABLE_TICKS_VALIDATION);
rtems_test_assert(test_status == RTEMS_INVALID_CLOCK);
}
@@ -309,7 +276,7 @@ static void test_every_day(void)
rtems_status_code sc = RTEMS_SUCCESSFUL;
rtems_time_of_day now;
- for (every_day.year = 1988; every_day.year <= 2100; ++every_day.year) {
+ for (every_day.year = 1988; every_day.year <= 2099; ++every_day.year) {
int leap_year = test_year_is_leap_year(every_day.year) ? 1 : 0;
for (every_day.month = 1; every_day.month <= 12; ++every_day.month) {
int days = days_per_month[leap_year][every_day.month - 1];
diff --git a/testsuites/sptests/spclock_err02/init.c b/testsuites/sptests/spclock_err02/init.c
index c879c4ce1f..2200b24ec6 100644
--- a/testsuites/sptests/spclock_err02/init.c
+++ b/testsuites/sptests/spclock_err02/init.c
@@ -89,7 +89,7 @@ rtems_task Init(
directive_failed( status, "rtems_clock_get_tod" );
print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
- build_time( &time, 12, 31, 2100, 23, 59, 59, 0 );
+ build_time( &time, 12, 31, 2099, 23, 59, 59, 0 );
status = rtems_clock_set( &time );
directive_failed( status, "rtems_clock_set" );
print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
@@ -98,10 +98,10 @@ rtems_task Init(
directive_failed( status, "rtems_clock_set" );
print_time( "TA1 - rtems_clock_get_tod - ", &time, " - RTEMS_SUCCESSFUL\n" );
- build_time( &time, 12, 31, 2099, 23, 59, 59, 0 );
+ build_time( &time, 1, 1, 2100, 0, 0, 0, 0 );
status = rtems_clock_set( &time );
- directive_failed( status, "rtems_clock_set" );
- print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_SUCCESSFUL\n" );
+ fatal_directive_status( status, RTEMS_INVALID_CLOCK, "rtems_clock_set" );
+ print_time( "TA1 - rtems_clock_set - ", &time, " - RTEMS_INVALID_CLOCK\n" );
status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
status = rtems_clock_get_tod( &time );
directive_failed( status, "rtems_clock_set" );