Skip to content

tests-mbed_hal-common_tickers: disable ticker free test cases. #7741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions TESTS/mbed_hal/common_tickers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,6 @@ void ticker_speed_test(void)

const ticker_info_t *us_ticker_info = get_us_ticker_data()->interface->get_info();

/* Free function will disable the ticker. For time measurement
* we need to use other one if available.
*/
#if DEVICE_LPTICKER
const ticker_info_t *lp_ticker_info = get_lp_ticker_data()->interface->get_info();
bool us_ticker_test = (intf == get_us_ticker_data()->interface);
#endif

/* ---- Test ticker_read function. ---- */
start = us_ticker_read();
while (counter--) {
Expand Down Expand Up @@ -498,71 +490,8 @@ void ticker_speed_test(void)

TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)));

/* ---- Test free function. ---- */
#if DEVICE_LPTICKER
counter = NUM_OF_CALLS;
if (us_ticker_test) {
lp_ticker_init();
}
start = us_ticker_test ? lp_ticker_read() : us_ticker_read();
while (counter--) {
intf->free();
}
stop = us_ticker_test ? lp_ticker_read() : us_ticker_read();

TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)));
#endif
}

/* Test that ticker_free disables ticker interrupt. */
void ticker_free_interrupt_test(void)
{
overflow_protect();

uint32_t cycles_500_ticks = 50;
uint32_t reference_ticks_count = 0;

while (reference_ticks_count < TICKER_500_TICKS) {
cycles_500_ticks *= 2;
const uint32_t start = intf->read();
wait_cycles(cycles_500_ticks);
reference_ticks_count = intf->read() - start;
}

intFlag = 0;

intf->set_interrupt(intf->read() + (TICKER_500_TICKS / 2));
intf->free();
wait_cycles(cycles_500_ticks);
intf->init();
TEST_ASSERT_EQUAL(0, intFlag);
}

/* Test that ticker can be successfully re-initialized after free(). */
void ticker_init_free_test(void)
{
intf->free();
intf->init();

overflow_protect();

intFlag = 0;

const uint32_t tick_count = intf->read();

intf->set_interrupt(intf->read() + TICKER_INT_VAL);

while (intf->read() < (tick_count + TICKER_INT_VAL - TICKER_DELTA)) {
TEST_ASSERT_EQUAL_INT_MESSAGE(0, intFlag, "Interrupt fired too early");
}

while (intf->read() < (tick_count + TICKER_INT_VAL + TICKER_DELTA)) {
}

TEST_ASSERT_EQUAL(1, intFlag);
}


utest::v1::status_t us_ticker_setup(const Case *const source, const size_t index_of_case)
{
intf = get_us_ticker_data()->interface;
Expand Down Expand Up @@ -637,8 +566,6 @@ Case cases[] = {
Case("Microsecond ticker overflow test", us_ticker_setup, ticker_overflow_test, us_ticker_teardown),
Case("Microsecond ticker increment test", us_ticker_setup, ticker_increment_test, us_ticker_teardown),
Case("Microsecond ticker speed test", us_ticker_setup, ticker_speed_test, us_ticker_teardown),
Case("Microsecond ticker free interrupt test", us_ticker_setup, ticker_free_interrupt_test, us_ticker_teardown),
Case("Microsecond re-init after free test", us_ticker_setup, ticker_init_free_test, us_ticker_teardown),
#if DEVICE_LPTICKER
Case("lp ticker init is safe to call repeatedly", lp_ticker_setup, ticker_init_test, lp_ticker_teardown),
Case("lp ticker info test", lp_ticker_setup, ticker_info_test, lp_ticker_teardown),
Expand All @@ -649,8 +576,6 @@ Case cases[] = {
Case("lp ticker overflow test", lp_ticker_setup, ticker_overflow_test, lp_ticker_teardown),
Case("lp ticker increment test", lp_ticker_setup, ticker_increment_test, lp_ticker_teardown),
Case("lp ticker speed test", lp_ticker_setup, ticker_speed_test, lp_ticker_teardown),
Case("lp ticker free interrupt test", lp_ticker_setup, ticker_free_interrupt_test, lp_ticker_teardown),
Case("lp ticker re-init after free test", lp_ticker_setup, ticker_init_free_test, lp_ticker_teardown),
#endif
};

Expand Down
15 changes: 0 additions & 15 deletions TESTS/mbed_hal/common_tickers/ticker_api_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,6 @@ void ticker_speed_test(void);
*/
void ticker_overflow_test(void);

/** Test ticker_free disables ticker interrupt.
*
* Given ticker is available.
* When ticker interrupt is set and then ticker_free is called.
* Then ticker interrupt is not triggered.
*/
void ticker_free_interrupt_test(void);

/** Test that ticker can be successfully re-initialized after free().
*
* Given ticker is available.
* When ticker has been re-initialized after free().
* Then ticker counts and generates interrupts.
*/
void ticker_init_free_test(void);
/**@}*/

#ifdef __cplusplus
Expand Down
2 changes: 0 additions & 2 deletions hal/us_ticker_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ extern "C" {
* Verified by ::ticker_fire_now_test
* * The ticker operations ticker_read, ticker_clear_interrupt, ticker_set_interrupt and ticker_fire_interrupt
* take less than 20us to complete - Verified by ::ticker_speed_test
* * The function ticker_free disables the ticker interrupt - ::ticker_free_interrupt_test
* * The function ticker_init re-initializes ticker after has been disabled by means of ticker_free - Verified by ::ticker_init_free_test
*
* # Undefined behavior
* * Calling any function other than ticker_init before the initialization of the ticker
Expand Down