mirror of https://github.com/ARMmbed/mbed-os.git
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 thispull/6534/head
parent
953bbeb7de
commit
044eb1e8ce
|
@ -44,7 +44,9 @@ private:
|
||||||
Semaphore _sem;
|
Semaphore _sem;
|
||||||
virtual void handler()
|
virtual void handler()
|
||||||
{
|
{
|
||||||
increment_tick();
|
core_util_critical_section_enter();
|
||||||
|
_increment_tick();
|
||||||
|
core_util_critical_section_exit();
|
||||||
_sem.release();
|
_sem.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,26 +81,29 @@ void test_created_with_zero_tick_count(void)
|
||||||
/** Test tick count is updated correctly
|
/** Test tick count is updated correctly
|
||||||
*
|
*
|
||||||
* Given a SysTimer
|
* Given a SysTimer
|
||||||
* When @a update_tick method is called immediately after creation
|
* When the @a suspend and @a resume methods are called immediately after creation
|
||||||
* Then the tick count is not updated
|
* Then the tick count is not updated
|
||||||
* When @a update_tick is called again after a delay
|
* When @a suspend and @a resume methods are called again after a delay
|
||||||
* Then the tick count is updated
|
* Then the tick count is updated
|
||||||
* and the number of ticks incremented is equal TEST_TICKS - 1
|
* and the number of ticks incremented is equal TEST_TICKS - 1
|
||||||
* When @a update_tick is called again without a delay
|
* When @a suspend and @a resume methods are called again without a delay
|
||||||
* Then the tick count is not updated
|
* Then the tick count is not updated
|
||||||
*/
|
*/
|
||||||
void test_update_tick(void)
|
void test_update_tick(void)
|
||||||
{
|
{
|
||||||
SysTimerTest st;
|
SysTimerTest st;
|
||||||
TEST_ASSERT_EQUAL_UINT32(0, st.update_tick());
|
st.suspend(TEST_TICKS * 2);
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(0, st.resume());
|
||||||
TEST_ASSERT_EQUAL_UINT32(0, st.get_tick());
|
TEST_ASSERT_EQUAL_UINT32(0, st.get_tick());
|
||||||
us_timestamp_t test_ticks_elapsed_ts = st.get_time() + DELAY_US;
|
us_timestamp_t test_ticks_elapsed_ts = st.get_time() + DELAY_US;
|
||||||
|
|
||||||
|
st.suspend(TEST_TICKS * 2);
|
||||||
while (st.get_time() <= test_ticks_elapsed_ts) {}
|
while (st.get_time() <= test_ticks_elapsed_ts) {}
|
||||||
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.update_tick());
|
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.resume());
|
||||||
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
|
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_UINT32(0, st.update_tick());
|
st.suspend(TEST_TICKS * 2);
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(0, st.resume());
|
||||||
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
|
TEST_ASSERT_EQUAL_UINT32(TEST_TICKS - 1, st.get_tick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue