Skip to content

Commit 0b27736

Browse files
committed
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.
1 parent 1397eb5 commit 0b27736

File tree

4 files changed

+2
-74
lines changed

4 files changed

+2
-74
lines changed

TESTS/mbed_hal/sleep_manager/main.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ using utest::v1::Case;
3434
using utest::v1::Specification;
3535
using utest::v1::Harness;
3636

37-
static uint32_t num_test_errors = 0UL;
38-
39-
mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value,
40-
const char *filename, int line_number)
41-
{
42-
(void) error_status;
43-
(void) error_msg;
44-
(void) error_value;
45-
(void) filename;
46-
(void) line_number;
47-
48-
num_test_errors++;
49-
return MBED_SUCCESS;
50-
}
51-
5237
void test_lock_unlock()
5338
{
5439
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
@@ -60,16 +45,6 @@ void test_lock_unlock()
6045
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
6146
}
6247

63-
void test_lone_unlock()
64-
{
65-
uint32_t expected_err_count = num_test_errors + 1;
66-
sleep_manager_unlock_deep_sleep();
67-
TEST_ASSERT_EQUAL_UINT32(expected_err_count, num_test_errors);
68-
69-
// Make sure upcoming tests won't be broken.
70-
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
71-
}
72-
7348
void test_lock_eq_ushrt_max()
7449
{
7550
uint32_t lock_count = 0;
@@ -87,27 +62,6 @@ void test_lock_eq_ushrt_max()
8762
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
8863
}
8964

90-
void test_lock_gt_ushrt_max()
91-
{
92-
uint32_t lock_count = 0;
93-
while (lock_count < USHRT_MAX) {
94-
sleep_manager_lock_deep_sleep();
95-
lock_count++;
96-
TEST_ASSERT_FALSE(sleep_manager_can_deep_sleep());
97-
}
98-
99-
uint32_t expected_err_count = num_test_errors + 1;
100-
sleep_manager_lock_deep_sleep();
101-
TEST_ASSERT_EQUAL_UINT32(expected_err_count, num_test_errors);
102-
103-
// Make sure upcoming tests won't be broken.
104-
while (lock_count > 0) {
105-
sleep_manager_unlock_deep_sleep();
106-
lock_count--;
107-
}
108-
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
109-
}
110-
11165
#if DEVICE_LPTICKER
11266
#if DEVICE_USTICKER
11367
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)
279233

280234
Case cases[] = {
281235
Case("deep sleep lock/unlock", test_lock_unlock),
282-
Case("deep sleep unbalanced unlock", test_lone_unlock),
283236
Case("deep sleep locked USHRT_MAX times", test_lock_eq_ushrt_max),
284-
Case("deep sleep locked more than USHRT_MAX times", test_lock_gt_ushrt_max),
285237
#if DEVICE_LPTICKER
286238
#if DEVICE_USTICKER
287239
Case("sleep_auto calls sleep/deep sleep based on lock",

TESTS/mbed_hal/sleep_manager/sleep_manager_api_tests.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838
*/
3939
void test_lock_unlock();
4040

41-
/** Test an unbalanced unlock call
42-
*
43-
* Given the deep sleep has not been locked
44-
* When the deep sleep mode is unlocked
45-
* Then an mbed_error is raised
46-
*/
47-
void test_lone_unlock();
48-
4941
/** Test lock USHRT_MAX times
5042
*
5143
* Given a device with sleep mode support
@@ -58,14 +50,6 @@ void test_lone_unlock();
5850
*/
5951
void test_lock_eq_ushrt_max();
6052

61-
/** Test lock more than USHRT_MAX times
62-
*
63-
* Given the deep sleep has already been locked USHRT_MAX times
64-
* When the deep sleep mode is locked again
65-
* Then an mbed_error is raised
66-
*/
67-
void test_lock_gt_ushrt_max();
68-
6953
/** Test sleep_auto calls sleep and deep sleep based on lock
7054
*
7155
* Given a device with sleep mode support

hal/mbed_sleep_manager.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ void sleep_manager_lock_deep_sleep_internal(void)
163163
if (deep_sleep_lock == USHRT_MAX) {
164164
core_util_critical_section_exit();
165165
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
166-
// When running sleep_manager tests, the mbed_error() is overridden
167-
// and no longer calls mbed_halt_system(). Return to prevent
168-
// execution of the following code.
169-
return;
170166
}
171167
core_util_atomic_incr_u16(&deep_sleep_lock, 1);
172168
core_util_critical_section_exit();
@@ -178,10 +174,6 @@ void sleep_manager_unlock_deep_sleep_internal(void)
178174
if (deep_sleep_lock == 0) {
179175
core_util_critical_section_exit();
180176
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
181-
// When running sleep_manager tests, the mbed_error() is overridden
182-
// and no longer calls mbed_halt_system(). Return to prevent
183-
// execution of the following code.
184-
return;
185177
}
186178
core_util_atomic_decr_u16(&deep_sleep_lock, 1);
187179
core_util_critical_section_exit();

platform/mbed_power_mgmt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ extern "C" {
4646
*
4747
* # Defined behavior
4848
* * The lock is a counter
49-
* * The lock can be locked up to USHRT_MAX - Verified by ::test_lock_eq_ushrt_max and ::test_lock_gt_ushrt_max
50-
* * The lock has to be equally unlocked as locked - Verified by ::test_lone_unlock and ::test_lock_eq_ushrt_max
49+
* * The lock can be locked up to USHRT_MAX - Verified by ::test_lock_eq_ushrt_max
50+
* * The lock has to be equally unlocked as locked - Verified by ::test_lock_eq_ushrt_max
5151
* * The function sleep_manager_lock_deep_sleep_internal() locks the automatic deep mode selection - Verified by ::test_lock_unlock
5252
* * The function sleep_manager_unlock_deep_sleep_internal() unlocks the automatic deep mode selection - Verified by ::test_lock_unlock
5353
* * The function sleep_manager_sleep_auto() chooses the sleep or deep sleep modes based on the lock - Verified by ::test_sleep_auto

0 commit comments

Comments
 (0)