Skip to content

tests-mbed_hal-sleep fix #7036

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 3 commits into from
Jun 15, 2018
Merged
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
25 changes: 22 additions & 3 deletions TESTS/mbed_hal/sleep/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if 1 || !DEVICE_SLEEP
#if !DEVICE_SLEEP
#error [NOT_SUPPORTED] sleep not supported for this target
#endif

Expand All @@ -37,7 +37,12 @@ using namespace utest::v1;

/* Used for regular sleep mode, a target should be awake within 10 us. Define us delta value as follows:
* delta = default 10 us + worst ticker resolution + extra time for code execution */
#if defined(MBED_CPU_STATS_ENABLED)
/* extra 25us for stats computation (for more details see MBED_CPU_STATS_ENABLED) */
static const uint32_t sleep_mode_delta_us = (10 + 4 + 5 + 25);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for stating that clearly

#else
static const uint32_t sleep_mode_delta_us = (10 + 4 + 5);
#endif

/* Used for deep-sleep mode, a target should be awake within 10 ms. Define us delta value as follows:
* delta = default 10 ms + worst ticker resolution + extra time for code execution */
Expand Down Expand Up @@ -98,13 +103,23 @@ void lp_ticker_isr(const ticker_data_t *const ticker_data)
* high frequency ticker interrupt can wake-up target from sleep. */
void sleep_usticker_test()
{
#if 0
const ticker_data_t * ticker = get_us_ticker_data();
const unsigned int ticker_freq = ticker->interface->get_info()->frequency;
const unsigned int ticker_width = ticker->interface->get_info()->bits;

const ticker_irq_handler_type us_ticker_irq_handler_org = set_us_ticker_irq_handler(us_ticker_isr);

// call ticker_read_us to initialize ticker upper layer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the lines above, there's if #0 - should also be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove this, we need to have fix for MBED_ALL_STATS_ENABLED

@maciejbocianski Please provide details

Copy link
Contributor Author

@maciejbocianski maciejbocianski May 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When MBED_ALL_STATS_ENABLED is enable then sleep_manager_sleep_auto function calls some extra logging code, what makes return from sleep takes more time than expected

To enable sleep_usticker_test test
We could disable this flag globally for all test, or create mechanism to selectively mark tests which should be running without extra log/stats flags

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just unset the flag instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impossible to do, this flag is set globally for all tests

Jenkins code:
mbed_test_build_cmd=(mbed test --compile -m ${target} -t ${toolchain} -DMBED_HEAP_STATS_ENABLED=1 -DMBED_STACK_STATS_ENABLED=1 -DMBED_TRAP_ERRORS_ENABLED=1 -DMBED_ALL_STATS_ENABLED)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@studavekar Please review

// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
// (e.g when ticker_read_us is called)
ticker_read_us(ticker);
#ifdef DEVICE_LPTICKER
// call ticker_read_us to initialize lp_ticker
// prevents scheduling interrupt during ticker initialization (in lp_ticker_init) while test execution
// (e.g when ticker_read_us is called for lp_ticker, see MBED_CPU_STATS_ENABLED)
ticker_read_us(get_lp_ticker_data());
#endif

/* Test only sleep functionality. */
sleep_manager_lock_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should be locked");
Expand All @@ -130,7 +145,6 @@ void sleep_usticker_test()

sleep_manager_unlock_deep_sleep();
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
#endif
}

#ifdef DEVICE_LPTICKER
Expand All @@ -143,6 +157,11 @@ void deepsleep_lpticker_test()
const unsigned int ticker_freq = ticker->interface->get_info()->frequency;
const unsigned int ticker_width = ticker->interface->get_info()->bits;

// call ticker_read_us to initialize ticker upper layer
// prevents subsequent scheduling of max_delta interrupt during ticker initialization while test execution
// (e.g when ticker_read_us is called)
ticker_read_us(ticker);

const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);

/* Give some time Green Tea to finish UART transmission before entering
Expand Down