mirror of https://github.com/ARMmbed/mbed-os.git
Remove sleep manager tests that trigger mbed_error
Intercepting mbed_error will be too hard after mbed_error becomes [[noreturn]], so remove tests that do this.pull/8328/head
parent
1397eb5110
commit
0b27736536
|
@ -34,21 +34,6 @@ using utest::v1::Case;
|
|||
using utest::v1::Specification;
|
||||
using utest::v1::Harness;
|
||||
|
||||
static uint32_t num_test_errors = 0UL;
|
||||
|
||||
mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value,
|
||||
const char *filename, int line_number)
|
||||
{
|
||||
(void) error_status;
|
||||
(void) error_msg;
|
||||
(void) error_value;
|
||||
(void) filename;
|
||||
(void) line_number;
|
||||
|
||||
num_test_errors++;
|
||||
return MBED_SUCCESS;
|
||||
}
|
||||
|
||||
void test_lock_unlock()
|
||||
{
|
||||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
|
@ -60,16 +45,6 @@ void test_lock_unlock()
|
|||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
void test_lone_unlock()
|
||||
{
|
||||
uint32_t expected_err_count = num_test_errors + 1;
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
TEST_ASSERT_EQUAL_UINT32(expected_err_count, num_test_errors);
|
||||
|
||||
// Make sure upcoming tests won't be broken.
|
||||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
void test_lock_eq_ushrt_max()
|
||||
{
|
||||
uint32_t lock_count = 0;
|
||||
|
@ -87,27 +62,6 @@ void test_lock_eq_ushrt_max()
|
|||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
void test_lock_gt_ushrt_max()
|
||||
{
|
||||
uint32_t lock_count = 0;
|
||||
while (lock_count < USHRT_MAX) {
|
||||
sleep_manager_lock_deep_sleep();
|
||||
lock_count++;
|
||||
TEST_ASSERT_FALSE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
uint32_t expected_err_count = num_test_errors + 1;
|
||||
sleep_manager_lock_deep_sleep();
|
||||
TEST_ASSERT_EQUAL_UINT32(expected_err_count, num_test_errors);
|
||||
|
||||
// Make sure upcoming tests won't be broken.
|
||||
while (lock_count > 0) {
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
lock_count--;
|
||||
}
|
||||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
#if DEVICE_LPTICKER
|
||||
#if DEVICE_USTICKER
|
||||
utest::v1::status_t testcase_setup(const Case * const source, const size_t index_of_case)
|
||||
|
@ -279,9 +233,7 @@ utest::v1::status_t testsuite_setup(const size_t number_of_cases)
|
|||
|
||||
Case cases[] = {
|
||||
Case("deep sleep lock/unlock", test_lock_unlock),
|
||||
Case("deep sleep unbalanced unlock", test_lone_unlock),
|
||||
Case("deep sleep locked USHRT_MAX times", test_lock_eq_ushrt_max),
|
||||
Case("deep sleep locked more than USHRT_MAX times", test_lock_gt_ushrt_max),
|
||||
#if DEVICE_LPTICKER
|
||||
#if DEVICE_USTICKER
|
||||
Case("sleep_auto calls sleep/deep sleep based on lock",
|
||||
|
|
|
@ -38,14 +38,6 @@
|
|||
*/
|
||||
void test_lock_unlock();
|
||||
|
||||
/** Test an unbalanced unlock call
|
||||
*
|
||||
* Given the deep sleep has not been locked
|
||||
* When the deep sleep mode is unlocked
|
||||
* Then an mbed_error is raised
|
||||
*/
|
||||
void test_lone_unlock();
|
||||
|
||||
/** Test lock USHRT_MAX times
|
||||
*
|
||||
* Given a device with sleep mode support
|
||||
|
@ -58,14 +50,6 @@ void test_lone_unlock();
|
|||
*/
|
||||
void test_lock_eq_ushrt_max();
|
||||
|
||||
/** Test lock more than USHRT_MAX times
|
||||
*
|
||||
* Given the deep sleep has already been locked USHRT_MAX times
|
||||
* When the deep sleep mode is locked again
|
||||
* Then an mbed_error is raised
|
||||
*/
|
||||
void test_lock_gt_ushrt_max();
|
||||
|
||||
/** Test sleep_auto calls sleep and deep sleep based on lock
|
||||
*
|
||||
* Given a device with sleep mode support
|
||||
|
|
|
@ -163,10 +163,6 @@ void sleep_manager_lock_deep_sleep_internal(void)
|
|||
if (deep_sleep_lock == USHRT_MAX) {
|
||||
core_util_critical_section_exit();
|
||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
|
||||
// When running sleep_manager tests, the mbed_error() is overridden
|
||||
// and no longer calls mbed_halt_system(). Return to prevent
|
||||
// execution of the following code.
|
||||
return;
|
||||
}
|
||||
core_util_atomic_incr_u16(&deep_sleep_lock, 1);
|
||||
core_util_critical_section_exit();
|
||||
|
@ -178,10 +174,6 @@ void sleep_manager_unlock_deep_sleep_internal(void)
|
|||
if (deep_sleep_lock == 0) {
|
||||
core_util_critical_section_exit();
|
||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
|
||||
// When running sleep_manager tests, the mbed_error() is overridden
|
||||
// and no longer calls mbed_halt_system(). Return to prevent
|
||||
// execution of the following code.
|
||||
return;
|
||||
}
|
||||
core_util_atomic_decr_u16(&deep_sleep_lock, 1);
|
||||
core_util_critical_section_exit();
|
||||
|
|
|
@ -46,8 +46,8 @@ extern "C" {
|
|||
*
|
||||
* # Defined behavior
|
||||
* * The lock is a counter
|
||||
* * The lock can be locked up to USHRT_MAX - Verified by ::test_lock_eq_ushrt_max and ::test_lock_gt_ushrt_max
|
||||
* * The lock has to be equally unlocked as locked - Verified by ::test_lone_unlock and ::test_lock_eq_ushrt_max
|
||||
* * The lock can be locked up to USHRT_MAX - Verified by ::test_lock_eq_ushrt_max
|
||||
* * The lock has to be equally unlocked as locked - Verified by ::test_lock_eq_ushrt_max
|
||||
* * The function sleep_manager_lock_deep_sleep_internal() locks the automatic deep mode selection - Verified by ::test_lock_unlock
|
||||
* * The function sleep_manager_unlock_deep_sleep_internal() unlocks the automatic deep mode selection - Verified by ::test_lock_unlock
|
||||
* * The function sleep_manager_sleep_auto() chooses the sleep or deep sleep modes based on the lock - Verified by ::test_sleep_auto
|
||||
|
|
Loading…
Reference in New Issue