tests: ztest: add CONFIG_ZTEST_NO_YIELD to keep SOC awake after test

Some SOCs cannot be flashed reliably in low power modes. If
CONFIG_ZTEST_NO_YIELD is selected, do not yield to the idle thread after
testsuite completes, so that the SOC will not enter low power mode.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2022-01-18 18:08:11 -06:00 committed by David Leach
commit 5ba1787163
2 changed files with 20 additions and 0 deletions

View file

@ -79,6 +79,14 @@ config ZTEST_ASSERT_HOOK
error test case. Remember to add ignore_fault tag in yaml file when
using twister to run testing.
config ZTEST_NO_YIELD
bool "Do not yield to the idle thread after tests complete"
help
When the tests complete, do not yield to the idle thread and instead
spin in a loop. This is useful for low power mode tests, where
yielding to the idle thread may put the board into a low power state
where a debugger cannot connect to it.
if ZTEST_NEW_API
menu "ztest provided rules"

View file

@ -579,5 +579,17 @@ void main(void)
state.boots = 0;
}
}
#ifdef CONFIG_ZTEST_NO_YIELD
/*
* Rather than yielding to idle thread, keep the part awake so debugger can
* still access it, since some SOCs cannot be debugged in low power states.
*/
uint32_t key = irq_lock();
while (1) {
; /* Spin */
}
irq_unlock(key);
#endif
}
#endif