Skip to content

Commit 044eb1e

Browse files
committed
Update the SysTimer test
Update the SysTimer test to match the updated API. Changes are: - increment_tick() renamed to _increment_tick() and explicitly synchronized -update_tick() replaced with resume() and a call to suspend() was added before this
1 parent 953bbeb commit 044eb1e

File tree

1 file changed

+12
-7
lines changed
  • TESTS/mbedmicro-rtos-mbed/systimer

1 file changed

+12
-7
lines changed

TESTS/mbedmicro-rtos-mbed/systimer/main.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class SysTimerTest: public rtos::internal::SysTimer {
4444
Semaphore _sem;
4545
virtual void handler()
4646
{
47-
increment_tick();
47+
core_util_critical_section_enter();
48+
_increment_tick();
49+
core_util_critical_section_exit();
4850
_sem.release();
4951
}
5052

@@ -79,26 +81,29 @@ void test_created_with_zero_tick_count(void)
7981
/** Test tick count is updated correctly
8082
*
8183
* Given a SysTimer
82-
* When @a update_tick method is called immediately after creation
84+
* When the @a suspend and @a resume methods are called immediately after creation
8385
* Then the tick count is not updated
84-
* When @a update_tick is called again after a delay
86+
* When @a suspend and @a resume methods are called again after a delay
8587
* Then the tick count is updated
8688
* and the number of ticks incremented is equal TEST_TICKS - 1
87-
* When @a update_tick is called again without a delay
89+
* When @a suspend and @a resume methods are called again without a delay
8890
* Then the tick count is not updated
8991
*/
9092
void test_update_tick(void)
9193
{
9294
SysTimerTest st;
93-
TEST_ASSERT_EQUAL_UINT32(0, st.update_tick());
95+
st.suspend(TEST_TICKS * 2);
96+
TEST_ASSERT_EQUAL_UINT32(0, st.resume());
9497
TEST_ASSERT_EQUAL_UINT32(0, st.get_tick());
9598
us_timestamp_t test_ticks_elapsed_ts = st.get_time() + DELAY_US;
9699

100+
st.suspend(TEST_TICKS * 2);
97101
while (st.get_time() <= test_ticks_elapsed_ts) {}
98-
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.update_tick());
102+
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.resume());
99103
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
100104

101-
TEST_ASSERT_EQUAL_UINT32(0, st.update_tick());
105+
st.suspend(TEST_TICKS * 2);
106+
TEST_ASSERT_EQUAL_UINT32(0, st.resume());
102107
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
103108
}
104109

0 commit comments

Comments
 (0)