From 3c40945fea5379db8ccfa06aef0bd9cfa1e878fd Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 17 Oct 2017 13:00:11 +0000 Subject: Test suite cleaned up of direct math operations on system time. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10844 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/configuration.xml | 75 ++++++++++++++++-------------- test/rt/source/test/rt_test_root.c | 2 +- test/rt/source/test/rt_test_sequence_003.c | 22 ++++----- test/rt/source/test/rt_test_sequence_004.c | 4 +- test/rt/source/test/rt_test_sequence_005.c | 5 +- test/rt/source/test/rt_test_sequence_006.c | 8 ++-- test/rt/source/test/rt_test_sequence_008.c | 20 ++++---- test/rt/source/test/rt_test_sequence_010.c | 16 +++---- 8 files changed, 83 insertions(+), 69 deletions(-) (limited to 'test/rt') diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml index bb8904668..4f7fab6fb 100644 --- a/test/rt/configuration.xml +++ b/test/rt/configuration.xml @@ -688,8 +688,8 @@ while (time == chVTGetSystemTimeX()) { @@ -703,8 +703,8 @@ test_assert_time_window(time + 100, @@ -718,8 +718,8 @@ test_assert_time_window(time + TIME_US2I(100000), @@ -733,8 +733,8 @@ test_assert_time_window(time + TIME_MS2I(100), @@ -747,9 +747,9 @@ test_assert_time_window(time + TIME_S2I(1), @@ -1040,8 +1040,8 @@ test_wait_threads();]]> time = chVTGetSystemTimeX(); msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000)); chSysUnlock(); -test_assert_time_window(time + TIME_MS2I(1000), - time + TIME_MS2I(1000) + CH_CFG_ST_TIMEDELTA + 1, +test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)), + chTimeAddX(time, TIME_MS2I(1000) + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); test_assert(NULL == tr1, "not NULL"); test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]> @@ -1284,7 +1284,7 @@ test_assert(sem1.cnt == 0, "counter not zero");]]> - @@ -1545,7 +1546,7 @@ void test_cpu_pulse(unsigned duration) { systime_t start, end, now; start = chThdGetTicksX(chThdGetSelfX()); - end = start + TIME_MS2I(duration); + end = chTimeAddX(start, TIME_MS2I(duration)); do { now = chThdGetTicksX(chThdGetSelfX()); #if defined(SIMULATOR) @@ -1834,7 +1835,8 @@ test_assert_sequence("ABC", "invalid sequence");]]> - @@ -1899,7 +1901,8 @@ test_assert_sequence("ABCDE", "invalid sequence");]]> - @@ -2804,7 +2807,7 @@ test_assert(m == 0, "stuck event");]]> - @@ -2818,7 +2821,8 @@ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - @@ -2898,7 +2902,8 @@ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - @@ -2989,7 +2994,8 @@ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - @@ -3115,7 +3121,8 @@ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, n = 0; start = test_wait_tick(); -end = start + TIME_MS2I(1000); +end = chTimeAddX(start, TIME_MS2I(1000)); do { chSysLock(); chSchWakeupS(tp, MSG_OK); @@ -3820,7 +3827,7 @@ systime_t start, end;]]> n = 0; start = test_wait_tick(); -end = start + TIME_MS2I(1000); +end = chTimeAddX(start, TIME_MS2I(1000)); do { chSysLock(); chVTDoSetI(&vt1, 1, tmo, NULL); @@ -4167,7 +4174,7 @@ The performance is calculated by measuring the number of iterations after a seco n = 0; start = test_wait_tick(); -end = start + TIME_MS2I(1000); +end = chTimeAddX(start, TIME_MS2I(1000)); do { chSemWait(&sem1); chSemSignal(&sem1); @@ -4234,7 +4241,7 @@ The performance is calculated by measuring the number of iterations after a seco n = 0; start = test_wait_tick(); -end = start + TIME_MS2I(1000); +end = chTimeAddX(start, TIME_MS2I(1000)); do { chMtxLock(&mtx1); chMtxUnlock(&mtx1); diff --git a/test/rt/source/test/rt_test_root.c b/test/rt/source/test/rt_test_root.c index 9e0365686..0349fc1e6 100644 --- a/test/rt/source/test/rt_test_root.c +++ b/test/rt/source/test/rt_test_root.c @@ -79,7 +79,7 @@ const testsequence_t * const rt_test_suite_array[] = { * @brief Test suite root structure. */ const testsuite_t rt_test_suite = { - "ChibiOS/RT Library Test Suite.", + "ChibiOS/RT Test Suite.", rt_test_suite_array }; diff --git a/test/rt/source/test/rt_test_sequence_003.c b/test/rt/source/test/rt_test_sequence_003.c index 9069502e9..5a9771d4f 100644 --- a/test/rt/source/test/rt_test_sequence_003.c +++ b/test/rt/source/test/rt_test_sequence_003.c @@ -83,8 +83,8 @@ static void rt_test_003_001_execute(void) { { time = chVTGetSystemTimeX(); chThdSleep(100); - test_assert_time_window(time + 100, - time + 100 + CH_CFG_ST_TIMEDELTA + 1, + test_assert_time_window(chTimeAddX(time, 100), + chTimeAddX(time, 100 + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); } @@ -95,8 +95,8 @@ static void rt_test_003_001_execute(void) { { time = chVTGetSystemTimeX(); chThdSleepMicroseconds(100000); - test_assert_time_window(time + TIME_US2I(100000), - time + TIME_US2I(100000) + CH_CFG_ST_TIMEDELTA + 1, + test_assert_time_window(chTimeAddX(time, TIME_US2I(100000)), + chTimeAddX(time, TIME_US2I(100000) + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); } @@ -107,8 +107,8 @@ static void rt_test_003_001_execute(void) { { time = chVTGetSystemTimeX(); chThdSleepMilliseconds(100); - test_assert_time_window(time + TIME_MS2I(100), - time + TIME_MS2I(100) + CH_CFG_ST_TIMEDELTA + 1, + test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)), + chTimeAddX(time, TIME_MS2I(100) + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); } @@ -118,8 +118,8 @@ static void rt_test_003_001_execute(void) { { time = chVTGetSystemTimeX(); chThdSleepSeconds(1); - test_assert_time_window(time + TIME_S2I(1), - time + TIME_S2I(1) + CH_CFG_ST_TIMEDELTA + 1, + test_assert_time_window(chTimeAddX(time, TIME_S2I(1)), + chTimeAddX(time, TIME_S2I(1) + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); } @@ -128,9 +128,9 @@ static void rt_test_003_001_execute(void) { test_set_step(5); { time = chVTGetSystemTimeX(); - chThdSleepUntil(time + 100); - test_assert_time_window(time + 100, - time + 100 + CH_CFG_ST_TIMEDELTA + 1, + chThdSleepUntil(chTimeAddX(time, 100)); + test_assert_time_window(chTimeAddX(time, 100), + chTimeAddX(time, 100 + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); } } diff --git a/test/rt/source/test/rt_test_sequence_004.c b/test/rt/source/test/rt_test_sequence_004.c index 67eaefdb1..9793102e1 100644 --- a/test/rt/source/test/rt_test_sequence_004.c +++ b/test/rt/source/test/rt_test_sequence_004.c @@ -101,8 +101,8 @@ static void rt_test_004_001_execute(void) { time = chVTGetSystemTimeX(); msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000)); chSysUnlock(); - test_assert_time_window(time + TIME_MS2I(1000), - time + TIME_MS2I(1000) + CH_CFG_ST_TIMEDELTA + 1, + test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)), + chTimeAddX(time, TIME_MS2I(1000) + CH_CFG_ST_TIMEDELTA + 1), "out of time window"); test_assert(NULL == tr1, "not NULL"); test_assert(MSG_TIMEOUT == msg, "wrong returned message"); diff --git a/test/rt/source/test/rt_test_sequence_005.c b/test/rt/source/test/rt_test_sequence_005.c index 29127092b..437bbaf87 100644 --- a/test/rt/source/test/rt_test_sequence_005.c +++ b/test/rt/source/test/rt_test_sequence_005.c @@ -260,7 +260,7 @@ static void rt_test_005_003_execute(void) { /* [5.3.3] Testing timeout condition.*/ test_set_step(3); { - target_time = test_wait_tick() + TIME_MS2I(5 * 50); + target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(5 * 50)); for (i = 0; i < 5; i++) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, TIME_MS2I(50)); @@ -269,7 +269,8 @@ static void rt_test_005_003_execute(void) { test_assert(sem1.cnt == 0, "counter not zero"); } test_assert_sequence("ABCDE", "invalid sequence"); - test_assert_time_window(target_time, target_time + ALLOWED_DELAY, + test_assert_time_window(target_time, + chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); } } diff --git a/test/rt/source/test/rt_test_sequence_006.c b/test/rt/source/test/rt_test_sequence_006.c index 14aa2dd78..4b4ec262f 100644 --- a/test/rt/source/test/rt_test_sequence_006.c +++ b/test/rt/source/test/rt_test_sequence_006.c @@ -71,7 +71,7 @@ void test_cpu_pulse(unsigned duration) { systime_t start, end, now; start = chThdGetTicksX(chThdGetSelfX()); - end = start + TIME_MS2I(duration); + end = chTimeAddX(start, TIME_MS2I(duration)); do { now = chThdGetTicksX(chThdGetSelfX()); #if defined(SIMULATOR) @@ -358,7 +358,8 @@ static void rt_test_006_002_execute(void) { time windows (100mS...100mS+ALLOWED_DELAY).*/ test_set_step(3); { - test_assert_time_window(time + TIME_MS2I(100), time + TIME_MS2I(100) + ALLOWED_DELAY, + test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)), + chTimeAddX(time, TIME_MS2I(100) + ALLOWED_DELAY), "out of time window"); } } @@ -430,7 +431,8 @@ static void rt_test_006_003_execute(void) { time windows (110mS...110mS+ALLOWED_DELAY).*/ test_set_step(3); { - test_assert_time_window(time + TIME_MS2I(110), time + TIME_MS2I(110) + ALLOWED_DELAY, + test_assert_time_window(chTimeAddX(time, TIME_MS2I(110)), + chTimeAddX(time, TIME_MS2I(110) + ALLOWED_DELAY), "out of time window"); } } diff --git a/test/rt/source/test/rt_test_sequence_008.c b/test/rt/source/test/rt_test_sequence_008.c index 77b49268d..3b23db132 100644 --- a/test/rt/source/test/rt_test_sequence_008.c +++ b/test/rt/source/test/rt_test_sequence_008.c @@ -225,7 +225,7 @@ static void rt_test_008_003_execute(void) { thread will set an event flag after 50mS.*/ test_set_step(3); { - target_time = test_wait_tick() + TIME_MS2I(50); + target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(50)); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, evt_thread3, chThdGetSelfX()); } @@ -236,7 +236,8 @@ static void rt_test_008_003_execute(void) { test_set_step(4); { m = chEvtWaitOne(ALL_EVENTS); - test_assert_time_window(target_time, target_time + ALLOWED_DELAY, + test_assert_time_window(target_time, + chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); test_assert(m == 1, "event flag error"); m = chEvtGetAndClearEvents(ALL_EVENTS); @@ -298,7 +299,7 @@ static void rt_test_008_004_execute(void) { thread will set an event flag after 50mS.*/ test_set_step(3); { - target_time = test_wait_tick() + TIME_MS2I(50); + target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(50)); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, evt_thread3, chThdGetSelfX()); } @@ -309,7 +310,8 @@ static void rt_test_008_004_execute(void) { test_set_step(4); { m = chEvtWaitAny(ALL_EVENTS); - test_assert_time_window(target_time, target_time + ALLOWED_DELAY, + test_assert_time_window(target_time, + chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); test_assert(m == 1, "event flag error"); m = chEvtGetAndClearEvents(ALL_EVENTS); @@ -378,7 +380,7 @@ static void rt_test_008_005_execute(void) { thread will set another event flag after 50mS.*/ test_set_step(4); { - target_time = test_wait_tick() + TIME_MS2I(50); + target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(50)); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, evt_thread3, chThdGetSelfX()); } @@ -389,7 +391,8 @@ static void rt_test_008_005_execute(void) { test_set_step(5); { m = chEvtWaitAll(5); - test_assert_time_window(target_time, target_time + ALLOWED_DELAY, + test_assert_time_window(target_time, + chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); test_assert(m == 5, "event flags error"); m = chEvtGetAndClearEvents(ALL_EVENTS); @@ -510,7 +513,7 @@ static void rt_test_008_007_execute(void) { other after 50mS.*/ test_set_step(2); { - target_time = test_wait_tick() + TIME_MS2I(50); + target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(50)); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, evt_thread7, "A"); } @@ -521,7 +524,8 @@ static void rt_test_008_007_execute(void) { test_set_step(3); { m = chEvtWaitAll(5); - test_assert_time_window(target_time, target_time + ALLOWED_DELAY, + test_assert_time_window(target_time, + chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(m == 0, "stuck event"); diff --git a/test/rt/source/test/rt_test_sequence_010.c b/test/rt/source/test/rt_test_sequence_010.c index 4a9d365f0..54f8ef879 100644 --- a/test/rt/source/test/rt_test_sequence_010.c +++ b/test/rt/source/test/rt_test_sequence_010.c @@ -80,7 +80,7 @@ NOINLINE static unsigned int msg_loop_test(thread_t *tp) { uint32_t n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { (void)chMsgSend(tp, 1); n++; @@ -372,7 +372,7 @@ static void rt_test_010_004_execute(void) { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chSysLock(); chSchWakeupS(tp, MSG_OK); @@ -442,7 +442,7 @@ static void rt_test_010_005_execute(void) { { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chThdWait(chThdCreateStatic(wa[0], WA_SIZE, prio, bmk_thread3, NULL)); n++; @@ -499,7 +499,7 @@ static void rt_test_010_006_execute(void) { { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { #if CH_CFG_USE_REGISTRY chThdRelease(chThdCreateStatic(wa[0], WA_SIZE, prio, bmk_thread3, NULL)); @@ -581,7 +581,7 @@ static void rt_test_010_007_execute(void) { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chSemReset(&sem1, 0); n++; @@ -706,7 +706,7 @@ static void rt_test_010_009_execute(void) { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chSysLock(); chVTDoSetI(&vt1, 1, tmo, NULL); @@ -775,7 +775,7 @@ static void rt_test_010_010_execute(void) { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chSemWait(&sem1); chSemSignal(&sem1); @@ -847,7 +847,7 @@ static void rt_test_010_011_execute(void) { n = 0; start = test_wait_tick(); - end = start + TIME_MS2I(1000); + end = chTimeAddX(start, TIME_MS2I(1000)); do { chMtxLock(&mtx1); chMtxUnlock(&mtx1); -- cgit v1.2.3